MCPcopy Index your code
hub / github.com/benfry/processing4 / drawString

Method drawString

core/src/processing/core/PShapeSVG.java:1846–1868  ·  view source on GitHub ↗
(PGraphics g, String str, float x, float y, float size)

Source from the content-addressed store, hash-verified

1844
1845
1846 public void drawString(PGraphics g, String str, float x, float y, float size) {
1847 // 1) scale by the 1.0/unitsPerEm
1848 // 2) scale up by a font size
1849 g.pushMatrix();
1850 float s = size / face.unitsPerEm;
1851 //System.out.println("scale is " + s);
1852 // swap y coord at the same time, since fonts have y=0 at baseline
1853 g.translate(x, y);
1854 g.scale(s, -s);
1855 char[] c = str.toCharArray();
1856 for (int i = 0; i < c.length; i++) {
1857 // call draw on each char (pulling it w/ the unicode table)
1858 FontGlyph fg = unicodeGlyphs.get(Character.valueOf(c[i]));
1859 if (fg != null) {
1860 fg.draw(g);
1861 // add horizAdvX/unitsPerEm to the x coordinate along the way
1862 g.translate(fg.horizAdvX, 0);
1863 } else {
1864 System.err.println("'" + c[i] + "' not available.");
1865 }
1866 }
1867 g.popMatrix();
1868 }
1869
1870
1871 public void drawChar(PGraphics g, char c, float x, float y, float size) {

Callers 1

GlyphMethod · 0.45

Calls 7

translateMethod · 0.65
scaleMethod · 0.65
getMethod · 0.65
pushMatrixMethod · 0.45
drawMethod · 0.45
printlnMethod · 0.45
popMatrixMethod · 0.45

Tested by

no test coverage detected