Esempio n. 1
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);
        }
Esempio n. 2
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
        }