Inheritance: PixelFarm.Drawing.Fonts.FontFace
Exemplo n.º 1
0
        internal TextureFont(TextureFontFace typeface, float sizeInPoints)
        {
            this.typeface = typeface;
            this.fontAtlas = typeface.FontAtlas;
            actualFont = typeface.InnerFontFace.GetFontAtPointsSize(sizeInPoints);

        }
Exemplo n.º 2
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;
        }