Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch 2 #74

Merged
merged 4 commits into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/com/sun/pdfview/PDFFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ private PDFObject readName() throws IOException {
break; // out-of-range, should have been hex
}
// H.3.2.4 indicates version 1.1 did not do hex escapes
if (c == '#' && (this.majorVersion != 1 && this.minorVersion != 1)) {
if (c == '#' && (this.majorVersion >= 1 && this.minorVersion > 1)) {
int hex = readHexPair();
if (hex >= 0) {
c = hex;
Expand Down
8 changes: 7 additions & 1 deletion src/com/sun/pdfview/font/CIDFontType0.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.sun.pdfview.PDFObject;
import com.sun.pdfview.font.cid.PDFCMap;
import com.sun.pdfview.font.ttf.AdobeGlyphList;

/*****************************************************************************
* At the moment this is not fully supported to parse CID based fonts
Expand Down Expand Up @@ -56,7 +57,12 @@ protected PDFGlyph getGlyph(char src, String name) {
// See "9.10 Extraction of Text Content" in the PDF spec.
if (this.glyphLookupMap != null) {
src = this.glyphLookupMap.map(src);
//The preferred method of getting the glyph should be by name.
if (name == null && src != 160){//unless it NBSP
//so, try to find the name by the char
name = AdobeGlyphList.getGlyphName(src);
}
}
return super.getGlyph(src, name);
}
}
}
5 changes: 3 additions & 2 deletions src/com/sun/pdfview/font/PDFFont.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ public synchronized static PDFFont getFont(PDFObject obj,
font = new CIDFontType2(baseFont, obj, descriptor);
}else {
// fake it with a built-in font
font = new BuiltinFont(baseFont, obj, descriptor);
//but it prefer to use the CIDFontType0 that have the extra handling of ToUnicode, if found in the fontObj
font = new CIDFontType0(baseFont, obj, descriptor);
}
} else if (subType.equals("CIDFontType0")) {
if(descriptor.getFontFile2() !=null){
Expand Down Expand Up @@ -526,4 +527,4 @@ public boolean equals(Object o) {
public int hashCode() {
return getBaseFont().hashCode();
}
}
}
9 changes: 7 additions & 2 deletions src/com/sun/pdfview/font/PDFFontDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ public PDFFontDescriptor(String basefont) {
public PDFFontDescriptor(PDFObject obj, String fontSubType) throws IOException {
// required parameters
setFlags(obj.getDictRef("Flags").getIntValue());
setFontName(obj.getDictRef("FontName").getStringValue());
PDFObject fontNameObj = obj.getDictRef("FontName");
if (fontNameObj == null){
// fallback to avoid NPE try to use the BaseFont
fontNameObj = obj.getDictRef("BaseFont");
}
setFontName(fontNameObj.getStringValue());
setItalicAngle(obj.getDictRef("ItalicAngle").getIntValue());

// conditionally required parameters
Expand Down Expand Up @@ -532,4 +537,4 @@ public Rectangle2D.Float getFontBBox() {
public void setFontBBox(Rectangle2D.Float fontBBox) {
this.fontBBox = fontBBox;
}
}
}