freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft] Loading FT_Face without having access to the font as whole


From: Khaled Hosny
Subject: Re: [ft] Loading FT_Face without having access to the font as whole
Date: Sun, 21 Jul 2013 13:05:52 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

Hi Werner,

On Sun, Jul 21, 2013 at 12:24:41PM +0200, Werner LEMBERG wrote:
> 
> Hello Khaled!
> 
> 
> > I’ve been using FreeType with Core Text fonts on Mac, and one of the
> > issues I had is that Core Text does not provide an API to get face
> > index from multi-font files (TTC, dfont, etc.) so I had to resort to
> > some hacks to guess the face index[1], but this fails for at least
> > one Apple-shipped font.
> 
> Looking at [1]: Why not referring to `face->face_index'?  This gives
> the current index of a multi-font file.

What that function does is take a CTFont and return its file name and
face index to be used by FreeType. Core Text has API to return file
name, so that is not an issue, but all fonts a TTC collection will have
the same file name, and there is no Core Text API to tell the face index
inside the file. The for loop simply opens the font with FreeType with
all possible face indices and compares the PS Name of the FT_Face and
that of the original CTFont until it finds a matching one. This works
pretty well until Core Text starts lying about the PS Name, and there is
at least one font where it does so (Helvetica CY; its PS Names lack the
hyphen between the family and style parts, but Core Text reports them
with hyphens).

> > I was wondering if there is a way or if it is possible to added a
> > new way to create FT_Face with callback function(s) for returning
> > individual font tables and other info that FreeType might need,
> > similar to HarfBuzz’s hb_face_create_for_tables(), so that I can
> > just hook it with the API for getting font tables and not have to
> > worry about face index.
> 
> It's not clear to me how this should work.  Can you give some
> pseudo-code?

I'm not good at writing pseudo code (or any code, for that matter :), so
I hope this explanation is clear enough.

HarfBuzz has hb_face_create_for_tables() that takes a callback function
and a pointer, the callback functions is called with the table tag and
the pointer and returns a buffer, whenever HarfBuzz wants to access a
font table. For my case the pointer would be a CTFont and the callback
function would call CTFontCopyTable() on it.

Check hb-ft.cc, for example, where HarfBuzz integrates with FreeType
this way.

Regards,
Khaled



reply via email to

[Prev in Thread] Current Thread [Next in Thread]