#define HB_SHAPER coretext
#include "hb-shaper-impl-private.hh"
-#define GlyphID GlyphID_mac
-#include <ApplicationServices/ApplicationServices.h>
-#undef GlyphID
-
#include "hb-coretext.h"
free (data);
}
+CGFontRef
+hb_coretext_face_get_cg_font (hb_face_t *face)
+{
+ if (unlikely (!hb_coretext_shaper_face_data_ensure (face))) return NULL;
+ hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face);
+ return face_data->cg_font;
+}
+
/*
* shaper font data
{
}
-
-/*
- * shaper
- */
-
CTFontRef
hb_coretext_font_get_ct_font (hb_font_t *font)
{
- if (unlikely (!hb_coretext_shaper_font_data_ensure (font))) return 0;
+ if (unlikely (!hb_coretext_shaper_font_data_ensure (font))) return NULL;
hb_coretext_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font);
return font_data->ct_font;
}
+
+/*
+ * shaper
+ */
+
hb_bool_t
_hb_coretext_shape (hb_shape_plan_t *shape_plan,
hb_font_t *font,
CFDictionaryRef attrs = CFDictionaryCreate (kCFAllocatorDefault,
(const void**) &kCTFontAttributeName,
(const void**) &font_data->ct_font,
- 1, // count of attributes
+ 1, /* count of attributes */
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
- // TODO: support features
+ /* TODO: support features */
- // Now we can create an attributed string
CFAttributedStringRef attr_string = CFAttributedStringCreate (kCFAllocatorDefault, string_ref, attrs);
CFRelease (string_ref);
CFRelease (attrs);
- // Create the CoreText line from our string, then we're done with it
CTLineRef line = CTLineCreateWithAttributedString (attr_string);
CFRelease (attr_string);
- // and finally retrieve the glyph data and store into the gfxTextRun
CFArrayRef glyph_runs = CTLineGetGlyphRuns (line);
unsigned int num_runs = CFArrayGetCount (glyph_runs);
- // Iterate through the glyph runs.
bool success = true;
buffer->len = 0;
buffer->ensure (buffer->len + num_glyphs);
- // retrieve the laid-out glyph data from the CTRun
-
- // Testing indicates that CTRunGetGlyphsPtr (almost?) always succeeds,
- // and so copying data to our own buffer with CTRunGetGlyphs will be
- // extremely rare.
+ /* Testing indicates that CTRunGetGlyphsPtr (almost?) always succeeds,
+ * and so copying data to our own buffer with CTRunGetGlyphs will be
+ * extremely rare. */
unsigned int scratch_size;
char *scratch = (char *) buffer->get_scratch_buffer (&scratch_size);
info->codepoint = glyphs[j];
info->cluster = string_indices[j];
- // currently, we do all x-positioning by setting the advance, we never use x-offset
+ /* Currently, we do all x-positioning by setting the advance, we never use x-offset. */
info->mask = advance;
info->var1.u32 = 0;
info->var2.u32 = positions[j].y;
pos->y_offset = info->var2.u32;
}
- // Fix up clusters so that we never return out-of-order indices;
- // if core text has reordered glyphs, we'll merge them to the
- // beginning of the reordered cluster.
- // This does *not* mean we'll form the same clusters as Uniscribe
- // or the native OT backend, only that the cluster indices will be
- // non-decreasing in the output buffer.
+ /* Fix up clusters so that we never return out-of-order indices;
+ * if core text has reordered glyphs, we'll merge them to the
+ * beginning of the reordered cluster.
+ *
+ * This does *not* mean we'll form the same clusters as Uniscribe
+ * or the native OT backend, only that the cluster indices will be
+ * monotonic in the output buffer. */
if (HB_DIRECTION_IS_FORWARD (buffer->props.direction)) {
unsigned int prev_cluster = 0;
for (unsigned int i = 0; i < count; i++) {
prev_cluster = curr_cluster;
}
} else {
- // For RTL runs, we make them non-increasing instead.
unsigned int prev_cluster = (unsigned int)-1;
for (unsigned int i = 0; i < count; i++) {
unsigned int curr_cluster = buffer->info[i].cluster;