Unless I'm totally mistaken that "synchronized" won't accomplish anything as there's nothing in that method that is not thread-safe. I wasn't able to reproduce the reported error but looking through FontInfo I found that TRIPLETS_TYPE constant which looks fishy to me. The Javadocs for toArray() says:
"a the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose." If there's no matching triplet, the method will probably return the constant's value (a FontTriplet[1]) and that single array item might even be null. Furthermore, that array is reused and might have been initialized with unwanted values in a prior call. I've attached a patch that will fix fontLookup(). But I suspect that might not have been it, yet. On 21.07.2008 18:48:15 acumiskey wrote: > Author: acumiskey > Date: Mon Jul 21 09:48:14 2008 > New Revision: 678477 > > URL: http://svn.apache.org/viewvc?rev=678477&view=rev > Log: > Renamed fname to more correct name fontKey. > Made createFontKey() in FontInfo synchronized which should hopefully fix Ingo > Maas's threading problem > (http://mail-archives.apache.org/mod_mbox/xmlgraphics-fop-users/200807.mbox/[EMAIL > PROTECTED]). > > Modified: > xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java > > Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java > URL: > http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java?rev=678477&r1=678476&r2=678477&view=diff > ============================================================================== > --- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java > (original) > +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java Mon Jul > 21 09:48:14 2008 > @@ -319,10 +319,10 @@ > Integer size = new Integer(fontSize); > Font font = (Font)sizes.get(size); > if (font == null) { > - String fname = getInternalFontKey(triplet); > - useFont(fname); > - FontMetrics metrics = getMetricsFor(fname); > - font = new Font(fname, triplet, metrics, fontSize); > + String fontKey = getInternalFontKey(triplet); > + useFont(fontKey); > + FontMetrics metrics = getMetricsFor(fontKey); > + font = new Font(fontKey, triplet, metrics, fontSize); > sizes.put(size, font); > } > return font; > @@ -504,7 +504,7 @@ > * @param weight font weight > * @return internal key > */ > - public static FontTriplet createFontKey(String family, String style, > + public static synchronized FontTriplet createFontKey(String family, > String style, > int weight) { > return new FontTriplet(family, style, weight); > } > > Jeremias Maerki
FontInfo-MT.diff
Description: Binary data
