示例#1
0
        public double stringWidth(String text)
        {
            double width = 0;

            int  len      = text.length();
            char prevChar = 0;

            for (int i = 0; i < len; i++)
            {
                char ch = text[i];

                if (ch >= 256)
                {
                    continue;
                }

                FontChar fontChar = _chars[ch];

                if (fontChar == null)
                {
                    continue;
                }

                width += fontChar.getWidth();

                // XXX: kerning

                prevChar = ch;
            }

            return(width);
        }
示例#2
0
        void addChar(FontChar fontChar)
        {
            int code = fontChar.getCode();

            if (code >= 0 && code < _chars.length)
            {
                _chars[code] = fontChar;

                _charCount++;
                _totalWidth += fontChar.getWidth();
                if (fontChar.getWidth() > _maxWidth)
                {
                    _maxWidth = fontChar.getWidth();
                }
            }
        }