Cairo exports and more (was Re: [cairo] Re: Munging header files for export (and other) attributes)

Owen Taylor otaylor at redhat.com
Sun Sep 4 16:13:31 PDT 2005


On Sun, 2005-09-04 at 17:15 -0400, Owen Taylor wrote:

>  * The portability stuff is mostly good. I think rather than
>    hacking up the PDF and PS backends to build without font
>    support, it would be better to not build them until we 
>    get font embedding working with win32 fonts. It's not
>    that much work.

I took a look at this some. The implications for the font interfaces
is pretty straightforward. What I did was add:

/* the font backend interface */

#define CAIRO_SFNT_TABLE_NAME(a,b,c,d)          \
    ((((uint32_t)(a)) << 24) |                  \
     (((uint32_t)(b)) << 16) |                  \
     (((uint32_t)(c)) << 8) |                   \
     (((uint32_t)(d))))

/* Enumeration of tables from the TrueType format that we are
 * interested in. Backends can be requested to return one of these
 * tables.
 */
typedef enum
{
    CAIRO_SFNT_TABLE_CMAP  = CAIRO_SFONT_TABLE_NAME('c', 'm', 'a', 'p'),
    [...]
} cairo_sfnt_table_t;

/**
 * _cairo_unscaled_font_load_sfnt_table:
 * @font: a #cairo_unscaled_font_t
 * @table: the table to load from the font.
 * @buffer: location to store a pointer to a newly allocated buffer,
 *   or %NULL. If %NULL, the function will only store the length
 *   of the table in @size, and not actually retrieve it.l
 *   If non-%NULL and function succeeds, the pointer stored here
 *   must be freed with free().
 * @size: location to store the size of the table
 *
 * Loads a table from a font in SFNT format. (That is, a TrueType
 * or OpenType/CFF font)
 *
 * Return value: %CAIRO_STATUS_SUCCESS, %CAIRO_INT_STATUS_UNSUPPORTED,
 *    or another error like %CAIRO_STATUS_NO_MEMORY.
 **/
cairo_int_status_t
_cairo_unscaled_font_load_sfnt_table (cairo_unscaled_font_t *font,
                                      cairo_sfnt_table_t     table,
                                      unsigned char        **buffer,
                                      size_t                *size);


/**
 * _cairo_scaled_font_get_unscaled_font:
 * @scaled_font: a #cairo_scaled_font_t
 *
 * Gets the #cairo_unscaled_font_t corresponding to @scaled_font, if any.
 * If the font backend does not support the interfaces for font embedding,
 * may return %NULL.
 *
 * Return value: a #cairo_unscaled_font_t, or %NULL. This value is owned by the
 *   scaled font. If you want to keep a reference to it, you must
 *   call _cairo_unscaled_font_reference().
 **/
cairo_unscaled_font_t *
_cairo_scaled_font_get_unscaled_font (cairo_scaled_font_t *scaled_font);

I think this is sufficient, though you might also want some sort of 
_cairo_unscaled_font_get_capabilities() function if we start adding
virtual functions to support other font formats.

(You can call
load_sfnt_table(unscaled, CAIRO_SFNT_TABLE_HEAD, NULL, &size); to check
if the font is a SFNT, but that's a little ugly.)

However, when I started looking at making cairo-font-subset.c actually
use this stuff, it became clear that it was going to *majorly* conflict
with Kristian's outstanding Type1-embedding patch. So, it should probably
wait for that to land.

Regards,
							Owen

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050904/ef533578/attachment.pgp


More information about the cairo mailing list