From ed4e49bb2ceaccd0a1d93545c621e310f92a4f21 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Wed, 16 Dec 2009 10:06:16 +0000 Subject: [PATCH] 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. 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 | 25 ++++----------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/src/java/org/apache/fop/fonts/FontInfo.java b/src/java/org/apache/fop/fonts/FontInfo.java index 8f8032767..a7b840fcc 100644 --- a/src/java/org/apache/fop/fonts/FontInfo.java +++ b/src/java/org/apache/fop/fonts/FontInfo.java @@ -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); -- 2.39.5