コード例 #1
0
        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.GetFontAtPointsSize(actualFont.SizeInPoints);
            specificFontSize.Add(key, nativeFont);
            return nativeFont;
        }
コード例 #2
0
ファイル: Fonts.cs プロジェクト: prepare/HTML-Renderer
 public RequestFont(string facename, float fontSizeInPts, FontStyle style = FontStyle.Regular)
 {
     HBDirection = Fonts.HBDirection.HB_DIRECTION_LTR;//default
     ScriptCode = HBScriptCode.HB_SCRIPT_LATIN;//default 
     Lang = "en";//default
     Name = facename;
     SizeInPoints = fontSizeInPts;
     Style = style;
     fontKey = new FontKey(facename, fontSizeInPts, style);
     //temp fix 
     //we need font height*** 
     //this.Height = SizeInPixels;
 }
コード例 #3
0
        public ActualFont LoadFont(string fontName, float fontSizeInPoints)
        {
            //find install font from fontname
            InstalledFont found = GLES2PlatformFontMx.GetInstalledFont(fontName, InstalledFontStyle.Regular);
            if (found == null)
            {
                return null;
            }

            FontFace fontFace;
            if (!fonts.TryGetValue(found, out fontFace))
            {
                fontFace = FreeTypeFontLoader.LoadFont(found,
                    GLES2PlatformFontMx.defaultLang,
                    GLES2PlatformFontMx.defaultHbDirection,
                    GLES2PlatformFontMx.defaultScriptCode);
                if (fontFace == null)
                {
                    throw new NotSupportedException();
                }
                fonts.Add(found, fontFace);//register
            }
            //-----------
            //create font at specific size from this fontface
            FontKey fontKey = new FontKey(fontName, fontSizeInPoints, FontStyle.Regular);
            ActualFont createdFont;
            if (!registerFonts.TryGetValue(fontKey, out createdFont))
            {
                createdFont = fontFace.GetFontAtPointsSize(fontSizeInPoints);
            }
            //-----------
            return createdFont;
        }
コード例 #4
0
ファイル: WinGdiFont.cs プロジェクト: prepare/HTML-Renderer
 public FontFaceKey(FontKey fontKey)
 {
     this.FontNameIndex = fontKey.FontNameIndex;
     this.FontStyle = fontKey.FontStyle;
 }