예제 #1
0
        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;
        }
예제 #2
0
        public ushort t;        // y offset in image where glyph starts (in pixels)

        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;
        }
예제 #3
0
        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 void Load(string fileName)
        {
            string[] allLines = File.ReadAllLines(fileName);

            if (allLines.Count() < 2)
            {
                throw new ApplicationException("Invalid format!");
            }
            if (!LoadInfo(allLines[0]))
            {
                throw new ApplicationException("Invalid format!");
            }
            if (!LoadCommon(allLines[1]))
            {
                throw new ApplicationException("Invalid format!");
            }

            var glyphLines = from line in allLines
                             where line.StartsWith("char")
                             select line;

            var pageLines = from line in allLines
                            where line.StartsWith("page")
                            select line;

            foreach (string line in glyphLines)
            {
                BMGlyph glyph = new BMGlyph();
                if (glyph.Load(line))
                {
                    glyphs.Add(glyph);
                }
            }

            foreach (string line in pageLines)
            {
                BMPage page = new BMPage();
                if (page.Load(line))
                {
                    pages.Add(page);
                }
            }
        }
예제 #5
0
파일: BMFonts.cs 프로젝트: Zbyl/BFGFontTool
        public bool unicode; // true if unicode (charset is empty then)

        #endregion Fields

        #region Methods

        public void Load(string fileName)
        {
            string[] allLines = File.ReadAllLines(fileName);

            if (allLines.Count() < 2)
                throw new ApplicationException("Invalid format!");
            if (!LoadInfo(allLines[0]))
                throw new ApplicationException("Invalid format!");
            if (!LoadCommon(allLines[1]))
                throw new ApplicationException("Invalid format!");

            var glyphLines = from line in allLines
                                where line.StartsWith("char")
                                select line;

            var pageLines = from line in allLines
                                where line.StartsWith("page")
                                select line;

            foreach (string line in glyphLines)
            {
                BMGlyph glyph = new BMGlyph();
                if (glyph.Load(line))
                {
                    glyphs.Add(glyph);
                }
            }

            foreach (string line in pageLines)
            {
                BMPage page = new BMPage();
                if (page.Load(line))
                {
                    pages.Add(page);
                }
            }
        }
예제 #6
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;
        }
예제 #7
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;
        }