/** * hb_feature_to_string: * @feature: an #hb_feature_t to convert * @buf: (array length=size) (out): output string * @size: the allocated size of @buf * * Converts a #hb_feature_t into a %NULL-terminated string in the format * understood by hb_feature_from_string(). The client in responsible for * allocating big enough size for @buf, 128 bytes is more than enough. * * Since: 0.9.5 **/ void hb_feature_to_string (hb_feature_t *feature, char *buf, unsigned int size) { if (unlikely (!size)) return; char s[128]; unsigned int len = 0; if (feature->value == 0) s[len++] = '-'; hb_tag_to_string (feature->tag, s + len); len += 4; while (len && s[len - 1] == ' ') len--; if (feature->start != 0 || feature->end != (unsigned int) -1) { s[len++] = '['; if (feature->start) len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%u", feature->start)); if (feature->end != feature->start + 1) { s[len++] = ':'; if (feature->end != (unsigned int) -1) len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%u", feature->end)); } s[len++] = ']'; } if (feature->value > 1) { s[len++] = '='; len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%u", feature->value)); } assert (len < ARRAY_LENGTH (s)); len = MIN (len, size - 1); memcpy (buf, s, len); buf[len] = '\0'; }
QString scriptShortText(hb_script_t script) { char buffer[5] = {0}; hb_tag_to_string(script, buffer); return QString(buffer); }