Gets the width of a <CODE>char</CODE> in normalized 1000 units.
@param char1 the unicode <CODE>char</CODE> to get the width of
@return the width in normalized 1000 units
18250
public int getWidth(int char1) {
        if (vertical)
            return 1000;
        if (fontSpecific) {
            if ((char1 & 0xff00) == 0 || (char1 & 0xff00) == 0xf000)
                return getRawWidth(char1 & 0xff, null);
            else
                return 0;
        }
        else {
            return getRawWidth(char1, encoding);
        }
    }
905549
public char charAt(int where) {
        int len = length();
        if (where < 0) {
            throw new IndexOutOfBoundsException("charAt: " + where + " < 0");
        } else if (where >= len) {
            throw new IndexOutOfBoundsException("charAt: " + where + " >= length " + len);
        }

        if (where >= mGapStart)
            return mText[where + mGapLength];
        else
            return mText[where];
    }
1060782
@Override
    public final int codeToMbc(int code, byte[] bytes, int p) {
        if (code > MAX_BYTE) return ErrorCodes.ERR_TOO_BIG_WIDE_CHAR_VALUE;

        bytes[p] = (byte)code;
        return 1;
    }
805747
int charStart() {
        if (recognizedLength > inCharStart - inPos.p) {
            System.arraycopy(inBytes, inCharStart, readBuf, recognizedLength, inP - inCharStart);
            charStart = 0;
            charStartBytes = readBuf;
        } else {
            charStart = inCharStart - recognizedLength;
            charStartBytes = inBytes;
        }

        return recognizedLength + (inP - inCharStart);
    }
1230275
public static int getSize(String descriptor) {
		int size = 0;
		int descriptorpos = 1; // start after the '('
		char ch;
		while ((ch = descriptor.charAt(descriptorpos)) != ')') {
			switch (ch) {
				case '[':
					size++;
					// jump to end of array, could be [[[[I
					while (descriptor.charAt(++descriptorpos) == '[') {
						;
					}
					if (descriptor.charAt(descriptorpos) == 'L') {
						descriptorpos = descriptor.indexOf(';', descriptorpos) + 1;
					}
					else {
						// Just a primitive array
						descriptorpos++;
					}
					break;
				case 'L':
					size++;
					// jump to end of 'L' signature
					descriptorpos = descriptor.indexOf(';', descriptorpos) + 1;
					break;
				case 'J':
					size = size + 2;
					descriptorpos++;
					break;
				case 'D':
					size = size + 2;
					descriptorpos++;
					break;
				case 'F':
				case 'B':
				case 'S':
				case 'I':
				case 'Z':
				case 'C':
					size++;
					descriptorpos++;
					break;
				default:
					throw new IllegalStateException("Unexpected character in descriptor: " + ch);
			}
		}
		return size;
	}
340260
@Nonnegative
  public static int getLeadingCharCount (@Nullable final String s, final char c)
  {
    int ret = 0;
    if (s != null)
    {
      final int nMax = s.length ();
      while (ret < nMax && s.charAt (ret) == c)
        ++ret;
    }
    return ret;
  }
1151199
static CharInput asCharInput(final CharSequence chars) {
    checkNotNull(chars);
    return new CharInput() {
      int index = 0;

      @Override
      public int read() {
        if (index < chars.length()) {
          return chars.charAt(index++);
        } else {
          return -1;
        }
      }

      @Override
      public void close() {
        index = chars.length();
      }
    };
  }
584549
public static int sizeUTF(String str) {
        int len=str != null? str.length() : 0, utflen=2;
        if(len == 0)
            return utflen;
        for(int i = 0; i < len; i++) {
           int  c=str.charAt(i);
            if((c >= 0x0001) && (c <= 0x007F))
                utflen++;
            else if (c > 0x07FF)
                utflen += 3;
            else
                utflen += 2;
        }
        return utflen;
    }
1213743
protected int getGlyphWidth(int glyph) {
        if (glyph >= GlyphWidths.length)
            glyph = GlyphWidths.length - 1;
        return GlyphWidths[glyph];
    }
190903
float width(int character) {
        if (image == null)
            return font.getWidthPoint(character, size) * hScale;
        else
            return image.getScaledWidth();
    }
270088
public static byte[] chars2Bytes(final char[] chars) {
        if (chars == null || chars.length <= 0) return null;
        int    len   = chars.length;
        byte[] bytes = new byte[len];
        for (int i = 0; i < len; i++) {
            bytes[i] = (byte) (chars[i]);
        }
        return bytes;
    }
1163913
public int getKerning(int char1, int char2) {
        int metrics[] = getMetricsTT(char1);
        if (metrics == null)
            return 0;
        int c1 = metrics[0];
        metrics = getMetricsTT(char2);
        if (metrics == null)
            return 0;
        int c2 = metrics[0];
        return kerning.get((c1 << 16) + c2);
    }
607704
def _getChar(self, char_spec):
        
        if len(char_spec) >= 4 and all(c in string.hexdigits for c in char_spec):
            char_number = int(char_spec, 16)
            if char_number not in range(0x110000):
                raise ValueError('No such character')
            return chr(char_number)
        elif len(char_spec) == 1:
            return char_spec
        else:
            raise ValueError('No such character')
1344861
def _char_density(self, c, font=ImageFont.load_default()):
        
        image = Image.new('1', font.getsize(c), color=255)
        draw = ImageDraw.Draw(image)
        draw.text((0, 0), c, fill="white", font=font)
        return collections.Counter(image.getdata())[0]
373814
public char readChar () throws IOException
  {
    if (m_nInBuf > 0)
    {
      --m_nInBuf;
      if (++m_nBufpos == m_nBufsize)
        m_nBufpos = 0;
      return m_aBuffer[m_nBufpos];
    }

    if (++m_nBufpos == m_nAvailable)
      _adjustBuffSize ();

    final char c = _readByte ();
    m_aBuffer[m_nBufpos] = c;

    // This would be the point to handle CSS (un)escaping
    if (m_bTrackLineColumn)
      _updateLineColumn (c);
    return c;
  }
485829
public Character getChar(String name) {
        Object o = get(name);
        if (o instanceof Character) {
            return (Character)o;
        }

        if (o != null) {
            String string = o.toString();
            if (string != null && string.length() == 1) {
                return string.charAt(0);
            }
        }
        return null;
    }
664009
private int countCharsStart(final char ch, final boolean allowSpaces)
    {
        int count = 0;
        for (int i = 0; i < this.value.length(); i++)
        {
            final char c = this.value.charAt(i);
            if (c == ' ' && allowSpaces)
            {
                continue;
            }
            if (c == ch)
            {
                count++;
            }
            else
            {
                break;
            }
        }
        return count;
    }