typedef void (*hb_destroy_func_t) (void *user_data);
typedef enum _hb_direction_t {
- HB_DIRECTION_LTR,
+ HB_DIRECTION_INVALID = -1,
+ HB_DIRECTION_LTR = 0,
HB_DIRECTION_RTL,
HB_DIRECTION_TTB,
HB_DIRECTION_BTT
U_ICU_VERSION_MAJOR_NUM > (major) || (U_ICU_VERSION_MAJOR_NUM == (major) && U_ICU_VERSION_MINOR_NUM >= (minor))
#define MATCH_SCRIPT(C) case USCRIPT_##C: return HB_SCRIPT_##C
#define MATCH_SCRIPT2(C1, C2) case USCRIPT_##C1: return HB_SCRIPT_##C2
- MATCH_SCRIPT (INVALID_CODE);
+
MATCH_SCRIPT (COMMON); /* Zyyy */
MATCH_SCRIPT (INHERITED); /* Qaai */
MATCH_SCRIPT (ARABIC); /* Arab */
break;
case HB_DIRECTION_TTB:
case HB_DIRECTION_BTT:
+ case HB_DIRECTION_INVALID:
default:
break;
}
/* TODO vertical */
if (HB_DIRECTION_IS_HORIZONTAL (direction) &&
- direction != _hb_script_get_horizontal_direction (c->buffer->props.script))
+ direction != hb_script_get_horizontal_direction (c->buffer->props.script))
{
hb_buffer_reverse_clusters (c->buffer);
c->buffer->props.direction = HB_DIRECTION_REVERSE (c->buffer->props.direction);
HB_BEGIN_DECLS
-void
-hb_shape (hb_font_t *font,
- hb_face_t *face,
- hb_buffer_t *buffer,
- hb_feature_t *features,
- unsigned int num_features)
+static void
+hb_shape_internal (hb_font_t *font,
+ hb_face_t *face,
+ hb_buffer_t *buffer,
+ hb_feature_t *features,
+ unsigned int num_features)
{
#if 0 && defined(HAVE_GRAPHITE)
hb_blob_t *silf_blob;
hb_ot_shape (font, face, buffer, features, num_features);
}
+void
+hb_shape (hb_font_t *font,
+ hb_face_t *face,
+ hb_buffer_t *buffer,
+ hb_feature_t *features,
+ unsigned int num_features)
+{
+ hb_segment_properties_t orig_props;
+
+ orig_props = buffer->props;
+
+ /* If script is set to INVALID, guess from buffer contents */
+ if (buffer->props.script == HB_SCRIPT_INVALID) {
+ hb_unicode_get_script_func_t get_script = buffer->unicode->v.get_script;
+ unsigned int count = buffer->len;
+ for (unsigned int i = 0; i < count; i++) {
+ hb_script_t script = get_script (buffer->info[i].codepoint);
+ if (likely (script > HB_SCRIPT_INHERITED)) {
+ buffer->props.script = script;
+ break;
+ }
+ }
+ }
+
+ /* If direction is set to INVALID, guess from script */
+ if (buffer->props.direction == HB_DIRECTION_INVALID) {
+ buffer->props.direction = hb_script_get_horizontal_direction (buffer->props.script);
+ }
+
+ /* If language is not set, use default language from locale */
+ if (buffer->props.language == NULL) {
+ /* TODO get_default_for_script? using $LANGUAGE */
+ //buffer->props.language = hb_language_get_default ();
+ }
+
+ hb_shape_internal (font, face, buffer, features, num_features);
+
+ buffer->props = orig_props;
+}
+
HB_END_DECLS
extern HB_INTERNAL hb_unicode_funcs_t _hb_unicode_funcs_nil;
-HB_INTERNAL hb_direction_t
-_hb_script_get_horizontal_direction (hb_script_t script);
-
-
HB_END_DECLS
#endif /* HB_UNICODE_PRIVATE_H */
#undef RTL
hb_direction_t
-_hb_script_get_horizontal_direction (hb_script_t script)
+hb_script_get_horizontal_direction (hb_script_t script)
{
if (unlikely ((unsigned int) script >= ARRAY_LENGTH (horiz_dir)))
return HB_DIRECTION_LTR;
/* Unicode Script property */
typedef enum
{ /* ISO 15924 code */
- HB_SCRIPT_INVALID_CODE = -1,
+ HB_SCRIPT_INVALID = -1,
+
HB_SCRIPT_COMMON = 0, /* Zyyy */
HB_SCRIPT_INHERITED, /* Qaai */
HB_SCRIPT_ARABIC, /* Arab */
hb_codepoint_t unicode);
+/* Misc functions */
+
+hb_direction_t
+hb_script_get_horizontal_direction (hb_script_t script);
+
HB_END_DECLS
#endif /* HB_UNICODE_H */
hb_buffer_set_unicode_funcs (hb_buffer, hb_glib_get_unicode_funcs ());
hb_buffer_add_utf8 (hb_buffer, text, len, 0, len);
- /* hb_buffer_set_script (hb_buffer, HB_SCRIPT_LATIN); */
- /* hb_buffer_set_direction (hb_buffer, HB_DIRECTION_LTR); */
+ hb_buffer_set_script (hb_buffer, HB_SCRIPT_INVALID);
+ hb_buffer_set_direction (hb_buffer, HB_DIRECTION_INVALID);
hb_buffer_set_language (hb_buffer, hb_language_from_string (language));
hb_shape (hb_font, hb_face, hb_buffer, NULL, 0);