+static int
+FcGetDefaultObjectLangIndex (FcPattern *font, FcObject object)
+{
+ FcChar8 *lang = FcGetDefaultLang ();
+ FcPatternElt *e = FcPatternObjectFindElt (font, object);
+ FcValueListPtr v;
+ FcValue value;
+ int idx = -1;
+ int i;
+
+ if (e)
+ {
+ for (v = FcPatternEltValues(e), i = 0; v; v = FcValueListNext(v), ++i)
+ {
+ value = FcValueCanonicalize (&v->value);
+
+ if (value.type == FcTypeString)
+ {
+ FcLangResult res = FcLangCompare (value.u.s, lang);
+ if (res == FcLangEqual)
+ return i;
+
+ if (res == FcLangDifferentCountry && idx < 0)
+ idx = i;
+ }
+ }
+ }
+
+ return (idx > 0) ? idx : 0;
+}
+