View | Details | Raw Unified | Return to bug 128354
Collapse All | Expand All

(-)pango/pangofc-fontmap.c.old (-1 / +72 lines)
Lines 23-28 Link Here
23
#define FONTSET_CACHE_SIZE 16
23
#define FONTSET_CACHE_SIZE 16
24
24
25
#include <math.h>
25
#include <math.h>
26
#include <locale.h>
27
#include <glib.h>
26
28
27
#include "pango-context.h"
29
#include "pango-context.h"
28
#include "pangofc-fontmap.h"
30
#include "pangofc-fontmap.h"
Lines 621-626 Link Here
621
  return FALSE;
623
  return FALSE;
622
}
624
}
623
625
626
#if defined (FC_FAMILYLANG) || defined (FC_STYLELANG)
627
static const char *
628
get_current_language_tag ()
629
{
630
  static char tag [6] = "en";
631
  int i;
632
633
  char *locale = setlocale (LC_CTYPE, 0);
634
635
  if (locale)
636
    {
637
      g_strlcpy (tag, setlocale (LC_CTYPE, 0), 6);
638
639
      for (i = 0; i < 6; ++i)
640
	{
641
	  if (tag [i] == '_') tag [i] = '-';
642
	  else if (tag [i] == '.') { tag [i] = 0; break; }
643
	  else tag [i] = g_ascii_tolower (tag [i]);
644
	}
645
    }
646
647
  return tag;
648
}
649
650
static FcResult 
651
get_pattern_string_for_language (FcPattern *p, const char *language, const char *obj, const char *objlang, FcChar8 **s)
652
{
653
  int i;
654
  FcResult res;
655
  FcChar8 *lang;
656
657
  res = FcPatternGetString (p, obj, 0, s);
658
659
  if (res == FcResultMatch)
660
    {
661
      for (i = 1; FcPatternGetString (p, objlang, i, &lang) == FcResultMatch; ++i)
662
	{
663
	  if (strncmp ((const char*) language, (const char*) lang, strlen ((const char*)lang)) == 0)
664
	    {
665
	      res = FcPatternGetString (p, obj, i, s);
666
	      break;
667
	    }
668
	}
669
    }
670
671
  return res;
672
}
673
#endif
674
624
static void
675
static void
625
pango_fc_font_map_list_families (PangoFontMap      *fontmap,
676
pango_fc_font_map_list_families (PangoFontMap      *fontmap,
626
				 PangoFontFamily ***families,
677
				 PangoFontFamily ***families,
Lines 644-651 Link Here
644
695
645
  if (priv->n_families < 0)
696
  if (priv->n_families < 0)
646
    {
697
    {
698
#ifdef FC_FAMILYLANG
699
      FcObjectSet *os = FcObjectSetBuild (FC_FAMILY, FC_FAMILYLANG, FC_SPACING, NULL);
700
      const char *language = get_current_language_tag ();
701
#else
647
      FcObjectSet *os = FcObjectSetBuild (FC_FAMILY, FC_SPACING, NULL);
702
      FcObjectSet *os = FcObjectSetBuild (FC_FAMILY, FC_SPACING, NULL);
703
#endif
648
      FcPattern *pat = FcPatternCreate ();
704
      FcPattern *pat = FcPatternCreate ();
705
649
      /* use hash table to avoid duplicate listings if different faces in
706
      /* use hash table to avoid duplicate listings if different faces in
650
       * the same family have different spacing values */
707
       * the same family have different spacing values */
651
      GHashTable *temp_family_hash;
708
      GHashTable *temp_family_hash;
Lines 664-671 Link Here
664
	  FcChar8 *s;
721
	  FcChar8 *s;
665
	  FcResult res;
722
	  FcResult res;
666
          int spacing;
723
          int spacing;
667
	  
724
725
#ifdef FC_FAMILYLANG
726
	  res = get_pattern_string_for_language (fontset->fonts[i], language, FC_FAMILY, FC_FAMILYLANG, &s);
727
#else
668
	  res = FcPatternGetString (fontset->fonts[i], FC_FAMILY, 0, (FcChar8 **) &s);
728
	  res = FcPatternGetString (fontset->fonts[i], FC_FAMILY, 0, (FcChar8 **) &s);
729
#endif
669
	  g_assert (res == FcResultMatch);
730
	  g_assert (res == FcResultMatch);
670
731
671
          res = FcPatternGetInteger (fontset->fonts[i], FC_SPACING, 0, &spacing);
732
          res = FcPatternGetInteger (fontset->fonts[i], FC_SPACING, 0, &spacing);
Lines 1887-1893 Link Here
1887
	}
1948
	}
1888
      else
1949
      else
1889
	{
1950
	{
1951
#ifdef FC_STYLELANG
1952
	  FcObjectSet *os = FcObjectSetBuild (FC_STYLE, FC_STYLELANG, NULL);
1953
	  const char *language = get_current_language_tag ();
1954
#else
1890
	  FcObjectSet *os = FcObjectSetBuild (FC_STYLE, NULL);
1955
	  FcObjectSet *os = FcObjectSetBuild (FC_STYLE, NULL);
1956
#endif
1891
	  FcPattern *pat = FcPatternBuild (NULL, 
1957
	  FcPattern *pat = FcPatternBuild (NULL, 
1892
					   FC_FAMILY, FcTypeString, fcfamily->family_name,
1958
					   FC_FAMILY, FcTypeString, fcfamily->family_name,
1893
					   NULL);
1959
					   NULL);
Lines 1905-1911 Link Here
1905
	      FcChar8 *s;
1971
	      FcChar8 *s;
1906
	      FcResult res;
1972
	      FcResult res;
1907
1973
1974
#ifdef FC_STYLELANG
1975
	      res = get_pattern_string_for_language (fontset->fonts[i], language, FC_STYLE, FC_STYLELANG, &s);
1976
#else
1908
	      res = FcPatternGetString (fontset->fonts[i], FC_STYLE, 0, &s);
1977
	      res = FcPatternGetString (fontset->fonts[i], FC_STYLE, 0, &s);
1978
#endif
1979
1909
	      if (res != FcResultMatch)
1980
	      if (res != FcResultMatch)
1910
		s = "Regular";
1981
		s = "Regular";
1911
1982

Return to bug 128354