Beispiel #1
0
static double
FcCompareFilename (FcValue *v1, FcValue *v2)
{
	const FcChar8 *s1 = FcValueString (v1), *s2 = FcValueString (v2);
	if (FcStrCmp (s1, s2) == 0)
	    return 0.0;
	else if (FcStrCmpIgnoreCase (s1, s2) == 0)
	    return 1.0;
	else if (FcStrRegexCmp (s2, s1))
	    return 2.0;
	else if (FcStrRegexCmpIgnoreCase (s2, s1))
	    return 3.0;
	else
	    return 4.0;
}
Beispiel #2
0
FcResult fcinfo_get_translated_string(const FcPattern *pattern, 
                                      const char *object, 
                                      const FcChar8 *lang, FcChar8 **s)
{
  FcChar8 *l;
  int n;
  FcResult r;
  const char *lang_object;

  if (strcmp(object, FC_FAMILY) == 0)
    lang_object = FC_FAMILYLANG;
  else if (strcmp(object, FC_STYLE) == 0)
    lang_object = FC_STYLELANG;
  else if (strcmp(object, FC_FULLNAME))
    lang_object = FC_FULLNAMELANG;
  else
  {
    fprintf(stderr, "fcinfo_get_translated_string():"
                    " no translatable string\n");
    exit (1);
  }

  if (FcPatternGetString(pattern, lang_object, 0, &l) != FcResultMatch)
  {
    /* no *_LANG element */
    return FcPatternGetString(pattern, object, 0, s);
  }

  n = 0;
  while ((r = FcPatternGetString(pattern, lang_object, n, &l)) == FcResultMatch)
    if (FcStrCmp(l, lang) == 0)
      break;
    else
      n++;
    
  if (r != FcResultMatch)
    n = 0; /* no lang found */
  
  return FcPatternGetString(pattern, object, n, s);
}