コード例 #1
0
ファイル: TypeFace.cs プロジェクト: lalanikarim/agg-sharp
        internal IVertexSource GetGlyphForCharacter(char character)
        {
            if (ttfTypeFace != null)
            {
                // TODO: MAKE SURE THIS IS OFF!!!!!!! It is un-needed and only for debugging
                //glyphs.Clear();
            }

            IVertexSource vertexSource = null;
            // 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 (ttfTypeFace != null)
                {
                    glyph = new Glyph();
                    var translator = new VertexSourceGlyphTranslator(glyph.glyphData);
                    var glyphIndex = ttfTypeFace.LookupIndex(character);
                    var ttfGlyph   = ttfTypeFace.GetGlyphByIndex(glyphIndex);
                    translator.Read(ttfGlyph.GlyphPoints, ttfGlyph.EndPoints);
                    glyph.unicode     = character;
                    glyph.horiz_adv_x = ttfTypeFace.GetHAdvanceWidthFromGlyphIndex(glyphIndex);
                    glyphs.Add(character, glyph);
                    vertexSource = glyph.glyphData;
                }
            }
            else
            {
                vertexSource = glyph.glyphData;
            }

            return(vertexSource);
        }
コード例 #2
0
 public void AddGlyph(ushort glyphIndex, TtfGlyph glyph)
 {
     if (!glyph.HasOriginalAdvancedWidth)
     {
         glyph.OriginalAdvanceWidth = _typeface.GetHAdvanceWidthFromGlyphIndex(glyphIndex);
     }
     _glyphs.Add(new GlyphPos(glyphIndex, glyph.GlyphClass, glyph.OriginalAdvanceWidth));
 }