diff options
author | Jeremias Maerki <jeremias@apache.org> | 2005-12-02 14:27:35 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2005-12-02 14:27:35 +0000 |
commit | f9932f4c138aa324e6e544dc7ddcaa9773dbb2fa (patch) | |
tree | d78ee074757e7bf60c4cbc76b10bfd69e430bd1b /src/java/org/apache/fop/fonts/FontInfo.java | |
parent | 56cfb0b22dac19a9112c74c6c9a31d5b3ca44437 (diff) | |
download | xmlgraphics-fop-f9932f4c138aa324e6e544dc7ddcaa9773dbb2fa.tar.gz xmlgraphics-fop-f9932f4c138aa324e6e544dc7ddcaa9773dbb2fa.zip |
font-family list still not fully supported but a comma-separated list is now properly tokenized. FOP will now go through all fonts in the list to find one that is available, but it doesn't do so per character, yet.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@351734 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fonts/FontInfo.java')
-rw-r--r-- | src/java/org/apache/fop/fonts/FontInfo.java | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/src/java/org/apache/fop/fonts/FontInfo.java b/src/java/org/apache/fop/fonts/FontInfo.java index cb50804bf..e1bc87884 100644 --- a/src/java/org/apache/fop/fonts/FontInfo.java +++ b/src/java/org/apache/fop/fonts/FontInfo.java @@ -111,10 +111,11 @@ public class FontInfo { * @param family font family * @param style font style * @param weight font weight + * @param substFont true if the font may be substituted with the default font if not found * @return internal key */ - public String fontLookup(String family, String style, - int weight) { + private String fontLookup(String family, String style, + int weight, boolean substFont) { String key; // first try given parameters key = createFontKey(family, style, weight); @@ -123,6 +124,9 @@ public class FontInfo { // then adjust weight, favouring normal or bold f = findAdjustWeight(family, style, weight); + if (!substFont && f == null) { + return null; + } // then try any family with orig weight if (f == null) { notifyFontReplacement(key); @@ -141,6 +145,46 @@ public class FontInfo { return f; } + /** + * Lookup a font. + * <br> + * Locate the font name for a given family, style and weight. + * The font name can then be used as a key as it is unique for + * the associated document. + * This also adds the font to the list of used fonts. + * @param family font family + * @param style font style + * @param weight font weight + * @return internal key + */ + public String fontLookup(String family, String style, + int weight) { + return fontLookup(family, style, weight, true); + } + + /** + * Lookup a font. + * <br> + * Locate the font name for a given family, style and weight. + * The font name can then be used as a key as it is unique for + * the associated document. + * This also adds the font to the list of used fonts. + * @param family font family (priority list) + * @param style font style + * @param weight font weight + * @return internal key + */ + public String fontLookup(String[] family, String style, + int weight) { + for (int i = 0; i < family.length; i++) { + String key = fontLookup(family[i], style, weight, (i >= family.length - 1)); + if (key != null) { + return key; + } + } + throw new IllegalStateException("fontLookup must return a key on the last call"); + } + private void notifyFontReplacement(String key) { if (loggedFontKeys == null) { loggedFontKeys = new java.util.HashSet(); |