]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugfix for font selection fallbacks:
authorJeremias Maerki <jeremias@apache.org>
Wed, 16 Dec 2009 10:06:16 +0000 (10:06 +0000)
committerJeremias Maerki <jeremias@apache.org>
Wed, 16 Dec 2009 10:06:16 +0000 (10:06 +0000)
"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.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@891174 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fonts/FontInfo.java

index 8f8032767a1cdaf71d0daef1e69d1dca2bd3886f..a7b840fcc6ae76cf4c87471f94c7c2263a456b6f 100644 (file)
@@ -258,31 +258,14 @@ public class FontInfo {
             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);