-#ifdef HAVE_GRAPHITE
- hb_blob_t *silf_blob;
- silf_blob = hb_face_get_table (face, HB_GRAPHITE_TAG_Silf);
- if (hb_blob_get_length(silf_blob))
- {
- hb_graphite_shape(font, face, buffer, features, num_features);
- hb_blob_destroy(silf_blob);
- return;
+ 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_funcs_t *unicode = buffer->unicode;
+ unsigned int count = buffer->len;
+ for (unsigned int i = 0; i < count; i++) {
+ hb_script_t script = unicode->get_script (buffer->info[i].codepoint);
+ if (likely (script != HB_SCRIPT_COMMON &&
+ script != HB_SCRIPT_INHERITED &&
+ script != HB_SCRIPT_UNKNOWN)) {
+ buffer->props.script = script;
+ break;
+ }
+ }