[coretext] Use CGFont as face_data
This commit is contained in:
parent
d277c3d7ee
commit
087733dd66
|
@ -27,6 +27,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define HB_SHAPER coretext
|
#define HB_SHAPER coretext
|
||||||
|
#define hb_coretext_shaper_face_data_t CGFont
|
||||||
#include "hb-shaper-impl-private.hh"
|
#include "hb-shaper-impl-private.hh"
|
||||||
|
|
||||||
#include "hb-coretext.h"
|
#include "hb-coretext.h"
|
||||||
|
@ -77,10 +78,6 @@ HB_SHAPER_DATA_ENSURE_DECLARE(coretext, font)
|
||||||
* shaper face data
|
* shaper face data
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct hb_coretext_shaper_face_data_t {
|
|
||||||
CGFontRef cg_font;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
release_data (void *info, const void *data, size_t size)
|
release_data (void *info, const void *data, size_t size)
|
||||||
{
|
{
|
||||||
|
@ -93,13 +90,11 @@ release_data (void *info, const void *data, size_t size)
|
||||||
hb_coretext_shaper_face_data_t *
|
hb_coretext_shaper_face_data_t *
|
||||||
_hb_coretext_shaper_face_data_create (hb_face_t *face)
|
_hb_coretext_shaper_face_data_create (hb_face_t *face)
|
||||||
{
|
{
|
||||||
hb_coretext_shaper_face_data_t *data = (hb_coretext_shaper_face_data_t *) calloc (1, sizeof (hb_coretext_shaper_face_data_t));
|
hb_coretext_shaper_face_data_t *data = NULL;
|
||||||
if (unlikely (!data))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (face->destroy == (hb_destroy_func_t) CGFontRelease)
|
if (face->destroy == (hb_destroy_func_t) CGFontRelease)
|
||||||
{
|
{
|
||||||
data->cg_font = CGFontRetain ((CGFontRef) face->user_data);
|
data = CGFontRetain ((CGFontRef) face->user_data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -110,14 +105,12 @@ _hb_coretext_shaper_face_data_create (hb_face_t *face)
|
||||||
DEBUG_MSG (CORETEXT, face, "Face has empty blob");
|
DEBUG_MSG (CORETEXT, face, "Face has empty blob");
|
||||||
|
|
||||||
CGDataProviderRef provider = CGDataProviderCreateWithData (blob, blob_data, blob_length, &release_data);
|
CGDataProviderRef provider = CGDataProviderCreateWithData (blob, blob_data, blob_length, &release_data);
|
||||||
data->cg_font = CGFontCreateWithDataProvider (provider);
|
data = CGFontCreateWithDataProvider (provider);
|
||||||
CGDataProviderRelease (provider);
|
CGDataProviderRelease (provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlikely (!data->cg_font)) {
|
if (unlikely (!data)) {
|
||||||
DEBUG_MSG (CORETEXT, face, "Face CGFontCreateWithDataProvider() failed");
|
DEBUG_MSG (CORETEXT, face, "Face CGFontCreateWithDataProvider() failed");
|
||||||
free (data);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
@ -126,8 +119,7 @@ _hb_coretext_shaper_face_data_create (hb_face_t *face)
|
||||||
void
|
void
|
||||||
_hb_coretext_shaper_face_data_destroy (hb_coretext_shaper_face_data_t *data)
|
_hb_coretext_shaper_face_data_destroy (hb_coretext_shaper_face_data_t *data)
|
||||||
{
|
{
|
||||||
CFRelease (data->cg_font);
|
CFRelease (data);
|
||||||
free (data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CGFontRef
|
CGFontRef
|
||||||
|
@ -135,7 +127,7 @@ hb_coretext_face_get_cg_font (hb_face_t *face)
|
||||||
{
|
{
|
||||||
if (unlikely (!hb_coretext_shaper_face_data_ensure (face))) return NULL;
|
if (unlikely (!hb_coretext_shaper_face_data_ensure (face))) return NULL;
|
||||||
hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face);
|
hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face);
|
||||||
return face_data->cg_font;
|
return face_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -159,7 +151,7 @@ _hb_coretext_shaper_font_data_create (hb_font_t *font)
|
||||||
hb_face_t *face = font->face;
|
hb_face_t *face = font->face;
|
||||||
hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face);
|
hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face);
|
||||||
|
|
||||||
data->ct_font = CTFontCreateWithGraphicsFont (face_data->cg_font, font->y_scale, NULL, NULL);
|
data->ct_font = CTFontCreateWithGraphicsFont (face_data, font->y_scale, NULL, NULL);
|
||||||
if (unlikely (!data->ct_font)) {
|
if (unlikely (!data->ct_font)) {
|
||||||
DEBUG_MSG (CORETEXT, font, "Font CTFontCreateWithGraphicsFont() failed");
|
DEBUG_MSG (CORETEXT, font, "Font CTFontCreateWithGraphicsFont() failed");
|
||||||
free (data);
|
free (data);
|
||||||
|
@ -698,7 +690,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
|
||||||
CFDictionaryRef attributes = CTRunGetAttributes (run);
|
CFDictionaryRef attributes = CTRunGetAttributes (run);
|
||||||
CTFontRef run_ct_font = static_cast<CTFontRef>(CFDictionaryGetValue (attributes, kCTFontAttributeName));
|
CTFontRef run_ct_font = static_cast<CTFontRef>(CFDictionaryGetValue (attributes, kCTFontAttributeName));
|
||||||
CGFontRef run_cg_font = CTFontCopyGraphicsFont (run_ct_font, 0);
|
CGFontRef run_cg_font = CTFontCopyGraphicsFont (run_ct_font, 0);
|
||||||
if (!CFEqual (run_cg_font, face_data->cg_font))
|
if (!CFEqual (run_cg_font, face_data))
|
||||||
{
|
{
|
||||||
CFRelease (run_cg_font);
|
CFRelease (run_cg_font);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue