You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Bertrand Delacretaz <bd...@apache.org> on 2006/10/11 13:15:54 UTC

Kerning for CID fonts, use unicode indexes in ?

Hi FOPpers,

See http://issues.apache.org/bugzilla/show_bug.cgi?id=40724 , kerning
doesn't work for me with user-specified CID fonts at the moment.

IIUC the code, org.apache.fop.layoutmgr.inline.TextLayoutManager
expects unicode indexes for kerning pairs, but currently the TTFReader
writes glyph indexes in the XML file, like:

  <kerning kpx1="3">
    <pair kern="-279" kpx2="4"/>
  </kerning>

Where 3 and 4 are glyph indexes (I'm playing with a test font with
very few glyphs, it's easier).

I've tried changing the TTFFile code to use unicode indexes for kpx1
and kpx2 and it seems to work - anything against making this change?

-Bertrand

Re: Kerning for CID fonts, use unicode indexes in ?

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Right, it isn't hard. Almost works after a train ride to Zurich and back.
:-)

On 13.10.2006 11:33:09 Bertrand Delacretaz wrote:
> On 10/13/06, Jeremias Maerki <de...@jeremias-maerki.ch> wrote:
> 
> > ...Maybe I'll try to figure
> > out if it's a small change to bypass the metrics file entirely. :-)
> 
> Shouldn't be hard at all, but right now I have to create a test
> document to demonstrate the "new" font features for my own project, so
> I won't be able to do it ATM. I hear you work well on trains ;-)
> 
> -Bertrand



Jeremias Maerki


Re: Kerning for CID fonts, use unicode indexes in ?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On 10/13/06, Jeremias Maerki <de...@jeremias-maerki.ch> wrote:

> ...Maybe I'll try to figure
> out if it's a small change to bypass the metrics file entirely. :-)

Shouldn't be hard at all, but right now I have to create a test
document to demonstrate the "new" font features for my own project, so
I won't be able to do it ATM. I hear you work well on trains ;-)

-Bertrand

Re: Kerning for CID fonts, use unicode indexes in ?

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Thanks for the changes. I understand the necessity now. I've done some
tests and after your latest fix, everything seems to be working fine.
Let's hope our users won't be too mad at us for changing the format. I
have some time in trains this and next week. Maybe I'll try to figure
out if it's a small change to bypass the metrics file entirely. :-)
Actually, finishing my DataMatrix implementation is more important but
if this were only a small step we should take it. *g* Otherwise, we'll
defer that to the FOray stuff.

On 12.10.2006 12:17:36 Bertrand Delacretaz wrote:
> On 10/11/06, Jeremias Maerki <de...@jeremias-maerki.ch> wrote:
> 
> > ...I wonder how much should
> > be invested in versioning of those files....
> 
> Ok, so I have added a simplistic versioning system for these metrics
> XML files, an exception is thrown when attempting to read incompatible
> metrics files (http://issues.apache.org/bugzilla/show_bug.cgi?id=40739).
> 
> Mapping the glyph indexes to unicode indexes when reading the XML
> metrics file seemed more complicated than when creating the file, so I
> have implemented the change in the TTFFile class, which now writes the
> <kerning> info based on unicode code points.
> 
> A note in the FOray release notes
> (http://foray.sourceforge.net/app/using/release.html) says "Kerning
> has been fixed for subsetted fonts", makes me wonder if kerning did
> work before for custom CID fonts. Anyway it should work now.
> 
> -Bertrand



Jeremias Maerki


Re: Kerning for CID fonts, use unicode indexes in ?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On 10/11/06, Jeremias Maerki <de...@jeremias-maerki.ch> wrote:
> ...the goal should be that we
> don't rely on those XML files much longer, so I wonder how much should
> be invested in versioning of those files...

Agreed - versioning is easy though, if I need to make the suggested
changes I'll probably implement it just to be safe, before going to
direct reading of the font files.

> ... I still don't understand why exactly this change is
> necessary....

The layout code definitely expects unicode indexes for the kerning
values, so something's wrong currently. I'll see how mapping on the
other side (i.e. when reading the metrics xml file) looks, as it would
avoid having to modify the metrics xml files.

-Bertrand

Re: Kerning for CID fonts, use unicode indexes in ?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On 10/11/06, Jeremias Maerki <de...@jeremias-maerki.ch> wrote:

> ...I wonder how much should
> be invested in versioning of those files....

Ok, so I have added a simplistic versioning system for these metrics
XML files, an exception is thrown when attempting to read incompatible
metrics files (http://issues.apache.org/bugzilla/show_bug.cgi?id=40739).

Mapping the glyph indexes to unicode indexes when reading the XML
metrics file seemed more complicated than when creating the file, so I
have implemented the change in the TTFFile class, which now writes the
<kerning> info based on unicode code points.

A note in the FOray release notes
(http://foray.sourceforge.net/app/using/release.html) says "Kerning
has been fixed for subsetted fonts", makes me wonder if kerning did
work before for custom CID fonts. Anyway it should work now.

-Bertrand

Re: Kerning for CID fonts, use unicode indexes in ?

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Sure. However, as we discussed in Amsterdam, the goal should be that we
don't rely on those XML files much longer, so I wonder how much should
be invested in versioning of those files. But if you don't see a way
around it... I still don't understand why exactly this change is
necessary.

On 11.10.2006 18:59:07 Bertrand Delacretaz wrote:
> On 10/11/06, Jeremias Maerki <de...@jeremias-maerki.ch> wrote:
> 
> > ...If this change has an effect on the XML files generated, then we should
> > be careful because people might not recreate their metric files and
> > subsequently run into problems...
> 
> How about adding a version number to the XML metrics files?
> 
> This would make them more future-proof, and in this case we could
> detect old files and bark.
> 
> -Bertrand



Jeremias Maerki


Re: Kerning for CID fonts, use unicode indexes in ?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On 10/11/06, Jeremias Maerki <de...@jeremias-maerki.ch> wrote:

> ...If this change has an effect on the XML files generated, then we should
> be careful because people might not recreate their metric files and
> subsequently run into problems...

How about adding a version number to the XML metrics files?

This would make them more future-proof, and in this case we could
detect old files and bark.

-Bertrand

Re: Kerning for CID fonts, use unicode indexes in ?

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
I wonder where this got broken. I believe this used to work. 

If this change has an effect on the XML files generated, then we should
be careful because people might not recreate their metric files and
subsequently run into problems.

On 11.10.2006 13:15:54 Bertrand Delacretaz wrote:
> Hi FOPpers,
> 
> See http://issues.apache.org/bugzilla/show_bug.cgi?id=40724 , kerning
> doesn't work for me with user-specified CID fonts at the moment.
> 
> IIUC the code, org.apache.fop.layoutmgr.inline.TextLayoutManager
> expects unicode indexes for kerning pairs, but currently the TTFReader
> writes glyph indexes in the XML file, like:
> 
>   <kerning kpx1="3">
>     <pair kern="-279" kpx2="4"/>
>   </kerning>
> 
> Where 3 and 4 are glyph indexes (I'm playing with a test font with
> very few glyphs, it's easier).
> 
> I've tried changing the TTFFile code to use unicode indexes for kpx1
> and kpx2 and it seems to work - anything against making this change?
> 
> -Bertrand



Jeremias Maerki