fop-commits  

svn commit: r655281 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/fo/FOPropertyMapping.java src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java status.xml

maxberger
Sun, 11 May 2008 02:01:59 -0700

Author: maxberger
Date: Sun May 11 02:01:31 2008
New Revision: 655281

URL: http://svn.apache.org/viewvc?rev=655281&view=rev
Log:
Support character-by-character font-selection strategy on fo:character element

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java
    
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
    xmlgraphics/fop/trunk/status.xml

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java?rev=655281&r1=655280&r2=655281&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java 
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java Sun 
May 11 02:01:31 2008
@@ -963,7 +963,7 @@
         // 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);
 

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java?rev=655281&r1=655280&r2=655281&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
 (original)
+++ 
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
 Sun May 11 02:01:31 2008
@@ -61,11 +61,8 @@
     
     /** [EMAIL PROTECTED] */
     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 @@
         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

Modified: xmlgraphics/fop/trunk/status.xml
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=655281&r1=655280&r2=655281&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Sun May 11 02:01:31 2008
@@ -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



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

  • svn commit: r655281 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/fo/FOPropertyMapping.java src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java status.xml maxberger