public static GlyphTypeface GlyphTypeface(this CmFont font, double emSize = 10) { var code = FontCodes[font]; if (EmSizes.ContainsKey(font)) { // take font size which is closest to the em size var size = EmSizes[font] .OrderBy(s => Math.Abs(s - emSize)) .First(); code = code + size; } if (Fonts.ContainsKey(code)) { return(Fonts[code]); } var uri = new Uri("pack://application:,,,/LatexEditor;component/Fonts/" + code + ".ttf"); return(Fonts[code] = new GlyphTypeface(uri)); }
public GlyphSegment(CmFont font, int charId) { CharId = charId; _glyphDescriptor = new GlyphDescriptor(font.GlyphTypeface(), CharId); }