コード例 #1
0
ファイル: Program.cs プロジェクト: Zbyl/BFGFontTool
 public static void createBFG(CreateBFGOptions options)
 {
     BMFont font = new BMFont();
     font.Load(options.bmFontInputFileName);
     font.SaveBFGFont(options.bfgFontOutputFileName);
     if (options.generateFakeD3Dats)
     {
         string outputDirectory = Path.GetDirectoryName(options.bfgFontOutputFileName);
         font.SaveFakeD3Fonts(outputDirectory);
     }
 }
コード例 #2
0
ファイル: BFGFonts.cs プロジェクト: Zbyl/BFGFontTool
        short pointSize = 48; // must be 48!

        #endregion Fields

        #region Methods

        public void Load(BMFont font)
        {
            Debug.Assert(font.pages.Count == 1);
            BMPage page = font.pages[0];
            var bmGlyphs = from g in font.glyphs
                         where g.page == 0
                         select g;

            pointSize = 48; // must be 48!
            ascender = (short)font.fontBase;
            descender = (short)(font.fontBase - font.lineHeight);

            int lowestPoint = 0;
            foreach (BMGlyph g in bmGlyphs)
            {
                BFGGlyph glyph = new BFGGlyph();
                glyph.Load(font, g);
                glyphs.Add(glyph);

                int lowestGlyph = g.yoffset + glyph.height;
                if (lowestGlyph > lowestPoint)
                    lowestPoint = lowestGlyph;

                if (lowestGlyph > font.lineHeight)
                {
                    Console.WriteLine("WARNING: Glyph {0} is too high {1} for line height {2}.", g.id, lowestGlyph, font.lineHeight);
                }
            }

            if (lowestPoint != font.lineHeight)
            {
                Console.WriteLine("WARNING: Line height ({0}) is not what I thought it would be ({1}).", font.lineHeight, lowestPoint);
                Console.WriteLine("         BMFont's settings used to generate source font might be wrong.");
                Console.WriteLine("         Also descender might be wrong: {0} instead of {1}.", descender, font.fontBase - lowestPoint);
            }
        }
コード例 #3
0
ファイル: D3Fonts.cs プロジェクト: Zbyl/BFGFontTool
        public void Load(BMFont font, bool hackForBFG, float hackScaleForBFG = 1.0f)
        {
            Debug.Assert(font.pages.Count == 1);
            BMPage page = font.pages[0];
            var bmglyphs = from g in font.glyphs
                         where g.page == 0
                         select g;

            var dict = bmglyphs.ToDictionary(g => g.id, g => g);

            maxHeight = 0;
            maxWidth = 0;
            maxTop = 0;
            maxBottom = 0;
            for (int i = 0; i < GLYPHS_PER_FONT; ++i)
            {
                BMGlyph bmglyph = dict.ContainsKey(i) ? dict[i] : bmglyphs.First();

                D3Glyph glyph = new D3Glyph();
                glyph.Load(font, bmglyph, hackForBFG, hackScaleForBFG);
                name = font.faceName;

                if (maxHeight < glyph.height)
                    maxHeight = glyph.height;
                if (maxWidth < glyph.xSkip)
                    maxWidth = glyph.xSkip;
                if (maxTop < glyph.top)
                    maxTop = glyph.top;
                if (maxBottom < glyph.bottom)
                    maxBottom = glyph.bottom;

                glyphs[i] = glyph;
            }

            this.glyphScale = hackScaleForBFG;
        }
コード例 #4
0
ファイル: BFGFonts.cs プロジェクト: Zbyl/BFGFontTool
        public byte xSkip; // x adjustment after rendering this glyph

        #endregion Fields

        #region Methods

        public void Load(BMFont font, BMGlyph glyph)
        {
            id = glyph.id;

            width = (byte)glyph.width;
            height = (byte)glyph.height;
            top = (byte)(font.fontBase - glyph.yoffset);
            //top = (byte)(font.lineHeight - glyph.yoffset);
            left = (byte)glyph.xoffset;
            xSkip = (byte)glyph.xadvance;
            s = (ushort)glyph.x;
            t = (ushort)glyph.y;
        }
コード例 #5
0
ファイル: D3Fonts.cs プロジェクト: Zbyl/BFGFontTool
        public int xSkip; // x adjustment

        #endregion Fields

        #region Methods

        public void Load(BMFont font, BMGlyph glyph, bool hackForBFG, float hackScaleForBFG = 1.0f)
        {
            int textureWidth = hackForBFG ? 256 : font.scaleW;
            int textureHeight = hackForBFG ? 256 : font.scaleH;

            height = glyph.height;
            top = font.lineHeight - glyph.height;
            bottom = 0;
            pitch = glyph.width;
            xSkip = glyph.xadvance;
            imageHeight = glyph.height;
            imageWidth = glyph.width;

            s = (float)glyph.x / textureWidth;
            t = (float)glyph.y / textureHeight;
            s2 = (float)(glyph.x + glyph.width) / textureWidth;
            t2 = (float)(glyph.y + glyph.height) / textureHeight;

            if (hackForBFG)
            {
                Scale(hackScaleForBFG);
                s2 = s + (float)imageWidth / textureWidth;
                t2 = t + (float)imageHeight / textureHeight;
            }

            Debug.Assert(font.pages.Count == 1);
            textureName = "fonts/" + font.pages[0].file;
            //textureName = "fonts/" + font.faceName;
        }
コード例 #6
0
 public void AddCharactersFromFont(BMFont font)
 {
     allInterestingCharacters.UnionWith(from glyph in font.glyphs select glyph.id);
 }