예제 #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
        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
        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);
 }