Author: cbowditch
Date: Thu Jan 19 14:26:06 2012
New Revision: 1233393

URL: http://svn.apache.org/viewvc?rev=1233393&view=rev
Log:
Bugzilla #52416:
Suppress unnecessary "font not found warnings" when generating AFP with raster 
fonts 
Submitted by: Luis Bernardo

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/RasterFont.java
    xmlgraphics/fop/trunk/status.xml

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/RasterFont.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/RasterFont.java?rev=1233393&r1=1233392&r2=1233393&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/RasterFont.java 
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/RasterFont.java Thu 
Jan 19 14:26:06 2012
@@ -70,14 +70,14 @@ public class RasterFont extends AFPFont 
     /**
      * Get the character set metrics for the specified point size.
      *
-     * @param size the point size (in mpt)
+     * @param sizeInMpt the point size (in mpt)
      * @return the character set metrics
      */
-    public CharacterSet getCharacterSet(int size) {
+    public CharacterSet getCharacterSet(int sizeInMpt) {
 
-        //TODO: replace with Integer.valueOf() once we switch to Java 5
-        Integer requestedSize = new Integer(size);
+        Integer requestedSize = Integer.valueOf(sizeInMpt);
         CharacterSet csm = (CharacterSet) charSets.get(requestedSize);
+        double sizeInPt = sizeInMpt / 1000.0;
 
         if (csm != null) {
             return csm;
@@ -101,10 +101,10 @@ public class RasterFont extends AFPFont 
 
             Integer fontSize;
             if (!smallerSizes.isEmpty()
-                            && (size - smallerSize) <= (largerSize - size)) {
-                fontSize = new Integer(smallerSize);
+                            && (sizeInMpt - smallerSize) <= (largerSize - 
sizeInMpt)) {
+                fontSize = Integer.valueOf(smallerSize);
             } else {
-                fontSize = new Integer(largerSize);
+                fontSize = Integer.valueOf(largerSize);
             }
             csm = (CharacterSet) charSets.get(fontSize);
 
@@ -115,16 +115,18 @@ public class RasterFont extends AFPFont 
                     substitutionCharSets = new HashMap();
                 }
                 substitutionCharSets.put(requestedSize, csm);
-                String msg = "No " + (size / 1000f) + "pt font " + 
getFontName()
-                    + " found, substituted with " + fontSize.intValue() / 
1000f + "pt font";
-                LOG.warn(msg);
+                // do not output the warning if the font size is closer to an 
integer less than 0.1
+                if (!(Math.abs(fontSize.intValue() / 1000.0 - sizeInPt) < 
0.1)) {
+                    String msg = "No " + sizeInPt + "pt font " + getFontName()
+                            + " found, substituted with " + 
fontSize.intValue() / 1000f + "pt font";
+                    LOG.warn(msg);
+                }
             }
         }
 
         if (csm == null) {
             // Still no match -> error
-            String msg = "No font found for font " + getFontName()
-                + " with point size " + size / 1000f;
+            String msg = "No font found for font " + getFontName() + " with 
point size " + sizeInPt;
             LOG.error(msg);
             throw new FontRuntimeException(msg);
         }

Modified: xmlgraphics/fop/trunk/status.xml
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=1233393&r1=1233392&r2=1233393&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Thu Jan 19 14:26:06 2012
@@ -61,6 +61,9 @@
       documents. Example: the fix of marks layering will be such a case when 
it's done.
     -->
     <release version="FOP Trunk" date="TBD">
+      <action context="Code" dev="CB" type="add" fixes-bug="52416" 
due-to="Luis Bernardo">
+        Suppress unnecessary "font not found warnings" when generating AFP 
with raster fonts 
+      </action>
       <action context="Code" dev="CB" type="add" fixes-bug="51209" 
due-to="Luis Bernardo">
         SVG text in AFP creates miscoded GOCA text
       </action>



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to