From 4efdc589aa4952b83fccddab117e7fcc1507b2a4 Mon Sep 17 00:00:00 2001 From: Glenn Adams Date: Fri, 18 Jan 2013 21:13:42 +0000 Subject: [PATCH] FOP-2194: optimize lazy font load invocation for hot methods git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1435344 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/fonts/LazyFont.java | 28 +++++++++++++++------ status.xml | 3 +++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/java/org/apache/fop/fonts/LazyFont.java b/src/java/org/apache/fop/fonts/LazyFont.java index fef42f74c..e990e4052 100644 --- a/src/java/org/apache/fop/fonts/LazyFont.java +++ b/src/java/org/apache/fop/fonts/LazyFont.java @@ -153,7 +153,9 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, * {@inheritDoc} */ public char mapChar(char c) { - load(true); + if ( !isMetricsLoaded ) { + load(true); + } return realFont.mapChar(c); } @@ -169,7 +171,9 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, * {@inheritDoc} */ public boolean hasChar(char c) { - load(true); + if ( !isMetricsLoaded ) { + load(true); + } return realFont.hasChar(c); } @@ -250,7 +254,9 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, * {@inheritDoc} */ public int getWidth(int i, int size) { - load(true); + if ( !isMetricsLoaded ) { + load(true); + } return realFont.getWidth(i, size); } @@ -384,7 +390,9 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, */ public CharSequence reorderCombiningMarks ( CharSequence cs, int[][] gpa, String script, String language ) { - load(true); + if ( !isMetricsLoaded ) { + load(true); + } if ( realFontDescriptor instanceof Substitutable ) { return ((Substitutable)realFontDescriptor) .reorderCombiningMarks(cs, gpa, script, language); @@ -397,7 +405,9 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, * {@inheritDoc} */ public boolean performsPositioning() { - load(true); + if ( !isMetricsLoaded ) { + load(true); + } if ( realFontDescriptor instanceof Positionable ) { return ((Positionable)realFontDescriptor).performsPositioning(); } else { @@ -410,7 +420,9 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, */ public int[][] performPositioning ( CharSequence cs, String script, String language, int fontSize ) { - load(true); + if ( !isMetricsLoaded ) { + load(true); + } if ( realFontDescriptor instanceof Positionable ) { return ((Positionable)realFontDescriptor) .performPositioning(cs, script, language, fontSize); @@ -424,7 +436,9 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, */ public int[][] performPositioning ( CharSequence cs, String script, String language ) { - load(true); + if ( !isMetricsLoaded ) { + load(true); + } if ( realFontDescriptor instanceof Positionable ) { return ((Positionable)realFontDescriptor) .performPositioning(cs, script, language); diff --git a/status.xml b/status.xml index 925ba4c17..97bf7784d 100644 --- a/status.xml +++ b/status.xml @@ -59,6 +59,9 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> + + Optimize lazy font load invocation for hot methods. + Fix checkstyle and findbugs warnings. -- 2.39.5