From fed51541a016c371ca28dabbf31ba624db4704e6 Mon Sep 17 00:00:00 2001 From: Marco Postigo Perez <44845832+mppperez@users.noreply.github.com> Date: Sun, 15 Aug 2021 12:24:42 +0200 Subject: [PATCH] allow disabling/enabling of compositeFontDrawer programmatically --- .../java/com/lowagie/text/pdf/PdfGraphics2D.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/openpdf/src/main/java/com/lowagie/text/pdf/PdfGraphics2D.java b/openpdf/src/main/java/com/lowagie/text/pdf/PdfGraphics2D.java index 99472adbb..2ecbe520a 100755 --- a/openpdf/src/main/java/com/lowagie/text/pdf/PdfGraphics2D.java +++ b/openpdf/src/main/java/com/lowagie/text/pdf/PdfGraphics2D.java @@ -193,8 +193,8 @@ public class PdfGraphics2D extends Graphics2D { private final CompositeFontDrawer compositeFontDrawer = new CompositeFontDrawer(); - // make use of compositeFontDrawer configurable ... note: must be explicitly set to false otherwise always true (backwards compatibility). - private final boolean isCompositeFontDrawerEnabled = SystemPropertyUtil.getBoolean("com.github.librepdf.openpdf.compositeFontDrawerEnabled", true); + // make use of compositeFontDrawer configurable ... may be set via property or directly via setter + private boolean isCompositeFontDrawerEnabled = SystemPropertyUtil.getBoolean("com.github.librepdf.openpdf.compositeFontDrawerEnabled", true); private PdfGraphics2D() { dg2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); @@ -1377,8 +1377,15 @@ private void internalDispose(ByteBuffer buf) { // implementation specific methods // // - - + + /** + * Enables/Disables the composite font drawer due to issues with custom font mappers that do not always default to one specific font but allow custom fonts. + * @param compositeFontDrawerEnabled true if the composite font drawer should be used else false. + */ + public void setCompositeFontDrawerEnabled(boolean compositeFontDrawerEnabled) { + isCompositeFontDrawerEnabled = compositeFontDrawerEnabled; + } + private void followPath(Shape s, int drawType) { if (s==null) return; if (drawType==STROKE) {