diff options
author | Maximilian Berger <maxberger@apache.org> | 2008-05-11 09:01:31 +0000 |
---|---|---|
committer | Maximilian Berger <maxberger@apache.org> | 2008-05-11 09:01:31 +0000 |
commit | b79ac835070e53519be4167a224b59fcbc03722e (patch) | |
tree | f2783af50a08592f307941cbfbf0b1910a8abbab | |
parent | 9526915ada1d579194a4b38a596d43f75921311c (diff) | |
download | xmlgraphics-fop-b79ac835070e53519be4167a224b59fcbc03722e.tar.gz xmlgraphics-fop-b79ac835070e53519be4167a224b59fcbc03722e.zip |
Support character-by-character font-selection strategy on fo:character element
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@655281 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/java/org/apache/fop/fo/FOPropertyMapping.java | 2 | ||||
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java | 34 | ||||
-rw-r--r-- | status.xml | 3 |
3 files changed, 33 insertions, 6 deletions
diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java index 643fc7b73..8fed90a35 100644 --- a/src/java/org/apache/fop/fo/FOPropertyMapping.java +++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java @@ -963,7 +963,7 @@ public final class FOPropertyMapping implements Constants { // font-family m = new FontFamilyProperty.Maker(PR_FONT_FAMILY); m.setInherited(true); - m.setDefault("sans-serif"); + m.setDefault("sans-serif,Symbol,ZapfDingbats"); m.addShorthand(s_generics[PR_FONT]); addPropertyMaker("font-family", m); diff --git a/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java index b53e442d4..b292d97bf 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java @@ -61,11 +61,8 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager { /** {@inheritDoc} */ public void initialize() { - Character fobj = (Character)this.fobj; - - FontInfo fi = fobj.getFOEventHandler().getFontInfo(); - FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi); - font = fi.getFontInstance(fontkeys[0], fobj.getCommonFont().fontSize.getValue(this)); + Character fobj = (Character)this.fobj; + font = this.selectFontForCharacter(fobj); SpaceVal ls = SpaceVal.makeLetterSpacing(fobj.getLetterSpacing()); letterSpaceIPD = ls.getSpace(); hyphIPD = fobj.getCommonHyphenation().getHyphIPD(font); @@ -75,6 +72,33 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager { chArea.setBaselineOffset(font.getAscender()); setCurrentArea(chArea); } + + /** + * Selects a font which is able to display the given character. + * <p> + * Please note: this implements the font-selection-strategy + * character-by-character. + * <p> + * TODO: The same function could apply to other elements as well. + * + * @param fobj + * a Character object containing the character and its + * attributed. + * @return a Font object. + */ + private Font selectFontForCharacter(Character fobj) { + FontInfo fi = fobj.getFOEventHandler().getFontInfo(); + FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi); + for (int i = 0; i < fontkeys.length; i++) { + font = fi.getFontInstance(fontkeys[i], + fobj.getCommonFont().fontSize.getValue(this)); + if (font.hasChar(fobj.getCharacter())) { + return font; + } + } + return fi.getFontInstance(fontkeys[0], + fobj.getCommonFont().fontSize.getValue(this)); + } private org.apache.fop.area.inline.TextArea getCharacterInlineArea(Character node) { org.apache.fop.area.inline.TextArea text diff --git a/status.xml b/status.xml index 3bfcaf827..2f0df7c31 100644 --- a/status.xml +++ b/status.xml @@ -57,6 +57,9 @@ <action context="Renderers" dev="AC" importance="high" type="add"> Added SVG support for AFP (GOCA). </action --> + <action context="Layout" dev="MB" type="add"> + Support character-by-character font-selection strategy on fo:character element. + </action> <action context="Layout" dev="AD" type="fix" fixes-bug="44794"> Added support for page-number-citation and page-number-citation-last of fo:inline. Corrected behavior for page-number-citation-last |