FairyGUI.BitmapFont.GetGlyph C# (CSharp) Method

GetGlyph() public method

public GetGlyph ( char ch, GlyphInfo glyph ) : bool
ch char
glyph GlyphInfo
return bool
        public override bool GetGlyph(char ch, GlyphInfo glyph)
        {
            BMGlyph bg;
            if (ch == ' ')
            {
                glyph.width = Mathf.CeilToInt(size * scale / 2);
                glyph.height = Mathf.CeilToInt(size * scale);
                glyph.vert.xMin = 0;
                glyph.vert.xMax = 0;
                glyph.vert.yMin = 0;
                glyph.vert.yMax = 0;
                glyph.uvTopLeft = Vector2.zero;
                glyph.uvBottomLeft = Vector2.zero;
                glyph.uvTopRight = Vector2.zero;
                glyph.uvBottomRight = Vector2.zero;
                glyph.channel = 0;
                return true;
            }
            else if (_dict.TryGetValue((int)ch, out bg))
            {
                glyph.width = Mathf.CeilToInt(bg.advance * scale);
                glyph.height = Mathf.CeilToInt(bg.lineHeight * scale);
                glyph.vert.xMin = bg.offsetX * scale;
                glyph.vert.xMax = (bg.offsetX + bg.width) * scale;
                glyph.vert.yMin = (-bg.height - bg.offsetY) * scale;
                glyph.vert.yMax = -bg.offsetY * scale;
                glyph.uvBottomLeft = new Vector2(bg.uvRect.xMin, bg.uvRect.yMin);
                glyph.uvTopLeft = new Vector2(bg.uvRect.xMin, bg.uvRect.yMax);
                glyph.uvTopRight = new Vector2(bg.uvRect.xMax, bg.uvRect.yMax);
                glyph.uvBottomRight = new Vector2(bg.uvRect.xMax, bg.uvRect.yMin);
                glyph.channel = bg.channel;
                return true;
            }
            else
                return false;
        }

Usage Example

 static public int GetGlyph(IntPtr l)
 {
     try {
         FairyGUI.BitmapFont self = (FairyGUI.BitmapFont)checkSelf(l);
         System.Char         a1;
         checkType(l, 2, out a1);
         var ret = self.GetGlyph(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }