public void CreateTextureFontFromInputChars( SimpleBitmapAtlasBuilder atlasBuilder, Typeface typeface, float sizeInPoint, TextureKind textureKind, char[] chars, OnEachGlyph onEachGlyphDel = null) { _onEachGlyphDel = onEachGlyphDel; SetCurrentFontInfo(typeface, sizeInPoint); //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++; } //------------------------------------------------------------- atlasBuilder.SetAtlasInfo(textureKind, _currentDPI); atlasBuilder.SetAtlasFontInfo(typeface.Name, sizeInPoint); //------------------------------------------------------------- //we can specfic subset with special setting for each set CreateTextureFontFromGlyphIndices( HintTechnique.TrueTypeInstruction_VerticalOnly, atlasBuilder, GetUniqueGlyphIndexList(glyphIndices)); _onEachGlyphDel = null;//reset }
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 }