(PGraphics g, String str, float x, float y, float size)
| 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) { |
no test coverage detected