From 59cf5844fee1fc289eefa96ca86c5e59aa7ca98a Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Fri, 1 Jan 2010 13:57:10 +0000 Subject: [PATCH] Fixed a multi-threading bugfix, visible for example when opening examples/fo/basic/readme.fo with the AWT Preview. Words could be jumbled and the wrong fonts were sometimes used. The class still has a performance problem concerning the use of the TextLayout class for determining some font metrics otherwise not available from the Java2D/AWT subsystem. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@895012 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/render/java2d/Java2DFontMetrics.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/java/org/apache/fop/render/java2d/Java2DFontMetrics.java b/src/java/org/apache/fop/render/java2d/Java2DFontMetrics.java index 88ceb1270..544f9c589 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DFontMetrics.java +++ b/src/java/org/apache/fop/render/java2d/Java2DFontMetrics.java @@ -142,7 +142,7 @@ public class Java2DFontMetrics { * @param size font size * @return ascent in milliponts */ - public int getMaxAscent(String family, int style, int size) { + public synchronized int getMaxAscent(String family, int style, int size) { setFont(family, style, size); return Math.round(lineMetrics.getAscent() * FONT_FACTOR); } @@ -155,7 +155,7 @@ public class Java2DFontMetrics { * @param size font size * @return ascent in milliponts */ - public int getAscender(String family, int style, int size) { + public synchronized int getAscender(String family, int style, int size) { setFont(family, style, size); return ascender * 1000; @@ -193,7 +193,7 @@ public class Java2DFontMetrics { * @param size font size * @return capital height in millipoints */ - public int getCapHeight(String family, int style, int size) { + public synchronized int getCapHeight(String family, int style, int size) { // currently just gets Ascent value but maybe should use // getMaxAcent() at some stage return getAscender(family, style, size); @@ -207,7 +207,7 @@ public class Java2DFontMetrics { * @param size font size * @return descent in milliponts */ - public int getDescender(String family, int style, int size) { + public synchronized int getDescender(String family, int style, int size) { setFont(family, style, size); return descender * 1000; } @@ -220,7 +220,7 @@ public class Java2DFontMetrics { * @param size font size * @return font height in milliponts */ - public int getXHeight(String family, int style, int size) { + public synchronized int getXHeight(String family, int style, int size) { setFont(family, style, size); return xHeight * 1000; } @@ -234,7 +234,7 @@ public class Java2DFontMetrics { * @param size font size * @return character width in millipoints */ - public int width(int i, String family, int style, int size) { + public synchronized int width(int i, String family, int style, int size) { int w; setFont(family, style, size); w = internalCharWidth(i) * 1000; @@ -256,7 +256,7 @@ public class Java2DFontMetrics { * @param size font size * @return array of character widths in millipoints */ - public int[] getWidths(String family, int style, int size) { + public synchronized int[] getWidths(String family, int style, int size) { int i; if (width == null) { @@ -351,7 +351,7 @@ public class Java2DFontMetrics { * @param size font size * @return font with the desired characeristics. */ - public java.awt.Font getFont(String family, int style, int size) { + public synchronized java.awt.Font getFont(String family, int style, int size) { setFont(family, style, size); return f1; /* @@ -372,7 +372,7 @@ public class Java2DFontMetrics { * @param c the glyph to check * @return true if the character is supported */ - public boolean hasChar(String family, int style, int size, char c) { + public synchronized boolean hasChar(String family, int style, int size, char c) { setFont(family, style, size); return f1.canDisplay(c); } -- 2.39.5