diff options
author | Simon Steiner <ssteiner@apache.org> | 2021-06-26 06:22:24 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2021-06-26 06:22:24 +0000 |
commit | 1b8ca39cbbd7945e505f75da595d27c411f40c9c (patch) | |
tree | 04858c06bfa3debc985cb53865501443b63cadc6 /fop-core/src/main | |
parent | 9a63b81a0e0da395589d1a74f3feb5e96b116e32 (diff) | |
download | xmlgraphics-fop-1b8ca39cbbd7945e505f75da595d27c411f40c9c.tar.gz xmlgraphics-fop-1b8ca39cbbd7945e505f75da595d27c411f40c9c.zip |
FOP-3017: Add option to disable positioning per char
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1891051 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'fop-core/src/main')
-rw-r--r-- | fop-core/src/main/java/org/apache/fop/render/afp/AFPFontConfig.java | 17 | ||||
-rw-r--r-- | fop-core/src/main/java/org/apache/fop/render/afp/AFPPainter.java | 8 |
2 files changed, 17 insertions, 8 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/render/afp/AFPFontConfig.java b/fop-core/src/main/java/org/apache/fop/render/afp/AFPFontConfig.java index eb6c4a77f..a9f222bf1 100644 --- a/fop-core/src/main/java/org/apache/fop/render/afp/AFPFontConfig.java +++ b/fop-core/src/main/java/org/apache/fop/render/afp/AFPFontConfig.java @@ -266,8 +266,9 @@ public final class AFPFontConfig implements FontConfig { return null; } String subfont = cfg.getAttribute("sub-font", null); + boolean positionByChar = cfg.getAttributeAsBoolean("position-by-char", true); return new TrueTypeFontConfig(fontTriplets, type, codepage, encoding, "", - name, subfont, isEmbbedable(fontTriplets), uri); + name, subfont, isEmbbedable(fontTriplets), uri, positionByChar); } private RasterFontConfig getRasterFont(List<FontTriplet> triplets, String type, @@ -368,14 +369,16 @@ public final class AFPFontConfig implements FontConfig { private String characterset; private String subfont; private String fontUri; + private boolean positionByChar; private TrueTypeFontConfig(List<FontTriplet> triplets, String type, String codePage, String encoding, String characterset, String name, String subfont, - boolean embeddable, String uri) { + boolean embeddable, String uri, boolean positionByChar) { super(triplets, type, codePage, encoding, name, embeddable, null); this.characterset = characterset; this.subfont = subfont; this.fontUri = uri; + this.positionByChar = positionByChar; } @Override @@ -390,7 +393,7 @@ public final class AFPFontConfig implements FontConfig { CharacterSet characterSet = CharacterSetBuilder.getDoubleByteInstance().build(characterset, super.codePage, super.encoding, tf, accessor, eventProducer); OutlineFont font = new AFPTrueTypeFont(super.name, super.embeddable, characterSet, - eventProducer, subfont, new URI(fontUri)); + eventProducer, subfont, new URI(fontUri), positionByChar); return getFontInfo(font, this); } catch (URISyntaxException e) { throw new IOException(e); @@ -401,11 +404,13 @@ public final class AFPFontConfig implements FontConfig { public static class AFPTrueTypeFont extends OutlineFont { private String ttc; private URI uri; + private boolean positionByChar; public AFPTrueTypeFont(String name, boolean embeddable, CharacterSet charSet, AFPEventProducer eventProducer, - String ttc, URI uri) { + String ttc, URI uri, boolean positionByChar) { super(name, embeddable, charSet, eventProducer); this.ttc = ttc; this.uri = uri; + this.positionByChar = positionByChar; } public FontType getFontType() { @@ -419,6 +424,10 @@ public final class AFPFontConfig implements FontConfig { public URI getUri() { return uri; } + + public boolean isPositionByChar() { + return positionByChar; + } } static final class OutlineFontConfig extends AFPFontConfigData { diff --git a/fop-core/src/main/java/org/apache/fop/render/afp/AFPPainter.java b/fop-core/src/main/java/org/apache/fop/render/afp/AFPPainter.java index 35235668a..9a4a7b93e 100644 --- a/fop-core/src/main/java/org/apache/fop/render/afp/AFPPainter.java +++ b/fop-core/src/main/java/org/apache/fop/render/afp/AFPPainter.java @@ -70,7 +70,6 @@ import org.apache.fop.afp.ptoca.PtocaProducer; import org.apache.fop.afp.util.AFPResourceAccessor; import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontTriplet; -import org.apache.fop.fonts.FontType; import org.apache.fop.fonts.Typeface; import org.apache.fop.render.ImageHandlerUtil; import org.apache.fop.render.RenderingContext; @@ -1026,11 +1025,12 @@ public class AFPPainter extends AbstractIFPainter<AFPDocumentHandler> { boolean fixedSpaceMode = false; double ttPos = p.x; - + boolean positionByChar = afpFont instanceof AFPFontConfig.AFPTrueTypeFont + && ((AFPFontConfig.AFPTrueTypeFont) afpFont).isPositionByChar(); for (int i = 0; i < l; i++) { char orgChar = text.charAt(i); float glyphAdjust = 0; - if (afpFont.getFontType() == FontType.TRUETYPE) { + if (positionByChar) { flushText(builder, sb, charSet); fixedSpaceMode = true; int charWidth = font.getCharWidth(orgChar); @@ -1064,7 +1064,7 @@ public class AFPPainter extends AbstractIFPainter<AFPDocumentHandler> { glyphAdjust += dx[i + 1]; } - if (afpFont.getFontType() == FontType.TRUETYPE) { + if (positionByChar) { flushText(builder, sb, charSet); ttPos += unitConv.mpt2units(glyphAdjust); builder.absoluteMoveInline((int) Math.round(ttPos)); |