summaryrefslogtreecommitdiff
path: root/src/cairo-quartz-font.c
diff options
context:
space:
mode:
authorAndrea Canciani <ranma42@gmail.com>2010-11-01 14:06:32 +0100
committerAndrea Canciani <ranma42@gmail.com>2010-11-01 14:06:32 +0100
commit947d35c19539b84c866d792c067a0cc63485e94e (patch)
tree5e2d205134c227d0fac0d5050b6ec094bb2ff34d /src/cairo-quartz-font.c
parentbb30dae210da3fc71bb242c7a73b8f9308eec2a1 (diff)
downloadcairo-947d35c19539b84c866d792c067a0cc63485e94e.tar.gz
quartz-font: Add truetype font table tags accessor
Improves the quality of embedded fonts.
Diffstat (limited to 'src/cairo-quartz-font.c')
-rw-r--r--src/cairo-quartz-font.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/cairo-quartz-font.c b/src/cairo-quartz-font.c
index 2c7e017af..d13b395cf 100644
--- a/src/cairo-quartz-font.c
+++ b/src/cairo-quartz-font.c
@@ -61,6 +61,8 @@
* This macro can be used to conditionally compile backend-specific code.
*/
+static CFDataRef (*CGFontCopyTableForTagPtr) (CGFontRef font, uint32_t tag) = NULL;
+
/* CreateWithFontName exists in 10.5, but not in 10.4; CreateWithName isn't public in 10.4 */
static CGFontRef (*CGFontCreateWithFontNamePtr) (CFStringRef) = NULL;
static CGFontRef (*CGFontCreateWithNamePtr) (const char *) = NULL;
@@ -99,6 +101,8 @@ quartz_font_ensure_symbols(void)
if (_cairo_quartz_font_symbol_lookup_done)
return;
+ CGFontCopyTableForTagPtr = dlsym(RTLD_DEFAULT, "CGFontCopyTableForTag");
+
/* Look for the 10.5 versions first */
CGFontGetGlyphBBoxesPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphBBoxes");
if (!CGFontGetGlyphBBoxesPtr)
@@ -754,6 +758,39 @@ _cairo_quartz_ucs4_to_index (void *abstract_font,
return glyph;
}
+static cairo_int_status_t
+_cairo_quartz_load_truetype_table (void *abstract_font,
+ unsigned long tag,
+ long offset,
+ unsigned char *buffer,
+ unsigned long *length)
+{
+ cairo_quartz_font_face_t *font_face = _cairo_quartz_scaled_to_face (abstract_font);
+ CFDataRef data = NULL;
+ CFIndex len;
+
+ if (likely (CGFontCopyTableForTagPtr))
+ data = CGFontCopyTableForTagPtr (font_face->cgFont, tag);
+
+ if (!data)
+ return CAIRO_INT_STATUS_UNSUPPORTED;
+
+ if (length) {
+ if (*length == 0) {
+ *length = CFDataGetLength (data);
+ return CAIRO_STATUS_SUCCESS;
+ }
+
+ len = *length;
+ } else
+ len = CFDataGetLength (data);
+
+ if (buffer)
+ CFDataGetBytes (data, CFRangeMake (offset, len), buffer);
+
+ return CAIRO_STATUS_SUCCESS;
+}
+
static const cairo_scaled_font_backend_t _cairo_quartz_scaled_font_backend = {
CAIRO_FONT_TYPE_QUARTZ,
_cairo_quartz_scaled_font_fini,
@@ -761,7 +798,7 @@ static const cairo_scaled_font_backend_t _cairo_quartz_scaled_font_backend = {
NULL, /* text_to_glyphs */
_cairo_quartz_ucs4_to_index,
NULL, /* show_glyphs */
- NULL, /* load_truetype_table */
+ _cairo_quartz_load_truetype_table,
NULL, /* map_glyphs_to_unicode */
};