ASF Bugzilla – Attachment 21353 Details for
Bug 44176
[PATCH] Custom Fonts in Java2DRenderer
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Custom font support for Java2DRenderer
fop-java2d-configured-fonts.patch (text/plain), 27.85 KB, created by
Jeremias Maerki
on 2008-01-07 07:01:22 UTC
(
hide
)
Description:
Custom font support for Java2DRenderer
Filename:
MIME Type:
Creator:
Jeremias Maerki
Created:
2008-01-07 07:01:22 UTC
Size:
27.85 KB
patch
obsolete
>Index: org/apache/fop/fonts/FontMetricsMapper.java >=================================================================== >--- org/apache/fop/fonts/FontMetricsMapper.java (revision 0) >+++ org/apache/fop/fonts/FontMetricsMapper.java (revision 0) >@@ -0,0 +1,34 @@ >+/* >+ * Licensed to the Apache Software Foundation (ASF) under one or more >+ * contributor license agreements. See the NOTICE file distributed with >+ * this work for additional information regarding copyright ownership. >+ * The ASF licenses this file to You under the Apache License, Version 2.0 >+ * (the "License"); you may not use this file except in compliance with >+ * the License. You may obtain a copy of the License at >+ * >+ * http://www.apache.org/licenses/LICENSE-2.0 >+ * >+ * Unless required by applicable law or agreed to in writing, software >+ * distributed under the License is distributed on an "AS IS" BASIS, >+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >+ * See the License for the specific language governing permissions and >+ * limitations under the License. >+ */ >+ >+/* $Id: $ */ >+package org.apache.fop.fonts; >+ >+/** >+ * Adds method to retrieve the actual <tt>java.awt.Font</tt> >+ * for use by <tt>Java2DRenderer</tt>s. >+ */ >+public interface FontMetricsMapper extends FontMetrics { >+ >+ /** >+ * Gets a Font instance of the Font that this >+ * FontMetrics describes in the desired size. >+ * @param size font size >+ * @return font with the desired characteristics. >+ */ >+ java.awt.Font getFont(int size); >+} >Index: org/apache/fop/render/bitmap/TIFFRendererConfigurator.java >=================================================================== >--- org/apache/fop/render/bitmap/TIFFRendererConfigurator.java (revision 600373) >+++ org/apache/fop/render/bitmap/TIFFRendererConfigurator.java (working copy) >@@ -68,5 +68,6 @@ > log.info("TIFF compression set to " + name); > } > } >+ super.configure(renderer); > } > } >Index: org/apache/fop/render/java2d/CustomFontMetricsMapper.java >=================================================================== >--- org/apache/fop/render/java2d/CustomFontMetricsMapper.java (revision 0) >+++ org/apache/fop/render/java2d/CustomFontMetricsMapper.java (revision 0) >@@ -0,0 +1,206 @@ >+/* >+ * Licensed to the Apache Software Foundation (ASF) under one or more >+ * contributor license agreements. See the NOTICE file distributed with >+ * this work for additional information regarding copyright ownership. >+ * The ASF licenses this file to You under the Apache License, Version 2.0 >+ * (the "License"); you may not use this file except in compliance with >+ * the License. You may obtain a copy of the License at >+ * >+ * http://www.apache.org/licenses/LICENSE-2.0 >+ * >+ * Unless required by applicable law or agreed to in writing, software >+ * distributed under the License is distributed on an "AS IS" BASIS, >+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >+ * See the License for the specific language governing permissions and >+ * limitations under the License. >+ */ >+ >+/* $Id: $ */ >+package org.apache.fop.render.java2d; >+ >+import java.awt.Font; >+import java.awt.FontFormatException; >+import java.io.IOException; >+import java.io.InputStream; >+import java.util.Map; >+import java.util.Set; >+ >+import javax.xml.transform.Source; >+import javax.xml.transform.stream.StreamSource; >+ >+import org.apache.fop.fonts.CustomFont; >+import org.apache.fop.fonts.FontMetrics; >+import org.apache.fop.fonts.FontMetricsMapper; >+import org.apache.fop.fonts.FontType; >+import org.apache.fop.fonts.LazyFont; >+import org.apache.fop.fonts.Typeface; >+ >+/** >+ * FontMetricsMapper that delegates most methods to an underlying >+ * <tt>FontMetrics</tt> instance. This class was designed to allow >+ * the underlying <tt>java.awt.Font</tt> to be loaded from a >+ * user-configured file not registered in the current graphics environment. >+ */ >+public class CustomFontMetricsMapper extends Typeface implements >+FontMetricsMapper { >+ >+ /** >+ * Font metrics for the font this class models. >+ */ >+ private Typeface typeface; >+ >+ /** >+ * The font required by the Java2D renderer. >+ */ >+ private java.awt.Font font; >+ >+ /** >+ * Maintains the most recently requested size. >+ */ >+ private float size = 1; >+ >+ /** >+ * Construction of this class results in the immediate construction. >+ * of the underlying <tt>java.awt.Font</tt> >+ * @param fontMetrics >+ * @throws FontFormatException >+ * @throws IOException >+ */ >+ public CustomFontMetricsMapper(final CustomFont fontMetrics) >+ throws FontFormatException, IOException { >+ this.typeface = fontMetrics; >+ initialize(fontMetrics.getEmbedFileSource()); >+ } >+ >+ /** >+ * Construction of this class results in the immediate construction >+ * of the underlying <tt>java.awt.Font</tt> >+ * @param fontMetrics >+ * @throws FontFormatException >+ * @throws IOException >+ */ >+ public CustomFontMetricsMapper(final LazyFont fontMetrics, final Source fontSource) >+ throws FontFormatException, IOException { >+ this.typeface = fontMetrics; >+ initialize(fontSource); >+ } >+ >+ /** >+ * Loads the java.awt.Font >+ * @param source >+ * @throws FontFormatException >+ * @throws IOException >+ */ >+ private void initialize(final Source source) >+ throws FontFormatException, IOException { >+ int type = Font.TRUETYPE_FONT; >+ if (FontType.TYPE1.equals(typeface.getFontType())) { >+ type = Font.TYPE1_FONT; >+ } >+ >+ InputStream is = null; >+ if (source instanceof StreamSource) { >+ is = ((StreamSource) source).getInputStream(); >+ } else if (source.getSystemId() != null) { >+ is = new java.net.URL(source.getSystemId()).openStream(); >+ } else { >+ throw new IllegalArgumentException("No font source provided."); >+ } >+ >+ this.font = Font.createFont(type, is); >+ is.close(); >+ >+ } >+ >+ /** {@inheritDoc} */ >+ public final String getEncoding() { >+ return null; //Not applicable to Java2D rendering >+ } >+ >+ /** {@inheritDoc} */ >+ public final boolean hasChar(final char c) { >+ return font.canDisplay(c); >+ } >+ >+ /** {@inheritDoc} */ >+ public final char mapChar(final char c) { >+ return typeface.mapChar(c); >+ } >+ >+ /** {@inheritDoc} */ >+ public final Font getFont(final int size) { >+ if (this.size == size) { >+ return font; >+ } >+ >+ this.size = size / 1000f; >+ font = font.deriveFont(this.size); >+ return font; >+ } >+ >+ /** {@inheritDoc} */ >+ public final int getAscender(final int size) { >+ return typeface.getAscender(size); >+ } >+ >+ /** {@inheritDoc} */ >+ public final int getCapHeight(final int size) { >+ return typeface.getCapHeight(size); >+ } >+ >+ /** {@inheritDoc} */ >+ public final int getDescender(final int size) { >+ return typeface.getDescender(size); >+ } >+ >+ /** {@inheritDoc} */ >+ public final String getEmbedFontName() { >+ return typeface.getEmbedFontName(); >+ } >+ >+ /** {@inheritDoc} */ >+ public final Set getFamilyNames() { >+ return typeface.getFamilyNames(); >+ } >+ >+ /** {@inheritDoc} */ >+ public final String getFontName() { >+ return typeface.getFontName(); >+ } >+ >+ /** {@inheritDoc} */ >+ public final FontType getFontType() { >+ return typeface.getFontType(); >+ } >+ >+ /** {@inheritDoc} */ >+ public final String getFullName() { >+ return typeface.getFullName(); >+ } >+ >+ /** {@inheritDoc} */ >+ public final Map getKerningInfo() { >+ return typeface.getKerningInfo(); >+ } >+ >+ /** {@inheritDoc} */ >+ public final int getWidth(final int i, final int size) { >+ return typeface.getWidth(i, size); >+ } >+ >+ /** {@inheritDoc} */ >+ public final int[] getWidths() { >+ return typeface.getWidths(); >+ } >+ >+ /** {@inheritDoc} */ >+ public final int getXHeight(final int size) { >+ return typeface.getXHeight(size); >+ } >+ >+ /** {@inheritDoc} */ >+ public final boolean hasKerningInfo() { >+ return typeface.hasKerningInfo(); >+ } >+ >+} >Index: org/apache/fop/render/java2d/FontMetricsMapper.java >=================================================================== >--- org/apache/fop/render/java2d/FontMetricsMapper.java (revision 600373) >+++ org/apache/fop/render/java2d/FontMetricsMapper.java (working copy) >@@ -1,198 +0,0 @@ >-/* >- * Licensed to the Apache Software Foundation (ASF) under one or more >- * contributor license agreements. See the NOTICE file distributed with >- * this work for additional information regarding copyright ownership. >- * The ASF licenses this file to You under the Apache License, Version 2.0 >- * (the "License"); you may not use this file except in compliance with >- * the License. You may obtain a copy of the License at >- * >- * http://www.apache.org/licenses/LICENSE-2.0 >- * >- * Unless required by applicable law or agreed to in writing, software >- * distributed under the License is distributed on an "AS IS" BASIS, >- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >- * See the License for the specific language governing permissions and >- * limitations under the License. >- */ >- >-/* $Id$ */ >- >-package org.apache.fop.render.java2d; >- >-// Java >-import java.awt.Graphics2D; >-import java.util.Map; >-import java.util.Set; >- >-import org.apache.fop.fonts.FontMetrics; >-import org.apache.fop.fonts.FontType; >-import org.apache.fop.fonts.Typeface; >- >- >-/** >- * This class implements org.apache.fop.layout.FontMetrics and >- * is added to the hash table in FontInfo. It deferes the >- * actual calculation of the metrics to >- * Java2DFontMetrics. It only keeps the java name and >- * style as member varibles >- */ >- >-public class FontMetricsMapper extends Typeface implements FontMetrics { >- >- /** >- * This is a Java2DFontMetrics that does the real calculation. >- * It is only one class that dynamically determines the font-size. >- */ >- private static Java2DFontMetrics metric = null; >- >- /** >- * The java name of the font. >- * # Make the family name immutable. >- */ >- private final String family; >- >- /** >- * The java style of the font. >- * # Make the style immutable. >- */ >- private final int style; >- >- /** >- * Constructs a new Font-metrics. >- * @param family the family name of the font (java value) >- * @param style the java type style value of the font >- * @param graphics a Graphics2D object - this is needed so >- * that we can get an instance of java.awt.FontMetrics >- */ >- public FontMetricsMapper(String family, int style, Graphics2D graphics) { >- this.family = family; >- this.style = style; >- if (metric == null) { >- metric = new Java2DFontMetrics(graphics); >- } >- } >- >- /** {@inheritDoc} */ >- public String getFontName() { >- return family; >- } >- >- /** {@inheritDoc} */ >- public String getEmbedFontName() { >- return getFontName(); >- } >- >- /** {@inheritDoc} */ >- public String getFullName() { >- return getFontName(); >- } >- >- /** {@inheritDoc} */ >- public Set getFamilyNames() { >- Set s = new java.util.HashSet(); >- s.add(this.family); >- return s; >- } >- >- /** >- * {@inheritDoc} >- */ >- public FontType getFontType() { >- return FontType.OTHER; >- } >- >- /** >- * {@inheritDoc} >- */ >- public int getMaxAscent(int size) { >- return metric.getMaxAscent(family, style, size); >- } >- >- /** >- * {@inheritDoc} >- */ >- public int getAscender(int size) { >- return metric.getAscender(family, style, size); >- } >- >- /** >- * {@inheritDoc} >- */ >- public int getCapHeight(int size) { >- return metric.getCapHeight(family, style, size); >- } >- >- /** >- * {@inheritDoc} >- */ >- public int getDescender(int size) { >- return metric.getDescender(family, style, size); >- } >- >- /** >- * {@inheritDoc} >- */ >- public int getXHeight(int size) { >- return metric.getXHeight(family, style, size); >- } >- >- /** >- * {@inheritDoc} >- */ >- public int getWidth(int i, int size) { >- return metric.width(i, family, style, size); >- } >- >- >- /** >- * {@inheritDoc} >- */ >- public int[] getWidths() { >- return metric.getWidths(family, style, Java2DFontMetrics.FONT_SIZE); >- } >- >- /** >- * Gets a Font instance of the Font that this >- * FontMetrics describes in the desired size. >- * @param size font size >- * @return font with the desired characeristics. >- */ >- public java.awt.Font getFont(int size) { >- return metric.getFont(family, style, size); >- } >- >- /** >- * {@inheritDoc} >- */ >- public Map getKerningInfo() { >- return java.util.Collections.EMPTY_MAP; >- } >- >- /** >- * {@inheritDoc} >- */ >- public boolean hasKerningInfo() { >- return false; >- } >- >- /** {@inheritDoc} */ >- public String getEncoding() { >- return null; //Not applicable to Java2D rendering >- } >- >- /** {@inheritDoc} */ >- public char mapChar(char c) { >- return c; >- } >- >- /** {@inheritDoc} */ >- public boolean hasChar(char c) { >- return metric.hasChar(family, style, Java2DFontMetrics.FONT_SIZE, c); >- } >- >-} >- >- >- >- >- >Index: org/apache/fop/render/java2d/FontSetup.java >=================================================================== >--- org/apache/fop/render/java2d/FontSetup.java (revision 600373) >+++ org/apache/fop/render/java2d/FontSetup.java (working copy) >@@ -5,9 +5,9 @@ > * The ASF licenses this file to You under the Apache License, Version 2.0 > * (the "License"); you may not use this file except in compliance with > * the License. You may obtain a copy of the License at >- * >+ * > * http://www.apache.org/licenses/LICENSE-2.0 >- * >+ * > * Unless required by applicable law or agreed to in writing, software > * distributed under the License is distributed on an "AS IS" BASIS, > * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >@@ -22,14 +22,23 @@ > // FOP > import java.awt.Graphics2D; > import java.awt.GraphicsEnvironment; >+import java.util.List; > import java.util.Set; > >+import javax.xml.transform.Source; >+ > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; >+import org.apache.fop.fonts.CustomFont; >+import org.apache.fop.fonts.EmbedFontInfo; > import org.apache.fop.fonts.Font; > import org.apache.fop.fonts.FontInfo; >+import org.apache.fop.fonts.FontLoader; >+import org.apache.fop.fonts.FontMetricsMapper; >+import org.apache.fop.fonts.FontResolver; > import org.apache.fop.fonts.FontTriplet; > import org.apache.fop.fonts.FontUtil; >+import org.apache.fop.fonts.LazyFont; > > /** > * Sets up the Java2D/AWT fonts. It is similar to >@@ -70,10 +79,12 @@ > * triplets for lookup. > * > * @param fontInfo the font info object to set up >- * @param graphics needed for acces to font metrics >+ * @param configuredFontList of fop config fonts >+ * @param resolver for resolving the font file URI >+ * @param graphics needed for access to font metrics > */ >- public static void setup(FontInfo fontInfo, Graphics2D graphics) { >- FontMetricsMapper metric; >+ public static void setup(FontInfo fontInfo, List configuredFontList, FontResolver resolver, Graphics2D graphics) { >+ FontMetricsMapper metric; > int normal, bold, bolditalic, italic; > > /* >@@ -87,47 +98,47 @@ > italic = java.awt.Font.ITALIC; > bolditalic = java.awt.Font.BOLD + java.awt.Font.ITALIC; > >- metric = new FontMetricsMapper("SansSerif", normal, graphics); >+ metric = new SystemFontMetricsMapper("SansSerif", normal, graphics); > // --> goes to F1 > fontInfo.addMetrics("F1", metric); >- metric = new FontMetricsMapper("SansSerif", italic, graphics); >+ metric = new SystemFontMetricsMapper("SansSerif", italic, graphics); > // --> goes to F2 > fontInfo.addMetrics("F2", metric); >- metric = new FontMetricsMapper("SansSerif", bold, graphics); >+ metric = new SystemFontMetricsMapper("SansSerif", bold, graphics); > // --> goes to F3 > fontInfo.addMetrics("F3", metric); >- metric = new FontMetricsMapper("SansSerif", bolditalic, graphics); >+ metric = new SystemFontMetricsMapper("SansSerif", bolditalic, graphics); > // --> goes to F4 > fontInfo.addMetrics("F4", metric); > > >- metric = new FontMetricsMapper("Serif", normal, graphics); >+ metric = new SystemFontMetricsMapper("Serif", normal, graphics); > // --> goes to F5 > fontInfo.addMetrics("F5", metric); >- metric = new FontMetricsMapper("Serif", italic, graphics); >+ metric = new SystemFontMetricsMapper("Serif", italic, graphics); > // --> goes to F6 > fontInfo.addMetrics("F6", metric); >- metric = new FontMetricsMapper("Serif", bold, graphics); >+ metric = new SystemFontMetricsMapper("Serif", bold, graphics); > // --> goes to F7 > fontInfo.addMetrics("F7", metric); >- metric = new FontMetricsMapper("Serif", bolditalic, graphics); >+ metric = new SystemFontMetricsMapper("Serif", bolditalic, graphics); > // --> goes to F8 > fontInfo.addMetrics("F8", metric); > >- metric = new FontMetricsMapper("MonoSpaced", normal, graphics); >+ metric = new SystemFontMetricsMapper("MonoSpaced", normal, graphics); > // --> goes to F9 > fontInfo.addMetrics("F9", metric); >- metric = new FontMetricsMapper("MonoSpaced", italic, graphics); >+ metric = new SystemFontMetricsMapper("MonoSpaced", italic, graphics); > // --> goes to F10 > fontInfo.addMetrics("F10", metric); >- metric = new FontMetricsMapper("MonoSpaced", bold, graphics); >+ metric = new SystemFontMetricsMapper("MonoSpaced", bold, graphics); > // --> goes to F11 > fontInfo.addMetrics("F11", metric); >- metric = new FontMetricsMapper("MonoSpaced", bolditalic, graphics); >+ metric = new SystemFontMetricsMapper("MonoSpaced", bolditalic, graphics); > // --> goes to F12 > fontInfo.addMetrics("F12", metric); > >- metric = new FontMetricsMapper("Serif", normal, graphics); >+ metric = new SystemFontMetricsMapper("Serif", normal, graphics); > //"Symbol" doesn't seem to work here, but "Serif" does the job just fine. *shrug* > // --> goes to F13 and F14 > fontInfo.addMetrics("F13", metric); >@@ -207,10 +218,11 @@ > fontInfo.addFontProperties("F9", "Computer-Modern-Typewriter", > "normal", Font.WEIGHT_NORMAL); > >- configureInstalledAWTFonts(fontInfo, graphics, LAST_PREDEFINED_FONT_NUMBER + 1); >+ int lastNum = configureInstalledAWTFonts(fontInfo, graphics, LAST_PREDEFINED_FONT_NUMBER + 1); >+ addConfiguredFonts(fontInfo, configuredFontList, resolver, lastNum++); > } > >- private static void configureInstalledAWTFonts(FontInfo fontInfo, Graphics2D graphics, >+ private static int configureInstalledAWTFonts(FontInfo fontInfo, Graphics2D graphics, > int startNumber) { > int num = startNumber; > GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); >@@ -250,9 +262,69 @@ > guessedStyle, guessedWeight, fontKey); > } > } >+ return num; > > } > >+ /** >+ * Add fonts from configuration file starting with internal name F<num>. >+ * >+ * @param fontInfo the font info object to set up >+ * @param fontList a list of EmbedFontInfo objects >+ * @param num starting index for internal font numbering >+ * @param resolver the font resolver >+ */ >+ private static void addConfiguredFonts(FontInfo fontInfo, List fontList, FontResolver resolver, int num) { >+ >+ if (fontList == null || fontList.size() < 1) { >+ log.debug("No user configured fonts found."); >+ return; >+ } >+ if (resolver == null) { >+ // Ensure that we have minimal font resolution capabilities >+ resolver = org.apache.fop.fonts.FontSetup >+ .createMinimalFontResolver(); >+ } >+ String internalName = null; >+ >+ for (int i = 0; i < fontList.size(); i++) { >+ >+ EmbedFontInfo configFontInfo = (EmbedFontInfo) fontList.get(i); >+ String fontFile = configFontInfo.getEmbedFile(); >+ internalName = "F" + num; >+ num++; >+ try { >+ FontMetricsMapper font = null; >+ String metricsUrl = configFontInfo.getMetricsFile(); >+ // If the user specified an XML-based metrics file, we'll use it >+ // Otherwise, calculate metrics directly from the font file. >+ if (metricsUrl != null) { >+ LazyFont fontMetrics = new LazyFont(configFontInfo, resolver); >+ Source fontSource = resolver.resolve(configFontInfo.getEmbedFile()); >+ font = new CustomFontMetricsMapper(fontMetrics, fontSource); >+ } else { >+ CustomFont fontMetrics = FontLoader.loadFont(fontFile, resolver); >+ font = new CustomFontMetricsMapper(fontMetrics); >+ } >+ >+ fontInfo.addMetrics(internalName, font); >+ >+ List triplets = configFontInfo.getFontTriplets(); >+ for (int c = 0; c < triplets.size(); c++) { >+ FontTriplet triplet = (FontTriplet) triplets.get(c); >+ >+ if (log.isDebugEnabled()) { >+ log.debug("Registering: " + triplet + " under " + internalName); >+ } >+ fontInfo.addFontProperties(internalName, triplet); >+ } >+ } catch (Exception e) { >+ log.warn("Unable to load custom font from file '" + fontFile + "'", e); >+ } >+ } >+ } >+ >+ > private static void addFontTriplet(FontInfo fontInfo, String fontName, String fontStyle, > int fontWeight, String fontKey) { > FontTriplet triplet = FontInfo.createFontKey(fontName, fontStyle, fontWeight); >@@ -261,7 +333,7 @@ > > private static void addFontMetricsMapper(FontInfo fontInfo, String family, String fontKey, > Graphics2D graphics, int style) { >- FontMetricsMapper metric = new FontMetricsMapper(family, style, graphics); >+ FontMetricsMapper metric = new SystemFontMetricsMapper(family, style, graphics); > fontInfo.addMetrics(fontKey, metric); > } > >Index: org/apache/fop/render/java2d/Java2DGraphicsState.java >=================================================================== >--- org/apache/fop/render/java2d/Java2DGraphicsState.java (revision 600373) >+++ org/apache/fop/render/java2d/Java2DGraphicsState.java (working copy) >@@ -30,6 +30,7 @@ > > import org.apache.fop.fo.Constants; > import org.apache.fop.fonts.FontInfo; >+import org.apache.fop.fonts.FontMetricsMapper; > > /** > * Keeps information about the current state of the Graphics2D currentGraphics. >Index: org/apache/fop/render/java2d/Java2DRenderer.java >=================================================================== >--- org/apache/fop/render/java2d/Java2DRenderer.java (revision 600373) >+++ org/apache/fop/render/java2d/Java2DRenderer.java (working copy) >@@ -179,7 +179,7 @@ > //The next line is important to get accurate font metrics! > g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, > RenderingHints.VALUE_FRACTIONALMETRICS_ON); >- FontSetup.setup(fontInfo, g); >+ FontSetup.setup(fontInfo, fontList, fontResolver, g); > } > > /** {@inheritDoc} */ >Index: org/apache/fop/render/java2d/Java2DRendererConfigurator.java >=================================================================== >--- org/apache/fop/render/java2d/Java2DRendererConfigurator.java (revision 600373) >+++ org/apache/fop/render/java2d/Java2DRendererConfigurator.java (working copy) >@@ -53,5 +53,6 @@ > java2dRenderer.setTransparentPageBackground("true".equalsIgnoreCase(value)); > } > } >+ super.configure(renderer); > } > } >Index: org/apache/fop/render/java2d/SystemFontMetricsMapper.java >=================================================================== >--- org/apache/fop/render/java2d/SystemFontMetricsMapper.java (revision 600042) >+++ org/apache/fop/render/java2d/SystemFontMetricsMapper.java (working copy) >@@ -16,7 +16,6 @@ > */ > > /* $Id$ */ >- > package org.apache.fop.render.java2d; > > // Java >@@ -24,7 +23,7 @@ > import java.util.Map; > import java.util.Set; > >-import org.apache.fop.fonts.FontMetrics; >+import org.apache.fop.fonts.FontMetricsMapper; > import org.apache.fop.fonts.FontType; > import org.apache.fop.fonts.Typeface; > >@@ -37,7 +36,7 @@ > * style as member varibles > */ > >-public class FontMetricsMapper extends Typeface implements FontMetrics { >+public class SystemFontMetricsMapper extends Typeface implements FontMetricsMapper { > > /** > * This is a Java2DFontMetrics that does the real calculation. >@@ -64,7 +63,7 @@ > * @param graphics a Graphics2D object - this is needed so > * that we can get an instance of java.awt.FontMetrics > */ >- public FontMetricsMapper(String family, int style, Graphics2D graphics) { >+ public SystemFontMetricsMapper(String family, int style, Graphics2D graphics) { > this.family = family; > this.style = style; > if (metric == null) { >@@ -100,7 +99,7 @@ > public FontType getFontType() { > return FontType.OTHER; > } >- >+ > /** > * {@inheritDoc} > */ >@@ -137,7 +136,7 @@ > } > > /** >- * {@inheritDoc} >+ * {@inheritDoc} > */ > public int getWidth(int i, int size) { > return metric.width(i, family, style, size); >@@ -152,10 +151,7 @@ > } > > /** >- * Gets a Font instance of the Font that this >- * FontMetrics describes in the desired size. >- * @param size font size >- * @return font with the desired characeristics. >+ * {@inheritDoc} > */ > public java.awt.Font getFont(int size) { > return metric.getFont(family, style, size); >Index: org/apache/fop/render/pcl/PCLRenderer.java >=================================================================== >--- org/apache/fop/render/pcl/PCLRenderer.java (revision 600373) >+++ org/apache/fop/render/pcl/PCLRenderer.java (working copy) >@@ -79,7 +79,7 @@ > import org.apache.fop.render.PrintRenderer; > import org.apache.fop.render.RendererContext; > import org.apache.fop.render.RendererContextConstants; >-import org.apache.fop.render.java2d.FontMetricsMapper; >+import org.apache.fop.render.java2d.SystemFontMetricsMapper; > import org.apache.fop.render.java2d.FontSetup; > import org.apache.fop.render.java2d.Java2DRenderer; > import org.apache.fop.render.pcl.extensions.PCLElementMapping; >@@ -182,7 +182,7 @@ > //The next line is important to get accurate font metrics! > g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, > RenderingHints.VALUE_FRACTIONALMETRICS_ON); >- FontSetup.setup(fontInfo, g); >+ FontSetup.setup(fontInfo, fontList, fontResolver, g); > } > > /** >@@ -617,7 +617,7 @@ > > //for cursive fonts, so the text isn't clipped > int extraWidth = font.getFontSize() / 3; >- final FontMetricsMapper mapper = (FontMetricsMapper)fontInfo.getMetricsFor( >+ final SystemFontMetricsMapper mapper = (SystemFontMetricsMapper)fontInfo.getMetricsFor( > font.getFontName()); > int maxAscent = mapper.getMaxAscent(font.getFontSize()) / 1000; > final int additionalBPD = maxAscent - baseline;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 44176
: 21353