Character info.
예제 #1
0
 static public int get_uvBottomRight(IntPtr l)
 {
     try {
         FairyGUI.GlyphInfo self = (FairyGUI.GlyphInfo)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.uvBottomRight);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #2
0
 static public int constructor(IntPtr l)
 {
     try {
         FairyGUI.GlyphInfo o;
         o = new FairyGUI.GlyphInfo();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #3
0
 static public int set_uvBottomRight(IntPtr l)
 {
     try {
         FairyGUI.GlyphInfo  self = (FairyGUI.GlyphInfo)checkSelf(l);
         UnityEngine.Vector2 v;
         checkType(l, 2, out v);
         self.uvBottomRight = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #4
0
 static public int set_vert(IntPtr l)
 {
     try {
         FairyGUI.GlyphInfo self = (FairyGUI.GlyphInfo)checkSelf(l);
         UnityEngine.Rect   v;
         checkValueType(l, 2, out v);
         self.vert = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #5
0
 static public int set_channel(IntPtr l)
 {
     try {
         FairyGUI.GlyphInfo self = (FairyGUI.GlyphInfo)checkSelf(l);
         System.Int32       v;
         checkType(l, 2, out v);
         self.channel = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #6
0
 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;
 }
예제 #7
0
        override public bool GetGlyph(char ch, GlyphInfo glyph)
        {
            if (_font.GetCharacterInfo(ch, out sTempChar, _size, _style))
            {
                RenderInfo ri;
                if (_lastFontSize == _size)                 //避免一次查表
                {
                    ri = _lastRenderInfo;
                }
                else
                {
                    _lastFontSize = _size;
                    ri            = _lastRenderInfo = GetRenderInfo(_size);
                }
#if (UNITY_5 || UNITY_5_3_OR_NEWER)
                glyph.vert.xMin = sTempChar.minX;
                glyph.vert.yMin = sTempChar.minY - ri.yIndent;
                glyph.vert.xMax = sTempChar.maxX;
                if (sTempChar.glyphWidth == 0)                 //zero width, space etc
                {
                    glyph.vert.xMax = glyph.vert.xMin + _size / 2;
                }
                glyph.vert.yMax = sTempChar.maxY - ri.yIndent;

                glyph.uv[0] = sTempChar.uvBottomLeft;
                glyph.uv[1] = sTempChar.uvTopLeft;
                glyph.uv[2] = sTempChar.uvTopRight;
                glyph.uv[3] = sTempChar.uvBottomRight;

                glyph.width  = sTempChar.advance;
                glyph.height = ri.height;
                if (customBold)
                {
                    glyph.width++;
                }
#else
                glyph.vert.xMin = sTempChar.vert.xMin;
                glyph.vert.yMin = sTempChar.vert.yMax - ri.yIndent;
                glyph.vert.xMax = sTempChar.vert.xMax;
                if (sTempChar.vert.width == 0)                 //zero width, space etc
                {
                    glyph.vert.xMax = glyph.vert.xMin + _size / 2;
                }
                glyph.vert.yMax = sTempChar.vert.yMin - ri.yIndent;

                if (!sTempChar.flipped)
                {
                    glyph.uv[0] = new Vector2(sTempChar.uv.xMin, sTempChar.uv.yMin);
                    glyph.uv[1] = new Vector2(sTempChar.uv.xMin, sTempChar.uv.yMax);
                    glyph.uv[2] = new Vector2(sTempChar.uv.xMax, sTempChar.uv.yMax);
                    glyph.uv[3] = new Vector2(sTempChar.uv.xMax, sTempChar.uv.yMin);
                }
                else
                {
                    glyph.uv[0] = new Vector2(sTempChar.uv.xMin, sTempChar.uv.yMin);
                    glyph.uv[1] = new Vector2(sTempChar.uv.xMax, sTempChar.uv.yMin);
                    glyph.uv[2] = new Vector2(sTempChar.uv.xMax, sTempChar.uv.yMax);
                    glyph.uv[3] = new Vector2(sTempChar.uv.xMin, sTempChar.uv.yMax);
                }

                glyph.width  = Mathf.CeilToInt(sTempChar.width);
                glyph.height = sTempChar.size;
                if (customBold)
                {
                    glyph.width++;
                }
#endif
                if (keepCrisp)
                {
                    glyph.vert.xMin /= UIContentScaler.scaleFactor;
                    glyph.vert.yMin /= UIContentScaler.scaleFactor;
                    glyph.vert.xMax /= UIContentScaler.scaleFactor;
                    glyph.vert.yMax /= UIContentScaler.scaleFactor;
                    glyph.width     /= UIContentScaler.scaleFactor;
                    glyph.height    /= UIContentScaler.scaleFactor;
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #8
0
        override public bool GetGlyph(char ch, GlyphInfo glyph)
        {
            if (_font.GetCharacterInfo(ch, out sTempChar, _size, _style))
            {
                float baseline;
                if (_lastFontSize == _size)
                {
                    baseline = _lastBaseLine;
                }
                else
                {
                    _lastFontSize = _size;
                    baseline      = GetBaseLine(_size);
                    _lastBaseLine = baseline;
                }
#if UNITY_5
                glyph.vert.xMin = sTempChar.minX;
                glyph.vert.yMin = sTempChar.minY - baseline;
                glyph.vert.xMax = sTempChar.maxX;
                if (sTempChar.glyphWidth == 0)                 //zero width, space etc
                {
                    glyph.vert.xMax = glyph.vert.xMin + _size / 2;
                }
                glyph.vert.yMax     = sTempChar.maxY - baseline;
                glyph.uvTopLeft     = sTempChar.uvTopLeft;
                glyph.uvBottomLeft  = sTempChar.uvBottomLeft;
                glyph.uvTopRight    = sTempChar.uvTopRight;
                glyph.uvBottomRight = sTempChar.uvBottomRight;

                glyph.width  = sTempChar.advance;
                glyph.height = sTempChar.size;
                if (customBold)
                {
                    glyph.width++;
                }
#else
                glyph.vert.xMin = sTempChar.vert.xMin;
                glyph.vert.yMin = sTempChar.vert.yMax - baseline;
                glyph.vert.xMax = sTempChar.vert.xMax;
                if (sTempChar.vert.width == 0)                 //zero width, space etc
                {
                    glyph.vert.xMax = glyph.vert.xMin + _size / 2;
                }
                glyph.vert.yMax = sTempChar.vert.yMin - baseline;
                if (!sTempChar.flipped)
                {
                    glyph.uvBottomLeft  = new Vector2(sTempChar.uv.xMin, sTempChar.uv.yMin);
                    glyph.uvTopLeft     = new Vector2(sTempChar.uv.xMin, sTempChar.uv.yMax);
                    glyph.uvTopRight    = new Vector2(sTempChar.uv.xMax, sTempChar.uv.yMax);
                    glyph.uvBottomRight = new Vector2(sTempChar.uv.xMax, sTempChar.uv.yMin);
                }
                else
                {
                    glyph.uvBottomLeft  = new Vector2(sTempChar.uv.xMin, sTempChar.uv.yMin);
                    glyph.uvTopLeft     = new Vector2(sTempChar.uv.xMax, sTempChar.uv.yMin);
                    glyph.uvTopRight    = new Vector2(sTempChar.uv.xMax, sTempChar.uv.yMax);
                    glyph.uvBottomRight = new Vector2(sTempChar.uv.xMin, sTempChar.uv.yMax);
                }

                glyph.width  = Mathf.CeilToInt(sTempChar.width);
                glyph.height = sTempChar.size;
                if (customBold)
                {
                    glyph.width++;
                }
#endif
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #9
0
 virtual public bool GetGlyph(char ch, ref GlyphInfo glyph)
 {
     return(false);
 }
예제 #10
0
 public virtual bool GetGlyph(char ch, GlyphInfo glyph)
 {
     return false;
 }
예제 #11
0
 public virtual bool GetGlyph(char ch, GlyphInfo glyph)
 {
     return(false);
 }
예제 #12
0
        public override bool GetGlyph(char ch, GlyphInfo glyph)
        {
            if (_font.GetCharacterInfo(ch, out sTempChar, _size, _style))
            {
                float baseline;
                if (_lastFontSize == _size)
                    baseline = _lastBaseLine;
                else
                {
                    _lastFontSize = _size;
                    baseline = GetBaseLine(_size);
                    _lastBaseLine = baseline;
                }
            #if UNITY_5
                glyph.vert.xMin = sTempChar.minX;
                glyph.vert.yMin = sTempChar.minY - baseline;
                glyph.vert.xMax = sTempChar.maxX;
                if (sTempChar.glyphWidth == 0) //zero width, space etc
                    glyph.vert.xMax = glyph.vert.xMin + _size / 2;
                glyph.vert.yMax = sTempChar.maxY - baseline;

                glyph.uvTopLeft = sTempChar.uvTopLeft;
                glyph.uvBottomLeft = sTempChar.uvBottomLeft;
                glyph.uvTopRight = sTempChar.uvTopRight;
                glyph.uvBottomRight = sTempChar.uvBottomRight;

                glyph.width = sTempChar.advance;
                glyph.height = sTempChar.size;
                if (customBold)
                    glyph.width++;
            #else
                glyph.vert.xMin = sTempChar.vert.xMin;
                glyph.vert.yMin = sTempChar.vert.yMax - baseline;
                glyph.vert.xMax = sTempChar.vert.xMax;
                if (sTempChar.vert.width == 0) //zero width, space etc
                    glyph.vert.xMax = glyph.vert.xMin + _size / 2;
                glyph.vert.yMax = sTempChar.vert.yMin - baseline;

                if (!sTempChar.flipped)
                {
                    glyph.uvBottomLeft = new Vector2(sTempChar.uv.xMin, sTempChar.uv.yMin);
                    glyph.uvTopLeft = new Vector2(sTempChar.uv.xMin, sTempChar.uv.yMax);
                    glyph.uvTopRight = new Vector2(sTempChar.uv.xMax, sTempChar.uv.yMax);
                    glyph.uvBottomRight = new Vector2(sTempChar.uv.xMax, sTempChar.uv.yMin);
                }
                else
                {
                    glyph.uvBottomLeft = new Vector2(sTempChar.uv.xMin, sTempChar.uv.yMin);
                    glyph.uvTopLeft = new Vector2(sTempChar.uv.xMax, sTempChar.uv.yMin);
                    glyph.uvTopRight = new Vector2(sTempChar.uv.xMax, sTempChar.uv.yMax);
                    glyph.uvBottomRight = new Vector2(sTempChar.uv.xMin, sTempChar.uv.yMax);
                }

                glyph.width = Mathf.CeilToInt(sTempChar.width);
                glyph.height = sTempChar.size;
                if (customBold)
                    glyph.width++;
            #endif
                if (keepCrisp)
                {
                    glyph.vert.xMin /= UIContentScaler.scaleFactor;
                    glyph.vert.yMin /= UIContentScaler.scaleFactor;
                    glyph.vert.xMax /= UIContentScaler.scaleFactor;
                    glyph.vert.yMax /= UIContentScaler.scaleFactor;
                    glyph.width /= UIContentScaler.scaleFactor;
                    glyph.height /= UIContentScaler.scaleFactor;
                }

                return true;
            }
            else
                return false;
        }