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

Method parseFont

core/src/processing/core/PShapeSVG.java:1616–1691  ·  view source on GitHub ↗
(XML properties)

Source from the content-addressed store, hash-verified

1614// static private float TEXT_QUALITY = 1;
1615
1616 static private PFont parseFont(XML properties) {
1617 String fontFamily = null;
1618 float size = 10;
1619 int weight = PLAIN; // 0
1620 int italic = 0;
1621
1622 if (properties.hasAttribute("style")) {
1623 String styleText = properties.getString("style");
1624 String[] styleTokens = PApplet.splitTokens(styleText, ";");
1625
1626 //PApplet.println(styleTokens);
1627 for (int i = 0; i < styleTokens.length; i++) {
1628 String[] tokens = PApplet.splitTokens(styleTokens[i], ":");
1629 //PApplet.println(tokens);
1630
1631 tokens[0] = PApplet.trim(tokens[0]);
1632
1633 if (tokens[0].equals("font-style")) {
1634 // PApplet.println("font-style: " + tokens[1]);
1635 if (tokens[1].contains("italic")) {
1636 italic = ITALIC;
1637 }
1638 } else if (tokens[0].equals("font-variant")) {
1639 // PApplet.println("font-variant: " + tokens[1]);
1640 // setFillOpacity(tokens[1]);
1641
1642 } else if (tokens[0].equals("font-weight")) {
1643 // PApplet.println("font-weight: " + tokens[1]);
1644
1645 if (tokens[1].contains("bold")) {
1646 weight = BOLD;
1647 // PApplet.println("Bold weight ! ");
1648 }
1649
1650
1651 } else if (tokens[0].equals("font-stretch")) {
1652 // not supported.
1653
1654 } else if (tokens[0].equals("font-size")) {
1655 // PApplet.println("font-size: " + tokens[1]);
1656 size = Float.parseFloat(tokens[1].split("px")[0]);
1657 // PApplet.println("font-size-parsed: " + size);
1658 } else if (tokens[0].equals("line-height")) {
1659 // not supported
1660
1661 } else if (tokens[0].equals("font-family")) {
1662 // PApplet.println("Font-family: " + tokens[1]);
1663 fontFamily = tokens[1];
1664
1665 } else if (tokens[0].equals("text-align")) {
1666 // not supported
1667
1668 } else if (tokens[0].equals("letter-spacing")) {
1669 // not supported
1670
1671 } else if (tokens[0].equals("word-spacing")) {
1672 // not supported
1673

Callers 2

TextMethod · 0.80
LineOfTextMethod · 0.80

Calls 9

splitTokensMethod · 0.95
trimMethod · 0.95
createFontMethod · 0.95
hasAttributeMethod · 0.80
parseFloatMethod · 0.80
splitMethod · 0.80
getStringMethod · 0.65
equalsMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected