@Override public boolean hasSubstitution(int index) { return substMap.containsKey(index); } }
@Override public boolean hasSubstitution(int index) { return substMap.containsKey(index); } }
public boolean hasClass(int glyph) { return mapClass.containsKey(glyph); }
public boolean hasClass(int glyph) { return mapClass.containsKey(glyph); }
/** * Checks is {@code text} only has PDF_DOC_ENCODING characters. * * @param text the {@code String} to test * @return {@code true} if only PDF_DOC_ENCODING characters are present */ public static boolean isPdfDocEncoding(String text) { if (text == null) return true; int len = text.length(); for (int k = 0; k < len; k++) { char ch = text.charAt(k); if (ch < 128 || ch > 160 && ch <= 255) continue; if (!pdfEncoding.containsKey((int) ch)) return false; } return true; }
/** * Checks is {@code text} only has PDF_DOC_ENCODING characters. * * @param text the {@code String} to test * @return {@code true} if only PDF_DOC_ENCODING characters are present */ public static boolean isPdfDocEncoding(String text) { if (text == null) return true; int len = text.length(); for (int k = 0; k < len; k++) { char ch = text.charAt(k); if (ch < 128 || ch > 160 && ch <= 255) continue; if (!pdfEncoding.containsKey((int) ch)) return false; } return true; }
/** * Check whether a unicode symbol or font specific code can be converted * to {@code byte} according to the encoding. * * @param unicode a unicode symbol or font specific code to be checked. * @return {@code true} if {@code ch} could be encoded. */ public boolean canEncode(int unicode) { return unicodeToCode.containsKey(unicode) || TextUtil.isNonPrintable(unicode); }
/** * Check whether a unicode symbol or font specific code can be converted * to {@code byte} according to the encoding. * * @param unicode a unicode symbol or font specific code to be checked. * @return {@code true} if {@code ch} could be encoded. */ public boolean canEncode(int unicode) { return unicodeToCode.containsKey(unicode) || TextUtil.isNonPrintable(unicode); }
/** * Converts a {@code String} to a {@code byte} array according to the encoding. * String could contain a unicode symbols or font specific codes. * * @param text the {@code String} to be converted. * @return an array of {@code byte} representing the conversion according to the encoding */ public byte[] convertToBytes(String text) { if (text == null || text.length() == 0) { return emptyBytes; } int ptr = 0; byte[] bytes = new byte[text.length()]; for (int i = 0; i < text.length(); i++) { if (unicodeToCode.containsKey(text.charAt(i))) { bytes[ptr++] = (byte) convertToByte(text.charAt(i)); } } return ArrayUtil.shortenArray(bytes, ptr); }
/** * Converts a {@code String} to a {@code byte} array according to the encoding. * String could contain a unicode symbols or font specific codes. * * @param text the {@code String} to be converted. * @return an array of {@code byte} representing the conversion according to the encoding */ public byte[] convertToBytes(String text) { if (text == null || text.length() == 0) { return emptyBytes; } int ptr = 0; byte[] bytes = new byte[text.length()]; for (int i = 0; i < text.length(); i++) { if (unicodeToCode.containsKey(text.charAt(i))) { bytes[ptr++] = (byte) convertToByte(text.charAt(i)); } } return ArrayUtil.shortenArray(bytes, ptr); }
public int getOtfClass(int glyph, boolean strict) { if (strict) { if (mapClass.containsKey(glyph)) { return mapClass.get(glyph); } else { return -1; } } else { return mapClass.get(glyph); } } }
public int getOtfClass(int glyph, boolean strict) { if (strict) { if (mapClass.containsKey(glyph)) { return mapClass.get(glyph); } else { return -1; } } else { return mapClass.get(glyph); } } }
for (int cid : cid2Uni.getCids()) { int uni = cid2Uni.lookup(cid); int width = metrics.containsKey(cid) ? metrics.get(cid) : DEFAULT_WIDTH; Glyph glyph = new Glyph(cid, width, uni); avgWidth += glyph.getWidth();
for (int cid : cid2Uni.getCids()) { int uni = cid2Uni.lookup(cid); int width = metrics.containsKey(cid) ? metrics.get(cid) : DEFAULT_WIDTH; Glyph glyph = new Glyph(cid, width, uni); avgWidth += glyph.getWidth();
fontProgram.avgWidth = 0; for (int cid : toUnicode.getCodes()) { int width = widths.containsKey(cid) ? widths.get(cid) : dw; Glyph glyph = new Glyph(cid, width, toUnicode.lookup(cid)); if (glyph.hasValidUnicode()) { fontProgram.codeToGlyph.put(0, new Glyph(0, widths != null && widths.containsKey(0) ? widths.get(0) : dw, -1));
fontEncoding.unicodeDifferences.put((int) unicode, (int) unicode); } else { if (byte2uni.containsKey(currentNumber)) { unicode = byte2uni.get(currentNumber); fontEncoding.codeToUnicode[currentNumber] = (int) unicode;