Beispiel #1
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;
}
Beispiel #2
0
hb_tag_t
getIndLanguage(XeTeXFont font, hb_tag_t script, unsigned int index)
{
    hb_tag_t rval = 0;

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

    unsigned int scriptCount = getLargerScriptListTable(font, &scriptList);
    if (scriptList != NULL) {
        for (int i = 0; i < scriptCount; i++) {
            if (scriptList[i] == script) {
                unsigned int langCount;
                hb_tag_t* langList;

                langCount = hb_ot_layout_script_get_language_tags(face, HB_OT_TAG_GSUB, i, 0, NULL, NULL);
                langList = (hb_tag_t*) xcalloc(langCount, sizeof(hb_tag_t*));
                hb_ot_layout_script_get_language_tags(face, HB_OT_TAG_GSUB, i, 0, &langCount, langList);

                if (index < langCount) {
                    rval = langList[index];
                    break;
                }

                free(langList);

                langCount = hb_ot_layout_script_get_language_tags(face, HB_OT_TAG_GPOS, i, 0, NULL, NULL);
                langList = (hb_tag_t*) xcalloc(langCount, sizeof(hb_tag_t*));
                hb_ot_layout_script_get_language_tags(face, HB_OT_TAG_GPOS, i, 0, &langCount, langList);

                if (index < langCount) {
                    rval = langList[index];
                    break;
                }

                free(langList);
            }
        }
    }

    return rval;
}
Beispiel #3
0
unsigned int
countLanguages(XeTeXFont font, hb_tag_t script)
{
    unsigned int rval = 0;

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

    unsigned int scriptCount = getLargerScriptListTable(font, &scriptList);
    if (scriptList != NULL) {
        for (int i = 0; i < scriptCount; i++) {
            if (scriptList[i] == script) {
                rval += hb_ot_layout_script_get_language_tags (face, HB_OT_TAG_GSUB, i, 0, NULL, NULL);
                rval += hb_ot_layout_script_get_language_tags (face, HB_OT_TAG_GPOS, i, 0, NULL, NULL);
                break;
            }
        }
    }

    return rval;
}
Beispiel #4
0
static void
_hb_ot_layout_collect_lookups_languages (hb_face_t      *face,
                                         hb_tag_t        table_tag,
                                         unsigned int    script_index,
                                         const hb_tag_t *languages,
                                         const hb_tag_t *features,
                                         hb_set_t       *lookup_indexes /* OUT */)
{
  _hb_ot_layout_collect_lookups_features (face,
                                          table_tag,
                                          script_index,
                                          HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX,
                                          features,
                                          lookup_indexes);

  if (!languages)
  {
    /* All languages */
    unsigned int count = hb_ot_layout_script_get_language_tags (face,
                                                                table_tag,
                                                                script_index,
                                                                0, NULL, NULL);
    for (unsigned int language_index = 0; language_index < count; language_index++)
      _hb_ot_layout_collect_lookups_features (face,
                                              table_tag,
                                              script_index,
                                              language_index,
                                              features,
                                              lookup_indexes);
  }
  else
  {
    for (; *languages; languages++)
    {
      unsigned int language_index;
      if (hb_ot_layout_script_find_language (face,
                                             table_tag,
                                             script_index,
                                             *languages,
                                             &language_index))
        _hb_ot_layout_collect_lookups_features (face,
                                                table_tag,
                                                script_index,
                                                language_index,
                                                features,
                                                lookup_indexes);
    }
  }
}
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;
}