diff -ru modules/basic/basic-atsui.c modules/basic/basic-atsui.c
|
|
|
86 | 86 | const char *p; |
87 | 87 | PangoATSUIFont *afont = PANGO_ATSUI_FONT (font); |
88 | 88 | ATSUStyle style; |
89 | | ATSUFontID fontID; |
| 89 | CGFontRef fontID; |
90 | 90 | ATSUAttributeTag styleTags[] = { kATSUFontTag }; |
91 | 91 | ATSUAttributeValuePtr styleValues[] = { &fontID }; |
92 | | ByteCount styleSizes[] = { sizeof (ATSUFontID) }; |
| 92 | ByteCount styleSizes[] = { sizeof (CGFontRef) }; |
93 | 93 | |
94 | 94 | utf16 = g_utf8_to_utf16 (text, length, NULL, &n16, NULL); |
95 | 95 | |
… |
… |
|
97 | 97 | err = ATSUSetTextPointerLocation (text_layout, utf16, 0, n16, n16); |
98 | 98 | |
99 | 99 | err = ATSUCreateStyle(&style); |
100 | | fontID = pango_atsui_font_get_atsu_font_id (afont); |
| 100 | fontID = pango_atsui_font_get_cgfont (afont); |
101 | 101 | |
102 | 102 | err = ATSUSetAttributes(style, |
103 | 103 | sizeof(styleTags) / sizeof(styleTags[0]), |
diff -ru pango/pangoatsui-private.h pango/pangoatsui-private.h
|
|
|
93 | 93 | gpointer _pango_atsui_font_get_context_key (PangoATSUIFont *afont); |
94 | 94 | void _pango_atsui_font_set_context_key (PangoATSUIFont *afont, |
95 | 95 | gpointer context_key); |
96 | | void _pango_atsui_font_set_atsu_font_id (PangoATSUIFont *font, |
97 | | ATSUFontID font_id); |
| 96 | void _pango_atsui_font_set_cgfont (PangoATSUIFont *font, |
| 97 | CGFontRef font_id); |
98 | 98 | |
99 | 99 | G_END_DECLS |
100 | 100 | |
diff -ru pango/pangoatsui.c pango/pangoatsui.c
|
|
|
32 | 32 | PangoFontDescription *desc; |
33 | 33 | gpointer context_key; |
34 | 34 | |
35 | | ATSUFontID font_id; |
| 35 | CGFontRef font_id; |
36 | 36 | |
37 | 37 | PangoFontMap *fontmap; |
38 | 38 | }; |
… |
… |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | void |
179 | | _pango_atsui_font_set_atsu_font_id (PangoATSUIFont *font, |
180 | | ATSUFontID font_id) |
| 179 | _pango_atsui_font_set_cgfont (PangoATSUIFont *font, |
| 180 | CGFontRef font_id) |
181 | 181 | { |
182 | 182 | PangoATSUIFontPrivate *priv = font->priv; |
183 | 183 | |
… |
… |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
188 | | * pango_atsui_font_get_atsu_font_id: |
| 188 | * pango_atsui_font_get_cgfont: |
189 | 189 | * @font: A #PangoATSUIFont |
190 | 190 | * |
191 | | * Returns the ATSUFontID of a font. |
| 191 | * Returns the CGFontRef of a font. |
192 | 192 | * |
193 | | * Return value: the ATSUFontID associated to @font. |
| 193 | * Return value: the CGFontRef associated to @font. |
194 | 194 | * |
195 | 195 | * Since: 1.18 |
196 | 196 | */ |
197 | | ATSUFontID |
198 | | pango_atsui_font_get_atsu_font_id (PangoATSUIFont *font) |
| 197 | CGFontRef |
| 198 | pango_atsui_font_get_cgfont (PangoATSUIFont *font) |
199 | 199 | { |
200 | 200 | PangoATSUIFontPrivate *priv = font->priv; |
201 | 201 | |
diff -ru pango/pangoatsui.h pango/pangoatsui.h
|
|
|
68 | 68 | |
69 | 69 | #endif /* PANGO_ENABLE_BACKEND */ |
70 | 70 | |
71 | | ATSUFontID pango_atsui_font_get_atsu_font_id (PangoATSUIFont *font); |
| 71 | CGFontRef pango_atsui_font_get_cgfont (PangoATSUIFont *font); |
72 | 72 | |
73 | 73 | #endif /* PANGO_ENABLE_ENGINE || PANGO_ENABLE_BACKEND */ |
74 | 74 | |
diff -ru pango/pangocairo-atsuifont.c pango/pangocairo-atsuifont.c
|
|
|
82 | 82 | pango_cairo_atsui_font_create_font_face (PangoCairoFont *font) |
83 | 83 | { |
84 | 84 | PangoATSUIFont *afont = (PangoATSUIFont *) (font); |
85 | | ATSUFontID font_id; |
| 85 | CGFontRef font_id; |
86 | 86 | |
87 | | font_id = pango_atsui_font_get_atsu_font_id (afont); |
88 | | return cairo_quartz_font_face_create_for_atsu_font_id (font_id); |
| 87 | font_id = pango_atsui_font_get_cgfont (afont); |
| 88 | return cairo_quartz_font_face_create_for_cgfont (font_id); |
89 | 89 | } |
90 | 90 | |
91 | 91 | static int |
… |
… |
|
118 | 118 | { |
119 | 119 | PangoCairoATSUIFont *cafont = (PangoCairoATSUIFont *) font; |
120 | 120 | PangoATSUIFont *afont = (PangoATSUIFont *) font; |
121 | | ATSFontRef ats_font; |
122 | | ATSFontMetrics ats_metrics; |
| 121 | CGFontRef cg_font; |
| 122 | CTFontRef ct_font; |
123 | 123 | PangoFontMetrics *metrics; |
124 | 124 | PangoFontDescription *font_desc; |
125 | 125 | PangoLayout *layout; |
… |
… |
|
127 | 127 | PangoLanguage *language = pango_context_get_language (context); |
128 | 128 | const char *sample_str = pango_language_get_sample_string (language); |
129 | 129 | |
130 | | ats_font = FMGetATSFontRefFromFont (pango_atsui_font_get_atsu_font_id (afont)); |
131 | | |
132 | | ATSFontGetHorizontalMetrics (ats_font, kATSOptionFlagsDefault, &ats_metrics); |
| 130 | cg_font = pango_atsui_font_get_cgfont (afont); |
| 131 | ct_font = CTFontCreateWithGraphicsFont(cg_font, cafont->size, NULL, NULL); |
133 | 132 | |
134 | 133 | metrics = pango_font_metrics_new (); |
135 | 134 | |
136 | | metrics->ascent = ats_metrics.ascent * cafont->size * PANGO_SCALE; |
137 | | metrics->descent = -ats_metrics.descent * cafont->size * PANGO_SCALE; |
| 135 | metrics->ascent = CTFontGetAscent(ct_font) * PANGO_SCALE; |
| 136 | metrics->descent = -CTFontGetDescent(ct_font) * PANGO_SCALE; |
138 | 137 | |
139 | | metrics->underline_position = ats_metrics.underlinePosition * cafont->size * PANGO_SCALE; |
140 | | metrics->underline_thickness = ats_metrics.underlineThickness * cafont->size * PANGO_SCALE; |
| 138 | metrics->underline_position = CTFontGetUnderlinePosition(ct_font) * PANGO_SCALE; |
| 139 | metrics->underline_thickness = CTFontGetUnderlineThickness(ct_font) * PANGO_SCALE; |
141 | 140 | |
142 | 141 | metrics->strikethrough_position = metrics->ascent / 3; |
143 | | metrics->strikethrough_thickness = ats_metrics.underlineThickness * cafont->size * PANGO_SCALE; |
| 142 | metrics->strikethrough_thickness = metrics->underline_thickness * PANGO_SCALE; |
144 | 143 | |
145 | 144 | layout = pango_layout_new (context); |
146 | 145 | font_desc = pango_font_describe_with_absolute_size ((PangoFont *) font); |
… |
… |
|
155 | 154 | |
156 | 155 | pango_font_description_free (font_desc); |
157 | 156 | g_object_unref (layout); |
| 157 | |
| 158 | |
158 | 159 | |
159 | 160 | return metrics; |
160 | 161 | } |
… |
… |
|
207 | 208 | PangoATSUIFont *afont; |
208 | 209 | CFStringRef cfstr; |
209 | 210 | ATSFontRef font_ref; |
210 | | ATSUFontID font_id; |
| 211 | CGFontRef font_id; |
211 | 212 | double size; |
212 | 213 | double dpi; |
213 | 214 | double m; |
… |
… |
|
252 | 253 | if (font_ref == kATSFontRefUnspecified) |
253 | 254 | return NULL; |
254 | 255 | |
255 | | font_id = FMGetFontFromATSFontRef (font_ref); |
| 256 | font_id = CGFontCreateWithPlatformFont (&font_ref); |
256 | 257 | if (!font_id) |
257 | 258 | return NULL; |
258 | 259 | |
… |
… |
|
263 | 264 | _pango_atsui_font_set_face (afont, face); |
264 | 265 | |
265 | 266 | size = (double) pango_font_description_get_size (desc) / PANGO_SCALE; |
266 | | _pango_atsui_font_set_atsu_font_id (afont, font_id); |
| 267 | _pango_atsui_font_set_cgfont (afont, font_id); |
267 | 268 | |
268 | 269 | if (context) |
269 | 270 | { |