xmlgraphics-fop-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rafal Maczewski" <...@pa70.ziebice.sdi.tpnet.pl>
Subject Re: TTF Font Support with Fop-0.18.1
Date Sun, 08 Apr 2001 12:50:10 GMT
Hello,

I've had the same problem. I tried to embed arial.ttf or verdana.ttf and the
letters were invisible although the font was included in the file.
After some investigation I found two bugs in FOP code that is responsible
for embedding fonts.
1. The header table of the font file created by FOP is incorrect for some
fonts. In the header table there is flag that determines the number of bytes
that will be used by the loca table. This flag should be set to 1 if loca
table is composed of longs and 0 if loca table is composed of shorts.  The
loca table created by FOP uses longs, but the flag is set to the value used
by the original font. So the embedding does not work for fonts that use
shorts in loca table (like Arial and Verdana)
2. The checksum created for the "glyf" section is incorrect which is not a
big problem (Acrobat does not check checksums) but sometimes FOP will exceed
allocated array boundaries and cause an exception.

Below you can find the patch that fixes both of these problems.

Hope this helps,

Rafal


File: src/org/apache/fop/fonts/TTFSubSetFile.java
/* -- $Id: TTFSubSetFile.java,v 1.1 2001/03/23 08:41:34 fotis Exp $ */


*** src/org/apache/fop/fonts/TTFSubSetFile.java.0.18.1 Sun Apr  8 10:32:54
2001
--- src/org/apache/fop/fonts/TTFSubSetFile.java Sun Apr  8 11:00:17 2001
***************
*** 277,283 ****
           output[currentPos+9] = 0;
           output[currentPos+10] = 0;
           output[currentPos+11] = 0;
!          output[currentPos+(int)entry.length-2] = 0; // long locaformat

           int checksum = getCheckSum(currentPos, (int)entry.length);
           writeULong(headDirOffset, checksum);
--- 277,284 ----
           output[currentPos+9] = 0;
           output[currentPos+10] = 0;
           output[currentPos+11] = 0;
!          output[currentPos+50] = 0; // long locaformat
!          output[currentPos+51] = 1; // long locaformat

           int checksum = getCheckSum(currentPos, (int)entry.length);
           writeULong(headDirOffset, checksum);
***************
*** 341,347 ****

           size = currentPos - start;

!          int checksum = getCheckSum(currentPos, size);
           writeULong(glyfDirOffset, checksum);
           writeULong(glyfDirOffset+4, start);
           writeULong(glyfDirOffset+8, size);
--- 342,348 ----

           size = currentPos - start;

!          int checksum = getCheckSum(start, size);
           writeULong(glyfDirOffset, checksum);
           writeULong(glyfDirOffset+4, start);
           writeULong(glyfDirOffset+8, size);




> Hello,
>
> after reading the instructions on the web site, I tried to include a ttf
font (arial). I modified userconfig.xml:
>
> <font metrics-file="file:///E:/Temp/Fop-0.18.1-DEV/Fonts/arial.xml"
kerning="yes"  embed-file="E:\Temp\Fop-0.18.1-DEV\Fonts\arial.ttf">
>   <font-triplet name="Arial" style="normal" weight="normal"/>
> </font>
>
> and I've used the font.fo example with
>
> <fo:block space-after.optimum="10pt"
>           font-family="Arial">
>    Ok !
> </fo:block>
>
> With fop.bat there where no error messages:
>
> >fop -c conf\userconfig.xml docs\examples\fo\fonts.fo
docs\examples\fo\fonts.pdf
> java -cp
fop.jar;lib\w3c.jar;lib\xalan-2.0.0.jar;lib\xerces-1.2.3.jar;lib\jimi-1.0.ja
r org.apache.fop.apps.Fop -c conf\userconfig.xml docs\examples\fo\fonts.fo
docs\examples\fo\fonts.pdf
> reading user configuration file
> FOP 0.18.1-DEV
> using SAX parser org.apache.xerces.parsers.SAXParser
> building formatting object tree
> setting up fonts
> formatting FOs into areas
>  [1]
> rendering areas to PDF
> Writing 3536 bytes of font data
> Writing 6284 bytes of font data
> writing out PDF
>
> In the pdf-file there is only some invisible text (I can select). The
> Font is included, Acrobat Reader shows in Font information
> 1E3ea7Arial    TrueType (CID)    Windows   eingebettet
>
> What have I missed ?
>
> Carsten


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Mime
View raw message