| 10502 | |
| 10503 | // Parse SVG font-file into block of Canvas commands |
| 10504 | var parseSVGFont = function parseSVGFontse(svg) { |
| 10505 | // Store font attributes |
| 10506 | var font = svg.getElementsByTagName("font"); |
| 10507 | p.glyphTable[url].horiz_adv_x = font[0].getAttribute("horiz-adv-x"); |
| 10508 | |
| 10509 | var font_face = svg.getElementsByTagName("font-face")[0]; |
| 10510 | p.glyphTable[url].units_per_em = parseFloat(font_face.getAttribute("units-per-em")); |
| 10511 | p.glyphTable[url].ascent = parseFloat(font_face.getAttribute("ascent")); |
| 10512 | p.glyphTable[url].descent = parseFloat(font_face.getAttribute("descent")); |
| 10513 | |
| 10514 | var glyph = svg.getElementsByTagName("glyph"), |
| 10515 | len = glyph.length; |
| 10516 | |
| 10517 | // Loop through each glyph in the SVG |
| 10518 | for (var i = 0; i < len; i++) { |
| 10519 | // Store attributes for this glyph |
| 10520 | var unicode = glyph[i].getAttribute("unicode"); |
| 10521 | var name = glyph[i].getAttribute("glyph-name"); |
| 10522 | horiz_adv_x = glyph[i].getAttribute("horiz-adv-x"); |
| 10523 | if (horiz_adv_x === null) { |
| 10524 | horiz_adv_x = p.glyphTable[url].horiz_adv_x; |
| 10525 | } |
| 10526 | d = glyph[i].getAttribute("d"); |
| 10527 | // Split path commands in glpyh |
| 10528 | if (d !== undef) { |
| 10529 | path = buildPath(d); |
| 10530 | eval(path); |
| 10531 | // Store glyph data to table object |
| 10532 | p.glyphTable[url][name] = { |
| 10533 | name: name, |
| 10534 | unicode: unicode, |
| 10535 | horiz_adv_x: horiz_adv_x, |
| 10536 | draw: path.draw |
| 10537 | }; |
| 10538 | } |
| 10539 | } // finished adding glyphs to table |
| 10540 | }; |
| 10541 | |
| 10542 | // Load and parse Batik SVG font as XML into a Processing Glyph object |
| 10543 | var loadXML = function loadXML() { |