From ajohnson at kemper.freedesktop.org Wed Jan 4 22:08:03 2017 From: ajohnson at kemper.freedesktop.org (Adrian Johnson) Date: Wed, 4 Jan 2017 22:08:03 +0000 (UTC) Subject: [cairo-commit] 2 commits - src/cairo-pdf.h src/cairo-pdf-interchange.c test/pdf-tagged-text.c Message-ID: <20170104220803.E94897619C@kemper.freedesktop.org> src/cairo-pdf-interchange.c | 6 +++--- src/cairo-pdf.h | 13 ++++++------- test/pdf-tagged-text.c | 7 ++++--- 3 files changed, 13 insertions(+), 13 deletions(-) New commits: commit dd4706d0a9d123d3aa4284ac9ab35fbe165278b2 Author: Kouhei Sutou Date: Wed Jan 4 23:38:17 2017 +0900 pdf: Fix wrong cairo_pdf_outline_flags_t item prefix diff --git a/src/cairo-pdf-interchange.c b/src/cairo-pdf-interchange.c index 18dd4d8..1fc8197 100644 --- a/src/cairo-pdf-interchange.c +++ b/src/cairo-pdf-interchange.c @@ -579,9 +579,9 @@ cairo_pdf_interchange_write_outline (cairo_pdf_surface_t *surface) if (outline->flags) { int flags = 0; - if (outline->flags & CAIRO_BOOKMARK_FLAG_ITALIC) + if (outline->flags & CAIRO_PDF_OUTLINE_FLAG_ITALIC) flags |= 1; - if (outline->flags & CAIRO_BOOKMARK_FLAG_BOLD) + if (outline->flags & CAIRO_PDF_OUTLINE_FLAG_BOLD) flags |= 2; _cairo_output_stream_printf (surface->output, " /F %d\n", @@ -1338,7 +1338,7 @@ _cairo_pdf_interchange_add_outline (cairo_pdf_surface_t *surface, /* Update Count */ outline = outline->parent; while (outline) { - if (outline->flags & CAIRO_BOOKMARK_FLAG_OPEN) { + if (outline->flags & CAIRO_PDF_OUTLINE_FLAG_OPEN) { outline->count++; } else { outline->count--; diff --git a/src/cairo-pdf.h b/src/cairo-pdf.h index 74117f4..040c0ed 100644 --- a/src/cairo-pdf.h +++ b/src/cairo-pdf.h @@ -87,9 +87,9 @@ cairo_pdf_surface_set_size (cairo_surface_t *surface, /** * cairo_pdf_outline_flags_t: - * @CAIRO_BOOKMARK_FLAG_OPEN: The outline item defaults to open in the PDF viewer (Since 1.16) - * @CAIRO_BOOKMARK_FLAG_BOLD: The outline item is displayed by the viewer in bold text (Since 1.16) - * @CAIRO_BOOKMARK_FLAG_ITALIC: The outline item is displayed by the viewer in italic text (Since 1.16) + * @CAIRO_PDF_OUTLINE_FLAG_OPEN: The outline item defaults to open in the PDF viewer (Since 1.16) + * @CAIRO_PDF_OUTLINE_FLAG_BOLD: The outline item is displayed by the viewer in bold text (Since 1.16) + * @CAIRO_PDF_OUTLINE_FLAG_ITALIC: The outline item is displayed by the viewer in italic text (Since 1.16) * * #cairo_pdf_outline_flags_t is used by the * cairo_pdf_surface_add_outline() function specify the attributes of @@ -99,9 +99,9 @@ cairo_pdf_surface_set_size (cairo_surface_t *surface, * Since: 1.16 **/ typedef enum _cairo_pdf_outline_flags { - CAIRO_BOOKMARK_FLAG_OPEN = 0x1, - CAIRO_BOOKMARK_FLAG_BOLD = 0x2, - CAIRO_BOOKMARK_FLAG_ITALIC = 0x4, + CAIRO_PDF_OUTLINE_FLAG_OPEN = 0x1, + CAIRO_PDF_OUTLINE_FLAG_BOLD = 0x2, + CAIRO_PDF_OUTLINE_FLAG_ITALIC = 0x4, } cairo_pdf_outline_flags_t; #define CAIRO_PDF_OUTLINE_ROOT 0 diff --git a/test/pdf-tagged-text.c b/test/pdf-tagged-text.c index 14dbad1..74e7968 100644 --- a/test/pdf-tagged-text.c +++ b/test/pdf-tagged-text.c @@ -244,7 +244,7 @@ draw_section (cairo_surface_t *surface, cairo_t *cr, const struct section *secti cairo_tag_end (cr, CAIRO_TAG_DEST); cairo_tag_end (cr, "H1"); y_pos = MARGIN + HEADING_HEIGHT; - flags = CAIRO_BOOKMARK_FLAG_BOLD | CAIRO_BOOKMARK_FLAG_OPEN; + flags = CAIRO_PDF_OUTLINE_FLAG_BOLD | CAIRO_PDF_OUTLINE_FLAG_OPEN; outline_parents[0] = cairo_pdf_surface_add_outline (surface, CAIRO_PDF_OUTLINE_ROOT, section->heading, @@ -256,7 +256,7 @@ draw_section (cairo_surface_t *surface, cairo_t *cr, const struct section *secti flags = 0; } else { cairo_set_font_size(cr, HEADING3_SIZE); - flags = CAIRO_BOOKMARK_FLAG_ITALIC; + flags = CAIRO_PDF_OUTLINE_FLAG_ITALIC; } if (y_pos + HEADING_HEIGHT + paragraph_height + MARGIN > PAGE_HEIGHT) { @@ -335,7 +335,8 @@ create_document (cairo_surface_t *surface, cairo_t *cr) cairo_pdf_surface_add_outline (surface, CAIRO_PDF_OUTLINE_ROOT, - "Contents", "TOC", CAIRO_BOOKMARK_FLAG_BOLD); + "Contents", "TOC", + CAIRO_PDF_OUTLINE_FLAG_BOLD); cairo_tag_begin (cr, CAIRO_TAG_DEST, "name='TOC'"); cairo_tag_begin (cr, "TOC", NULL); commit c7e87cd9df401f2c5a62534697d12a4e0afda2ce Author: Kouhei Sutou Date: Wed Jan 4 23:32:59 2017 +0900 pdf: Remove duplicated item diff --git a/src/cairo-pdf.h b/src/cairo-pdf.h index 1e46a7c..74117f4 100644 --- a/src/cairo-pdf.h +++ b/src/cairo-pdf.h @@ -120,7 +120,6 @@ cairo_pdf_surface_add_outline (cairo_surface_t *surface, * @CAIRO_PDF_METADATA_SUBJECT: The document subject (Since 1.16) * @CAIRO_PDF_METADATA_KEYWORDS: The document keywords (Since 1.16) * @CAIRO_PDF_METADATA_CREATOR: The document creator (Since 1.16) - * @CAIRO_PDF_METADATA_TITLE: The document title (Since 1.16) * @CAIRO_PDF_METADATA_CREATE_DATE: The document creation date (Since 1.16) * @CAIRO_PDF_METADATA_MOD_DATE: The document modification date (Since 1.16) * From ranma42 at kemper.freedesktop.org Sat Jan 21 11:21:30 2017 From: ranma42 at kemper.freedesktop.org (Andrea Canciani) Date: Sat, 21 Jan 2017 11:21:30 +0000 (UTC) Subject: [cairo-commit] README src/cairo-quartz-font.c src/cairo-quartz-private.h Message-ID: <20170121112130.53565761A2@kemper.freedesktop.org> README | 2 +- src/cairo-quartz-font.c | 26 ++++++++++++++++++++++---- src/cairo-quartz-private.h | 12 ++++++++---- 3 files changed, 31 insertions(+), 9 deletions(-) New commits: commit 5a8a9c97ed268004cbac510d39739ff56c0fb43c Author: Andrea Canciani Date: Wed Jan 18 13:08:11 2017 +0100 quartz: Restore 10.4-specific font code The code for extracting font glyphs was replaced in 70cc8f250b5669e757b4f044571ba0f71e3dea9e with an implementation based on CoreText, which is not available on MacOSX 10.4. This commit restores automatic detection of which API should be used by means of dynamic linking. diff --git a/README b/README index 0be9947..7ee2c18 100644 --- a/README +++ b/README @@ -121,7 +121,7 @@ Supported, "platform" surface backends quartz backend -------------- - MacOS X >= 10.5 with Xcode >= 3.0 + MacOS X >= 10.4 with Xcode >= 2.5 win32 backend ------------- diff --git a/src/cairo-quartz-font.c b/src/cairo-quartz-font.c index feee61a..897b2d0 100644 --- a/src/cairo-quartz-font.c +++ b/src/cairo-quartz-font.c @@ -81,6 +81,14 @@ static void (*CGFontGetGlyphsForUnicharsPtr) (CGFontRef, const UniChar[], const static void (*CGContextSetAllowsFontSmoothingPtr) (CGContextRef, bool) = NULL; static bool (*CGContextGetAllowsFontSmoothingPtr) (CGContextRef) = NULL; +/* Not public in the least bit */ +static CGPathRef (*CGFontGetGlyphPathPtr) (CGFontRef fontRef, CGAffineTransform *textTransform, int unknown, CGGlyph glyph) = NULL; + +/* CTFontCreateWithGraphicsFont is not available until 10.5 */ +typedef const struct __CTFontDescriptor *CTFontDescriptorRef; +static CTFontRef (*CTFontCreateWithGraphicsFontPtr) (CGFontRef, CGFloat, const CGAffineTransform*, CTFontDescriptorRef) = NULL; +static CGPathRef (*CTFontCreatePathForGlyphPtr) (CTFontRef, CGGlyph, CGAffineTransform *) = NULL; + /* CGFontGetHMetrics isn't public, but the other functions are public/present in 10.5 */ typedef struct { int ascent; @@ -125,6 +133,11 @@ quartz_font_ensure_symbols(void) CGFontGetUnitsPerEmPtr = dlsym(RTLD_DEFAULT, "CGFontGetUnitsPerEm"); CGFontGetGlyphAdvancesPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphAdvances"); + CTFontCreateWithGraphicsFontPtr = dlsym(RTLD_DEFAULT, "CTFontCreateWithGraphicsFont"); + CTFontCreatePathForGlyphPtr = dlsym(RTLD_DEFAULT, "CTFontCreatePathForGlyph"); + if (!CTFontCreateWithGraphicsFontPtr || !CTFontCreatePathForGlyphPtr) + CGFontGetGlyphPathPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphPath"); + CGFontGetHMetricsPtr = dlsym(RTLD_DEFAULT, "CGFontGetHMetrics"); CGFontGetAscentPtr = dlsym(RTLD_DEFAULT, "CGFontGetAscent"); CGFontGetDescentPtr = dlsym(RTLD_DEFAULT, "CGFontGetDescent"); @@ -140,6 +153,7 @@ quartz_font_ensure_symbols(void) CGFontGetGlyphsForUnicharsPtr && CGFontGetUnitsPerEmPtr && CGFontGetGlyphAdvancesPtr && + ((CTFontCreateWithGraphicsFontPtr && CTFontCreatePathForGlyphPtr) || CGFontGetGlyphPathPtr) && (CGFontGetHMetricsPtr || (CGFontGetAscentPtr && CGFontGetDescentPtr && CGFontGetLeadingPtr))) _cairo_quartz_font_symbols_present = TRUE; @@ -545,7 +559,6 @@ _cairo_quartz_init_glyph_path (cairo_quartz_scaled_font_t *font, CGGlyph glyph = _cairo_quartz_scaled_glyph_index (scaled_glyph); CGAffineTransform textMatrix; CGPathRef glyphPath; - CTFontRef ctFont; cairo_path_fixed_t *path; if (glyph == INVALID_GLYPH) { @@ -560,9 +573,14 @@ _cairo_quartz_init_glyph_path (cairo_quartz_scaled_font_t *font, -font->base.scale.yy, 0, 0); - ctFont = CTFontCreateWithGraphicsFont (font_face->cgFont, 1.0, NULL, NULL); - glyphPath = CTFontCreatePathForGlyph (ctFont, glyph, &textMatrix); - CFRelease (ctFont); + if (CTFontCreateWithGraphicsFontPtr && CTFontCreatePathForGlyphPtr) { + CTFontRef ctFont = CTFontCreateWithGraphicsFontPtr (font_face->cgFont, 1.0, NULL, NULL); + glyphPath = CTFontCreatePathForGlyphPtr (ctFont, glyph, &textMatrix); + CFRelease (ctFont); + } else { + glyphPath = CGFontGetGlyphPathPtr (font_face->cgFont, &textMatrix, 0, glyph); + } + if (!glyphPath) return CAIRO_INT_STATUS_UNSUPPORTED; diff --git a/src/cairo-quartz-private.h b/src/cairo-quartz-private.h index 3ef14c3..42e1f9e 100644 --- a/src/cairo-quartz-private.h +++ b/src/cairo-quartz-private.h @@ -44,12 +44,13 @@ #include "cairo-quartz.h" #include "cairo-surface-clipper-private.h" -#ifdef CGFLOAT_DEFINED -typedef CGFloat cairo_quartz_float_t; -#else -typedef float cairo_quartz_float_t; +#ifndef CGFLOAT_DEFINED +/* On 10.4, Quartz APIs used float instead of CGFloat */ +typedef float CGFloat; #endif +typedef CGFloat cairo_quartz_float_t; + typedef enum { DO_DIRECT, DO_SHADING, @@ -57,6 +58,9 @@ typedef enum { DO_TILED_IMAGE } cairo_quartz_action_t; +/* define CTFontRef for pre-10.5 SDKs */ +typedef const struct __CTFont *CTFontRef; + typedef struct cairo_quartz_surface { cairo_surface_t base;