MCPcopy Index your code
hub / github.com/processing/processing / drawString

Method drawString

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

Source from the content-addressed store, hash-verified

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

Callers 12

GlyphMethod · 0.80
paintComponentMethod · 0.80
drawMethod · 0.80
paintPlainLineMethod · 0.80
paintSyntaxLineMethod · 0.80
placeTabsMethod · 0.80
paintMethod · 0.80
paintComponentMethod · 0.80
paintMethod · 0.80
drawButtonMethod · 0.80
drawUpdatesMethod · 0.80
drawMethod · 0.80

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