[cairo] Internal font subset interface

Carl Worth cworth at cworth.org
Wed May 10 15:29:38 PDT 2006


On Wed, 10 May 2006 07:43:38 +0200, Emmanuel Pacaud wrote:
> Looks ok for me.

Thanks for looking it over.

> One comment though: SVG backend doesn't have a glyph per subfont limit,
> so it would be great if _cairo_scaled_font_subsets_create could accept a
> value <= 0 as maxglyphs, indicating no limit.

Yes, it was the no-limit case of the SVG backend that prompted me to
add this parameter, and I had already planned to provide the
0==no-limit semantics you suggest.

> And also makes _cairo_scaled_font_subsets_allocate_glyph accept NULL as
> sub_font_id placeholder.

Oh, I didn't do that. But it would obviously be an easy change to
add if desired. (I almost went the other direction and made the SVG
backend simply output a three part glyph identifier (such as
"glyph-0-0-0") rather than encoding the assumption that it can just
ignore the subset_id).

> By the way, I think subsets_use_glyph would be a clearer name than
> subsets_allocate_glyph.

Much better, yes. I've gone one more and made in subsets_map_glyph.

So this is all implemented and pushed out now, (with both the SVG and
PS backends using it successfully, (at least as far as the test suite
can tell).

I also simplified the interface a bit since the last proposal, by
eliminating the second callback-iteration interface as well as the
glyph structure, (preferring instead to just provide a sorted array to
the first callback such that the array index is the
subset_glyph_index).

I'll add a bit of documentation to this interface now, and I suppose I
should do a quick check of this implementation for memory leaks.

The latest interface appears below.

It should now be much, much more straightforward to add type 3 font
output to the PDF backend.

Kristian, would you like to take a look and see if this interface
would need any changes to allow the TrueType subsetting you've done
before?

Is it possible that the interface here can remain unchanged and that
the caller can do everything necessary with the information provided
in the cairo_scaled_font_subset_t structure? (Of course, we'll still
need to add functions to allow the extraction of an unscaled font from
a scaled font when possible). Or if some more invasive change is
required, let me know.

-Carl

typedef struct _cairo_scaled_font_subsets cairo_scaled_font_subsets_t;

typedef struct _cairo_scaled_font_subset {
    cairo_scaled_font_t *scaled_font;
    unsigned int font_id;
    unsigned int subset_id;

    /* Index of glyphs array is subset_glyph_index.
     * Value of glyphs array is scaled_font_glyph_index.
     */
    unsigned long *glyphs;
    int num_glyphs;
} cairo_scaled_font_subset_t;

cairo_private cairo_scaled_font_subsets_t *
_cairo_scaled_font_subsets_create (int max_glyphs_per_subset);

cairo_private void
_cairo_scaled_font_subsets_destroy (cairo_scaled_font_subsets_t *font_subsets);

cairo_private cairo_status_t
_cairo_scaled_font_subsets_map_glyph (cairo_scaled_font_subsets_t	*font_subsets,
				      cairo_scaled_font_t		*scaled_font,
				      unsigned long			 scaled_font_glyph_index,
				      unsigned int			*font_id,
				      unsigned int			*subset_id,
				      unsigned int			*subset_glyph_index);

typedef cairo_status_t
(*cairo_scaled_font_subset_callback_func_t) (cairo_scaled_font_subset_t	*font_subset,
					     void			*closure);

cairo_private cairo_status_t
_cairo_scaled_font_subsets_foreach (cairo_scaled_font_subsets_t			*font_subsets,
				    cairo_scaled_font_subset_callback_func_t	 font_subset_callback,
				    void					*closure);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060510/08e191ad/attachment.pgp


More information about the cairo mailing list