Skip to content

Commit

Permalink
Support weight, ascent and descent calculation for Type1FontProgram
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Aug 29, 2024
1 parent ed13a0b commit b965f37
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/org/verapdf/pd/font/type1/Type1FontProgram.java
Original file line number Diff line number Diff line change
Expand Up @@ -339,16 +339,31 @@ public ASFileStreamCloser getFontProgramResource() {

@Override
public String getWeight() {
COSObject weight = this.getObjectFromUserDict(ASAtom.getASAtom(
Type1StringConstants.WEIGHT));
if (weight.getType() == COSObjType.COS_STRING) {
return weight.getString();
}
return null;
}

@Override
public Double getAscent() {
COSObject ascent = this.getObjectFromUserDict(ASAtom.getASAtom(
Type1StringConstants.ASCENT));
if (ascent.getType().isNumber()) {
return ascent.getReal();
}
return null;
}

@Override
public Double getDescent() {
COSObject descent = this.getObjectFromUserDict(ASAtom.getASAtom(
Type1StringConstants.DESCENT));
if (descent.getType().isNumber()) {
return descent.getReal();
}
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ public class Type1StringConstants {
static final String SUBRS = "Subrs";
static final String STANDARD_ENCODING_STRING = "StandardEncoding";
static final String NOACCESS = "noaccess";
static final String WEIGHT = "Weight";
static final String ASCENT = "Ascent";
static final String DESCENT = "Descent";
}

0 comments on commit b965f37

Please sign in to comment.