/** * Checks if a character exists in this font. * @param c the character to check * @return <CODE>true</CODE> if the character has a glyph, * <CODE>false</CODE> otherwise */ public boolean charExists(int c) { byte b[] = convertToBytes(c); return b.length > 0; }
/** * Checks if a character exists in this font. * @param c the character to check * @return <CODE>true</CODE> if the character has a glyph, * <CODE>false</CODE> otherwise */ public boolean charExists(int c) { byte b[] = convertToBytes(c); return b.length > 0; }
/** * Sets the character advance. * @param c the character * @param advance the character advance normalized to 1000 units * @return <CODE>true</CODE> if the advance was set, * <CODE>false</CODE> otherwise */ public boolean setCharAdvance(int c, int advance) { byte b[] = convertToBytes(c); if (b.length == 0) return false; widths[0xff & b[0]] = advance; return true; }
/** * Sets the character advance. * @param c the character * @param advance the character advance normalized to 1000 units * @return <CODE>true</CODE> if the advance was set, * <CODE>false</CODE> otherwise */ public boolean setCharAdvance(int c, int advance) { byte b[] = convertToBytes(c); if (b.length == 0) return false; widths[0xff & b[0]] = advance; return true; }
/** * Gets the smallest box enclosing the character contours. It will return * <CODE>null</CODE> if the font has not the information or the character has no * contours, as in the case of the space, for example. Characters with no contours may * also return [0,0,0,0]. * @param c the character to get the contour bounding box from * @return an array of four floats with the bounding box in the format [llx,lly,urx,ury] or * <code>null</code> */ public int[] getCharBBox(int c) { byte b[] = convertToBytes(c); if (b.length == 0) return null; else return charBBoxes[b[0] & 0xff]; }
/** * Gets the smallest box enclosing the character contours. It will return * <CODE>null</CODE> if the font has not the information or the character has no * contours, as in the case of the space, for example. Characters with no contours may * also return [0,0,0,0]. * @param c the character to get the contour bounding box from * @return an array of four floats with the bounding box in the format [llx,lly,urx,ury] or * <code>null</code> */ public int[] getCharBBox(int c) { byte b[] = convertToBytes(c); if (b.length == 0) return null; else return charBBoxes[b[0] & 0xff]; }
/** * 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 */ public int getWidth(int char1) { if (fastWinansi) { if (char1 < 128 || char1 >= 160 && char1 <= 255) return widths[char1]; else return widths[PdfEncodings.winansi.get(char1)]; } else { int total = 0; byte mbytes[] = convertToBytes(/*(char)*/char1); for (int k = 0; k < mbytes.length; ++k) total += widths[0xff & mbytes[k]]; return total; } }
/** * 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 */ public int getWidth(int char1) { if (fastWinansi) { if (char1 < 128 || char1 >= 160 && char1 <= 255) return widths[char1]; else return widths[PdfEncodings.winansi.get(char1)]; } else { int total = 0; byte mbytes[] = convertToBytes(/*(char)*/char1); for (int k = 0; k < mbytes.length; ++k) total += widths[0xff & mbytes[k]]; return total; } }
/** * Gets the width of a <CODE>String</CODE> in normalized 1000 units. * @param text the <CODE>String</CODE> to get the width of * @return the width in normalized 1000 units */ public int getWidth(String text) { int total = 0; if (fastWinansi) { int len = text.length(); for (int k = 0; k < len; ++k) { char char1 = text.charAt(k); if (char1 < 128 || char1 >= 160 && char1 <= 255) total += widths[char1]; else total += widths[PdfEncodings.winansi.get(char1)]; } return total; } else { byte mbytes[] = convertToBytes(text); for (int k = 0; k < mbytes.length; ++k) total += widths[0xff & mbytes[k]]; } return total; }
/** * Gets the width of a <CODE>String</CODE> in normalized 1000 units. * @param text the <CODE>String</CODE> to get the width of * @return the width in normalized 1000 units */ public int getWidth(String text) { int total = 0; if (fastWinansi) { int len = text.length(); for (int k = 0; k < len; ++k) { char char1 = text.charAt(k); if (char1 < 128 || char1 >= 160 && char1 <= 255) total += widths[char1]; else total += widths[PdfEncodings.winansi.get(char1)]; } return total; } else { byte mbytes[] = convertToBytes(text); for (int k = 0; k < mbytes.length; ++k) total += widths[0xff & mbytes[k]]; } return total; }
/** * Converts a <CODE>char</CODE> to a </CODE>byte</CODE> array according * to the font's encoding. * @param char1 the <CODE>char</CODE> to be converted * @return an array of <CODE>byte</CODE> representing the conversion according to the font's encoding */ @Override byte[] convertToBytes(int char1) { if (cidDirect) return super.convertToBytes(char1); return cidByte.lookup(uniCid.lookup(char1)); }
/** * Converts a <CODE>char</CODE> to a </CODE>byte</CODE> array according * to the font's encoding. * @param char1 the <CODE>char</CODE> to be converted * @return an array of <CODE>byte</CODE> representing the conversion according to the font's encoding */ @Override byte[] convertToBytes(int char1) { if (cidDirect) return super.convertToBytes(char1); return cidByte.lookup(uniCid.lookup(char1)); }
@Override byte[] convertToBytes(int char1) { if (cjkMirror != null) return cjkMirror.convertToBytes(char1); else if (isType0) { int[] ws = metrics.get(Integer.valueOf(char1)); if (ws != null) { int g = ws[0]; return new byte[]{(byte)(g / 256), (byte)g}; } else return new byte[0]; } else { if (uni2byte.containsKey(char1)) return new byte[]{(byte)uni2byte.get(char1)}; else return new byte[0]; } }
@Override byte[] convertToBytes(int char1) { if (cjkMirror != null) return cjkMirror.convertToBytes(char1); else if (isType0) { int[] ws = metrics.get(Integer.valueOf(char1)); if (ws != null) { int g = ws[0]; return new byte[]{(byte)(g / 256), (byte)g}; } else return new byte[0]; } else { if (uni2byte.containsKey(char1)) return new byte[]{(byte)uni2byte.get(char1)}; else return new byte[0]; } }
@Override public byte[] convertToBytes(String text) { if (cjkMirror != null) return cjkMirror.convertToBytes(text); else if (isType0) { char[] chars = text.toCharArray();
@Override public byte[] convertToBytes(String text) { if (cjkMirror != null) return cjkMirror.convertToBytes(text); else if (isType0) { char[] chars = text.toCharArray();
public byte[] convertToBytes(String text) { if (cidDirect) return super.convertToBytes(text); try { if (text.length() == 1)
public byte[] convertToBytes(String text) { if (cidDirect) return super.convertToBytes(text); try { if (text.length() == 1)
switch (fontType) { case BaseFont.FONT_TYPE_T3: return baseFont.convertToBytes(text); case BaseFont.FONT_TYPE_T1: case BaseFont.FONT_TYPE_TT: { b = baseFont.convertToBytes(text); int len = b.length; for (int k = 0; k < len; ++k) b = baseFont.convertToBytes(text); break;
switch (fontType) { case BaseFont.FONT_TYPE_T3: return baseFont.convertToBytes(text); case BaseFont.FONT_TYPE_T1: case BaseFont.FONT_TYPE_TT: { b = baseFont.convertToBytes(text); int len = b.length; for (int k = 0; k < len; ++k) b = baseFont.convertToBytes(text); break;