You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2007/11/12 10:40:18 UTC

svn commit: r594067 - in /xmlgraphics/fop/trunk/src: codegen/fonts/ java/org/apache/fop/fo/properties/ java/org/apache/fop/fonts/ java/org/apache/fop/render/ps/

Author: jeremias
Date: Mon Nov 12 01:40:16 2007
New Revision: 594067

URL: http://svn.apache.org/viewvc?rev=594067&view=rev
Log:
Avoid null values in generated Font classes so the encoding can be inspected.
Don't warn about missing hyphenation characters for fonts such as Symbol and ZapfDingbats which don't have the default hyphenation character.

Modified:
    xmlgraphics/fop/trunk/src/codegen/fonts/font-file.xsl
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonHyphenation.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Font.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/SingleByteFont.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSFontUtils.java

Modified: xmlgraphics/fop/trunk/src/codegen/fonts/font-file.xsl
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/codegen/fonts/font-file.xsl?rev=594067&r1=594066&r2=594067&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/codegen/fonts/font-file.xsl (original)
+++ xmlgraphics/fop/trunk/src/codegen/fonts/font-file.xsl Mon Nov 12 01:40:16 2007
@@ -30,7 +30,6 @@
   <xsl:output method="text"/>
 
   <xsl:param name="encoding" select="/font-metrics/encoding"/>
-  <xsl:variable name="native-encoding" select="/font-metrics/encoding"/>
   <xsl:variable name="glyphs" select="document('encodings.xml')/encoding-set/encoding[@id=$encoding]/glyph"/>
 
   <xsl:template match="font-metrics">
@@ -48,7 +47,7 @@
     private final static String fontName = "<xsl:value-of select="font-name"/>";
     private final static String fullName = "<xsl:value-of select="full-name"/>";
     private final static Set familyNames;
-    private final static String encoding = <xsl:choose><xsl:when test="$encoding != $native-encoding">"<xsl:value-of select="$encoding"/>"</xsl:when><xsl:otherwise>null</xsl:otherwise></xsl:choose>;
+    private final static String encoding = "<xsl:value-of select="$encoding"/>";
     private final static int capHeight = <xsl:value-of select="cap-height"/>;
     private final static int xHeight = <xsl:value-of select="x-height"/>;
     private final static int ascender = <xsl:value-of select="ascender"/>;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonHyphenation.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonHyphenation.java?rev=594067&r1=594066&r2=594067&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonHyphenation.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonHyphenation.java Mon Nov 12 01:40:16 2007
@@ -24,6 +24,8 @@
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fonts.FontMetrics;
+import org.apache.fop.fonts.Typeface;
 
 /**
  * Store all common hyphenation properties.
@@ -127,17 +129,40 @@
      */
     public char getHyphChar(org.apache.fop.fonts.Font font) {
         char hyphChar = hyphenationCharacter.getCharacter();
+        if (font.hasChar(hyphChar)) {
+            return hyphChar; //short-cut
+        }
         char effHyphChar = hyphChar;
-        if (font.hasChar(effHyphChar)) {
-            //nop
-        } else if (font.hasChar(HYPHEN_MINUS)) {
+        boolean warn = false;
+        if (font.hasChar(HYPHEN_MINUS)) {
             effHyphChar = HYPHEN_MINUS;
+            warn = true;
         } else if (font.hasChar(MINUS_SIGN)) {
             effHyphChar = MINUS_SIGN;
+            FontMetrics metrics = font.getFontMetrics();
+            if (metrics instanceof Typeface) {
+                Typeface typeface = (Typeface)metrics;
+                if ("SymbolEncoding".equals(typeface.getEncoding())) {
+                    //SymbolEncoding doesn't have HYPHEN_MINUS, so replace by MINUS_SIGN
+                } else {
+                    //only warn if the encoding is not SymbolEncoding
+                    warn = true;
+                }
+            }
         } else {
             effHyphChar = ' ';
+            FontMetrics metrics = font.getFontMetrics();
+            if (metrics instanceof Typeface) {
+                Typeface typeface = (Typeface)metrics;
+                if ("ZapfDingbatsEncoding".equals(typeface.getEncoding())) {
+                    //ZapfDingbatsEncoding doesn't have HYPHEN_MINUS, so replace by ' '
+                } else {
+                    //only warn if the encoding is not ZapfDingbatsEncoding
+                    warn = true;
+                }
+            }
         }
-        if (hyphChar != effHyphChar) {
+        if (warn) {
             log.warn("Substituted specified hyphenation character (0x"
                     + Integer.toHexString(hyphChar)
                     + ") with 0x" + Integer.toHexString(effHyphChar) 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Font.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Font.java?rev=594067&r1=594066&r2=594067&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Font.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Font.java Mon Nov 12 01:40:16 2007
@@ -81,6 +81,14 @@
     }
 
     /**
+     * Returns the associated font metrics object.
+     * @return the font metrics
+     */
+    public FontMetrics getFontMetrics() {
+        return this.metric;
+    }
+    
+    /**
      * Returns the font's ascender.
      * @return the ascender
      */

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/SingleByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/SingleByteFont.java?rev=594067&r1=594066&r2=594067&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/SingleByteFont.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/SingleByteFont.java Mon Nov 12 01:40:16 2007
@@ -103,8 +103,8 @@
         if (d != 0) {
             return d;
         } else {
-            log.warn("Glyph " + (int) c + " not available in font "
-                    + getFontName());
+            log.warn("Glyph " + (int)c + " (0x" + Integer.toHexString(c) 
+                    + ") not available in font " + getFontName());
             return '#';
         }
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSFontUtils.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSFontUtils.java?rev=594067&r1=594066&r2=594067&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSFontUtils.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSFontUtils.java Mon Nov 12 01:40:16 2007
@@ -100,8 +100,11 @@
             if (fm instanceof LazyFont && ((LazyFont)fm).getRealFont() == null) {
                 continue;
             } else if (null == fm.getEncoding()) {
-                //ignore (ZapfDingbats and Symbol run through here
-                //TODO: ZapfDingbats and Symbol should get getEncoding() fixed!
+                //ignore (ZapfDingbats and Symbol used to run through here, kept for safety reasons)
+            } else if ("SymbolEncoding".equals(fm.getEncoding())) {
+                //ignore (no encoding redefinition)
+            } else if ("ZapfDingbatsEncoding".equals(fm.getEncoding())) {
+                //ignore (no encoding redefinition)
             } else if ("WinAnsiEncoding".equals(fm.getEncoding())) {
                 redefineFontEncoding(gen, fm.getFontName(), fm.getEncoding());
             } else {



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Re: svn commit: r594067 - in /xmlgraphics/fop/trunk/src: codegen/fonts/ java/org/apache/fop/fo/properties/ java/org/apache/fop/fonts/ java/org/apache/fop/render/ps/

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Nov 12, 2007, at 11:13, Vincent Hennebert wrote:

>>
>> URL: http://svn.apache.org/viewvc?rev=594067&view=rev
>> Log:
>> Avoid null values in generated Font classes so the encoding can be  
>> inspected.
>> Don't warn about missing hyphenation characters for fonts such as  
>> Symbol and ZapfDingbats which don't have the default hyphenation  
>> character.
>
> Is this really necessary? If hyphenation must occur within a block  
> with
> the Symbol or ZapfDingbats fonts, doesn’t that mean that something is
> wrong somewhere, and may lead to an output unexpected by the user?
> Moreover I can’t see how hyphenation can be performed with  
> ZapfDingbats
> (and even for Symbol, although that might be discussed), simply due to
> a lack of hyphenation patterns.

FWIW:
Note that I once had the same reservation about hyphenating something  
other than words. One fop-user apparently expected this to work for  
numbers as well...
While it seems to make little sense in practice, in theory, it is  
possible to define hyphenation patterns for any series of Unicode  
characters, and that includes the codepoints covered by ZapfDingbats  
and Symbol.

Hey, what's stopping you from creating your own secret symbol- 
language with its own custom hyphenation patterns? :-)

I think Jeremias (again) simply enhanced FOP's functionality here  
(better error-reporting)

Just my 2 cents.


Cheers

Andreas

Re: svn commit: r594067 - in /xmlgraphics/fop/trunk/src: codegen/fonts/ java/org/apache/fop/fo/properties/ java/org/apache/fop/fonts/ java/org/apache/fop/render/ps/

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
On 12.11.2007 11:13:52 Vincent Hennebert wrote:
> Hi,
> 
> > Author: jeremias
> > Date: Mon Nov 12 01:40:16 2007
> > New Revision: 594067
> > 
> > URL: http://svn.apache.org/viewvc?rev=594067&view=rev
> > Log:
> > Avoid null values in generated Font classes so the encoding can be inspected.
> > Don't warn about missing hyphenation characters for fonts such as Symbol and ZapfDingbats which don't have the default hyphenation character.
> 
> Is this really necessary? 

I think, yes.

> If hyphenation must occur within a block with 
> the Symbol or ZapfDingbats fonts, doesn’t that mean that something is 
> wrong somewhere, and may lead to an output unexpected by the user? 

Not necessarily. Maybe someone likes to decorate his documents with lots
of characters from one of two fonts. :-)

> Moreover I can’t see how hyphenation can be performed with ZapfDingbats 
> (and even for Symbol, although that might be discussed), simply due to 
> a lack of hyphenation patterns.

Sure. That's why I actually chose this path. I didn't want to make
LineLM more complicated by handling the differences there. Ultimately,
the hyphenation character will probably never be used when one of those
two fonts is active.

> The encoding-agnostic version from the revision just before actually 
> looked fine to me.

There was one problem: You get lots of meaningless warnings about the
hyphenation char being substituted. If I just switch of the warning
completely, I'm back where I started. Having a "cannot map character"
when using a Symbol font loaded from a Type 1 font which is not very
helpful.

The way it is now I get properly warned with a meaningful message that
the hyphenation character I have chosen is not available for the current
font. And I don't have to manually redefine the hyphenation character in
FO each time I use Symbol or ZapfDingbats.

> WDYT?
> Vincent


Jeremias Maerki

Re: svn commit: r594067 - in /xmlgraphics/fop/trunk/src: codegen/fonts/ java/org/apache/fop/fo/properties/ java/org/apache/fop/fonts/ java/org/apache/fop/render/ps/

Posted by Vincent Hennebert <vi...@anyware-tech.com>.
Hi,

> Author: jeremias
> Date: Mon Nov 12 01:40:16 2007
> New Revision: 594067
> 
> URL: http://svn.apache.org/viewvc?rev=594067&view=rev
> Log:
> Avoid null values in generated Font classes so the encoding can be inspected.
> Don't warn about missing hyphenation characters for fonts such as Symbol and ZapfDingbats which don't have the default hyphenation character.

Is this really necessary? If hyphenation must occur within a block with 
the Symbol or ZapfDingbats fonts, doesn’t that mean that something is 
wrong somewhere, and may lead to an output unexpected by the user? 
Moreover I can’t see how hyphenation can be performed with ZapfDingbats 
(and even for Symbol, although that might be discussed), simply due to 
a lack of hyphenation patterns.
The encoding-agnostic version from the revision just before actually 
looked fine to me.

WDYT?
Vincent