forked from enlightenment/efl
Evas language: Added a character script querying function.
This is added until there will be a library that does it; From my understanding, there are already people working on such library. SVN revision: 59100
This commit is contained in:
parent
9389fed0a0
commit
afac2fdd18
|
@ -104,6 +104,7 @@ evas_scale_span.h \
|
|||
evas_pipe.h \
|
||||
language/evas_bidi_utils.h \
|
||||
language/evas_language_utils.h \
|
||||
language/evas_script_table.h \
|
||||
evas_text_utils.h \
|
||||
evas_font_ot.h \
|
||||
evas_map_image_internal.c \
|
||||
|
|
|
@ -10,6 +10,121 @@
|
|||
#include <Eina.h>
|
||||
#include "evas_font_private.h"
|
||||
|
||||
#ifdef USE_HARFBUZZ
|
||||
static const hb_script_t
|
||||
_evas_script_to_harfbuzz[] =
|
||||
{
|
||||
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_ABORIGINAL,
|
||||
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
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef OT_SUPPORT
|
||||
/* FIXME: doc. returns #items */
|
||||
EAPI int
|
||||
|
@ -233,7 +348,7 @@ evas_common_font_ot_populate_text_props(void *_fn, const Eina_Unicode *text,
|
|||
hb_buffer_set_unicode_funcs(buffer, evas_common_language_unicode_funcs_get());
|
||||
hb_buffer_set_language(buffer, hb_language_from_string(
|
||||
evas_common_language_from_locale_get()));
|
||||
hb_buffer_set_script(buffer, props->script);
|
||||
hb_buffer_set_script(buffer, _evas_script_to_harfbuzz[props->script]);
|
||||
hb_buffer_set_direction(buffer,
|
||||
(props->bidi.dir == EVAS_BIDI_DIRECTION_RTL) ?
|
||||
HB_DIRECTION_RTL : HB_DIRECTION_LTR);
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
# include <hb.h>
|
||||
#endif
|
||||
|
||||
#include "evas_script_table.h"
|
||||
|
||||
/* FIXME: rename and move */
|
||||
void *
|
||||
evas_common_language_unicode_funcs_get(void)
|
||||
|
@ -33,19 +35,38 @@ evas_common_language_unicode_funcs_get(void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static Evas_Script_Type
|
||||
_evas_common_language_char_script_search(Eina_Unicode unicode)
|
||||
{
|
||||
int min = 0;
|
||||
int max = (sizeof(_evas_script_slow_table) /
|
||||
sizeof(_evas_script_slow_table[0])) - 1;
|
||||
int mid;
|
||||
|
||||
do
|
||||
{
|
||||
mid = (min + max) / 2;
|
||||
|
||||
if (unicode < _evas_script_slow_table[mid].start)
|
||||
max = mid - 1;
|
||||
else if (unicode >= _evas_script_slow_table[mid].start +
|
||||
_evas_script_slow_table[mid].len)
|
||||
min = mid + 1;
|
||||
else
|
||||
return _evas_script_slow_table[mid].script;
|
||||
}
|
||||
while (min <= max);
|
||||
|
||||
return EVAS_SCRIPT_UNKNOWN;
|
||||
}
|
||||
|
||||
Evas_Script_Type
|
||||
evas_common_language_char_script_get(Eina_Unicode unicode)
|
||||
{
|
||||
#ifdef USE_HARFBUZZ
|
||||
static hb_unicode_funcs_t *funcs;
|
||||
if (!funcs)
|
||||
funcs = evas_common_language_unicode_funcs_get();
|
||||
if (funcs)
|
||||
return hb_unicode_get_script(funcs, unicode);
|
||||
#else
|
||||
(void) unicode;
|
||||
#endif
|
||||
return EVAS_SCRIPT_COMMON;
|
||||
if (unicode < EVAS_SCRIPT_DIRECT_TABLE_LIMIT)
|
||||
return _evas_script_fast_table[unicode];
|
||||
else
|
||||
return _evas_common_language_char_script_search(unicode);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue