public CharInfo GetCharInfo(CharFont charFont, TexStyle style) { var size = GetSizeFactor(style); var fontInfo = fontInfoList[charFont.FontId]; return(new CharInfo(charFont.Character, fontInfo.Font, size, charFont.FontId, GetMetrics(charFont, size))); }
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))); }
private TexFontMetrics GetMetrics(CharFont charFont, double size) { var fontInfo = fontInfoList[charFont.FontId]; var metrics = fontInfo.GetMetrics(charFont.Character); return(new TexFontMetrics(metrics[TexFontUtilities.MetricsWidth], metrics[TexFontUtilities.MetricsHeight], metrics[TexFontUtilities.MetricsDepth], metrics[TexFontUtilities.MetricsItalic], size * TexFontUtilities.PixelsPerPoint)); }
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)); }
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 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 CharInfo GetCharInfo(CharFont charFont, TexStyle style) => throw MethodNotSupported(nameof(GetCharInfo));
public CharInfo GetCharInfo(CharFont charFont, TexStyle style) { var size = GetSizeFactor(style); var fontInfo = fontInfoList[charFont.FontId]; return new CharInfo(charFont.Character, fontInfo.Font, size, charFont.FontId, GetMetrics(charFont, size)); }
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));
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) => Result.Error <CharInfo>(MethodNotSupported(nameof(this.GetCharInfo)));
public double GetKern(CharFont leftChar, CharFont rightChar, TexStyle style) => 0.0;
public FixedCharAtom(CharFont charFont) { this.CharFont = charFont; }
public CharFont GetLigature(CharFont leftChar, CharFont rightChar) => null;
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 TexFontMetrics GetMetrics(CharFont charFont, double size) { var fontInfo = fontInfoList[charFont.FontId]; var metrics = fontInfo.GetMetrics(charFont.Character); return new TexFontMetrics(metrics[TexFontUtilities.MetricsWidth], metrics[TexFontUtilities.MetricsHeight], metrics[TexFontUtilities.MetricsDepth], metrics[TexFontUtilities.MetricsItalic], size * TexFontUtilities.PixelsPerPoint); }
private CharInfo GetCharInfo(char character, CharFont[] charFont, TexStyle style) { TexCharKind charKind; int charIndexOffset; if (character >= '0' && character <= '9') { charKind = TexCharKind.Numbers; charIndexOffset = character - '0'; } else if (character >= 'a' && character <= 'z') { charKind = TexCharKind.Small; charIndexOffset = character - 'a'; } else { charKind = TexCharKind.Capitals; charIndexOffset = character - 'A'; } if (charFont[(int)charKind] == null) return GetDefaultCharInfo(character, style); else return GetCharInfo(new CharFont((char)(charFont[(int)charKind].Character + charIndexOffset), charFont[(int)charKind].FontId), style); }
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); }