Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 1 | /* |
Behdad Esfahbod | 3613696 | 2013-08-12 00:33:28 -0400 | [diff] [blame] | 2 | * Copyright © 2012,2013 Mozilla Foundation. |
| 3 | * Copyright © 2012,2013 Google, Inc. |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 4 | * |
| 5 | * This is part of HarfBuzz, a text shaping library. |
| 6 | * |
| 7 | * Permission is hereby granted, without written agreement and without |
| 8 | * license or royalty fees, to use, copy, modify, and distribute this |
| 9 | * software and its documentation for any purpose, provided that the |
| 10 | * above copyright notice and the following two paragraphs appear in |
| 11 | * all copies of this software. |
| 12 | * |
| 13 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
| 14 | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
| 15 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
| 16 | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
| 17 | * DAMAGE. |
| 18 | * |
| 19 | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
| 20 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 21 | * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
| 22 | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
| 23 | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 24 | * |
| 25 | * Mozilla Author(s): Jonathan Kew |
Behdad Esfahbod | 301168d | 2012-07-30 17:48:04 -0400 | [diff] [blame] | 26 | * Google Author(s): Behdad Esfahbod |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 27 | */ |
| 28 | |
Behdad Esfahbod | 027857d | 2012-07-26 17:34:25 -0400 | [diff] [blame] | 29 | #define HB_SHAPER coretext |
Behdad Esfahbod | 087733d | 2014-04-18 11:21:08 -0700 | [diff] [blame] | 30 | #define hb_coretext_shaper_face_data_t CGFont |
Behdad Esfahbod | 301168d | 2012-07-30 17:48:04 -0400 | [diff] [blame] | 31 | #include "hb-shaper-impl-private.hh" |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 32 | |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 33 | #include "hb-coretext.h" |
| 34 | |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 35 | |
| 36 | #ifndef HB_DEBUG_CORETEXT |
| 37 | #define HB_DEBUG_CORETEXT (HB_DEBUG+0) |
| 38 | #endif |
| 39 | |
| 40 | |
Behdad Esfahbod | a9e25e9 | 2014-03-14 19:55:46 -0700 | [diff] [blame] | 41 | static void |
| 42 | release_table_data (void *user_data) |
| 43 | { |
| 44 | CFDataRef cf_data = reinterpret_cast<CFDataRef> (user_data); |
| 45 | CFRelease(cf_data); |
| 46 | } |
| 47 | |
| 48 | static hb_blob_t * |
| 49 | reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data) |
| 50 | { |
| 51 | CGFontRef cg_font = reinterpret_cast<CGFontRef> (user_data); |
| 52 | CFDataRef cf_data = CGFontCopyTableForTag (cg_font, tag); |
| 53 | if (unlikely (!cf_data)) |
| 54 | return NULL; |
| 55 | |
| 56 | const char *data = reinterpret_cast<const char*> (CFDataGetBytePtr (cf_data)); |
| 57 | const size_t length = CFDataGetLength (cf_data); |
| 58 | if (!data || !length) |
| 59 | return NULL; |
| 60 | |
| 61 | return hb_blob_create (data, length, HB_MEMORY_MODE_READONLY, |
| 62 | reinterpret_cast<void *> (const_cast<__CFData *> (cf_data)), |
| 63 | release_table_data); |
| 64 | } |
| 65 | |
| 66 | hb_face_t * |
| 67 | hb_coretext_face_create (CGFontRef cg_font) |
| 68 | { |
| 69 | return hb_face_create_for_tables (reference_table, CGFontRetain (cg_font), (hb_destroy_func_t) CGFontRelease); |
| 70 | } |
| 71 | |
| 72 | |
Behdad Esfahbod | 301168d | 2012-07-30 17:48:04 -0400 | [diff] [blame] | 73 | HB_SHAPER_DATA_ENSURE_DECLARE(coretext, face) |
| 74 | HB_SHAPER_DATA_ENSURE_DECLARE(coretext, font) |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 75 | |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 76 | |
Behdad Esfahbod | 301168d | 2012-07-30 17:48:04 -0400 | [diff] [blame] | 77 | /* |
| 78 | * shaper face data |
| 79 | */ |
| 80 | |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 81 | static void |
| 82 | release_data (void *info, const void *data, size_t size) |
| 83 | { |
| 84 | assert (hb_blob_get_length ((hb_blob_t *) info) == size && |
| 85 | hb_blob_get_data ((hb_blob_t *) info, NULL) == data); |
| 86 | |
| 87 | hb_blob_destroy ((hb_blob_t *) info); |
| 88 | } |
| 89 | |
Behdad Esfahbod | 301168d | 2012-07-30 17:48:04 -0400 | [diff] [blame] | 90 | hb_coretext_shaper_face_data_t * |
| 91 | _hb_coretext_shaper_face_data_create (hb_face_t *face) |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 92 | { |
Behdad Esfahbod | 087733d | 2014-04-18 11:21:08 -0700 | [diff] [blame] | 93 | hb_coretext_shaper_face_data_t *data = NULL; |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 94 | |
Behdad Esfahbod | a9e25e9 | 2014-03-14 19:55:46 -0700 | [diff] [blame] | 95 | if (face->destroy == (hb_destroy_func_t) CGFontRelease) |
| 96 | { |
Behdad Esfahbod | 087733d | 2014-04-18 11:21:08 -0700 | [diff] [blame] | 97 | data = CGFontRetain ((CGFontRef) face->user_data); |
Behdad Esfahbod | a9e25e9 | 2014-03-14 19:55:46 -0700 | [diff] [blame] | 98 | } |
| 99 | else |
| 100 | { |
| 101 | hb_blob_t *blob = hb_face_reference_blob (face); |
| 102 | unsigned int blob_length; |
| 103 | const char *blob_data = hb_blob_get_data (blob, &blob_length); |
| 104 | if (unlikely (!blob_length)) |
| 105 | DEBUG_MSG (CORETEXT, face, "Face has empty blob"); |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 106 | |
Behdad Esfahbod | a9e25e9 | 2014-03-14 19:55:46 -0700 | [diff] [blame] | 107 | CGDataProviderRef provider = CGDataProviderCreateWithData (blob, blob_data, blob_length, &release_data); |
Behdad Esfahbod | 5ec45dd | 2014-08-11 17:46:12 -0400 | [diff] [blame] | 108 | if (likely (provider)) |
| 109 | { |
| 110 | data = CGFontCreateWithDataProvider (provider); |
| 111 | CGDataProviderRelease (provider); |
| 112 | } |
Behdad Esfahbod | a9e25e9 | 2014-03-14 19:55:46 -0700 | [diff] [blame] | 113 | } |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 114 | |
Behdad Esfahbod | 087733d | 2014-04-18 11:21:08 -0700 | [diff] [blame] | 115 | if (unlikely (!data)) { |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 116 | DEBUG_MSG (CORETEXT, face, "Face CGFontCreateWithDataProvider() failed"); |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | return data; |
| 120 | } |
| 121 | |
Behdad Esfahbod | 301168d | 2012-07-30 17:48:04 -0400 | [diff] [blame] | 122 | void |
| 123 | _hb_coretext_shaper_face_data_destroy (hb_coretext_shaper_face_data_t *data) |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 124 | { |
Behdad Esfahbod | 087733d | 2014-04-18 11:21:08 -0700 | [diff] [blame] | 125 | CFRelease (data); |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 126 | } |
| 127 | |
Behdad Esfahbod | 9a83958 | 2012-12-09 18:47:36 -0500 | [diff] [blame] | 128 | CGFontRef |
Behdad Esfahbod | e923e64 | 2012-12-09 19:39:40 -0500 | [diff] [blame] | 129 | hb_coretext_face_get_cg_font (hb_face_t *face) |
Behdad Esfahbod | 9a83958 | 2012-12-09 18:47:36 -0500 | [diff] [blame] | 130 | { |
| 131 | if (unlikely (!hb_coretext_shaper_face_data_ensure (face))) return NULL; |
| 132 | hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face); |
Behdad Esfahbod | 087733d | 2014-04-18 11:21:08 -0700 | [diff] [blame] | 133 | return face_data; |
Behdad Esfahbod | 9a83958 | 2012-12-09 18:47:36 -0500 | [diff] [blame] | 134 | } |
| 135 | |
Behdad Esfahbod | 301168d | 2012-07-30 17:48:04 -0400 | [diff] [blame] | 136 | |
| 137 | /* |
| 138 | * shaper font data |
| 139 | */ |
| 140 | |
| 141 | struct hb_coretext_shaper_font_data_t { |
| 142 | CTFontRef ct_font; |
| 143 | }; |
| 144 | |
| 145 | hb_coretext_shaper_font_data_t * |
| 146 | _hb_coretext_shaper_font_data_create (hb_font_t *font) |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 147 | { |
Behdad Esfahbod | 301168d | 2012-07-30 17:48:04 -0400 | [diff] [blame] | 148 | if (unlikely (!hb_coretext_shaper_face_data_ensure (font->face))) return NULL; |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 149 | |
Behdad Esfahbod | 301168d | 2012-07-30 17:48:04 -0400 | [diff] [blame] | 150 | hb_coretext_shaper_font_data_t *data = (hb_coretext_shaper_font_data_t *) calloc (1, sizeof (hb_coretext_shaper_font_data_t)); |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 151 | if (unlikely (!data)) |
Behdad Esfahbod | 301168d | 2012-07-30 17:48:04 -0400 | [diff] [blame] | 152 | return NULL; |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 153 | |
Behdad Esfahbod | 301168d | 2012-07-30 17:48:04 -0400 | [diff] [blame] | 154 | hb_face_t *face = font->face; |
| 155 | hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face); |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 156 | |
Behdad Esfahbod | 087733d | 2014-04-18 11:21:08 -0700 | [diff] [blame] | 157 | data->ct_font = CTFontCreateWithGraphicsFont (face_data, font->y_scale, NULL, NULL); |
Behdad Esfahbod | 301168d | 2012-07-30 17:48:04 -0400 | [diff] [blame] | 158 | if (unlikely (!data->ct_font)) { |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 159 | DEBUG_MSG (CORETEXT, font, "Font CTFontCreateWithGraphicsFont() failed"); |
Behdad Esfahbod | 301168d | 2012-07-30 17:48:04 -0400 | [diff] [blame] | 160 | free (data); |
| 161 | return NULL; |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | return data; |
| 165 | } |
| 166 | |
Behdad Esfahbod | 301168d | 2012-07-30 17:48:04 -0400 | [diff] [blame] | 167 | void |
| 168 | _hb_coretext_shaper_font_data_destroy (hb_coretext_shaper_font_data_t *data) |
| 169 | { |
| 170 | CFRelease (data->ct_font); |
| 171 | free (data); |
| 172 | } |
| 173 | |
| 174 | |
| 175 | /* |
| 176 | * shaper shape_plan data |
| 177 | */ |
| 178 | |
| 179 | struct hb_coretext_shaper_shape_plan_data_t {}; |
| 180 | |
| 181 | hb_coretext_shaper_shape_plan_data_t * |
Behdad Esfahbod | 45c1383 | 2012-08-14 09:33:18 -0400 | [diff] [blame] | 182 | _hb_coretext_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, |
| 183 | const hb_feature_t *user_features HB_UNUSED, |
| 184 | unsigned int num_user_features HB_UNUSED) |
Behdad Esfahbod | 301168d | 2012-07-30 17:48:04 -0400 | [diff] [blame] | 185 | { |
| 186 | return (hb_coretext_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; |
| 187 | } |
| 188 | |
| 189 | void |
Behdad Esfahbod | 45c1383 | 2012-08-14 09:33:18 -0400 | [diff] [blame] | 190 | _hb_coretext_shaper_shape_plan_data_destroy (hb_coretext_shaper_shape_plan_data_t *data HB_UNUSED) |
Behdad Esfahbod | 301168d | 2012-07-30 17:48:04 -0400 | [diff] [blame] | 191 | { |
| 192 | } |
| 193 | |
Behdad Esfahbod | 9a83958 | 2012-12-09 18:47:36 -0500 | [diff] [blame] | 194 | CTFontRef |
| 195 | hb_coretext_font_get_ct_font (hb_font_t *font) |
| 196 | { |
| 197 | if (unlikely (!hb_coretext_shaper_font_data_ensure (font))) return NULL; |
| 198 | hb_coretext_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font); |
| 199 | return font_data->ct_font; |
| 200 | } |
| 201 | |
Behdad Esfahbod | 301168d | 2012-07-30 17:48:04 -0400 | [diff] [blame] | 202 | |
| 203 | /* |
| 204 | * shaper |
| 205 | */ |
| 206 | |
Behdad Esfahbod | 3613696 | 2013-08-12 00:33:28 -0400 | [diff] [blame] | 207 | struct feature_record_t { |
| 208 | unsigned int feature; |
| 209 | unsigned int setting; |
| 210 | }; |
| 211 | |
| 212 | struct active_feature_t { |
| 213 | feature_record_t rec; |
| 214 | unsigned int order; |
| 215 | |
| 216 | static int cmp (const active_feature_t *a, const active_feature_t *b) { |
| 217 | return a->rec.feature < b->rec.feature ? -1 : a->rec.feature > b->rec.feature ? 1 : |
| 218 | a->order < b->order ? -1 : a->order > b->order ? 1 : |
| 219 | a->rec.setting < b->rec.setting ? -1 : a->rec.setting > b->rec.setting ? 1 : |
| 220 | 0; |
| 221 | } |
| 222 | bool operator== (const active_feature_t *f) { |
| 223 | return cmp (this, f) == 0; |
| 224 | } |
| 225 | }; |
| 226 | |
| 227 | struct feature_event_t { |
| 228 | unsigned int index; |
| 229 | bool start; |
| 230 | active_feature_t feature; |
| 231 | |
| 232 | static int cmp (const feature_event_t *a, const feature_event_t *b) { |
| 233 | return a->index < b->index ? -1 : a->index > b->index ? 1 : |
| 234 | a->start < b->start ? -1 : a->start > b->start ? 1 : |
| 235 | active_feature_t::cmp (&a->feature, &b->feature); |
| 236 | } |
| 237 | }; |
| 238 | |
| 239 | struct range_record_t { |
| 240 | CTFontRef font; |
| 241 | unsigned int index_first; /* == start */ |
| 242 | unsigned int index_last; /* == end - 1 */ |
| 243 | }; |
| 244 | |
| 245 | |
| 246 | /* The following enum members are added in OS X 10.8. */ |
| 247 | #define kAltHalfWidthTextSelector 6 |
| 248 | #define kAltProportionalTextSelector 5 |
| 249 | #define kAlternateHorizKanaOffSelector 1 |
| 250 | #define kAlternateHorizKanaOnSelector 0 |
| 251 | #define kAlternateKanaType 34 |
| 252 | #define kAlternateVertKanaOffSelector 3 |
| 253 | #define kAlternateVertKanaOnSelector 2 |
| 254 | #define kCaseSensitiveLayoutOffSelector 1 |
| 255 | #define kCaseSensitiveLayoutOnSelector 0 |
| 256 | #define kCaseSensitiveLayoutType 33 |
| 257 | #define kCaseSensitiveSpacingOffSelector 3 |
| 258 | #define kCaseSensitiveSpacingOnSelector 2 |
| 259 | #define kContextualAlternatesOffSelector 1 |
| 260 | #define kContextualAlternatesOnSelector 0 |
| 261 | #define kContextualAlternatesType 36 |
| 262 | #define kContextualLigaturesOffSelector 19 |
| 263 | #define kContextualLigaturesOnSelector 18 |
| 264 | #define kContextualSwashAlternatesOffSelector 5 |
| 265 | #define kContextualSwashAlternatesOnSelector 4 |
| 266 | #define kDefaultLowerCaseSelector 0 |
| 267 | #define kDefaultUpperCaseSelector 0 |
| 268 | #define kHistoricalLigaturesOffSelector 21 |
| 269 | #define kHistoricalLigaturesOnSelector 20 |
| 270 | #define kHojoCharactersSelector 12 |
| 271 | #define kJIS2004CharactersSelector 11 |
| 272 | #define kLowerCasePetiteCapsSelector 2 |
| 273 | #define kLowerCaseSmallCapsSelector 1 |
| 274 | #define kLowerCaseType 37 |
| 275 | #define kMathematicalGreekOffSelector 11 |
| 276 | #define kMathematicalGreekOnSelector 10 |
| 277 | #define kNLCCharactersSelector 13 |
| 278 | #define kQuarterWidthTextSelector 4 |
| 279 | #define kScientificInferiorsSelector 4 |
| 280 | #define kStylisticAltEightOffSelector 17 |
| 281 | #define kStylisticAltEightOnSelector 16 |
| 282 | #define kStylisticAltEighteenOffSelector 37 |
| 283 | #define kStylisticAltEighteenOnSelector 36 |
| 284 | #define kStylisticAltElevenOffSelector 23 |
| 285 | #define kStylisticAltElevenOnSelector 22 |
| 286 | #define kStylisticAltFifteenOffSelector 31 |
| 287 | #define kStylisticAltFifteenOnSelector 30 |
| 288 | #define kStylisticAltFiveOffSelector 11 |
| 289 | #define kStylisticAltFiveOnSelector 10 |
| 290 | #define kStylisticAltFourOffSelector 9 |
| 291 | #define kStylisticAltFourOnSelector 8 |
| 292 | #define kStylisticAltFourteenOffSelector 29 |
| 293 | #define kStylisticAltFourteenOnSelector 28 |
| 294 | #define kStylisticAltNineOffSelector 19 |
| 295 | #define kStylisticAltNineOnSelector 18 |
| 296 | #define kStylisticAltNineteenOffSelector 39 |
| 297 | #define kStylisticAltNineteenOnSelector 38 |
| 298 | #define kStylisticAltOneOffSelector 3 |
| 299 | #define kStylisticAltOneOnSelector 2 |
| 300 | #define kStylisticAltSevenOffSelector 15 |
| 301 | #define kStylisticAltSevenOnSelector 14 |
| 302 | #define kStylisticAltSeventeenOffSelector 35 |
| 303 | #define kStylisticAltSeventeenOnSelector 34 |
| 304 | #define kStylisticAltSixOffSelector 13 |
| 305 | #define kStylisticAltSixOnSelector 12 |
| 306 | #define kStylisticAltSixteenOffSelector 33 |
| 307 | #define kStylisticAltSixteenOnSelector 32 |
| 308 | #define kStylisticAltTenOffSelector 21 |
| 309 | #define kStylisticAltTenOnSelector 20 |
| 310 | #define kStylisticAltThirteenOffSelector 27 |
| 311 | #define kStylisticAltThirteenOnSelector 26 |
| 312 | #define kStylisticAltThreeOffSelector 7 |
| 313 | #define kStylisticAltThreeOnSelector 6 |
| 314 | #define kStylisticAltTwelveOffSelector 25 |
| 315 | #define kStylisticAltTwelveOnSelector 24 |
| 316 | #define kStylisticAltTwentyOffSelector 41 |
| 317 | #define kStylisticAltTwentyOnSelector 40 |
| 318 | #define kStylisticAltTwoOffSelector 5 |
| 319 | #define kStylisticAltTwoOnSelector 4 |
| 320 | #define kStylisticAlternativesType 35 |
| 321 | #define kSwashAlternatesOffSelector 3 |
| 322 | #define kSwashAlternatesOnSelector 2 |
| 323 | #define kThirdWidthTextSelector 3 |
| 324 | #define kTraditionalNamesCharactersSelector 14 |
| 325 | #define kUpperCasePetiteCapsSelector 2 |
| 326 | #define kUpperCaseSmallCapsSelector 1 |
| 327 | #define kUpperCaseType 38 |
| 328 | |
| 329 | /* Table data courtesy of Apple. */ |
| 330 | struct feature_mapping_t { |
| 331 | FourCharCode otFeatureTag; |
| 332 | uint16_t aatFeatureType; |
| 333 | uint16_t selectorToEnable; |
| 334 | uint16_t selectorToDisable; |
| 335 | } feature_mappings[] = { |
| 336 | { 'c2pc', kUpperCaseType, kUpperCasePetiteCapsSelector, kDefaultUpperCaseSelector }, |
| 337 | { 'c2sc', kUpperCaseType, kUpperCaseSmallCapsSelector, kDefaultUpperCaseSelector }, |
| 338 | { 'calt', kContextualAlternatesType, kContextualAlternatesOnSelector, kContextualAlternatesOffSelector }, |
| 339 | { 'case', kCaseSensitiveLayoutType, kCaseSensitiveLayoutOnSelector, kCaseSensitiveLayoutOffSelector }, |
| 340 | { 'clig', kLigaturesType, kContextualLigaturesOnSelector, kContextualLigaturesOffSelector }, |
| 341 | { 'cpsp', kCaseSensitiveLayoutType, kCaseSensitiveSpacingOnSelector, kCaseSensitiveSpacingOffSelector }, |
| 342 | { 'cswh', kContextualAlternatesType, kContextualSwashAlternatesOnSelector, kContextualSwashAlternatesOffSelector }, |
| 343 | { 'dlig', kLigaturesType, kRareLigaturesOnSelector, kRareLigaturesOffSelector }, |
| 344 | { 'expt', kCharacterShapeType, kExpertCharactersSelector, 16 }, |
| 345 | { 'frac', kFractionsType, kDiagonalFractionsSelector, kNoFractionsSelector }, |
| 346 | { 'fwid', kTextSpacingType, kMonospacedTextSelector, 7 }, |
| 347 | { 'halt', kTextSpacingType, kAltHalfWidthTextSelector, 7 }, |
| 348 | { 'hist', kLigaturesType, kHistoricalLigaturesOnSelector, kHistoricalLigaturesOffSelector }, |
| 349 | { 'hkna', kAlternateKanaType, kAlternateHorizKanaOnSelector, kAlternateHorizKanaOffSelector, }, |
| 350 | { 'hlig', kLigaturesType, kHistoricalLigaturesOnSelector, kHistoricalLigaturesOffSelector }, |
| 351 | { 'hngl', kTransliterationType, kHanjaToHangulSelector, kNoTransliterationSelector }, |
| 352 | { 'hojo', kCharacterShapeType, kHojoCharactersSelector, 16 }, |
| 353 | { 'hwid', kTextSpacingType, kHalfWidthTextSelector, 7 }, |
| 354 | { 'ital', kItalicCJKRomanType, kCJKItalicRomanOnSelector, kCJKItalicRomanOffSelector }, |
| 355 | { 'jp04', kCharacterShapeType, kJIS2004CharactersSelector, 16 }, |
| 356 | { 'jp78', kCharacterShapeType, kJIS1978CharactersSelector, 16 }, |
| 357 | { 'jp83', kCharacterShapeType, kJIS1983CharactersSelector, 16 }, |
| 358 | { 'jp90', kCharacterShapeType, kJIS1990CharactersSelector, 16 }, |
| 359 | { 'liga', kLigaturesType, kCommonLigaturesOnSelector, kCommonLigaturesOffSelector }, |
| 360 | { 'lnum', kNumberCaseType, kUpperCaseNumbersSelector, 2 }, |
| 361 | { 'mgrk', kMathematicalExtrasType, kMathematicalGreekOnSelector, kMathematicalGreekOffSelector }, |
| 362 | { 'nlck', kCharacterShapeType, kNLCCharactersSelector, 16 }, |
| 363 | { 'onum', kNumberCaseType, kLowerCaseNumbersSelector, 2 }, |
| 364 | { 'ordn', kVerticalPositionType, kOrdinalsSelector, kNormalPositionSelector }, |
| 365 | { 'palt', kTextSpacingType, kAltProportionalTextSelector, 7 }, |
| 366 | { 'pcap', kLowerCaseType, kLowerCasePetiteCapsSelector, kDefaultLowerCaseSelector }, |
| 367 | { 'pkna', kTextSpacingType, kProportionalTextSelector, 7 }, |
| 368 | { 'pnum', kNumberSpacingType, kProportionalNumbersSelector, 4 }, |
| 369 | { 'pwid', kTextSpacingType, kProportionalTextSelector, 7 }, |
| 370 | { 'qwid', kTextSpacingType, kQuarterWidthTextSelector, 7 }, |
| 371 | { 'ruby', kRubyKanaType, kRubyKanaOnSelector, kRubyKanaOffSelector }, |
| 372 | { 'sinf', kVerticalPositionType, kScientificInferiorsSelector, kNormalPositionSelector }, |
| 373 | { 'smcp', kLowerCaseType, kLowerCaseSmallCapsSelector, kDefaultLowerCaseSelector }, |
| 374 | { 'smpl', kCharacterShapeType, kSimplifiedCharactersSelector, 16 }, |
| 375 | { 'ss01', kStylisticAlternativesType, kStylisticAltOneOnSelector, kStylisticAltOneOffSelector }, |
| 376 | { 'ss02', kStylisticAlternativesType, kStylisticAltTwoOnSelector, kStylisticAltTwoOffSelector }, |
| 377 | { 'ss03', kStylisticAlternativesType, kStylisticAltThreeOnSelector, kStylisticAltThreeOffSelector }, |
| 378 | { 'ss04', kStylisticAlternativesType, kStylisticAltFourOnSelector, kStylisticAltFourOffSelector }, |
| 379 | { 'ss05', kStylisticAlternativesType, kStylisticAltFiveOnSelector, kStylisticAltFiveOffSelector }, |
| 380 | { 'ss06', kStylisticAlternativesType, kStylisticAltSixOnSelector, kStylisticAltSixOffSelector }, |
| 381 | { 'ss07', kStylisticAlternativesType, kStylisticAltSevenOnSelector, kStylisticAltSevenOffSelector }, |
| 382 | { 'ss08', kStylisticAlternativesType, kStylisticAltEightOnSelector, kStylisticAltEightOffSelector }, |
| 383 | { 'ss09', kStylisticAlternativesType, kStylisticAltNineOnSelector, kStylisticAltNineOffSelector }, |
| 384 | { 'ss10', kStylisticAlternativesType, kStylisticAltTenOnSelector, kStylisticAltTenOffSelector }, |
| 385 | { 'ss11', kStylisticAlternativesType, kStylisticAltElevenOnSelector, kStylisticAltElevenOffSelector }, |
| 386 | { 'ss12', kStylisticAlternativesType, kStylisticAltTwelveOnSelector, kStylisticAltTwelveOffSelector }, |
| 387 | { 'ss13', kStylisticAlternativesType, kStylisticAltThirteenOnSelector, kStylisticAltThirteenOffSelector }, |
| 388 | { 'ss14', kStylisticAlternativesType, kStylisticAltFourteenOnSelector, kStylisticAltFourteenOffSelector }, |
| 389 | { 'ss15', kStylisticAlternativesType, kStylisticAltFifteenOnSelector, kStylisticAltFifteenOffSelector }, |
| 390 | { 'ss16', kStylisticAlternativesType, kStylisticAltSixteenOnSelector, kStylisticAltSixteenOffSelector }, |
| 391 | { 'ss17', kStylisticAlternativesType, kStylisticAltSeventeenOnSelector, kStylisticAltSeventeenOffSelector }, |
| 392 | { 'ss18', kStylisticAlternativesType, kStylisticAltEighteenOnSelector, kStylisticAltEighteenOffSelector }, |
| 393 | { 'ss19', kStylisticAlternativesType, kStylisticAltNineteenOnSelector, kStylisticAltNineteenOffSelector }, |
| 394 | { 'ss20', kStylisticAlternativesType, kStylisticAltTwentyOnSelector, kStylisticAltTwentyOffSelector }, |
| 395 | { 'subs', kVerticalPositionType, kInferiorsSelector, kNormalPositionSelector }, |
| 396 | { 'sups', kVerticalPositionType, kSuperiorsSelector, kNormalPositionSelector }, |
| 397 | { 'swsh', kContextualAlternatesType, kSwashAlternatesOnSelector, kSwashAlternatesOffSelector }, |
| 398 | { 'titl', kStyleOptionsType, kTitlingCapsSelector, kNoStyleOptionsSelector }, |
| 399 | { 'tnam', kCharacterShapeType, kTraditionalNamesCharactersSelector, 16 }, |
| 400 | { 'tnum', kNumberSpacingType, kMonospacedNumbersSelector, 4 }, |
| 401 | { 'trad', kCharacterShapeType, kTraditionalCharactersSelector, 16 }, |
| 402 | { 'twid', kTextSpacingType, kThirdWidthTextSelector, 7 }, |
| 403 | { 'unic', kLetterCaseType, 14, 15 }, |
| 404 | { 'valt', kTextSpacingType, kAltProportionalTextSelector, 7 }, |
| 405 | { 'vert', kVerticalSubstitutionType, kSubstituteVerticalFormsOnSelector, kSubstituteVerticalFormsOffSelector }, |
| 406 | { 'vhal', kTextSpacingType, kAltHalfWidthTextSelector, 7 }, |
| 407 | { 'vkna', kAlternateKanaType, kAlternateVertKanaOnSelector, kAlternateVertKanaOffSelector }, |
| 408 | { 'vpal', kTextSpacingType, kAltProportionalTextSelector, 7 }, |
| 409 | { 'vrt2', kVerticalSubstitutionType, kSubstituteVerticalFormsOnSelector, kSubstituteVerticalFormsOffSelector }, |
| 410 | { 'zero', kTypographicExtrasType, kSlashedZeroOnSelector, kSlashedZeroOffSelector }, |
| 411 | }; |
| 412 | |
| 413 | static int |
| 414 | _hb_feature_mapping_cmp (const void *key_, const void *entry_) |
| 415 | { |
| 416 | unsigned int key = * (unsigned int *) key_; |
| 417 | const feature_mapping_t * entry = (const feature_mapping_t *) entry_; |
| 418 | return key < entry->otFeatureTag ? -1 : |
| 419 | key > entry->otFeatureTag ? 1 : |
| 420 | 0; |
| 421 | } |
| 422 | |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 423 | hb_bool_t |
Behdad Esfahbod | 301168d | 2012-07-30 17:48:04 -0400 | [diff] [blame] | 424 | _hb_coretext_shape (hb_shape_plan_t *shape_plan, |
| 425 | hb_font_t *font, |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 426 | hb_buffer_t *buffer, |
| 427 | const hb_feature_t *features, |
| 428 | unsigned int num_features) |
| 429 | { |
Behdad Esfahbod | 301168d | 2012-07-30 17:48:04 -0400 | [diff] [blame] | 430 | hb_face_t *face = font->face; |
Behdad Esfahbod | 58cc233 | 2013-11-29 19:17:42 -0500 | [diff] [blame] | 431 | hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face); |
Behdad Esfahbod | 301168d | 2012-07-30 17:48:04 -0400 | [diff] [blame] | 432 | hb_coretext_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font); |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 433 | |
Behdad Esfahbod | 624a299 | 2014-08-11 15:29:18 -0400 | [diff] [blame] | 434 | /* Attach marks to their bases, to match the 'ot' shaper. |
| 435 | * Adapted from hb-ot-shape:hb_form_clusters(). |
| 436 | * Note that this only makes us be closer to the 'ot' shaper, |
| 437 | * but by no means the same. For example, if there's |
| 438 | * B1 M1 B2 M2, and B1-B2 form a ligature, M2's cluster will |
| 439 | * continue pointing to B2 even though B2 was merged into B1's |
| 440 | * cluster... */ |
| 441 | { |
| 442 | hb_unicode_funcs_t *unicode = buffer->unicode; |
| 443 | unsigned int count = buffer->len; |
| 444 | hb_glyph_info_t *info = buffer->info; |
| 445 | for (unsigned int i = 1; i < count; i++) |
| 446 | if (HB_UNICODE_GENERAL_CATEGORY_IS_MARK (unicode->general_category (info[i].codepoint))) |
| 447 | buffer->merge_clusters (i - 1, i + 1); |
| 448 | } |
| 449 | |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 450 | hb_auto_array_t<feature_record_t> feature_records; |
| 451 | hb_auto_array_t<range_record_t> range_records; |
| 452 | |
Behdad Esfahbod | 3613696 | 2013-08-12 00:33:28 -0400 | [diff] [blame] | 453 | /* |
| 454 | * Set up features. |
| 455 | * (copied + modified from code from hb-uniscribe.cc) |
| 456 | */ |
Behdad Esfahbod | 3613696 | 2013-08-12 00:33:28 -0400 | [diff] [blame] | 457 | if (num_features) |
| 458 | { |
| 459 | /* Sort features by start/end events. */ |
| 460 | hb_auto_array_t<feature_event_t> feature_events; |
| 461 | for (unsigned int i = 0; i < num_features; i++) |
| 462 | { |
| 463 | const feature_mapping_t * mapping = (const feature_mapping_t *) bsearch (&features[i].tag, |
| 464 | feature_mappings, |
| 465 | ARRAY_LENGTH (feature_mappings), |
| 466 | sizeof (feature_mappings[0]), |
| 467 | _hb_feature_mapping_cmp); |
| 468 | if (!mapping) |
| 469 | continue; |
| 470 | |
| 471 | active_feature_t feature; |
| 472 | feature.rec.feature = mapping->aatFeatureType; |
| 473 | feature.rec.setting = features[i].value ? mapping->selectorToEnable : mapping->selectorToDisable; |
| 474 | feature.order = i; |
| 475 | |
| 476 | feature_event_t *event; |
| 477 | |
| 478 | event = feature_events.push (); |
| 479 | if (unlikely (!event)) |
| 480 | goto fail_features; |
| 481 | event->index = features[i].start; |
| 482 | event->start = true; |
| 483 | event->feature = feature; |
| 484 | |
| 485 | event = feature_events.push (); |
| 486 | if (unlikely (!event)) |
| 487 | goto fail_features; |
| 488 | event->index = features[i].end; |
| 489 | event->start = false; |
| 490 | event->feature = feature; |
| 491 | } |
Behdad Esfahbod | fb8cc86 | 2014-06-19 15:30:18 -0400 | [diff] [blame] | 492 | feature_events.qsort (); |
Behdad Esfahbod | 3613696 | 2013-08-12 00:33:28 -0400 | [diff] [blame] | 493 | /* Add a strategic final event. */ |
| 494 | { |
| 495 | active_feature_t feature; |
| 496 | feature.rec.feature = HB_TAG_NONE; |
| 497 | feature.rec.setting = 0; |
| 498 | feature.order = num_features + 1; |
| 499 | |
| 500 | feature_event_t *event = feature_events.push (); |
| 501 | if (unlikely (!event)) |
| 502 | goto fail_features; |
| 503 | event->index = 0; /* This value does magic. */ |
| 504 | event->start = false; |
| 505 | event->feature = feature; |
| 506 | } |
| 507 | |
| 508 | /* Scan events and save features for each range. */ |
| 509 | hb_auto_array_t<active_feature_t> active_features; |
| 510 | unsigned int last_index = 0; |
| 511 | for (unsigned int i = 0; i < feature_events.len; i++) |
| 512 | { |
| 513 | feature_event_t *event = &feature_events[i]; |
| 514 | |
| 515 | if (event->index != last_index) |
| 516 | { |
| 517 | /* Save a snapshot of active features and the range. */ |
| 518 | range_record_t *range = range_records.push (); |
| 519 | if (unlikely (!range)) |
| 520 | goto fail_features; |
| 521 | |
Behdad Esfahbod | 3613696 | 2013-08-12 00:33:28 -0400 | [diff] [blame] | 522 | if (active_features.len) |
| 523 | { |
| 524 | CFMutableArrayRef features_array = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); |
| 525 | |
| 526 | /* TODO sort and resolve conflicting features? */ |
Behdad Esfahbod | fb8cc86 | 2014-06-19 15:30:18 -0400 | [diff] [blame] | 527 | /* active_features.qsort (); */ |
Behdad Esfahbod | 3613696 | 2013-08-12 00:33:28 -0400 | [diff] [blame] | 528 | for (unsigned int j = 0; j < active_features.len; j++) |
| 529 | { |
| 530 | CFStringRef keys[2] = { |
| 531 | kCTFontFeatureTypeIdentifierKey, |
| 532 | kCTFontFeatureSelectorIdentifierKey |
| 533 | }; |
| 534 | CFNumberRef values[2] = { |
| 535 | CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &active_features[j].rec.feature), |
| 536 | CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &active_features[j].rec.setting) |
| 537 | }; |
| 538 | CFDictionaryRef dict = CFDictionaryCreate (kCFAllocatorDefault, |
| 539 | (const void **) keys, |
| 540 | (const void **) values, |
| 541 | 2, |
| 542 | &kCFTypeDictionaryKeyCallBacks, |
| 543 | &kCFTypeDictionaryValueCallBacks); |
| 544 | CFRelease (values[0]); |
| 545 | CFRelease (values[1]); |
| 546 | |
| 547 | CFArrayAppendValue (features_array, dict); |
| 548 | CFRelease (dict); |
| 549 | |
| 550 | } |
| 551 | |
| 552 | CFDictionaryRef attributes = CFDictionaryCreate (kCFAllocatorDefault, |
| 553 | (const void **) &kCTFontFeatureSettingsAttribute, |
| 554 | (const void **) &features_array, |
| 555 | 1, |
| 556 | &kCFTypeDictionaryKeyCallBacks, |
| 557 | &kCFTypeDictionaryValueCallBacks); |
| 558 | CFRelease (features_array); |
| 559 | |
| 560 | CTFontDescriptorRef font_desc = CTFontDescriptorCreateWithAttributes (attributes); |
| 561 | CFRelease (attributes); |
| 562 | |
| 563 | range->font = CTFontCreateCopyWithAttributes (font_data->ct_font, 0.0, NULL, font_desc); |
Behdad Esfahbod | 3613696 | 2013-08-12 00:33:28 -0400 | [diff] [blame] | 564 | CFRelease (font_desc); |
| 565 | } |
| 566 | else |
| 567 | { |
| 568 | range->font = NULL; |
| 569 | } |
| 570 | |
| 571 | range->index_first = last_index; |
| 572 | range->index_last = event->index - 1; |
| 573 | |
| 574 | last_index = event->index; |
| 575 | } |
| 576 | |
| 577 | if (event->start) { |
| 578 | active_feature_t *feature = active_features.push (); |
| 579 | if (unlikely (!feature)) |
| 580 | goto fail_features; |
| 581 | *feature = event->feature; |
| 582 | } else { |
| 583 | active_feature_t *feature = active_features.find (&event->feature); |
| 584 | if (feature) |
| 585 | active_features.remove (feature - active_features.array); |
| 586 | } |
| 587 | } |
| 588 | |
| 589 | if (!range_records.len) /* No active feature found. */ |
| 590 | goto fail_features; |
| 591 | } |
| 592 | else |
| 593 | { |
| 594 | fail_features: |
| 595 | num_features = 0; |
| 596 | } |
| 597 | |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 598 | unsigned int scratch_size; |
Behdad Esfahbod | 68c372e | 2013-11-13 14:44:01 -0500 | [diff] [blame] | 599 | hb_buffer_t::scratch_buffer_t *scratch = buffer->get_scratch_buffer (&scratch_size); |
Behdad Esfahbod | 8fcadb9 | 2013-11-13 14:33:57 -0500 | [diff] [blame] | 600 | |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 601 | #define ALLOCATE_ARRAY(Type, name, len, on_no_room) \ |
Behdad Esfahbod | 8fcadb9 | 2013-11-13 14:33:57 -0500 | [diff] [blame] | 602 | Type *name = (Type *) scratch; \ |
| 603 | { \ |
| 604 | unsigned int _consumed = DIV_CEIL ((len) * sizeof (Type), sizeof (*scratch)); \ |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 605 | if (unlikely (_consumed > scratch_size)) \ |
| 606 | { \ |
| 607 | on_no_room; \ |
| 608 | assert (0); \ |
| 609 | } \ |
Behdad Esfahbod | 8fcadb9 | 2013-11-13 14:33:57 -0500 | [diff] [blame] | 610 | scratch += _consumed; \ |
| 611 | scratch_size -= _consumed; \ |
| 612 | } |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 613 | |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 614 | ALLOCATE_ARRAY (UniChar, pchars, buffer->len * 2, /*nothing*/); |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 615 | unsigned int chars_len = 0; |
| 616 | for (unsigned int i = 0; i < buffer->len; i++) { |
| 617 | hb_codepoint_t c = buffer->info[i].codepoint; |
Behdad Esfahbod | 7627100 | 2014-07-11 14:54:42 -0400 | [diff] [blame] | 618 | if (likely (c <= 0xFFFFu)) |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 619 | pchars[chars_len++] = c; |
Behdad Esfahbod | 7627100 | 2014-07-11 14:54:42 -0400 | [diff] [blame] | 620 | else if (unlikely (c > 0x10FFFFu)) |
| 621 | pchars[chars_len++] = 0xFFFDu; |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 622 | else { |
Behdad Esfahbod | 7627100 | 2014-07-11 14:54:42 -0400 | [diff] [blame] | 623 | pchars[chars_len++] = 0xD800u + ((c - 0x10000u) >> 10); |
| 624 | pchars[chars_len++] = 0xDC00u + ((c - 0x10000u) & ((1 << 10) - 1)); |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 625 | } |
| 626 | } |
| 627 | |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 628 | ALLOCATE_ARRAY (unsigned int, log_clusters, chars_len, /*nothing*/); |
Behdad Esfahbod | 9b3c60c | 2014-08-11 13:25:43 -0400 | [diff] [blame] | 629 | chars_len = 0; |
| 630 | for (unsigned int i = 0; i < buffer->len; i++) |
| 631 | { |
| 632 | hb_codepoint_t c = buffer->info[i].codepoint; |
| 633 | unsigned int cluster = buffer->info[i].cluster; |
| 634 | log_clusters[chars_len++] = cluster; |
| 635 | if (hb_in_range (c, 0x10000u, 0x10FFFFu)) |
| 636 | log_clusters[chars_len++] = cluster; /* Surrogates. */ |
| 637 | } |
| 638 | |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 639 | #define FAIL(...) \ |
| 640 | HB_STMT_START { \ |
| 641 | DEBUG_MSG (CORETEXT, NULL, __VA_ARGS__); \ |
| 642 | ret = false; \ |
| 643 | goto fail; \ |
| 644 | } HB_STMT_END; |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 645 | |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 646 | bool ret = true; |
| 647 | CFStringRef string_ref = NULL; |
| 648 | CTLineRef line = NULL; |
Behdad Esfahbod | a782a5e | 2013-08-07 21:08:54 -0400 | [diff] [blame] | 649 | |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 650 | if (0) |
Behdad Esfahbod | a782a5e | 2013-08-07 21:08:54 -0400 | [diff] [blame] | 651 | { |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 652 | resize_and_retry: |
Behdad Esfahbod | 1b55077 | 2014-08-11 20:45:12 -0400 | [diff] [blame] | 653 | DEBUG_MSG (CORETEXT, buffer, "Buffer resize"); |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 654 | /* string_ref uses the scratch-buffer for backing store, and line references |
| 655 | * string_ref (via attr_string). We must release those before resizing buffer. */ |
| 656 | assert (string_ref); |
| 657 | assert (line); |
| 658 | CFRelease (string_ref); |
| 659 | CFRelease (line); |
| 660 | string_ref = NULL; |
| 661 | line = NULL; |
| 662 | if (unlikely (!buffer->ensure (buffer->allocated * 2))) |
Behdad Esfahbod | b9993d8 | 2014-08-10 17:40:24 -0400 | [diff] [blame] | 663 | FAIL ("Buffer resize failed"); |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 664 | |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 665 | /* Adjust scratch, pchars, and log_cluster arrays. This is ugly, but really the cleanest way to do without |
| 666 | * completely restructuring the rest of this shaper. */ |
| 667 | hb_buffer_t::scratch_buffer_t *old_scratch = scratch; |
Behdad Esfahbod | 68c372e | 2013-11-13 14:44:01 -0500 | [diff] [blame] | 668 | scratch = buffer->get_scratch_buffer (&scratch_size); |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 669 | pchars = reinterpret_cast<UniChar *> (((char *) scratch + ((char *) pchars - (char *) old_scratch))); |
| 670 | log_clusters = reinterpret_cast<unsigned int *> (((char *) scratch + ((char *) log_clusters - (char *) old_scratch))); |
| 671 | } |
| 672 | retry: |
| 673 | { |
| 674 | string_ref = CFStringCreateWithCharactersNoCopy (NULL, |
| 675 | pchars, chars_len, |
| 676 | kCFAllocatorNull); |
| 677 | if (unlikely (!string_ref)) |
| 678 | FAIL ("CFStringCreateWithCharactersNoCopy failed"); |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 679 | |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 680 | /* Create an attributed string, populate it, and create a line from it, then release attributed string. */ |
| 681 | { |
Behdad Esfahbod | fd1a6aa | 2014-08-11 20:01:37 -0400 | [diff] [blame] | 682 | CFMutableAttributedStringRef attr_string = CFAttributedStringCreateMutable (kCFAllocatorDefault, |
| 683 | chars_len); |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 684 | if (unlikely (!attr_string)) |
| 685 | FAIL ("CFAttributedStringCreateMutable failed"); |
| 686 | CFAttributedStringReplaceString (attr_string, CFRangeMake (0, 0), string_ref); |
| 687 | CFAttributedStringSetAttribute (attr_string, CFRangeMake (0, chars_len), |
Behdad Esfahbod | 5a0eed3 | 2014-08-11 23:47:16 -0400 | [diff] [blame^] | 688 | kCTVerticalFormsAttributeName, |
| 689 | HB_DIRECTION_IS_VERTICAL (buffer->props.direction) ? |
| 690 | kCFBooleanTrue : kCFBooleanFalse); |
| 691 | CFAttributedStringSetAttribute (attr_string, CFRangeMake (0, chars_len), |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 692 | kCTFontAttributeName, font_data->ct_font); |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 693 | |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 694 | if (num_features) |
| 695 | { |
| 696 | unsigned int start = 0; |
| 697 | range_record_t *last_range = &range_records[0]; |
| 698 | for (unsigned int k = 0; k < chars_len; k++) |
| 699 | { |
| 700 | range_record_t *range = last_range; |
| 701 | while (log_clusters[k] < range->index_first) |
| 702 | range--; |
| 703 | while (log_clusters[k] > range->index_last) |
| 704 | range++; |
| 705 | if (range != last_range) |
| 706 | { |
| 707 | if (last_range->font) |
| 708 | CFAttributedStringSetAttribute (attr_string, CFRangeMake (start, k - start), |
| 709 | kCTFontAttributeName, last_range->font); |
| 710 | |
| 711 | start = k; |
| 712 | } |
| 713 | |
| 714 | last_range = range; |
| 715 | } |
| 716 | if (start != chars_len && last_range->font) |
| 717 | CFAttributedStringSetAttribute (attr_string, CFRangeMake (start, chars_len - start), |
| 718 | kCTFontAttributeName, last_range->font); |
| 719 | } |
| 720 | |
Behdad Esfahbod | 4acce77 | 2014-08-11 17:46:50 -0400 | [diff] [blame] | 721 | int level = HB_DIRECTION_IS_FORWARD (buffer->props.direction) ? 0 : 1; |
| 722 | CFNumberRef level_number = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &level); |
| 723 | CFDictionaryRef options = CFDictionaryCreate (kCFAllocatorDefault, |
| 724 | (const void **) &kCTTypesetterOptionForcedEmbeddingLevel, |
| 725 | (const void **) &level_number, |
| 726 | 1, |
| 727 | &kCFTypeDictionaryKeyCallBacks, |
| 728 | &kCFTypeDictionaryValueCallBacks); |
| 729 | if (unlikely (!options)) |
| 730 | FAIL ("CFDictionaryCreate failed"); |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 731 | |
Behdad Esfahbod | 4acce77 | 2014-08-11 17:46:50 -0400 | [diff] [blame] | 732 | CTTypesetterRef typesetter = CTTypesetterCreateWithAttributedStringAndOptions (attr_string, options); |
| 733 | CFRelease (options); |
| 734 | CFRelease (attr_string); |
| 735 | if (unlikely (!typesetter)) |
| 736 | FAIL ("CTTypesetterCreateWithAttributedStringAndOptions failed"); |
| 737 | |
| 738 | line = CTTypesetterCreateLine (typesetter, CFRangeMake(0, 0)); |
| 739 | CFRelease (typesetter); |
| 740 | if (unlikely (!line)) |
| 741 | FAIL ("CTTypesetterCreateLine failed"); |
| 742 | } |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 743 | |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 744 | CFArrayRef glyph_runs = CTLineGetGlyphRuns (line); |
| 745 | unsigned int num_runs = CFArrayGetCount (glyph_runs); |
Behdad Esfahbod | 5a0eed3 | 2014-08-11 23:47:16 -0400 | [diff] [blame^] | 746 | DEBUG_MSG (CORETEXT, NULL, "Num runs: %d", num_runs); |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 747 | |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 748 | buffer->len = 0; |
Behdad Esfahbod | 10b1104 | 2014-08-11 20:02:45 -0400 | [diff] [blame] | 749 | uint32_t status_and = ~0, status_or = 0; |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 750 | |
| 751 | const CFRange range_all = CFRangeMake (0, 0); |
| 752 | |
| 753 | for (unsigned int i = 0; i < num_runs; i++) |
| 754 | { |
| 755 | CTRunRef run = static_cast<CTRunRef>(CFArrayGetValueAtIndex (glyph_runs, i)); |
Behdad Esfahbod | 10b1104 | 2014-08-11 20:02:45 -0400 | [diff] [blame] | 756 | CTRunStatus run_status = CTRunGetStatus (run); |
| 757 | status_or |= run_status; |
| 758 | status_and &= run_status; |
| 759 | DEBUG_MSG (CORETEXT, run, "CTRunStatus: %x", run_status); |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 760 | |
| 761 | /* CoreText does automatic font fallback (AKA "cascading") for characters |
| 762 | * not supported by the requested font, and provides no way to turn it off, |
| 763 | * so we detect if the returned run uses a font other than the requested |
| 764 | * one and fill in the buffer with .notdef glyphs instead of random glyph |
| 765 | * indices from a different font. |
| 766 | */ |
| 767 | CFDictionaryRef attributes = CTRunGetAttributes (run); |
| 768 | CTFontRef run_ct_font = static_cast<CTFontRef>(CFDictionaryGetValue (attributes, kCTFontAttributeName)); |
| 769 | if (!CFEqual (run_ct_font, font_data->ct_font)) |
| 770 | { |
| 771 | /* The run doesn't use our main font. See if it uses any of our subfonts |
| 772 | * created to set font features... Only if the font didn't match any of |
| 773 | * those, consider reject the font. What we really want is to check the |
| 774 | * underlying CGFont, but apparently there's no safe way to do that. |
| 775 | * See: http://github.com/behdad/harfbuzz/pull/36 */ |
| 776 | bool matched = false; |
| 777 | for (unsigned int i = 0; i < range_records.len; i++) |
| 778 | if (range_records[i].font && CFEqual (run_ct_font, range_records[i].font)) |
| 779 | { |
| 780 | matched = true; |
| 781 | break; |
| 782 | } |
| 783 | if (!matched) |
| 784 | { |
| 785 | CFRange range = CTRunGetStringRange (run); |
Behdad Esfahbod | 5a0eed3 | 2014-08-11 23:47:16 -0400 | [diff] [blame^] | 786 | DEBUG_MSG (CORETEXT, run, "Run used fallback font: %ld..%ld", |
| 787 | range.location, range.location + range.length); |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 788 | if (!buffer->ensure_inplace (buffer->len + range.length)) |
| 789 | goto resize_and_retry; |
| 790 | hb_glyph_info_t *info = buffer->info + buffer->len; |
| 791 | |
| 792 | CGGlyph notdef = 0; |
| 793 | double advance = CTFontGetAdvancesForGlyphs (font_data->ct_font, kCTFontHorizontalOrientation, ¬def, NULL, 1); |
| 794 | |
| 795 | for (CFIndex j = range.location; j < range.location + range.length; j++) |
| 796 | { |
| 797 | UniChar ch = CFStringGetCharacterAtIndex (string_ref, j); |
| 798 | if (hb_in_range<UniChar> (ch, 0xDC00u, 0xDFFFu) && range.location < j) |
| 799 | { |
| 800 | ch = CFStringGetCharacterAtIndex (string_ref, j - 1); |
| 801 | if (hb_in_range<UniChar> (ch, 0xD800u, 0xDBFFu)) |
| 802 | /* This is the second of a surrogate pair. Don't need .notdef |
| 803 | * for this one. */ |
| 804 | continue; |
| 805 | } |
| 806 | |
| 807 | info->codepoint = notdef; |
Behdad Esfahbod | 3c41ccb | 2014-08-11 15:11:59 -0400 | [diff] [blame] | 808 | info->cluster = log_clusters[j]; |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 809 | |
| 810 | info->mask = advance; |
| 811 | info->var1.u32 = 0; |
| 812 | info->var2.u32 = 0; |
| 813 | |
| 814 | info++; |
| 815 | buffer->len++; |
| 816 | } |
| 817 | continue; |
| 818 | } |
| 819 | } |
| 820 | |
| 821 | unsigned int num_glyphs = CTRunGetGlyphCount (run); |
| 822 | if (num_glyphs == 0) |
| 823 | continue; |
| 824 | |
Behdad Esfahbod | 1b55077 | 2014-08-11 20:45:12 -0400 | [diff] [blame] | 825 | if (!buffer->ensure (buffer->len + num_glyphs)) |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 826 | goto resize_and_retry; |
| 827 | |
Behdad Esfahbod | 5a0eed3 | 2014-08-11 23:47:16 -0400 | [diff] [blame^] | 828 | hb_glyph_info_t *run_info = buffer->info + buffer->len; |
| 829 | |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 830 | /* Testing used to indicate that CTRunGetGlyphsPtr, etc (almost?) always |
| 831 | * succeed, and so copying data to our own buffer will be rare. Reports |
| 832 | * have it that this changed in OS X 10.10 Yosemite, and NULL is returned |
| 833 | * frequently. At any rate, we can test that codepath by setting USE_PTR |
| 834 | * to false. */ |
| 835 | #define USE_PTR true |
Behdad Esfahbod | 5a0eed3 | 2014-08-11 23:47:16 -0400 | [diff] [blame^] | 836 | { |
| 837 | const CGGlyph* glyphs = USE_PTR ? CTRunGetGlyphsPtr (run) : NULL; |
| 838 | if (!glyphs) { |
| 839 | ALLOCATE_ARRAY (CGGlyph, glyph_buf, num_glyphs, goto resize_and_retry); |
| 840 | CTRunGetGlyphs (run, range_all, glyph_buf); |
| 841 | glyphs = glyph_buf; |
| 842 | } |
| 843 | const CFIndex* string_indices = USE_PTR ? CTRunGetStringIndicesPtr (run) : NULL; |
| 844 | if (!string_indices) { |
| 845 | ALLOCATE_ARRAY (CFIndex, index_buf, num_glyphs, goto resize_and_retry); |
| 846 | CTRunGetStringIndices (run, range_all, index_buf); |
| 847 | string_indices = index_buf; |
| 848 | } |
| 849 | hb_glyph_info_t *info = run_info; |
| 850 | for (unsigned int j = 0; j < num_glyphs; j++) |
| 851 | { |
| 852 | info->codepoint = glyphs[j]; |
| 853 | info->cluster = log_clusters[string_indices[j]]; |
| 854 | info++; |
| 855 | } |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 856 | } |
Behdad Esfahbod | 5a0eed3 | 2014-08-11 23:47:16 -0400 | [diff] [blame^] | 857 | { |
| 858 | const CGPoint* positions = USE_PTR ? CTRunGetPositionsPtr (run) : NULL; |
| 859 | if (!positions) { |
| 860 | ALLOCATE_ARRAY (CGPoint, position_buf, num_glyphs, goto resize_and_retry); |
| 861 | CTRunGetPositions (run, range_all, position_buf); |
| 862 | positions = position_buf; |
| 863 | } |
| 864 | double run_advance = CTRunGetTypographicBounds (run, range_all, NULL, NULL, NULL); |
| 865 | DEBUG_MSG (CORETEXT, run, "Run advance: %g", run_advance); |
| 866 | hb_glyph_info_t *info = run_info; |
| 867 | if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction)) |
| 868 | { |
| 869 | for (unsigned int j = 0; j < num_glyphs; j++) |
| 870 | { |
| 871 | double advance = (j + 1 < num_glyphs ? positions[j + 1].x : positions[0].x + run_advance) - positions[j].x; |
| 872 | info->mask = advance; |
| 873 | info->var1.u32 = positions[0].x; /* Yes, zero. */ |
| 874 | info->var2.u32 = positions[j].y; |
| 875 | info++; |
| 876 | } |
| 877 | } |
| 878 | else |
| 879 | { |
| 880 | run_advance = -run_advance; |
| 881 | for (unsigned int j = 0; j < num_glyphs; j++) |
| 882 | { |
| 883 | double advance = (j + 1 < num_glyphs ? positions[j + 1].y : positions[0].y + run_advance) - positions[j].y; |
| 884 | info->mask = advance; |
| 885 | info->var1.u32 = positions[j].x; |
| 886 | info->var2.u32 = positions[0].y; /* Yes, zero. */ |
| 887 | info++; |
| 888 | } |
| 889 | } |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 890 | } |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 891 | #undef USE_PTR |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 892 | #undef ALLOCATE_ARRAY |
| 893 | |
Behdad Esfahbod | 5a0eed3 | 2014-08-11 23:47:16 -0400 | [diff] [blame^] | 894 | buffer->len += num_glyphs; |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 895 | } |
| 896 | |
Behdad Esfahbod | 10b1104 | 2014-08-11 20:02:45 -0400 | [diff] [blame] | 897 | /* Make sure all runs had the expected direction. */ |
| 898 | bool backward = HB_DIRECTION_IS_BACKWARD (buffer->props.direction); |
| 899 | assert (bool (status_and & kCTRunStatusRightToLeft) == backward); |
| 900 | assert (bool (status_or & kCTRunStatusRightToLeft) == backward); |
| 901 | |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 902 | buffer->clear_positions (); |
| 903 | |
| 904 | unsigned int count = buffer->len; |
Behdad Esfahbod | 5a0eed3 | 2014-08-11 23:47:16 -0400 | [diff] [blame^] | 905 | hb_glyph_info_t *info = buffer->info; |
| 906 | hb_glyph_position_t *pos = buffer->pos; |
| 907 | if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction)) |
| 908 | for (unsigned int i = 0; i < count; i++) |
| 909 | { |
| 910 | pos->x_advance = info->mask; |
| 911 | pos->x_offset = info->var1.u32; |
| 912 | pos->y_offset = info->var2.u32; |
| 913 | info++, pos++; |
| 914 | } |
| 915 | else |
| 916 | for (unsigned int i = 0; i < count; i++) |
| 917 | { |
| 918 | pos->y_advance = info->mask; |
| 919 | pos->x_offset = info->var1.u32; |
| 920 | pos->y_offset = info->var2.u32; |
| 921 | info++, pos++; |
| 922 | } |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 923 | |
| 924 | /* Fix up clusters so that we never return out-of-order indices; |
| 925 | * if core text has reordered glyphs, we'll merge them to the |
Behdad Esfahbod | 10b1104 | 2014-08-11 20:02:45 -0400 | [diff] [blame] | 926 | * beginning of the reordered cluster. CoreText is nice enough |
| 927 | * to tell us whenever it has produced nonmonotonic results... |
| 928 | * Note that we assume the input clusters were nonmonotonic to |
| 929 | * begin with. |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 930 | * |
| 931 | * This does *not* mean we'll form the same clusters as Uniscribe |
| 932 | * or the native OT backend, only that the cluster indices will be |
| 933 | * monotonic in the output buffer. */ |
Behdad Esfahbod | 10b1104 | 2014-08-11 20:02:45 -0400 | [diff] [blame] | 934 | if (count > 1 && (status_or & kCTRunStatusNonMonotonic)) |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 935 | { |
| 936 | hb_glyph_info_t *info = buffer->info; |
| 937 | if (HB_DIRECTION_IS_FORWARD (buffer->props.direction)) |
| 938 | { |
| 939 | unsigned int cluster = info[count - 1].cluster; |
| 940 | for (unsigned int i = count - 1; i > 0; i--) |
| 941 | { |
| 942 | cluster = MIN (cluster, info[i - 1].cluster); |
| 943 | info[i - 1].cluster = cluster; |
| 944 | } |
| 945 | } |
| 946 | else |
| 947 | { |
| 948 | unsigned int cluster = info[0].cluster; |
| 949 | for (unsigned int i = 1; i < count; i++) |
| 950 | { |
| 951 | cluster = MIN (cluster, info[i].cluster); |
| 952 | info[i].cluster = cluster; |
| 953 | } |
| 954 | } |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 955 | } |
| 956 | } |
| 957 | |
Behdad Esfahbod | 4acce77 | 2014-08-11 17:46:50 -0400 | [diff] [blame] | 958 | #undef FAIL |
| 959 | |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 960 | fail: |
| 961 | if (string_ref) |
| 962 | CFRelease (string_ref); |
| 963 | if (line) |
| 964 | CFRelease (line); |
| 965 | |
Behdad Esfahbod | 25f4fb9 | 2014-08-10 19:05:25 -0400 | [diff] [blame] | 966 | for (unsigned int i = 0; i < range_records.len; i++) |
| 967 | if (range_records[i].font) |
| 968 | CFRelease (range_records[i].font); |
| 969 | |
Behdad Esfahbod | a6b8dc8 | 2014-08-11 15:08:19 -0400 | [diff] [blame] | 970 | return ret; |
Jonathan Kew | aa6d849 | 2012-07-24 15:52:32 -0400 | [diff] [blame] | 971 | } |
Behdad Esfahbod | c79865f | 2014-03-14 19:37:55 -0400 | [diff] [blame] | 972 | |
| 973 | |
| 974 | /* |
| 975 | * AAT shaper |
| 976 | */ |
| 977 | |
| 978 | HB_SHAPER_DATA_ENSURE_DECLARE(coretext_aat, face) |
| 979 | HB_SHAPER_DATA_ENSURE_DECLARE(coretext_aat, font) |
| 980 | |
| 981 | |
| 982 | /* |
| 983 | * shaper face data |
| 984 | */ |
| 985 | |
| 986 | struct hb_coretext_aat_shaper_face_data_t {}; |
| 987 | |
| 988 | hb_coretext_aat_shaper_face_data_t * |
| 989 | _hb_coretext_aat_shaper_face_data_create (hb_face_t *face) |
| 990 | { |
| 991 | hb_blob_t *mort_blob = face->reference_table (HB_CORETEXT_TAG_MORT); |
| 992 | /* Umm, we just reference the table to check whether it exists. |
| 993 | * Maybe add better API for this? */ |
| 994 | if (!hb_blob_get_length (mort_blob)) |
| 995 | { |
| 996 | hb_blob_destroy (mort_blob); |
| 997 | mort_blob = face->reference_table (HB_CORETEXT_TAG_MORX); |
| 998 | if (!hb_blob_get_length (mort_blob)) |
| 999 | { |
| 1000 | hb_blob_destroy (mort_blob); |
| 1001 | return NULL; |
| 1002 | } |
| 1003 | } |
| 1004 | hb_blob_destroy (mort_blob); |
| 1005 | |
| 1006 | return hb_coretext_shaper_face_data_ensure (face) ? (hb_coretext_aat_shaper_face_data_t *) HB_SHAPER_DATA_SUCCEEDED : NULL; |
| 1007 | } |
| 1008 | |
| 1009 | void |
| 1010 | _hb_coretext_aat_shaper_face_data_destroy (hb_coretext_aat_shaper_face_data_t *data HB_UNUSED) |
| 1011 | { |
| 1012 | } |
| 1013 | |
| 1014 | |
| 1015 | /* |
| 1016 | * shaper font data |
| 1017 | */ |
| 1018 | |
| 1019 | struct hb_coretext_aat_shaper_font_data_t {}; |
| 1020 | |
| 1021 | hb_coretext_aat_shaper_font_data_t * |
| 1022 | _hb_coretext_aat_shaper_font_data_create (hb_font_t *font) |
| 1023 | { |
| 1024 | return hb_coretext_shaper_font_data_ensure (font) ? (hb_coretext_aat_shaper_font_data_t *) HB_SHAPER_DATA_SUCCEEDED : NULL; |
| 1025 | } |
| 1026 | |
| 1027 | void |
| 1028 | _hb_coretext_aat_shaper_font_data_destroy (hb_coretext_aat_shaper_font_data_t *data HB_UNUSED) |
| 1029 | { |
| 1030 | } |
| 1031 | |
| 1032 | |
| 1033 | /* |
| 1034 | * shaper shape_plan data |
| 1035 | */ |
| 1036 | |
| 1037 | struct hb_coretext_aat_shaper_shape_plan_data_t {}; |
| 1038 | |
| 1039 | hb_coretext_aat_shaper_shape_plan_data_t * |
| 1040 | _hb_coretext_aat_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, |
| 1041 | const hb_feature_t *user_features HB_UNUSED, |
| 1042 | unsigned int num_user_features HB_UNUSED) |
| 1043 | { |
| 1044 | return (hb_coretext_aat_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; |
| 1045 | } |
| 1046 | |
| 1047 | void |
| 1048 | _hb_coretext_aat_shaper_shape_plan_data_destroy (hb_coretext_aat_shaper_shape_plan_data_t *data HB_UNUSED) |
| 1049 | { |
| 1050 | } |
| 1051 | |
| 1052 | |
| 1053 | /* |
| 1054 | * shaper |
| 1055 | */ |
| 1056 | |
| 1057 | hb_bool_t |
| 1058 | _hb_coretext_aat_shape (hb_shape_plan_t *shape_plan, |
| 1059 | hb_font_t *font, |
| 1060 | hb_buffer_t *buffer, |
| 1061 | const hb_feature_t *features, |
| 1062 | unsigned int num_features) |
| 1063 | { |
| 1064 | return _hb_coretext_shape (shape_plan, font, buffer, features, num_features); |
| 1065 | } |