private void ParseTextStyleMappings() { this.parsedTextStyles = new Dictionary <string, CharFont[]>(); var textStyleMappings = rootElement.Element("TextStyleMappings"); if (textStyleMappings == null) { throw new InvalidOperationException("Cannot find TextStyleMappings element."); } foreach (var mappingElement in textStyleMappings.Elements("TextStyleMapping")) { var textStyleName = mappingElement.AttributeValue("name"); var charFonts = new CharFont[3]; foreach (var mapRangeElement in mappingElement.Elements("MapRange")) { var fontId = mapRangeElement.AttributeInt32Value("fontId"); var character = mapRangeElement.AttributeInt32Value("start"); var code = mapRangeElement.AttributeValue("code"); var codeMapping = rangeTypeMappings[code]; charFonts[(int)codeMapping] = new CharFont((char)character, fontId); } this.parsedTextStyles.Add(textStyleName, charFonts); } }
public Result <CharInfo> GetCharInfo(CharFont charFont, TexStyle style) { var size = GetSizeFactor(style); var fontInfo = fontInfoList[charFont.FontId]; var metrics = GetMetrics(charFont, size); return(metrics.Map(m => new CharInfo(charFont.Character, fontInfo.Font, size, charFont.FontId, m))); }
public double GetSkew(CharFont charFont, TexStyle style) { var fontInfo = fontInfoList[charFont.FontId]; char skewChar = fontInfo.SkewCharacter; if (skewChar == 1) { return(0); } return(GetKern(charFont, new CharFont(skewChar, charFont.FontId), style)); }
public CharFont GetLigature(CharFont leftCharFont, CharFont rightCharFont) { if (leftCharFont.FontId != rightCharFont.FontId) { return(null); } var fontInfo = fontInfoList[leftCharFont.FontId]; return(fontInfo.GetLigature(leftCharFont.Character, rightCharFont.Character)); }
private static Result <TexFontMetrics> GetMetrics(CharFont charFont, double size) { var fontInfo = fontInfoList[charFont.FontId]; var metrics = fontInfo.GetMetrics(charFont.Character); return(metrics.Map(m => new TexFontMetrics( m[TexFontUtilities.MetricsWidth], m[TexFontUtilities.MetricsHeight], m[TexFontUtilities.MetricsDepth], m[TexFontUtilities.MetricsItalic], size * TexFontUtilities.PixelsPerPoint))); }
public double GetKern(CharFont leftCharFont, CharFont rightCharFont, TexStyle style) { if (leftCharFont.FontId != rightCharFont.FontId) { return(0); } var fontInfo = fontInfoList[leftCharFont.FontId]; return(fontInfo.GetKern(leftCharFont.Character, rightCharFont.Character, GetSizeFactor(style) * TexFontUtilities.PixelsPerPoint)); }
public double GetSkew(CharFont charFont, TexStyle style) => throw MethodNotSupported(nameof(GetSkew));
public double GetKern(CharFont leftChar, CharFont rightChar, TexStyle style) => 0.0;
public Result <CharInfo> GetCharInfo(CharFont charFont, TexStyle style) => Result.Error <CharInfo>(MethodNotSupported(nameof(this.GetCharInfo)));
public CharFont GetLigature(CharFont leftChar, CharFont rightChar) => null;