Author: jeremias
Date: Wed Dec 16 10:06:16 2009
New Revision: 891174

URL: http://svn.apache.org/viewvc?rev=891174&view=rev
Log:
Bugfix for font selection fallbacks:
"Freestyle Script", for example, only has a single variant.
Freestyle Script,normal,100 was properly resolved to Freestyle 
Script,normal,400.
Freestyle Script,italic,400 was properly resolved to Freestyle 
Script,normal,400.
But Freestyle Script,italic,100 was resolved to the "any" font.
All combinations of weights and styles are now remaining on the same font 
family where possible.

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=891174&r1=891173&r2=891174&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 Wed Dec 
16 10:06:16 2009
@@ -258,31 +258,14 @@
             internalFontKey = getInternalFontKey(key);
         }
 
-        if (internalFontKey == null && weight != Font.WEIGHT_NORMAL) {
-            int diffWeight = (Font.WEIGHT_NORMAL - weight) / 100;
-            int direction = diffWeight > 0 ? 1 : -1;
-            int tryWeight = weight;
-            while (tryWeight != Font.WEIGHT_NORMAL) {
-                tryWeight += 100 * direction;
-                key = createFontKey(family, style, weight);
+        // fallback 2: try the same font-family with default style and try to 
adjust weight
+        if (internalFontKey == null && style != Font.STYLE_NORMAL) {
+            key = findAdjustWeight(family, Font.STYLE_NORMAL, weight);
+            if (key != null) {
                 internalFontKey = getInternalFontKey(key);
-                if (internalFontKey == null) {
-                    key = createFontKey(family, Font.STYLE_NORMAL, weight);
-                    internalFontKey = getInternalFontKey(key);
-                }
-                if (internalFontKey != null) {
-                    break;
-                }
             }
         }
 
-        // fallback 2: try the same font-family with default style and weight
-        /* obsolete: replaced by the loop above
-        if (internalFontKey == null) {
-            key = createFontKey(family, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
-            internalFontKey = getInternalFontKey(key);
-        }*/
-
         // fallback 3: try any family with original style/weight
         if (internalFontKey == null) {
             return fuzzyFontLookup("any", style, weight, startKey, false);



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

Reply via email to