@Override public Glyph getGlyph(int unicode) { if (fontEncoding.canEncode(unicode) || unicode < 33) { Glyph 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; }
@Override public boolean containsGlyph(int unicode) { return (fontEncoding.canEncode(unicode) || unicode < 33) && getFontProgram().getGlyph(fontEncoding.getUnicodeDifference(unicode)) != null; }
@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 = 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; }
@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; }
@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; } }
@Override public byte[] convertToBytes(Glyph glyph) { byte[] bytes = new byte[1]; if (fontEncoding.isFontSpecific()) { bytes[0] = (byte) glyph.getCode(); } else { if (fontEncoding.canEncode(glyph.getUnicode())) { bytes[0] = (byte) fontEncoding.convertToByte(glyph.getUnicode()); } else { return EMPTY_BYTES; } } shortTag[bytes[0] & 0xff] = 1; return bytes; }
@Override public void writeText(GlyphLine text, int from, int to, PdfOutputStream stream) { byte[] bytes = new byte[to - from + 1]; int ptr = 0; if (fontEncoding.isFontSpecific()) { for (int i = from; i <= to; i++) { bytes[ptr++] = (byte) text.get(i).getCode(); } } else { for (int i = from; i <= to; i++) { if (fontEncoding.canEncode(text.get(i).getUnicode())) { bytes[ptr++] = (byte) fontEncoding.convertToByte(text.get(i).getUnicode()); } } } bytes = ArrayUtil.shortenArray(bytes, ptr); for (byte b : bytes) { shortTag[b & 0xff] = 1; } StreamUtil.writeEscapedString(stream, bytes); }
@Override public byte[] convertToBytes(GlyphLine glyphLine) { if (glyphLine != null) { byte[] bytes = new byte[glyphLine.size()]; int ptr = 0; if (fontEncoding.isFontSpecific()) { for (int i = 0; i < glyphLine.size(); i++) { bytes[ptr++] = (byte) glyphLine.get(i).getCode(); } } else { for (int i = 0; i < glyphLine.size(); i++) { if (fontEncoding.canEncode(glyphLine.get(i).getUnicode())) { bytes[ptr++] = (byte) fontEncoding.convertToByte(glyphLine.get(i).getUnicode()); } } } bytes = ArrayUtil.shortenArray(bytes, ptr); for (byte b : bytes) { shortTag[b & 0xff] = 1; } return bytes; } else { return EMPTY_BYTES; } }
if (unicode != -1 && fontEncoding.canEncode(unicode)) { int code = fontEncoding.convertToByte(unicode); ((Type3Font) getFontProgram()).addGlyph(code, unicode, widths[code], null, new Type3Glyph(charProcsDic.getAsStream(glyphName), getDocument()));