Skip to content

Add InvalidAfmPfm to IOException. #53

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions io/src/main/java/com/itextpdf/io/IOException.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public class IOException extends RuntimeException {
public static final String InvalidWoffFile = "Invalid WOFF font file.";
public static final String InvalidMagicValueForBmpFileMustBeBM = "Invalid magic value for bmp file. Must be 'BM'";
public static final String InvalidTtcFile = "{0} is not a valid TTC file.";
public static final String InvalidAfmPfm = "Invalid afm or pfm font file.";
public static final String IoException = "I/O exception.";
public static final String Jbig2ImageException = "JBIG2 image exception.";
public static final String Jpeg2000ImageException = "JPEG2000 image exception.";
Expand Down
4 changes: 2 additions & 2 deletions io/src/main/java/com/itextpdf/io/font/Type1Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ public RandomAccessFileOrArray getMetricsFile() throws java.io.IOException {
try {
Pfm2afm.convert(rf, ba);
} catch (Exception ignored) {
throw new IOException("Invalid afm or pfm font file.");
throw new IOException(IOException.InvalidAfmPfm);
} finally {
rf.close();
}
return new RandomAccessFileOrArray(sourceFactory.createSource(ba.toByteArray()));
}
} else {
throw new IOException("Invalid afm or pfm font file.");
throw new IOException(IOException.InvalidAfmPfm);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ public void createWrongAfm1() throws IOException {
} catch (com.itextpdf.io.IOException e) {
message = e.getMessage();
}
Assert.assertEquals("Invalid afm or pfm font file.", message);
Assert.assertEquals(IOException.InvalidAfmPfm, message);
}

@Test
Expand Down