public void Parse(XElement element, char character, TexFontInfo fontInfo) { var extensionChars = new int[4]; extensionChars[TexFontUtilities.ExtensionRepeat] = element.AttributeInt32Value("rep"); extensionChars[TexFontUtilities.ExtensionTop] = element.AttributeInt32Value("top", (int)TexCharKind.None); extensionChars[TexFontUtilities.ExtensionMiddle] = element.AttributeInt32Value("mid", (int)TexCharKind.None); extensionChars[TexFontUtilities.ExtensionBottom] = element.AttributeInt32Value("bot", (int)TexCharKind.None); fontInfo.SetExtensions(character, extensionChars); }
private static void ProcessCharElement(XElement charElement, TexFontInfo fontInfo) { var character = (char)charElement.AttributeInt32Value("code"); var metrics = new double[4]; metrics[TexFontUtilities.MetricsWidth] = charElement.AttributeDoubleValue("width", 0d); metrics[TexFontUtilities.MetricsHeight] = charElement.AttributeDoubleValue("height", 0d); metrics[TexFontUtilities.MetricsDepth] = charElement.AttributeDoubleValue("depth", 0d); metrics[TexFontUtilities.MetricsItalic] = charElement.AttributeDoubleValue("italic", 0d); fontInfo.SetMetrics(character, metrics); foreach (var childElement in charElement.Elements()) { var parser = charChildParsers[childElement.Name.ToString()]; if (parser == null) { throw new InvalidOperationException("Unknown element type."); } parser.Parse(childElement, character, fontInfo); } }
public TexFontInfo[] GetFontDescriptions() { var result = new TexFontInfo[fontIdCount]; var fontDescriptions = rootElement.Element("FontDescriptions"); if (fontDescriptions != null) { foreach (var fontElement in fontDescriptions.Elements("Font")) { var fontName = fontElement.AttributeValue("name"); var fontId = fontElement.AttributeInt32Value("id"); var space = fontElement.AttributeDoubleValue("space"); var xHeight = fontElement.AttributeDoubleValue("xHeight"); var quad = fontElement.AttributeDoubleValue("quad"); var skewChar = fontElement.AttributeInt32Value("skewChar", -1); var font = CreateFont(fontName); var fontInfo = new TexFontInfo(fontId, font, xHeight, space, quad); if (skewChar != -1) { fontInfo.SkewCharacter = (char)skewChar; } foreach (var charElement in fontElement.Elements("Char")) { ProcessCharElement(charElement, fontInfo); } if (result[fontId] != null) { throw new InvalidOperationException(string.Format("Multiple entries for font with ID {0}.", fontId)); } result[fontId] = fontInfo; } } return(result); }
public void Parse(XElement element, char character, TexFontInfo fontInfo) { fontInfo.SetNextLarger(character, (char)element.AttributeInt32Value("code"), element.AttributeInt32Value("fontId")); }
public void Parse(XElement element, char character, TexFontInfo fontInfo) { fontInfo.AddLigature(character, (char)element.AttributeInt32Value("code"), (char)element.AttributeInt32Value("ligCode")); }
public void Parse(XElement element, char character, TexFontInfo fontInfo) { fontInfo.AddKern(character, (char)element.AttributeInt32Value("code"), element.AttributeDoubleValue("val")); }