Skip to content

Commit

Permalink
[glib] Default to glib's script type handling
Browse files Browse the repository at this point in the history
2.29.14 is almost released a decade ago, no need to support archaic glib versions.
  • Loading branch information
ebraminio committed Jul 29, 2020
1 parent dae32b4 commit 44a3136
Showing 1 changed file with 1 addition and 147 deletions.
148 changes: 1 addition & 147 deletions src/hb-glib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,138 +41,14 @@
* @short_description: GLib integration
* @include: hb-glib.h
*
* Functions for using HarfBuzz with the GLib library.
* Functions for using HarfBuzz with the GLib library.
*
* HarfBuzz supports using GLib to provide Unicode data, by attaching
* GLib functions to the virtual methods in a #hb_unicode_funcs_t function
* structure.
**/


#if !GLIB_CHECK_VERSION(2,29,14)
static const hb_script_t
glib_script_to_script[] =
{
HB_SCRIPT_COMMON,
HB_SCRIPT_INHERITED,
HB_SCRIPT_ARABIC,
HB_SCRIPT_ARMENIAN,
HB_SCRIPT_BENGALI,
HB_SCRIPT_BOPOMOFO,
HB_SCRIPT_CHEROKEE,
HB_SCRIPT_COPTIC,
HB_SCRIPT_CYRILLIC,
HB_SCRIPT_DESERET,
HB_SCRIPT_DEVANAGARI,
HB_SCRIPT_ETHIOPIC,
HB_SCRIPT_GEORGIAN,
HB_SCRIPT_GOTHIC,
HB_SCRIPT_GREEK,
HB_SCRIPT_GUJARATI,
HB_SCRIPT_GURMUKHI,
HB_SCRIPT_HAN,
HB_SCRIPT_HANGUL,
HB_SCRIPT_HEBREW,
HB_SCRIPT_HIRAGANA,
HB_SCRIPT_KANNADA,
HB_SCRIPT_KATAKANA,
HB_SCRIPT_KHMER,
HB_SCRIPT_LAO,
HB_SCRIPT_LATIN,
HB_SCRIPT_MALAYALAM,
HB_SCRIPT_MONGOLIAN,
HB_SCRIPT_MYANMAR,
HB_SCRIPT_OGHAM,
HB_SCRIPT_OLD_ITALIC,
HB_SCRIPT_ORIYA,
HB_SCRIPT_RUNIC,
HB_SCRIPT_SINHALA,
HB_SCRIPT_SYRIAC,
HB_SCRIPT_TAMIL,
HB_SCRIPT_TELUGU,
HB_SCRIPT_THAANA,
HB_SCRIPT_THAI,
HB_SCRIPT_TIBETAN,
HB_SCRIPT_CANADIAN_SYLLABICS,
HB_SCRIPT_YI,
HB_SCRIPT_TAGALOG,
HB_SCRIPT_HANUNOO,
HB_SCRIPT_BUHID,
HB_SCRIPT_TAGBANWA,

/* Unicode-4.0 additions */
HB_SCRIPT_BRAILLE,
HB_SCRIPT_CYPRIOT,
HB_SCRIPT_LIMBU,
HB_SCRIPT_OSMANYA,
HB_SCRIPT_SHAVIAN,
HB_SCRIPT_LINEAR_B,
HB_SCRIPT_TAI_LE,
HB_SCRIPT_UGARITIC,

/* Unicode-4.1 additions */
HB_SCRIPT_NEW_TAI_LUE,
HB_SCRIPT_BUGINESE,
HB_SCRIPT_GLAGOLITIC,
HB_SCRIPT_TIFINAGH,
HB_SCRIPT_SYLOTI_NAGRI,
HB_SCRIPT_OLD_PERSIAN,
HB_SCRIPT_KHAROSHTHI,

/* Unicode-5.0 additions */
HB_SCRIPT_UNKNOWN,
HB_SCRIPT_BALINESE,
HB_SCRIPT_CUNEIFORM,
HB_SCRIPT_PHOENICIAN,
HB_SCRIPT_PHAGS_PA,
HB_SCRIPT_NKO,

/* Unicode-5.1 additions */
HB_SCRIPT_KAYAH_LI,
HB_SCRIPT_LEPCHA,
HB_SCRIPT_REJANG,
HB_SCRIPT_SUNDANESE,
HB_SCRIPT_SAURASHTRA,
HB_SCRIPT_CHAM,
HB_SCRIPT_OL_CHIKI,
HB_SCRIPT_VAI,
HB_SCRIPT_CARIAN,
HB_SCRIPT_LYCIAN,
HB_SCRIPT_LYDIAN,

/* Unicode-5.2 additions */
HB_SCRIPT_AVESTAN,
HB_SCRIPT_BAMUM,
HB_SCRIPT_EGYPTIAN_HIEROGLYPHS,
HB_SCRIPT_IMPERIAL_ARAMAIC,
HB_SCRIPT_INSCRIPTIONAL_PAHLAVI,
HB_SCRIPT_INSCRIPTIONAL_PARTHIAN,
HB_SCRIPT_JAVANESE,
HB_SCRIPT_KAITHI,
HB_SCRIPT_TAI_THAM,
HB_SCRIPT_LISU,
HB_SCRIPT_MEETEI_MAYEK,
HB_SCRIPT_OLD_SOUTH_ARABIAN,
HB_SCRIPT_OLD_TURKIC,
HB_SCRIPT_SAMARITAN,
HB_SCRIPT_TAI_VIET,

/* Unicode-6.0 additions */
HB_SCRIPT_BATAK,
HB_SCRIPT_BRAHMI,
HB_SCRIPT_MANDAIC,

/* Unicode-6.1 additions */
HB_SCRIPT_CHAKMA,
HB_SCRIPT_MEROITIC_CURSIVE,
HB_SCRIPT_MEROITIC_HIEROGLYPHS,
HB_SCRIPT_MIAO,
HB_SCRIPT_SHARADA,
HB_SCRIPT_SORA_SOMPENG,
HB_SCRIPT_TAKRI
};
#endif

/**
* hb_glib_script_to_script:
* @script: The GUnicodeScript identifier to query
Expand All @@ -187,17 +63,7 @@ glib_script_to_script[] =
hb_script_t
hb_glib_script_to_script (GUnicodeScript script)
{
#if GLIB_CHECK_VERSION(2,29,14)
return (hb_script_t) g_unicode_script_to_iso15924 (script);
#else
if (likely ((unsigned int) script < ARRAY_LENGTH (glib_script_to_script)))
return glib_script_to_script[script];

if (unlikely (script == G_UNICODE_SCRIPT_INVALID_CODE))
return HB_SCRIPT_INVALID;

return HB_SCRIPT_UNKNOWN;
#endif
}

/**
Expand All @@ -214,19 +80,7 @@ hb_glib_script_to_script (GUnicodeScript script)
GUnicodeScript
hb_glib_script_from_script (hb_script_t script)
{
#if GLIB_CHECK_VERSION(2,29,14)
return g_unicode_script_from_iso15924 (script);
#else
unsigned int count = ARRAY_LENGTH (glib_script_to_script);
for (unsigned int i = 0; i < count; i++)
if (glib_script_to_script[i] == script)
return (GUnicodeScript) i;

if (unlikely (script == HB_SCRIPT_INVALID))
return G_UNICODE_SCRIPT_INVALID_CODE;

return G_UNICODE_SCRIPT_UNKNOWN;
#endif
}


Expand Down

4 comments on commit 44a3136

@khaledhosny
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be do the same for ICU, we have some support for ancient versions there as well IIRC.

@ebraminio
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't found it, awesome, let me know about it, thank you very much :)

@khaledhosny
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look for U_ICU_VERSION_MAJOR_NUM >= 49 in hb-icu.cc, ICU 49 was released in 2012.

@ebraminio
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I was just searching for wrong thing, done c9e5da8 thank you very much :)

Please sign in to comment.