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; }
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); } } }
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); } }
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); } } }