PixelFarm.DrawingGL.TextureFontFace.GetFontAtPointsSize C# (CSharp) Method

GetFontAtPointsSize() public method

public GetFontAtPointsSize ( float pointSize ) : ActualFont
pointSize float
return PixelFarm.Drawing.Fonts.ActualFont
        public override ActualFont GetFontAtPointsSize(float pointSize)
        {
            TextureFont t = new TextureFont(this, pointSize);
            return t;
        }
        protected override void OnDispose()

Usage Example

コード例 #1
0
        public ActualFont ResolveForTextureFont(RequestFont font)
        {
            //check if we have texture font fot this font 
            TextureFont t = TextureFont.GetCacheFontAsTextureFont(font);
            if (t != null)
            {
                return t;
            }
            //--------------------------------------------------------------------
            LateTextureFontInfo lateFontInfo;
            if (!textureBitmapInfos.TryGetValue(font.Name, out lateFontInfo))
            {
                //not found
                return null;
            }
            //check if we have create TextureFont
            TextureFontFace textureFontface = lateFontInfo.Fontface;
            if (textureFontface == null)
            {
                //load glyh image here
                GlyphImage glyphImage = null;
                using (var nativeImg = new PixelFarm.Drawing.Imaging.NativeImage(lateFontInfo.TextureBitmapFile))
                {
                    glyphImage = new GlyphImage(nativeImg.Width, nativeImg.Height);
                    var buffer = new int[nativeImg.Width * nativeImg.Height];
                    System.Runtime.InteropServices.Marshal.Copy(nativeImg.GetNativeImageHandle(), buffer, 0, buffer.Length);
                    glyphImage.SetImageBuffer(buffer, true);
                }

                InstalledFont installedFont = GLES2PlatformFontMx.GetInstalledFont(font.Name, InstalledFontStyle.Regular);
                FontFace nOpenTypeFontFace = NOpenTypeFontLoader.LoadFont(installedFont.FontPath,
                      GLES2PlatformFontMx.defaultLang,
                      GLES2PlatformFontMx.defaultHbDirection,
                      GLES2PlatformFontMx.defaultScriptCode);


                textureFontface = new TextureFontFace(nOpenTypeFontFace, lateFontInfo.FontMapFile, glyphImage);
                lateFontInfo.Fontface = textureFontface;
                return textureFontface.GetFontAtPointsSize(font.SizeInPoints);
            }
            if (textureFontface != null)
            {
                t = (TextureFont)(textureFontface.GetFontAtPointsSize(font.SizeInPoints));
                t.AssignToRequestFont(font);
                return t;
            }
            else
            {
                //
                //need to create font face
                //create fontface first

            }
            return null;
        }