diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc index 1e1c7b4f4..ec053938f 100644 --- a/src/hb-aat-layout.cc +++ b/src/hb-aat-layout.cc @@ -34,7 +34,7 @@ #include "hb-aat-layout-kerx-table.hh" #include "hb-aat-layout-morx-table.hh" #include "hb-aat-layout-trak-table.hh" -#include "hb-aat-ltag-table.hh" // Just so we compile it; unused otherwise. +#include "hb-aat-ltag-table.hh" /* Table data courtesy of Apple. Converted from mnemonics to integers @@ -181,6 +181,12 @@ _get_trak (hb_face_t *face) if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(AAT::trak); return *(hb_ot_face_data (face)->trak.get ()); } +static inline const AAT::ltag& +_get_ltag (hb_face_t *face) +{ + if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(AAT::ltag); + return *(hb_ot_face_data (face)->ltag.get ()); +} void @@ -248,3 +254,10 @@ hb_aat_layout_track (hb_ot_shape_plan_t *plan, AAT::hb_aat_apply_context_t c (plan, font, buffer); trak.apply (&c); } + +hb_language_t +_hb_aat_language_get (hb_face_t *face, + unsigned int i) +{ + return _get_ltag (face).get_language (i); +} diff --git a/src/hb-aat-layout.hh b/src/hb-aat-layout.hh index aea545689..8a558e6aa 100644 --- a/src/hb-aat-layout.hh +++ b/src/hb-aat-layout.hh @@ -80,4 +80,9 @@ hb_aat_layout_track (hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer); +HB_INTERNAL hb_language_t +_hb_aat_language_get (hb_face_t *face, + unsigned int i); + + #endif /* HB_AAT_LAYOUT_HH */ diff --git a/src/hb-aat-ltag-table.hh b/src/hb-aat-ltag-table.hh index 08a1b51a9..8a42b3510 100644 --- a/src/hb-aat-ltag-table.hh +++ b/src/hb-aat-ltag-table.hh @@ -25,7 +25,7 @@ #ifndef HB_AAT_LTAG_TABLE_HH #define HB_AAT_LTAG_TABLE_HH -#include "hb-aat-layout-common.hh" +#include "hb-open-type.hh" /* * ltag -- Language Tag @@ -36,9 +36,13 @@ namespace AAT { +using namespace OT; + struct FTStringRange { + friend struct ltag; + inline bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); @@ -58,10 +62,19 @@ struct ltag { static const hb_tag_t tableTag = HB_AAT_TAG_ltag; + inline hb_language_t get_language (unsigned int i) const + { + const FTStringRange &range = tagRanges[i]; + return hb_language_from_string ((const char *) (this+range.tag).arrayZ, + range.length); + } + inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); - return_trace (likely (c->check_struct (this) && tagRanges.sanitize (c, this))); + return_trace (likely (c->check_struct (this) && + version >= 1 && + tagRanges.sanitize (c, this))); } protected: diff --git a/src/hb-ot-face.hh b/src/hb-ot-face.hh index c810e9fb4..4c84f0a5f 100644 --- a/src/hb-ot-face.hh +++ b/src/hb-ot-face.hh @@ -66,10 +66,11 @@ HB_OT_ACCELERATOR(OT, hmtx) \ HB_OT_ACCELERATOR(OT, vmtx) \ HB_OT_ACCELERATOR(OT, post) \ - HB_OT_ACCELERATOR(OT, name) \ HB_OT_ACCELERATOR(OT, kern) \ HB_OT_ACCELERATOR(OT, glyf) \ HB_OT_TABLE(OT, VORG) \ + HB_OT_ACCELERATOR(OT, name) \ + HB_OT_TABLE(AAT, ltag) \ /* OpenType color fonts. */ \ HB_OT_TABLE(OT, COLR) \ HB_OT_TABLE(OT, CPAL) \ diff --git a/src/hb-ot-name-table.hh b/src/hb-ot-name-table.hh index f42c0db83..e58090848 100644 --- a/src/hb-ot-name-table.hh +++ b/src/hb-ot-name-table.hh @@ -29,6 +29,7 @@ #include "hb-open-type.hh" #include "hb-ot-name-language.hh" +#include "hb-aat-layout.hh" namespace OT { @@ -48,7 +49,7 @@ namespace OT { struct NameRecord { - inline hb_language_t language (void) const + inline hb_language_t language (hb_face_t *face) const { unsigned int p = platformID; unsigned int l = languageID; @@ -59,8 +60,8 @@ struct NameRecord if (p == 1) return _hb_ot_name_language_for_mac_code (l); - //if (p == 0) - /* TODO use 'ltag' table? */ + if (p == 0) + return _hb_aat_language_get (face, l); return HB_LANGUAGE_INVALID; } @@ -194,7 +195,7 @@ struct name hb_ot_name_entry_t *entry = this->names.push (); entry->name_id = all_names[i].nameID; - entry->language = all_names[i].language (); + entry->language = all_names[i].language (face); entry->entry_score = all_names[i].score (); entry->entry_index = i; }