Example #1
0
static unsigned int
getLargerScriptListTable(XeTeXFont font, hb_tag_t** scriptList)
{
    unsigned int rval = 0;

    hb_face_t* face = hb_font_get_face(((XeTeXFontInst*)font)->getHbFont());

    hb_tag_t* scriptListSub = NULL;
    hb_tag_t* scriptListPos = NULL;

    unsigned int scriptCountSub = hb_ot_layout_table_get_script_tags(face, HB_OT_TAG_GSUB, 0, NULL, NULL);
    scriptListSub = (hb_tag_t*) xcalloc(scriptCountSub, sizeof(hb_tag_t*));
    hb_ot_layout_table_get_script_tags(face, HB_OT_TAG_GSUB, 0, &scriptCountSub, scriptListSub);

    unsigned int scriptCountPos = hb_ot_layout_table_get_script_tags(face, HB_OT_TAG_GPOS, 0, NULL, NULL);
    scriptListPos = (hb_tag_t*) xcalloc(scriptCountPos, sizeof(hb_tag_t*));
    hb_ot_layout_table_get_script_tags(face, HB_OT_TAG_GSUB, 0, &scriptCountPos, scriptListPos);

    if (scriptCountSub > scriptCountPos) {
        if (scriptList != NULL)
            *scriptList = scriptListSub;
        rval = scriptCountSub;
    } else {
        if (scriptList != NULL)
            *scriptList = scriptListPos;
        rval = scriptCountPos;
    }

    return rval;
}
Example #2
0
static hb_script_t findScriptForVerticalGlyphSubstitution(hb_face_t* face) {
  static const unsigned maxCount = 32;

  unsigned scriptCount = maxCount;
  hb_tag_t scriptTags[maxCount];
  hb_ot_layout_table_get_script_tags(face, HB_OT_TAG_GSUB, 0, &scriptCount,
                                     scriptTags);
  for (unsigned scriptIndex = 0; scriptIndex < scriptCount; ++scriptIndex) {
    unsigned languageCount = maxCount;
    hb_tag_t languageTags[maxCount];
    hb_ot_layout_script_get_language_tags(face, HB_OT_TAG_GSUB, scriptIndex, 0,
                                          &languageCount, languageTags);
    for (unsigned languageIndex = 0; languageIndex < languageCount;
         ++languageIndex) {
      unsigned featureIndex;
      if (hb_ot_layout_language_find_feature(
              face, HB_OT_TAG_GSUB, scriptIndex, languageIndex,
              HarfBuzzFace::vertTag, &featureIndex) ||
          hb_ot_layout_language_find_feature(
              face, HB_OT_TAG_GSUB, scriptIndex, languageIndex,
              HarfBuzzFace::vrt2Tag, &featureIndex))
        return hb_ot_tag_to_script(scriptTags[scriptIndex]);
    }
  }
  return HB_SCRIPT_INVALID;
}
Example #3
0
/**
 * hb_ot_layout_collect_lookups:
 *
 * Since: 0.9.8
 **/
void
hb_ot_layout_collect_lookups (hb_face_t      *face,
                              hb_tag_t        table_tag,
                              const hb_tag_t *scripts,
                              const hb_tag_t *languages,
                              const hb_tag_t *features,
                              hb_set_t       *lookup_indexes /* OUT */)
{
  if (!scripts)
  {
    /* All scripts */
    unsigned int count = hb_ot_layout_table_get_script_tags (face,
                                                             table_tag,
                                                             0, NULL, NULL);
    for (unsigned int script_index = 0; script_index < count; script_index++)
      _hb_ot_layout_collect_lookups_languages (face,
                                               table_tag,
                                               script_index,
                                               languages,
                                               features,
                                               lookup_indexes);
  }
  else
  {
    for (; *scripts; scripts++)
    {
      unsigned int script_index;
      if (hb_ot_layout_table_find_script (face,
                                          table_tag,
                                          *scripts,
                                          &script_index))
        _hb_ot_layout_collect_lookups_languages (face,
                                                 table_tag,
                                                 script_index,
                                                 languages,
                                                 features,
                                                 lookup_indexes);
    }
  }
}
Example #4
0
static hb_script_t findScriptForVerticalGlyphSubstitution(hb_face_t* face)
{
    static const unsigned maxCount = 32;

    unsigned scriptCount = maxCount;
    hb_tag_t scriptTags[maxCount];
    hb_ot_layout_table_get_script_tags(face, HB_OT_TAG_GSUB, 0, &scriptCount, scriptTags);
    for (unsigned scriptIndex = 0; scriptIndex < scriptCount; ++scriptIndex) {
        unsigned languageCount = maxCount;
        hb_tag_t languageTags[maxCount];
        hb_ot_layout_script_get_language_tags(face, HB_OT_TAG_GSUB, scriptIndex, 0, &languageCount, languageTags);
        unsigned featureIndex;
        for (unsigned languageIndex = 0; languageIndex < languageCount; ++languageIndex) {
            if (hb_ot_layout_language_find_feature(face, HB_OT_TAG_GSUB, scriptIndex, languageIndex, HarfBuzzFace::vertTag, &featureIndex))
                return hb_ot_tag_to_script(scriptTags[scriptIndex]);
        }
        // Try DefaultLangSys if all LangSys failed.
        if (hb_ot_layout_language_find_feature(face, HB_OT_TAG_GSUB, scriptIndex, HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX, HarfBuzzFace::vertTag, &featureIndex))
            return hb_ot_tag_to_script(scriptTags[scriptIndex]);
    }
    return HB_SCRIPT_INVALID;
}