X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fhb-face.cc;h=d8af8c1f37e8dc67bee8b57e5bb6b0e96db593f8;hb=1c272a48507bb3c7905aa30d8bf0d092b474f781;hp=1800c995a46797b13cae00e4590f335ec24a7800;hpb=e3a9d0d2fe726180a0456893d22d4aaa3ddb8931;p=platform%2Fupstream%2Fharfbuzz.git diff --git a/src/hb-face.cc b/src/hb-face.cc index 1800c99..d8af8c1 100644 --- a/src/hb-face.cc +++ b/src/hb-face.cc @@ -43,23 +43,21 @@ const hb_face_t _hb_face_nil = { true, /* immutable */ - NULL, /* reference_table_func */ - NULL, /* user_data */ - NULL, /* destroy */ + nullptr, /* reference_table_func */ + nullptr, /* user_data */ + nullptr, /* destroy */ 0, /* index */ 1000, /* upem */ 0, /* num_glyphs */ - hb_face_t::NOTHING, /* dirty */ - { #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, #include "hb-shaper-list.hh" #undef HB_SHAPER_IMPLEMENT }, - NULL, /* shape_plans */ + nullptr, /* shape_plans */ }; @@ -111,7 +109,7 @@ _hb_face_for_data_closure_create (hb_blob_t *blob, unsigned int index) closure = (hb_face_for_data_closure_t *) calloc (1, sizeof (hb_face_for_data_closure_t)); if (unlikely (!closure)) - return NULL; + return nullptr; closure->blob = blob; closure->index = index; @@ -120,8 +118,10 @@ _hb_face_for_data_closure_create (hb_blob_t *blob, unsigned int index) } static void -_hb_face_for_data_closure_destroy (hb_face_for_data_closure_t *closure) +_hb_face_for_data_closure_destroy (void *data) { + hb_face_for_data_closure_t *closure = (hb_face_for_data_closure_t *) data; + hb_blob_destroy (closure->blob); free (closure); } @@ -164,14 +164,14 @@ hb_face_create (hb_blob_t *blob, if (unlikely (!blob)) blob = hb_blob_get_empty (); - hb_face_for_data_closure_t *closure = _hb_face_for_data_closure_create (OT::Sanitizer::sanitize (hb_blob_reference (blob)), index); + hb_face_for_data_closure_t *closure = _hb_face_for_data_closure_create (OT::Sanitizer().sanitize (hb_blob_reference (blob)), index); if (unlikely (!closure)) return hb_face_get_empty (); face = hb_face_create_for_tables (_hb_face_for_data_reference_table, closure, - (hb_destroy_func_t) _hb_face_for_data_closure_destroy); + _hb_face_for_data_closure_destroy); face->index = index; @@ -367,11 +367,6 @@ hb_face_set_index (hb_face_t *face, if (face->immutable) return; - if (face->index == index) - return; - - face->dirty |= face->INDEX; - face->index = index; } @@ -407,11 +402,6 @@ hb_face_set_upem (hb_face_t *face, if (face->immutable) return; - if (face->upem == upem) - return; - - face->dirty |= face->UPEM; - face->upem = upem; } @@ -434,7 +424,7 @@ hb_face_get_upem (hb_face_t *face) void hb_face_t::load_upem (void) const { - hb_blob_t *head_blob = OT::Sanitizer::sanitize (reference_table (HB_OT_TAG_head)); + hb_blob_t *head_blob = OT::Sanitizer().sanitize (reference_table (HB_OT_TAG_head)); const OT::head *head_table = OT::Sanitizer::lock_instance (head_blob); upem = head_table->get_upem (); hb_blob_destroy (head_blob); @@ -456,11 +446,6 @@ hb_face_set_glyph_count (hb_face_t *face, if (face->immutable) return; - if (face->num_glyphs == glyph_count) - return; - - face->dirty |= face->NUM_GLYPHS; - face->num_glyphs = glyph_count; } @@ -483,10 +468,39 @@ hb_face_get_glyph_count (hb_face_t *face) void hb_face_t::load_num_glyphs (void) const { - hb_blob_t *maxp_blob = OT::Sanitizer::sanitize (reference_table (HB_OT_TAG_maxp)); + hb_blob_t *maxp_blob = OT::Sanitizer().sanitize (reference_table (HB_OT_TAG_maxp)); const OT::maxp *maxp_table = OT::Sanitizer::lock_instance (maxp_blob); num_glyphs = maxp_table->get_num_glyphs (); hb_blob_destroy (maxp_blob); } +/** + * hb_face_get_table_tags: + * @face: a face. + * + * Retrieves table tags for a face, if possible. + * + * Return value: total number of tables, or 0 if not possible to list. + * + * Since: 1.6.0 + **/ +unsigned int +hb_face_get_table_tags (hb_face_t *face, + unsigned int start_offset, + unsigned int *table_count, /* IN/OUT */ + hb_tag_t *table_tags /* OUT */) +{ + if (face->destroy != _hb_face_for_data_closure_destroy) + { + if (table_count) + *table_count = 0; + return 0; + } + + hb_face_for_data_closure_t *data = (hb_face_for_data_closure_t *) face->user_data; + + const OT::OpenTypeFontFile &ot_file = *OT::Sanitizer::lock_instance (data->blob); + const OT::OpenTypeFontFace &ot_face = ot_file.get_face (data->index); + return ot_face.get_table_tags (start_offset, table_count, table_tags); +}