From af927734079e823c566b0791ae440d8a6722b7d6 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 13 Feb 2012 10:23:28 -0700 Subject: [PATCH] cocoa 64-bit: Core Text patch for Pango With this patch, the font fallback mechanisms in `racket/draw' can locate suitable replacement glyphs, the same as for the Pango ATSUI back end. --- src/download-libs.rkt | 2 +- src/get-libs.rkt | 4 +- src/mac/README.txt | 2 + src/mac/coretext.patch | 100 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 src/mac/coretext.patch diff --git a/src/download-libs.rkt b/src/download-libs.rkt index b39621bfda..5168af8ca7 100644 --- a/src/download-libs.rkt +++ b/src/download-libs.rkt @@ -4,7 +4,7 @@ (provide do-download) (define url-host "download.racket-lang.org") -(define url-path "/libs/6/") +(define url-path "/libs/7/") (define url-base (string-append "http://" url-host url-path)) (define architecture #f) ;; set in `do-download' diff --git a/src/get-libs.rkt b/src/get-libs.rkt index 9d09d97bf4..45eae2c942 100644 --- a/src/get-libs.rkt +++ b/src/get-libs.rkt @@ -31,9 +31,9 @@ ["libgio-2.0.0.dylib" 1511444] ["libjpeg.62.dylib" 412024] ["libglib-2.0.0.dylib" 1272192] - ["libpango-1.0.0.dylib" 351672] + ["libpango-1.0.0.dylib" 392432] ["libgmodule-2.0.0.dylib" 18820] - ["libpangocairo-1.0.0.dylib" 83728] + ["libpangocairo-1.0.0.dylib" 96352] ["libgobject-2.0.0.dylib" 308304] ["libpixman-1.0.dylib" 526716] ["libgthread-2.0.0.dylib" 12708] diff --git a/src/mac/README.txt b/src/mac/README.txt index e4e26e15b0..63b00c2407 100644 --- a/src/mac/README.txt +++ b/src/mac/README.txt @@ -28,6 +28,8 @@ Patches: // read_modules (); pango/modules/basic/basic-atsui.c:60: add if (!glyph) { glyph = PANGO_GET_UNKNOWN_GLYPH(glyph); } + pango/modules/basic/basic-coretext.c: + apply "coretext.patch" pango/pangocairo-atsuifont.c:141: add metrics->underline_position = -metrics->underline_position; pango_quantize_line_geometry (&metrics->underline_thickness, diff --git a/src/mac/coretext.patch b/src/mac/coretext.patch new file mode 100644 index 0000000000..463f97cbd7 --- /dev/null +++ b/src/mac/coretext.patch @@ -0,0 +1,100 @@ +--- pango-1.29.5-orig/modules/basic/basic-coretext.c 2011-08-15 19:11:08.000000000 -0600 ++++ pango-1.29.5/modules/basic/basic-coretext.c 2012-02-13 10:09:51.000000000 -0700 +@@ -58,6 +58,8 @@ + { + PangoRectangle logical_rect; + ++ if (!glyph) { glyph = PANGO_GET_UNKNOWN_GLYPH(glyph); } ++ + glyphs->glyphs[i].glyph = glyph; + + glyphs->glyphs[i].geometry.x_offset = 0; +@@ -87,15 +89,15 @@ + CFArrayRef runs; + CTRunRef run; + CTRunStatus run_status; +- CFIndex i, glyph_count; ++ CFIndex i, glyph_count, num_runs, run_index, run_offset, run_glyph_count; + const CGGlyph *cgglyphs; + + CFTypeRef keys[] = { +- (CFTypeRef) kCTFontAttributeName ++ (CFTypeRef) kCTFontAttributeName + }; + + CFTypeRef values[] = { +- pango_core_text_font_get_ctfont (cfont) ++ pango_core_text_font_get_ctfont (cfont) + }; + + attributes = CFDictionaryCreate (kCFAllocatorDefault, +@@ -120,13 +122,20 @@ + + runs = CTLineGetGlyphRuns (line); + +- /* Since Pango divides things into runs already, we assume there is +- * only a single run in this line. ++ /* Since Pango divides things into runs already, we might assume there is ++ * only a single run in this line. However, unknown glyphs lead to ++ * separate runs. + */ +- run = CFArrayGetValueAtIndex (runs, 0); +- run_status = CTRunGetStatus (run); +- glyph_count = CTRunGetGlyphCount (run); +- cgglyphs = CTRunGetGlyphsPtr (run); ++ num_runs = CFArrayGetCount (runs); ++ glyph_count = 0; ++ for (i = 0; i < num_runs; i++) { ++ run = CFArrayGetValueAtIndex (runs, i); ++ glyph_count += CTRunGetGlyphCount (run); ++ } ++ ++ run_offset = 0; ++ run_index = 0; ++ run_glyph_count = 0; + + p = text; + pango_glyph_string_set_size (glyphs, glyph_count); +@@ -135,10 +144,18 @@ + + for (i = 0; i < glyph_count; i++) + { +- CFIndex real_i, prev_i; ++ CFIndex real_i, prev_i, run_real_i; + gunichar wc; + gunichar mirrored_ch; + ++ if (i - run_offset >= run_glyph_count) { ++ run_offset = i; ++ run = CFArrayGetValueAtIndex (runs, run_index++); ++ run_glyph_count = CTRunGetGlyphCount (run); ++ run_status = CTRunGetStatus (run); ++ cgglyphs = CTRunGetGlyphsPtr (run); ++ } ++ + wc = g_utf8_get_char (p); + + if (analysis->level % 2) +@@ -147,11 +164,13 @@ + + if (run_status & kCTRunStatusRightToLeft) + { ++ run_real_i = run_glyph_count - (i - run_offset) - 1; + real_i = glyph_count - i - 1; + prev_i = real_i + 1; + } + else + { ++ run_real_i = i - run_offset; + real_i = i; + prev_i = real_i - 1; + } +@@ -171,7 +190,7 @@ + + if (result != PANGO_COVERAGE_NONE) + { +- set_glyph (font, glyphs, real_i, p - text, cgglyphs[real_i]); ++ set_glyph (font, glyphs, real_i, p - text, cgglyphs[run_real_i]); + + if (g_unichar_type (wc) == G_UNICODE_NON_SPACING_MARK) + {