diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc index 1e1c7b4f455bc9f6d67b99717e231aa495650a14..ec053938fdcc23fd8eae588a0cb6d1d33f4d007a 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 aea545689af5adf722cc8781a1cf70bcfc1fda2c..8a558e6aa73a3e0bc87fcd0bc946e9ee3be385db 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 08a1b51a9e838b57e923d4c9fff48199c5b924ef..8a42b3510bf84f78d432002895121695e3514d73 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 c810e9fb45e3a900f9d6023c089b8ee0dd3ab72b..4c84f0a5f0c3b4c0f4b15234f4bc0114b851e468 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 f42c0db83665f14c47df9d6109b41cde4e2bb09c..e58090848788e07cb120eabad1a87a09ec250ded 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; }