Skip to content

Commit

Permalink
GH-80 fontfile api renames, stuff that been bugging me for the last d…
Browse files Browse the repository at this point in the history
…ecade or so.
  • Loading branch information
Patrick Corless committed Mar 19, 2021
1 parent 843dc47 commit bb7c602
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public void resetAppearanceStream(double dx, double dy, AffineTransform pageTran
}
fontFile = fontFile.deriveFont(fontSize);
// init font's metrics
fontFile.echarAdvance(' ');
fontFile.getAdvance(' ');
TextSprite textSprites =
new TextSprite(fontFile,
content.length(),
Expand All @@ -456,7 +456,9 @@ public void resetAppearanceStream(double dx, double dy, AffineTransform pageTran
// iterate over each line of text painting the strings.
StringBuilder contents = new StringBuilder(content);

float lineHeight = (float) (Math.floor(fontFile.getAscent()) + Math.floor(fontFile.getDescent()));
// Rectangle2D fontBounds = fontFile.getMaxCharBounds();
// todo temporary get working until I can get back to calculating max char bounds.
float lineHeight = fontSize;

float borderOffsetX = borderStyle.getStrokeWidth() / 2 + 1; // 1 pixel padding
float borderOffsetY = borderStyle.getStrokeWidth() / 2;
Expand All @@ -466,7 +468,7 @@ public void resetAppearanceStream(double dx, double dy, AffineTransform pageTran

float currentX;
// we don't want to shift the whole line width just the ascent
float currentY = advanceY + (float) fontFile.getAscent();
float currentY = advanceY + lineHeight;

float lastx = 0;
float newAdvanceX;
Expand All @@ -475,7 +477,7 @@ public void resetAppearanceStream(double dx, double dy, AffineTransform pageTran

currentChar = contents.charAt(i);

newAdvanceX = (float) fontFile.echarAdvance(currentChar).getX();
newAdvanceX = (float) fontFile.getAdvance(currentChar).getX();
currentX = advanceX + lastx;
lastx += newAdvanceX;

Expand Down Expand Up @@ -570,7 +572,7 @@ public void resetAppearanceStream(double dx, double dy, AffineTransform pageTran
org.icepdf.core.pobjects.fonts.Font newFont;
if (form.getResources() == null ||
form.getResources().getFont(EMBEDDED_FONT_NAME) == null) {
newFont = new org.icepdf.core.pobjects.fonts.ofont.Font(
newFont = new org.icepdf.core.pobjects.fonts.zfont.SimpleFont(
library, fontDictionary);
newFont.setPObjectReference(stateManager.getNewReferenceNumber());
// create font entry
Expand All @@ -595,7 +597,7 @@ public void resetAppearanceStream(double dx, double dy, AffineTransform pageTran
}
newFont = form.getResources().getFont(EMBEDDED_FONT_NAME);
Reference reference = newFont.getPObjectReference();
newFont = new org.icepdf.core.pobjects.fonts.ofont.Font(library, fontDictionary);
newFont = new org.icepdf.core.pobjects.fonts.zfont.SimpleFont(library, fontDictionary);
newFont.setPObjectReference(reference);
}
// update hard reference to state manager and weak library reference.
Expand Down

0 comments on commit bb7c602

Please sign in to comment.