private Glyph GetGlyph(char character) { Glyph glyph; if (!glyphs.TryGetValue(character, out glyph)) { // if we have a loaded ttf try to create the glyph data if (_ofTypeface != null) { var storage = new VertexStorage(); var translator = new VertexSourceGlyphTranslator(storage); var glyphIndex = _ofTypeface.LookupIndex(character); var ttfGlyph = _ofTypeface.GetGlyphByIndex(glyphIndex); // Typography.OpenFont.IGlyphReaderExtensions.Read(translator, ttfGlyph.GlyphPoints, ttfGlyph.EndPoints); // glyph = new Glyph(); glyph.unicode = character; glyph.horiz_adv_x = _ofTypeface.GetHAdvanceWidthFromGlyphIndex(glyphIndex); glyphs.Add(character, glyph); // Wrap glyph data with ClosedLoopGlyphData to ensure all loops are correctly closed glyph.glyphData = new ClosedLoopGlyphData(storage); } } return(glyph); }
internal IVertexSource GetGlyphForCharacter(char character) { if (_ofTypeface != null) { // TODO: MAKE SURE THIS IS OFF!!!!!!! It is un-needed and only for debugging //glyphs.Clear(); } // TODO: check for multi character glyphs (we don't currently support them in the reader). Glyph glyph = null; if (!glyphs.TryGetValue(character, out glyph)) { // if we have a loaded ttf try to create the glyph data if (_ofTypeface != null) { var storage = new VertexStorage(); var translator = new VertexSourceGlyphTranslator(storage); var glyphIndex = _ofTypeface.LookupIndex(character); var ttfGlyph = _ofTypeface.GetGlyphByIndex(glyphIndex); // Typography.OpenFont.IGlyphReaderExtensions.Read(translator, ttfGlyph.GlyphPoints, ttfGlyph.EndPoints); // glyph = new Glyph(); glyph.unicode = character; glyph.horiz_adv_x = _ofTypeface.GetHAdvanceWidthFromGlyphIndex(glyphIndex); glyphs.Add(character, glyph); // Wrap glyph data with ClosedLoopGlyphData to ensure all loops are correctly closed glyph.glyphData = new ClosedLoopGlyphData(storage); } } return(glyph?.glyphData); }