NativeFont ResolveForNativeFont(ActualFont actualFont) { NativeFont nativeFont; FontFace fontface = actualFont.FontFace; FontKey key = new FontKey(fontface.Name, actualFont.SizeInPoints, FontStyle.Regular); if (specificFontSize.TryGetValue(key, out nativeFont)) { return(nativeFont); } //----------------------------- //not native font //if we need to use hardbuzz then //create a native one for use FontFace nativeFontFace; if (!nativeFontFaces.TryGetValue(fontface.Name, out nativeFontFace)) { //create new nativeFontFace = FreeTypeFontLoader.LoadFont(fontface.FontPath, "en", HBDirection.HB_DIRECTION_LTR); nativeFontFaces.Add(fontface.Name, nativeFontFace); } //check if we have native fontface for this font? nativeFont = (NativeFont)nativeFontFace.GetFontAtPointSize(actualFont.SizeInPoints); specificFontSize.Add(key, nativeFont); return(nativeFont); }
static ActualFont GetActualFont(string fontName, float size) { //in the case that we want to use FreeType FontFace face = FreeTypeFontLoader.LoadFont(fontName, "en", HBDirection.HB_DIRECTION_LTR); return(face.GetFontAtPointSize(size)); }