1 // C99 port from c++ is protected by a GNU Lesser GPLv3
2 // Copyright © 2013 Sylvain BERTRAND <sylvain.bertrand@gmail.com>
3 // <sylware@legeek.net>
5 #include "hb-private.h"
6 #include "hb-atomic-private.h"
8 #include "hb-unicode-private.h"
11 hb_glib_script_from_script(hb_script_t script
)
13 return g_unicode_script_from_iso15924(script
);
17 hb_glib_script_to_script(GUnicodeScript script
)
19 return (hb_script_t
)g_unicode_script_to_iso15924(script
);
22 static hb_unicode_combining_class_t
23 hb_glib_unicode_combining_class(hb_unicode_funcs_t
*ufuncs HB_UNUSED
,
24 hb_codepoint_t unicode
,
25 void *user_data HB_UNUSED
)
28 return (hb_unicode_combining_class_t
)g_unichar_combining_class(unicode
);
32 hb_glib_unicode_eastasian_width(hb_unicode_funcs_t
*ufuncs HB_UNUSED
,
33 hb_codepoint_t unicode
,
34 void *user_data HB_UNUSED
)
36 return g_unichar_iswide(unicode
) ? 2 : 1;
39 static hb_unicode_general_category_t
40 hb_glib_unicode_general_category(hb_unicode_funcs_t
*ufuncs HB_UNUSED
,
41 hb_codepoint_t unicode
,
42 void *user_data HB_UNUSED
)
45 //hb_unicode_general_category_t and GUnicodeType are identical
46 return (hb_unicode_general_category_t
)g_unichar_type(unicode
);
50 hb_glib_unicode_mirroring(hb_unicode_funcs_t
*ufuncs HB_UNUSED
,
51 hb_codepoint_t unicode
,
52 void *user_data HB_UNUSED
)
54 g_unichar_get_mirror_char(unicode
, &unicode
);
59 hb_glib_unicode_script(hb_unicode_funcs_t
*ufuncs HB_UNUSED
,
60 hb_codepoint_t unicode
,
61 void *user_data HB_UNUSED
)
63 return hb_glib_script_to_script(g_unichar_get_script(unicode
));
67 hb_glib_unicode_compose(hb_unicode_funcs_t
*ufuncs HB_UNUSED
,
71 void *user_data HB_UNUSED
)
73 return g_unichar_compose(a
, b
, ab
);
77 hb_glib_unicode_decompose(hb_unicode_funcs_t
*ufuncs HB_UNUSED
,
81 void *user_data HB_UNUSED
)
83 return g_unichar_decompose(ab
, a
, b
);
87 hb_glib_unicode_decompose_compatibility(hb_unicode_funcs_t
*ufuncs HB_UNUSED
,
89 hb_codepoint_t
*decomposed
,
90 void *user_data HB_UNUSED
)
92 return g_unichar_fully_decompose(u
,
95 HB_UNICODE_MAX_DECOMPOSITION_LEN
);
98 static hb_unicode_funcs_t hb_glib_unicode_funcs
= {
99 REF_CNT_INVALID_VAL
,//ref_cnt
103 hb_glib_unicode_combining_class
,
104 hb_glib_unicode_eastasian_width
,
105 hb_glib_unicode_general_category
,
106 hb_glib_unicode_mirroring
,
107 hb_glib_unicode_script
,
108 hb_glib_unicode_compose
,
109 hb_glib_unicode_decompose
,
110 hb_glib_unicode_decompose_compatibility
113 NULL
,//combining_class
114 NULL
,//eastasian_width
115 NULL
,//general_category
120 NULL
//decompose_compatibility
123 NULL
,//combining_class
124 NULL
,//eastasian_width
125 NULL
,//general_category
130 NULL
//decompose_compatibility
135 hb_glib_get_unicode_funcs(void)
137 return &hb_glib_unicode_funcs
;