public IFont GetFont(string name, int size, Weight weight, bool italic) { var fontStyle = GetFontStyle(weight, italic); var fce = new FontCacheEntry { FontFace = name, FontSize = size, FontStyle = fontStyle }; QFont font; var config = new QFontBuilderConfiguration(false) { TextGenerationRenderHint = GetFontFaceRenderHintingPreference(name), GlyphMargin = 2, TransformToCurrentOrthogProjection = true, KerningConfig = { alphaEmptyPixelTolerance = 40, }, }; if (!_fontCache.TryGetValue(fce, out font)) { var sysFont = GetFontBestSizeFit(name, size, fontStyle); font = new QFont(sysFont, config); _fontCache[fce] = font; } return new WrappedFont(font); }
private void CreateFontCacheEntry(FontCacheEntry fontCacheEntry) { var font = new Font(_device, fontCacheEntry.FontSize, 0, fontCacheEntry.FontWeight, 1, fontCacheEntry.Italic, CharacterSet.Default, Precision.Device, FontQuality.ClearTypeNatural, PitchAndFamily.DontCare, fontCacheEntry.FontFace); _fontCache[fontCacheEntry] = font; }
private static IntPtr GetCachedHFont(Font font) { //the original code struck me as bad. attempting to ID fonts by picking a subset of their fields is not gonna work. //don't call this.Font in InputRoll.cs, it is probably slow. //consider Fonts to be a jealously guarded resource (they need to be disposed, after all) and manage them carefully. //this cache maintains the HFONTs only. FontCacheEntry ce; if (!FontsCache.TryGetValue(font, out ce)) { FontsCache[font] = ce = new FontCacheEntry(); ce.HFont = font.ToHfont(); } return(ce.HFont); }
private FontCacheEntry GetCachedHFont(Font font) { FontCacheEntry fontEntry; var result = _fontsCache.TryGetValue(font, out fontEntry); if (!result) { // Hack! The 6 is hardcoded to make tastudio look like taseditor, because taseditor is so perfect and wonderful fontEntry = new FontCacheEntry { HFont = CreateNormalHFont(font, 6), RotatedHFont = CreateRotatedHFont(font, true) }; _fontsCache.Add(font, fontEntry); } return(fontEntry); }
public IFont GetFont(string fontFace="Arial", int fontSize=16, Weight weight=Weight.Normal, bool italic=false) { var fontWeight = MapWeight(weight); var testEntry = new FontCacheEntry { FontFace = fontFace, FontSize = fontSize, FontWeight = fontWeight, Italic = italic }; if (!_fontCache.ContainsKey(testEntry)) { CreateFontCacheEntry(testEntry); } return _fontCache[testEntry]; }
private IntPtr GetCachedHFont(Font font) { //the original code struck me as bad. attempting to ID fonts by picking a subset of their fields is not gonna work. //don't call this.Font in InputRoll.cs, it is probably slow. //consider Fonts to be a jealously guarded resource (they need to be disposed, after all) and manage them carefully. //this cache maintains the HFONTs only. FontCacheEntry ce; if (!FontsCache.TryGetValue(font, out ce)) { FontsCache[font] = ce = new FontCacheEntry(); ce.HFont = font.ToHfont(); } return ce.HFont; }