@Override public int appendAnyGlyph(String text, int from, List<Glyph> glyphs) { Glyph glyph; if (fontEncoding.isFontSpecific()) { glyph = fontProgram.getGlyphByCode(text.charAt(from)); } else { glyph = getGlyph((int) text.charAt(from)); } if (glyph != null) { glyphs.add(glyph); } return 1; }
@Override public GlyphLine createGlyphLine(String content) { List<Glyph> glyphs = new ArrayList<>(content.length()); if (fontEncoding.isFontSpecific()) { for (int i = 0; i < content.length(); i++) { Glyph glyph = fontProgram.getGlyphByCode(content.charAt(i)); if (glyph != null) { glyphs.add(glyph); } } } else { for (int i = 0; i < content.length(); i++) { Glyph glyph = getGlyph((int) content.charAt(i)); if (glyph != null) { glyphs.add(glyph); } } } return new GlyphLine(glyphs); }
@Override public Glyph getGlyph(int unicode) { if (fontEncoding.canEncode(unicode)) { Glyph glyph = getFontProgram().getGlyph(fontEncoding.getUnicodeDifference(unicode)); //TODO TrueType what if font is specific? if (glyph == null && (glyph = notdefGlyphs.get(unicode)) == null) { Glyph notdef = getFontProgram().getGlyphByCode(0); if (notdef != null) { glyph = new Glyph(getFontProgram().getGlyphByCode(0), unicode); notdefGlyphs.put(unicode, glyph); } } return glyph; } return null; }
for (int i = 0; i < metrics.length; i++) { int code = metrics[i]; if (fontProgram.getGlyphByCode(code).getChars() != null) { unicodeGlyphs.add(code); Glyph glyph = fontProgram.getGlyphByCode((int) unicodeGlyphs.get(k)); if (glyph.getChars() != null) { StringBuilder uni = new StringBuilder(glyph.getChars().length);
for (int i = 0; i < metrics.length; i++) { int[] metric = (int[]) metrics[i]; if (fontProgram.getGlyphByCode(metric[0]).getChars() != null) { unicodeGlyphs.add(metric[0]); Glyph glyph = fontProgram.getGlyphByCode((int) unicodeGlyphs.get(k)); if (glyph.getChars() != null) { StringBuilder uni = new StringBuilder(glyph.getChars().length);
glyph = fontProgram.getGlyphByCode(glyphCode); if (glyph != null) { i += codeLength - 1; glyphs.add(glyph); } else { glyphs.add(new Glyph(0, fontProgram.getGlyphByCode(0).getWidth(), -1));
@Override public Glyph getGlyph(int unicode) { // TODO handle unicode value with cmap and use only glyphByCode Glyph glyph = getFontProgram().getGlyph(unicode); if (glyph == null && (glyph = notdefGlyphs.get(unicode)) == null) { // Handle special layout characters like sfthyphen (00AD). // This glyphs will be skipped while converting to bytes Glyph notdef = getFontProgram().getGlyphByCode(0); if (notdef != null) { glyph = new Glyph(notdef, unicode); } else { glyph = new Glyph(-1, 0, unicode); } notdefGlyphs.put(unicode, glyph); } return glyph; }
@Override public int appendGlyphs(String text, int from, int to, List<Glyph> glyphs) { int processed = 0; if (fontEncoding.isFontSpecific()) { for (int i = from; i <= to; i++) { Glyph glyph = fontProgram.getGlyphByCode(text.charAt(i) & 0xFF); if (glyph != null) { glyphs.add(glyph); processed++; } else { break; } } } else { for (int i = from; i <= to; i++) { Glyph glyph = getGlyph((int) text.charAt(i)); if (glyph != null && (containsGlyph(glyph.getUnicode()) || isAppendableGlyph(glyph))) { glyphs.add(glyph); processed++; } else if (glyph == null && TextUtil.isWhitespaceOrNonPrintable((int) text.charAt(i))) { processed++; } else { break; } } } return processed; }
@Override public boolean containsGlyph(int unicode) { if (fontEncoding.isFontSpecific()) { return fontProgram.getGlyphByCode(unicode) != null; } else { return fontEncoding.canEncode(unicode) && getFontProgram().getGlyph(fontEncoding.getUnicodeDifference(unicode)) != null; } }
@Override public Glyph getGlyph(int unicode) { if (fontEncoding.canEncode(unicode)) { Glyph glyph; if (fontEncoding.isFontSpecific()) { glyph = getFontProgram().getGlyphByCode(unicode); } else { glyph = getFontProgram().getGlyph(fontEncoding.getUnicodeDifference(unicode)); if (glyph == null && (glyph = notdefGlyphs.get(unicode)) == null) { // Handle special layout characters like sfthyphen (00AD). // This glyphs will be skipped while converting to bytes glyph = new Glyph(-1, 0, unicode); notdefGlyphs.put(unicode, glyph); } } return glyph; } return null; }
if (cmapEncoding.isDirect()) { for (int k = 0; k < len; ++k) { Glyph glyph = fontProgram.getGlyphByCode((int) content.charAt(k)); if (glyph != null) { glyphs.add(glyph);
/** * {@inheritDoc} */ @Override public GlyphLine decodeIntoGlyphLine(PdfString content) { byte[] contentBytes = content.getValueBytes(); List<Glyph> glyphs = new ArrayList<>(contentBytes.length); for (byte b : contentBytes) { int code = b & 0xff; Glyph glyph = null; if (toUnicode != null && toUnicode.lookup(code) != null && (glyph = fontProgram.getGlyphByCode(code)) != null) { if (!Arrays.equals(toUnicode.lookup(code), glyph.getChars())) { // Copy the glyph because the original one may be reused (e.g. standard Helvetica font program) glyph = new Glyph(glyph); glyph.setChars(toUnicode.lookup(code)); } } else { int uni = fontEncoding.getUnicode(code); if (uni > -1) { glyph = getGlyph(uni); } else if (fontEncoding.getBaseEncoding() == null) { glyph = fontProgram.getGlyphByCode(code); } } if (glyph != null) { glyphs.add(glyph); } } return new GlyphLine(glyphs); }
Glyph glyph = fontProgram.getGlyphByCode((int) text.charAt(from)); if (glyph != null) { glyphs.add(glyph);
int processed = 0; for (int k = from; k <= to; k++) { Glyph glyph = fontProgram.getGlyphByCode((int) text.charAt(k)); if (glyph != null && (isAppendableGlyph(glyph))) { glyphs.add(glyph);
@Override public boolean containsGlyph(int unicode) { if (fontEncoding.canEncode(unicode)) { if (fontEncoding.isFontSpecific()) { return getFontProgram().getGlyphByCode(unicode) != null; } else { return getFontProgram().getGlyph(fontEncoding.getUnicodeDifference(unicode)) != null; } } else { return false; } }
boolean firstTime = true; for (int[] metric : metrics) { Glyph glyph = fontProgram.getGlyphByCode(metric[0]); if (glyph.getWidth() == FontProgram.DEFAULT_WIDTH) { continue;
boolean firstTime = true; for (int code : metrics) { Glyph glyph = fontProgram.getGlyphByCode(code); if (glyph.getWidth() == FontProgram.DEFAULT_WIDTH) { continue;
@Override public boolean containsGlyph(int unicode) { if (cidFontType == CID_FONT_TYPE_0) { if (cmapEncoding.isDirect()) { return fontProgram.getGlyphByCode(unicode) != null; } else { return getFontProgram().getGlyph(unicode) != null; } } else if (cidFontType == CID_FONT_TYPE_2) { if (fontProgram.isFontSpecific()) { byte[] b = PdfEncodings.convertToBytes((char) unicode, "symboltt"); return b.length > 0 && fontProgram.getGlyph(b[0] & 0xff) != null; } else { return getFontProgram().getGlyph(unicode) != null; } } else { throw new PdfException("Invalid CID font type: " + cidFontType); } }
if (shortTag[k] != 0) { int uni = fontEncoding.getUnicode(k); Glyph glyph = uni > -1 ? fontProgram.getGlyph(uni) : fontProgram.getGlyphByCode(k); if (glyph != null) { glyphs.add(glyph.getCode());
} else if (!fontEncoding.hasDifferences() && fontProgram.getGlyphByCode(k) != null) { shortTag[k] = 1; } else { Glyph glyph = uni > -1 ? getGlyph(uni) : fontProgram.getGlyphByCode(k); wd.add(new PdfNumber(glyph != null ? glyph.getWidth() : 0));