public void ReadSVG(string svgContent) { int startIndex = 0; String fontElementString = GetSubString(svgContent, "<font", ">", ref startIndex); fontId = GetStringValue(fontElementString, "id"); GetIntValue(fontElementString, "horiz-adv-x", out horiz_adv_x); String fontFaceString = GetSubString(svgContent, "<font-face", "/>", ref startIndex); fontFamily = GetStringValue(fontFaceString, "font-family"); GetIntValue(fontFaceString, "font-weight", out font_weight); font_stretch = GetStringValue(fontFaceString, "font-stretch"); GetIntValue(fontFaceString, "units-per-em", out unitsPerEm); panose_1 = new Panos_1(GetStringValue(fontFaceString, "panose-1")); GetIntValue(fontFaceString, "ascent", out ascent); GetIntValue(fontFaceString, "descent", out descent); GetIntValue(fontFaceString, "x-height", out x_height); GetIntValue(fontFaceString, "cap-height", out cap_height); String bboxString = GetStringValue(fontFaceString, "bbox"); String[] valuesString = bboxString.Split(' '); int.TryParse(valuesString[0], out boundingBox.Left); int.TryParse(valuesString[1], out boundingBox.Bottom); int.TryParse(valuesString[2], out boundingBox.Right); int.TryParse(valuesString[3], out boundingBox.Top); GetIntValue(fontFaceString, "underline-thickness", out underline_thickness); GetIntValue(fontFaceString, "underline-position", out underline_position); unicode_range = GetStringValue(fontFaceString, "unicode-range"); String missingGlyphString = GetSubString(svgContent, "<missing-glyph", "/>", ref startIndex); missingGlyph = CreateGlyphFromSVGGlyphData(missingGlyphString); String nextGlyphString = GetSubString(svgContent, "<glyph", "/>", ref startIndex); while (nextGlyphString != null) { // get the data and put it in the glyph dictionary FontGlyph newGlyph = CreateGlyphFromSVGGlyphData(nextGlyphString); if (newGlyph.unicode > 0) { originalGlyphs.Add(newGlyph.unicode, newGlyph); } nextGlyphString = GetSubString(svgContent, "<glyph", "/>", ref startIndex); } }
public void ReadSVG(String svgContent) { int startIndex = 0; String fontElementString = GetSubString(svgContent, "<font", ">", ref startIndex); fontId = GetStringValue(fontElementString, "id"); GetIntValue(fontElementString, "horiz-adv-x", out horiz_adv_x); String fontFaceString = GetSubString(svgContent, "<font-face", "/>", ref startIndex); fontFamily = GetStringValue(fontFaceString, "font-family"); GetIntValue(fontFaceString, "font-weight", out font_weight); font_stretch = GetStringValue(fontFaceString, "font-stretch"); GetIntValue(fontFaceString, "units-per-em", out unitsPerEm); panose_1 = new Panos_1(GetStringValue(fontFaceString, "panose-1")); GetIntValue(fontFaceString, "ascent", out ascent); GetIntValue(fontFaceString, "descent", out descent); GetIntValue(fontFaceString, "x-height", out x_height); GetIntValue(fontFaceString, "cap-height", out cap_height); String bboxString = GetStringValue(fontFaceString, "bbox"); String[] valuesString = bboxString.Split(' '); int.TryParse(valuesString[0], out boundingBox.Left); int.TryParse(valuesString[1], out boundingBox.Bottom); int.TryParse(valuesString[2], out boundingBox.Right); int.TryParse(valuesString[3], out boundingBox.Top); GetIntValue(fontFaceString, "underline-thickness", out underline_thickness); GetIntValue(fontFaceString, "underline-position", out underline_position); unicode_range = GetStringValue(fontFaceString, "unicode-range"); String missingGlyphString = GetSubString(svgContent, "<missing-glyph", "/>", ref startIndex); missingGlyph = CreateGlyphFromSVGGlyphData(missingGlyphString); String nextGlyphString = GetSubString(svgContent, "<glyph", "/>", ref startIndex); while (nextGlyphString != null) { // get the data and put it in the glyph dictionary Glyph newGlyph = CreateGlyphFromSVGGlyphData(nextGlyphString); if (newGlyph.unicode > 0) { glyphs.Add(newGlyph.unicode, newGlyph); } nextGlyphString = GetSubString(svgContent, "<glyph", "/>", ref startIndex); } }