Ejemplo n.º 1
0
        public SimpleBitmapAtlasBuilder CreateTextureFontFromInputChars(
            Typeface typeface, float sizeInPoint,
            TextureKind textureKind,
            char[] chars,
            OnEachGlyph onEachGlyphDel = null)
        {
            _onEachGlyphDel = onEachGlyphDel;
            //convert input chars into glyphIndex
            List <ushort> glyphIndices = new List <ushort>(chars.Length);
            int           i            = 0;

            foreach (char ch in chars)
            {
                glyphIndices.Add(typeface.GetGlyphIndex(ch));
                i++;
            }
            //-------------------------------------------------------------
            var atlasBuilder = new SimpleBitmapAtlasBuilder();

            atlasBuilder.SetAtlasInfo(textureKind, sizeInPoint);
            //-------------------------------------------------------------
            //we can specfic subset with special setting for each set
            CreateTextureFontFromGlyphIndices(typeface, sizeInPoint,
                                              HintTechnique.TrueTypeInstruction_VerticalOnly, atlasBuilder, GetUniqueGlyphIndexList(glyphIndices));

            _onEachGlyphDel = null;//reset
            return(atlasBuilder);
        }
Ejemplo n.º 2
0
 public GlyphNotFoundHelper(
     SimpleBitmapAtlasBuilder atlasBuilder,
     GlyphOutlineBuilder outlineBuilder,
     OnEachGlyph onEachGlyphDel,
     AggGlyphTextureGen aggTextureGen, float sizeInPoints)
 {
     _atlasBuilder   = atlasBuilder;
     _outlineBuilder = outlineBuilder;
     _onEachGlyphDel = onEachGlyphDel;
     _aggTextureGen  = aggTextureGen;
     _sizeInPoints   = sizeInPoints;
 }
Ejemplo n.º 3
0
        public SimpleBitmapAtlasBuilder CreateTextureFontFromBuildDetail(
            Typeface typeface, float sizeInPoint,
            TextureKind textureKind,
            GlyphTextureBuildDetail[] details,
            OnEachGlyph onEachGlyphDel = null)
        {
            _onEachGlyphDel = onEachGlyphDel;
            //-------------------------------------------------------------
            var atlasBuilder = new SimpleBitmapAtlasBuilder();

            atlasBuilder.SetAtlasInfo(textureKind, sizeInPoint);
            //-------------------------------------------------------------
            int j = details.Length;

            for (int i = 0; i < j; ++i)
            {
                GlyphTextureBuildDetail detail = details[i];
                if (detail.ScriptLang != null)
                {
                    //skip those script lang=null
                    //2. find associated glyph index base on input script langs
                    List <ushort> outputGlyphIndexList = new List <ushort>();
                    typeface.CollectAllAssociateGlyphIndex(outputGlyphIndexList, detail.ScriptLang);
                    CreateTextureFontFromGlyphIndices(typeface,
                                                      sizeInPoint,
                                                      detail.HintTechnique,
                                                      atlasBuilder,
                                                      GetUniqueGlyphIndexList(outputGlyphIndexList)
                                                      );
                }
            }
            for (int i = 0; i < j; ++i)
            {
                GlyphTextureBuildDetail detail = details[i];
                if (detail.OnlySelectedGlyphIndices != null)
                {
                    //skip those script lang=null
                    //2. find associated glyph index base on input script langs

                    CreateTextureFontFromGlyphIndices(typeface,
                                                      sizeInPoint,
                                                      detail.HintTechnique,
                                                      atlasBuilder,
                                                      detail.OnlySelectedGlyphIndices
                                                      );
                }
            }

            _onEachGlyphDel = null;//reset
            return(atlasBuilder);
        }
Ejemplo n.º 4
0
        public void CreateTextureFontFromBuildDetail(
            SimpleBitmapAtlasBuilder atlasBuilder,
            Typeface typeface,
            float sizeInPoint,
            TextureKind textureKind,
            GlyphTextureBuildDetail[] details,
            OnEachGlyph onEachGlyphDel = null)
        {
            _onEachGlyphDel = onEachGlyphDel;
            SetCurrentFontInfo(typeface, sizeInPoint);
            //-------------------------------------------------------------

            atlasBuilder.SetAtlasInfo(textureKind, _currentDPI);
            atlasBuilder.SetAtlasFontInfo(typeface.Name, sizeInPoint);
            //-------------------------------------------------------------
            int j = details.Length;

            for (int i = 0; i < j; ++i)
            {
                GlyphTextureBuildDetail detail = details[i];
                if (detail.AllGlyphs)
                {
                    //all
                    int      count          = typeface.GlyphCount;
                    ushort[] glyphIndexList = new ushort[count];
                    for (ushort m = 0; m < count; ++m)
                    {
                        glyphIndexList[m] = m;
                    }
                    CreateTextureFontFromGlyphIndices(
                        detail.HintTechnique,
                        atlasBuilder,
                        glyphIndexList
                        );
                }
                else if (!detail.ScriptLang.IsEmpty())
                {
                    //skip those script lang=null
                    //2. find associated glyph index base on input script langs
                    atlasBuilder.ScriptTags.Add(detail.ScriptLang.scriptTag);


                    List <ushort> outputGlyphIndexList = new List <ushort>();

                    typeface.CollectAllAssociateGlyphIndex(outputGlyphIndexList, detail.ScriptLang);
                    CreateTextureFontFromGlyphIndices(
                        detail.HintTechnique,
                        atlasBuilder,
                        GetUniqueGlyphIndexList(outputGlyphIndexList)
                        );
                }
                else
                {
                    //??
                }
            }

            for (int i = 0; i < j; ++i)
            {
                GlyphTextureBuildDetail detail = details[i];
                if (detail.OnlySelectedChars != null)
                {
                    //skip those script lang=null
                    //2. find associated glyph index base on input script langs

                    CreateTextureFontFromGlyphIndices(
                        detail.HintTechnique,
                        atlasBuilder,
                        detail.OnlySelectedChars
                        );
                }
            }

            _onEachGlyphDel = null;//reset
        }