/* * Copyright © 2009 Red Hat, Inc. * Copyright © 2011 Google, Inc. * * This is part of HarfBuzz, a text shaping library. * * Permission is hereby granted, without written agreement and without * license or royalty fees, to use, copy, modify, and distribute this * software and its documentation for any purpose, provided that the * above copyright notice and the following two paragraphs appear in * all copies of this software. * * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * * Red Hat Author(s): Behdad Esfahbod * Google Author(s): Behdad Esfahbod, Roozbeh Pournader */ #include "hb.hh" #ifndef HB_NO_OT_TAG /* hb_script_t */ static hb_tag_t hb_ot_old_tag_from_script (hb_script_t script) { … } static hb_script_t hb_ot_old_tag_to_script (hb_tag_t tag) { … } static hb_tag_t hb_ot_new_tag_from_script (hb_script_t script) { … } static hb_script_t hb_ot_new_tag_to_script (hb_tag_t tag) { … } #ifndef HB_DISABLE_DEPRECATED /** * hb_ot_tags_from_script: * @script: an #hb_script_t to convert. * @script_tag_1: (out): output #hb_tag_t. * @script_tag_2: (out): output #hb_tag_t. * * Converts an #hb_script_t to script tags. * * Since: 0.6.0 * Deprecated: 2.0.0: use hb_ot_tags_from_script_and_language() instead **/ void hb_ot_tags_from_script (hb_script_t script, hb_tag_t *script_tag_1, hb_tag_t *script_tag_2) { … } #endif /* * Complete list at: * https://docs.microsoft.com/en-us/typography/opentype/spec/scripttags * * Most of the script tags are the same as the ISO 15924 tag but lowercased. * So we just do that, and handle the exceptional cases in a switch. */ static void hb_ot_all_tags_from_script (hb_script_t script, unsigned int *count /* IN/OUT */, hb_tag_t *tags /* OUT */) { … } /** * hb_ot_tag_to_script: * @tag: a script tag * * Converts a script tag to an #hb_script_t. * * Return value: The #hb_script_t corresponding to @tag. * **/ hb_script_t hb_ot_tag_to_script (hb_tag_t tag) { … } /* hb_language_t */ static inline bool subtag_matches (const char *lang_str, const char *limit, const char *subtag, unsigned subtag_len) { … } static bool lang_matches (const char *lang_str, const char *limit, const char *spec, unsigned spec_len) { … } struct LangTag { … }; #include "hb-ot-tag-table.hh" /* The corresponding languages IDs for the following IDs are unclear, * overlap, or are architecturally weird. Needs more research. */ /*{"??", {HB_TAG('B','C','R',' ')}},*/ /* Bible Cree */ /*{"zh?", {HB_TAG('C','H','N',' ')}},*/ /* Chinese (seen in Microsoft fonts) */ /*{"ar-Syrc?", {HB_TAG('G','A','R',' ')}},*/ /* Garshuni */ /*{"??", {HB_TAG('N','G','R',' ')}},*/ /* Nagari */ /*{"??", {HB_TAG('Y','I','C',' ')}},*/ /* Yi Classic */ /*{"zh?", {HB_TAG('Z','H','P',' ')}},*/ /* Chinese Phonetic */ #ifndef HB_DISABLE_DEPRECATED /** * hb_ot_tag_from_language: * @language: an #hb_language_t to convert. * * Converts an #hb_language_t to an #hb_tag_t. * * Since: 0.6.0 * Deprecated: 2.0.0: use hb_ot_tags_from_script_and_language() instead **/ hb_tag_t hb_ot_tag_from_language (hb_language_t language) { … } #endif static void hb_ot_tags_from_language (const char *lang_str, const char *limit, unsigned int *count, hb_tag_t *tags) { … } static bool parse_private_use_subtag (const char *private_use_subtag, unsigned int *count, hb_tag_t *tags, const char *prefix, unsigned char (*normalize) (unsigned char)) { … } /** * hb_ot_tags_from_script_and_language: * @script: an #hb_script_t to convert. * @language: (nullable): an #hb_language_t to convert. * @script_count: (inout) (optional): maximum number of script tags to retrieve (IN) * and actual number of script tags retrieved (OUT) * @script_tags: (out) (optional): array of size at least @script_count to store the * script tag results * @language_count: (inout) (optional): maximum number of language tags to retrieve * (IN) and actual number of language tags retrieved (OUT) * @language_tags: (out) (optional): array of size at least @language_count to store * the language tag results * * Converts an #hb_script_t and an #hb_language_t to script and language tags. * * Since: 2.0.0 **/ void hb_ot_tags_from_script_and_language (hb_script_t script, hb_language_t language, unsigned int *script_count /* IN/OUT */, hb_tag_t *script_tags /* OUT */, unsigned int *language_count /* IN/OUT */, hb_tag_t *language_tags /* OUT */) { … } /** * hb_ot_tag_to_language: * @tag: an language tag * * Converts a language tag to an #hb_language_t. * * Return value: (transfer none) (nullable): * The #hb_language_t corresponding to @tag. * * Since: 0.9.2 **/ hb_language_t hb_ot_tag_to_language (hb_tag_t tag) { … } /** * hb_ot_tags_to_script_and_language: * @script_tag: a script tag * @language_tag: a language tag * @script: (out) (optional): the #hb_script_t corresponding to @script_tag. * @language: (out) (optional): the #hb_language_t corresponding to @script_tag and * @language_tag. * * Converts a script tag and a language tag to an #hb_script_t and an * #hb_language_t. * * Since: 2.0.0 **/ void hb_ot_tags_to_script_and_language (hb_tag_t script_tag, hb_tag_t language_tag, hb_script_t *script /* OUT */, hb_language_t *language /* OUT */) { … } #ifdef MAIN static inline void test_langs_sorted () { for (unsigned int i = 1; i < ARRAY_LENGTH (ot_languages2); i++) { int c = ot_languages2[i].cmp (&ot_languages2[i - 1]); if (c > 0) { fprintf (stderr, "ot_languages2 not sorted at index %u: %08x %d %08x\n", i, ot_languages2[i-1].language, c, ot_languages2[i].language); abort(); } } #ifndef HB_NO_LANGUAGE_LONG for (unsigned int i = 1; i < ARRAY_LENGTH (ot_languages3); i++) { int c = ot_languages3[i].cmp (&ot_languages3[i - 1]); if (c > 0) { fprintf (stderr, "ot_languages3 not sorted at index %u: %08x %d %08x\n", i, ot_languages3[i-1].language, c, ot_languages3[i].language); abort(); } } #endif } int main () { test_langs_sorted (); return 0; } #endif #endif