private void Clear() { _initialized = false; _currentFont = null; _currentFontFamily = null; _mbcs = false; }
private void SetFontByScale(float scale) { if(scale <= idE.CvarSystem.GetFloat("gui_smallFontLimit")) { _currentFont = _currentFontFamily.Small; } else if(scale <= idE.CvarSystem.GetFloat("gui_mediumFontLimit")) { _currentFont = _currentFontFamily.Medium; } else { _currentFont = _currentFontFamily.Large; } }
public idFontFamily RegisterFont(string fontName, string fileName) { float glyphScale; byte[] data; int pointSize; idFont outFont; idFontFamily fontFamily = new idFontFamily(fontName); string filePath; for(int fontCount = 0; fontCount < 3; fontCount++) { if(fontCount == 0) { pointSize = 12; } else if(fontCount == 1) { pointSize = 24; } else { pointSize = 48; } // we also need to adjust the scale based on point size relative to 48 points as the ui scaling is based on a 48 point font. // change the scale to be relative to 1 based on 72 dpi ( so dpi of 144 means a scale of .5 ) glyphScale = 1.0f; glyphScale *= 48.0f / pointSize; filePath = string.Format("{0}/fontImage_{1}.dat", fileName, pointSize); data = idE.FileSystem.ReadFile(filePath); if(data == null) { idConsole.Warning("RegisterFont: couldn't find font: {0}", fileName); return null; } using(BinaryReader r = new BinaryReader(new MemoryStream(data))) { outFont = new idFont(filePath); outFont.Init(r, fileName); if(fontCount == 0) { fontFamily.Small = outFont; } else if(fontCount == 1) { fontFamily.Medium = outFont; } else { fontFamily.Large = outFont; } } } return fontFamily; }