示例#1
0
        public static FontFace LoadFont(
            Typeface typeface,
            TextureFontCreationParams creationParams,
            out SimpleFontAtlas fontAtlas)
        {
            //1. read font info
            NOpenFontFace openFont = (NOpenFontFace)OpenFontLoader.LoadFont(typeface, creationParams.scriptLang, creationParams.writeDirection);

            //------------------------
            SimpleFontAtlasBuilder atlas1 = null;

            switch (creationParams.textureKind)
            {
            default: throw new System.NotSupportedException();

            case TextureKind.AggSubPixel:
                atlas1 = CreateAggSubPixelRenderingTextureFont(
                    typeface,
                    creationParams.originalFontSizeInPoint,
                    creationParams.hintTechnique,
                    GetGlyphIndexIter(typeface, creationParams.langBits)
                    );
                break;

            case TextureKind.AggGrayScale:
                atlas1 = CreateAggTextureFont(
                    typeface,
                    creationParams.originalFontSizeInPoint,
                    creationParams.hintTechnique,
                    GetGlyphIndexIter(typeface, creationParams.langBits)
                    );
                break;

            case TextureKind.Msdf:
                atlas1 = CreateSampleMsdfTextureFont(
                    typeface,
                    creationParams.originalFontSizeInPoint,
                    creationParams.hintTechnique,
                    GetGlyphIndexIter(typeface, creationParams.langBits)
                    );
                break;
            }

            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;

            return(openFont);
            //var textureFontFace = new TextureFontFace(openFont, fontAtlas);
            //return textureFontFace;
        }
示例#2
0
        public static FontFace LoadFont(Typeface typeface)
        {
            //read font file
            //TODO:...
            //set shape engine ***
            var openFont = new NOpenFontFace(typeface, typeface.Name, typeface.Filename);

            return(openFont);
        }
示例#3
0
 public NOpenFont(NOpenFontFace ownerFace, float sizeInPoints, FontStyle style)
 {
     this.ownerFace    = ownerFace;
     this.sizeInPoints = sizeInPoints;
     this.style        = style;
     this.typeFace     = ownerFace.Typeface;
     //calculate scale ***
     scale = typeFace.CalculateToPixelScaleFromPointSize(sizeInPoints);
 }
示例#4
0
 public NOpenFont(NOpenFontFace ownerFace, float sizeInPoints, FontStyle style)
 {
     _ownerFace    = ownerFace;
     _sizeInPoints = sizeInPoints;
     _style        = style;
     _typeFace     = ownerFace.Typeface;
     //calculate scale ***
     _scale = _typeFace.CalculateScaleToPixelFromPointSize(sizeInPoints);
     _recommendLineSpacing = _typeFace.CalculateRecommendLineSpacing() * _scale;
 }
        public static FontFace LoadFont(
            Typeface typeface,
            ScriptLang scriptLang,
            WriteDirection writeDirection = WriteDirection.LTR)
        {
            //read font file
            //TODO:...
            //set shape engine ***

            var openFont = new NOpenFontFace(typeface, typeface.Name, typeface.Filename);

            return(openFont);
        }