Пример #1
0
        public static FontFace LoadFont(string fontfile,
                                        ScriptLang scriptLang,
                                        WriteDirection writeDirection,
                                        out SimpleFontAtlas fontAtlas)
        {
            //1. read font info
            ManagedFontFace openFont = (ManagedFontFace)OpenFontLoader.LoadFont(fontfile, scriptLang, writeDirection);

            //2. build texture font on the fly! OR load from prebuilt file
            //
            //2.1 test build texture on the fly
            SimpleFontAtlasBuilder atlas1    = CreateSampleMsdfTextureFont(fontfile, 14, 0, 255);
            GlyphImage             glyphImg2 = atlas1.BuildSingleImage();

            fontAtlas            = atlas1.CreateSimpleFontAtlas();
            fontAtlas.TotalGlyph = glyphImg2;

            //string xmlFontFileInfo = "";
            //GlyphImage glyphImg = null;
            //MySimpleFontAtlasBuilder atlasBuilder = new MySimpleFontAtlasBuilder();
            //SimpleFontAtlas fontAtlas = atlasBuilder.LoadFontInfo(xmlFontFileInfo);
            //glyphImg = atlasBuilder.BuildSingleImage(); //we can create a new glyph or load from prebuilt file
            //fontAtlas.TotalGlyph = glyphImg;


            var textureFontFace = new TextureFontFace(openFont, fontAtlas);

            return(textureFontFace);
        }
Пример #2
0
 public ManagedActualFont(ManagedFontFace ownerFace, float sizeInPoints, FontStyle style)
 {
     this.ownerFace    = ownerFace;
     this.sizeInPoints = sizeInPoints;
     this.style        = style;
     this.typeFace     = ownerFace.Typeface;
     //calculate scale ***
     scale = typeFace.CalculateFromPointToPixelScale(sizeInPoints);
 }
Пример #3
0
        public static FontFace LoadFont(string fontfile,
                                        ScriptLang scriptLang,
                                        WriteDirection writeDirection = WriteDirection.LTR)
        {
            //read font file
            OpenFontReader openTypeReader = new OpenFontReader();
            Typeface       typeface       = null;

            using (FileStream fs = new FileStream(fontfile, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                typeface = openTypeReader.Read(fs);
                if (typeface == null)
                {
                    return(null);
                }
            }
            //TODO:...
            //set shape engine ***
            var openFont = new ManagedFontFace(typeface, typeface.Name, fontfile);

            return(openFont);
        }