Example #1
0
        public SimpleFontAtlas CreateSimpleFontAtlas()
        {
            SimpleFontAtlas simpleFontAtlas = new SimpleFontAtlas();

            simpleFontAtlas.TextureKind         = this.TextureKind;
            simpleFontAtlas.OriginalFontSizePts = this.FontSizeInPoints;
            foreach (CacheGlyph cacheGlyph in _glyphs.Values)
            {
                Rectangle           area      = cacheGlyph.area;
                TextureGlyphMapData glyphData = new TextureGlyphMapData();

                glyphData.Width  = cacheGlyph.img.Width;
                glyphData.Left   = area.X;
                glyphData.Top    = area.Top;
                glyphData.Height = area.Height;

                glyphData.TextureXOffset = cacheGlyph.img.TextureOffsetX;
                glyphData.TextureYOffset = cacheGlyph.img.TextureOffsetY;


                simpleFontAtlas.AddGlyph(cacheGlyph.glyphIndex, glyphData);
            }

            return(simpleFontAtlas);
        }
Example #2
0
        public SimpleFontAtlas CreateSimpleFontAtlas()
        {
            SimpleFontAtlas simpleFontAtlas = new SimpleFontAtlas();

            simpleFontAtlas.TextureKind         = this.TextureKind;
            simpleFontAtlas.OriginalFontSizePts = this.FontSizeInPoints;
            foreach (CacheGlyph cacheGlyph in _glyphs.Values)
            {
                //convert char to hex
                string              unicode   = ("0x" + ((int)cacheGlyph.character).ToString("X"));//code point
                Rectangle           area      = cacheGlyph.area;
                TextureGlyphMapData glyphData = new TextureGlyphMapData();
                area.Y += area.Height;//***

                ////set font matrix to glyph font data
                //glyphData.Rect = Rectangle.FromLTRB(area.X, area.Top, area.Right, area.Bottom);
                //glyphData.AdvanceY = cacheGlyph.glyphMatrix.advanceY;

                glyphData.Width  = cacheGlyph.img.Width;
                glyphData.Left   = area.X;
                glyphData.Top    = area.Top;
                glyphData.Height = area.Height;

                glyphData.TextureXOffset = (float)cacheGlyph.img.TextureOffsetX;
                glyphData.TextureYOffset = (float)cacheGlyph.img.TextureOffsetY;
                glyphData.BorderX        = cacheGlyph.borderX;
                glyphData.BorderY        = cacheGlyph.borderY;


                simpleFontAtlas.AddGlyph(cacheGlyph.glyphIndex, glyphData);
            }

            return(simpleFontAtlas);
        }