Skip to content

Commit

Permalink
m-abboud#18 refact: eliminated generic warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
batzorent committed Aug 22, 2019
1 parent bc122a1 commit 2cdfc4a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.mabb.fontverter.opentype.OpenTypeFont;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand All @@ -36,7 +37,7 @@ public class PsType0ToOpenTypeConverter {
private OpenTypeFont otfFont;
private PDType0Font type0Font;

public FVFont convert(PDType0Font type0Font) throws IOException, IllegalAccessException, InstantiationException {
public FVFont convert(PDType0Font type0Font) throws IOException, IllegalAccessException, InstantiationException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
this.type0Font = type0Font;
PDCIDFont descendantFont = type0Font.getDescendantFont();

Expand All @@ -56,7 +57,7 @@ public FVFont convert(PDType0Font type0Font) throws IOException, IllegalAccessEx
return otfFont;
}

private OpenTypeFont getOtfFromDescendantFont(PDCIDFont descendantFont) throws IOException, InstantiationException, IllegalAccessException {
private OpenTypeFont getOtfFromDescendantFont(PDCIDFont descendantFont) throws IOException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
if (isTtfDescendant()) {
byte[] ttfData = type0Font.getFontDescriptor().getFontFile2().toByteArray();
OpenTypeParser otfParser = new OpenTypeParser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.mabb.fontverter.woff.WoffTable;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;

public class WoffToOtfConverter implements FontConverter {
OpenTypeFont otfFont;
Expand All @@ -44,7 +45,7 @@ public FVFont convertFont(FVFont font) throws IOException {
return otfFont;
}

private void readTables() throws IOException, InstantiationException, IllegalAccessException {
private void readTables() throws IOException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
for (WoffTable tableOn : woffFont.getTables()) {
OpenTypeTable.OtfTableRecord record = new OpenTypeTable.OtfTableRecord();

Expand Down
28 changes: 13 additions & 15 deletions src/main/java/org/mabb/fontverter/opentype/OpenTypeFont.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import org.mabb.fontverter.converter.*;
import org.mabb.fontverter.io.FontDataOutputStream;
import org.mabb.fontverter.validator.RuleValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
Expand All @@ -41,9 +39,9 @@
* Apple TrueType spec can be found here: https://developer.apple.com/fonts/TrueType-Reference-Manual
*/
public class OpenTypeFont implements FVFont {

SfntHeader sfntHeader;
private List<OpenTypeTable> tables;
private static Logger log = LoggerFactory.getLogger(OpenTypeFont.class);
private File sourceFile;

public static OpenTypeFont createBlankFont() throws IOException {
Expand Down Expand Up @@ -149,7 +147,6 @@ public void normalize() throws IOException {
}

private void createNewOS2WinMetricsTable() {
HorizontalHeadTable hhea = getHhea();
OS2WinMetricsTable table = OS2WinMetricsTable.createDefaultTable();
setOs2(table);
}
Expand Down Expand Up @@ -248,18 +245,18 @@ else if (getPost() != null)
}

private byte[] getRawData() throws IOException {
FontDataOutputStream out = new FontDataOutputStream(FontDataOutputStream.OPEN_TYPE_CHARSET);
sfntHeader.setNumTables(tables.size());
try (FontDataOutputStream out = new FontDataOutputStream(FontDataOutputStream.OPEN_TYPE_CHARSET)) {
sfntHeader.setNumTables(tables.size());
out.write(sfntHeader.getData());

out.write(sfntHeader.getData());
for (OpenTypeTable tableOn : tables)
out.write(tableOn.getRecordData());

for (OpenTypeTable tableOn : tables)
out.write(tableOn.getRecordData());

for (OpenTypeTable tableOn : tables)
out.write(tableOn.getData());
for (OpenTypeTable tableOn : tables)
out.write(tableOn.getData());

return out.toByteArray();
return out.toByteArray();
}
}

private void calculateOffsets(List<OpenTypeTable> tables) throws IOException {
Expand Down Expand Up @@ -311,7 +308,7 @@ public void setSourceFile(File sourceFile) {
this.sourceFile = sourceFile;
}

public void removeTable(Class toRemoveType) {
public void removeTable(Class<? extends OpenTypeTable> toRemoveType) {
OpenTypeTable toRemoveTable = null;
for (OpenTypeTable tableOn : tables) {
if (tableOn.getClass() == toRemoveType)
Expand All @@ -322,7 +319,8 @@ public void removeTable(Class toRemoveType) {
tables.remove(toRemoveTable);
}

private <T extends OpenTypeTable> T findTableType(Class type) {
@SuppressWarnings("unchecked")
private <T extends OpenTypeTable> T findTableType(Class<T> type) {
for (OpenTypeTable tableOn : tables) {
if (tableOn.getClass() == type)
return (T) tableOn;
Expand Down

0 comments on commit 2cdfc4a

Please sign in to comment.