use of com.tom_roush.pdfbox.cos.COSName in project PdfBox-Android by TomRoush.
the class PDType0Font method readEncoding.
/**
* Reads the font's Encoding entry, which should be a CMap name/stream.
*/
private void readEncoding() throws IOException {
COSBase encoding = dict.getDictionaryObject(COSName.ENCODING);
if (encoding instanceof COSName) {
// predefined CMap
COSName encodingName = (COSName) encoding;
cMap = CMapManager.getPredefinedCMap(encodingName.getName());
if (cMap != null) {
isCMapPredefined = true;
} else {
throw new IOException("Missing required CMap");
}
} else if (encoding != null) {
cMap = readCMap(encoding);
if (cMap == null) {
throw new IOException("Missing required CMap");
} else if (!cMap.hasCIDMappings()) {
Log.w("PdfBox-Android", "Invalid Encoding CMap in font " + getName());
}
}
// check if the descendant font is CJK
PDCIDSystemInfo ros = descendantFont.getCIDSystemInfo();
if (ros != null) {
isDescendantCJK = "Adobe".equals(ros.getRegistry()) && ("GB1".equals(ros.getOrdering()) || "CNS1".equals(ros.getOrdering()) || "Japan1".equals(ros.getOrdering()) || "Korea1".equals(ros.getOrdering()));
}
}
use of com.tom_roush.pdfbox.cos.COSName in project PdfBox-Android by TomRoush.
the class PDType3Font method readEncoding.
@Override
protected final void readEncoding() throws IOException {
COSBase encodingBase = dict.getDictionaryObject(COSName.ENCODING);
if (encodingBase instanceof COSName) {
COSName encodingName = (COSName) encodingBase;
encoding = Encoding.getInstance(encodingName);
if (encoding == null) {
Log.w("PdfBox-Android", "Unknown encoding: " + encodingName.getName());
}
} else if (encodingBase instanceof COSDictionary) {
encoding = new DictionaryEncoding((COSDictionary) encodingBase);
}
glyphList = GlyphList.getAdobeGlyphList();
}
use of com.tom_roush.pdfbox.cos.COSName in project PdfBox-Android by TomRoush.
the class PDType3Font method generateBoundingBox.
private BoundingBox generateBoundingBox() {
PDRectangle rect = getFontBBox();
if (rect.getLowerLeftX() == 0 && rect.getLowerLeftY() == 0 && rect.getUpperRightX() == 0 && rect.getUpperRightY() == 0) {
// Plan B: get the max bounding box of the glyphs
COSDictionary cp = getCharProcs();
for (COSName name : cp.keySet()) {
COSBase base = cp.getDictionaryObject(name);
if (base instanceof COSStream) {
PDType3CharProc charProc = new PDType3CharProc(this, (COSStream) base);
try {
PDRectangle glyphBBox = charProc.getGlyphBBox();
if (glyphBBox == null) {
continue;
}
rect.setLowerLeftX(Math.min(rect.getLowerLeftX(), glyphBBox.getLowerLeftX()));
rect.setLowerLeftY(Math.min(rect.getLowerLeftY(), glyphBBox.getLowerLeftY()));
rect.setUpperRightX(Math.max(rect.getUpperRightX(), glyphBBox.getUpperRightX()));
rect.setUpperRightY(Math.max(rect.getUpperRightY(), glyphBBox.getUpperRightY()));
} catch (IOException ex) {
// ignore
}
}
}
}
return new BoundingBox(rect.getLowerLeftX(), rect.getLowerLeftY(), rect.getUpperRightX(), rect.getUpperRightY());
}
use of com.tom_roush.pdfbox.cos.COSName in project PdfBox-Android by TomRoush.
the class DictionaryEncoding method applyDifferences.
private void applyDifferences() {
// now replace with the differences
COSBase base = encoding.getDictionaryObject(COSName.DIFFERENCES);
if (!(base instanceof COSArray)) {
return;
}
COSArray diffArray = (COSArray) base;
int currentIndex = -1;
for (int i = 0; i < diffArray.size(); i++) {
COSBase next = diffArray.getObject(i);
if (next instanceof COSNumber) {
currentIndex = ((COSNumber) next).intValue();
} else if (next instanceof COSName) {
COSName name = (COSName) next;
overwrite(currentIndex, name.getName());
this.differences.put(currentIndex, name.getName());
currentIndex++;
}
}
}
use of com.tom_roush.pdfbox.cos.COSName in project PdfBox-Android by TomRoush.
the class PDFontDescriptor method getFontName.
/**
* Get the font name.
*
* @return The name of the font.
*/
public String getFontName() {
String retval = null;
COSBase base = dic.getDictionaryObject(COSName.FONT_NAME);
if (base instanceof COSName) {
retval = ((COSName) base).getName();
}
return retval;
}
Aggregations