private static IntMap <TextGlyph> ConvertCharacters(TMP_FontAsset asset) { List <Glyph> glyphList = asset.glyphTable; IntMap <TextGlyph> retn = new IntMap <TextGlyph>(glyphList.Count); for (int i = 0; i < asset.characterTable.Count; i++) { TextGlyph glyph = new TextGlyph(); Glyph tmpGlyph = asset.characterTable[i].glyph; glyph.id = (int)tmpGlyph.index; glyph.height = tmpGlyph.metrics.height; glyph.width = tmpGlyph.metrics.width; glyph.x = tmpGlyph.glyphRect.x; glyph.y = tmpGlyph.glyphRect.y; glyph.scale = tmpGlyph.scale; glyph.xAdvance = tmpGlyph.metrics.horizontalAdvance; glyph.xOffset = tmpGlyph.metrics.horizontalBearingX; glyph.yOffset = tmpGlyph.metrics.horizontalBearingY; retn.Add((int)asset.characterTable[i].unicode, glyph); } return(retn); }
private static IntMap <TextGlyph> ConvertCharacters(Dictionary <int, TMP_Glyph> tmpGlyphs) { IntMap <TextGlyph> retn = new IntMap <TextGlyph>(tmpGlyphs.Count); foreach (KeyValuePair <int, TMP_Glyph> pair in tmpGlyphs) { TMP_Glyph tmpGlyph = pair.Value; TextGlyph glyph = new TextGlyph(); glyph.id = tmpGlyph.id; glyph.height = tmpGlyph.height; glyph.width = tmpGlyph.width; glyph.x = tmpGlyph.x; glyph.y = tmpGlyph.y; glyph.scale = tmpGlyph.scale; glyph.xAdvance = tmpGlyph.xAdvance; glyph.xOffset = tmpGlyph.xOffset; glyph.yOffset = tmpGlyph.yOffset; retn.Add(pair.Key, glyph); } return(retn); }