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

(-)pango/pangofc-fontmap.c.old (-2 / +41 lines)
Lines 28-33 Link Here
28
#include "pangofc-fontmap.h"
28
#include "pangofc-fontmap.h"
29
#include "pangofc-private.h"
29
#include "pangofc-private.h"
30
#include "modules.h"
30
#include "modules.h"
31
#include "pango-utils.h"
31
32
32
typedef struct _PangoFcCoverageKey  PangoFcCoverageKey;
33
typedef struct _PangoFcCoverageKey  PangoFcCoverageKey;
33
typedef struct _PangoFcFace         PangoFcFace;
34
typedef struct _PangoFcFace         PangoFcFace;
Lines 621-626 Link Here
621
  return FALSE;
622
  return FALSE;
622
}
623
}
623
624
625
#if defined (FC_FAMILYLANG) || defined (FC_STYLELANG)
626
static FcResult 
627
get_pattern_string_for_language (FcPattern *p, const char *language, const char *obj, const char *objlang, FcChar8 **s)
628
{
629
  int i, idx=0;
630
  FcChar8 *lang;
631
632
  for (i = 1; FcPatternGetString (p, objlang, i, &lang) == FcResultMatch; ++i)
633
    if (strncmp ((const char*) language, (const char*) lang, strlen ((const char*)lang)) == 0)
634
      {
635
	idx = i;
636
	break;
637
      }
638
639
  return FcPatternGetString (p, obj, idx, s);
640
}
641
#endif
642
624
static void
643
static void
625
pango_fc_font_map_list_families (PangoFontMap      *fontmap,
644
pango_fc_font_map_list_families (PangoFontMap      *fontmap,
626
				 PangoFontFamily ***families,
645
				 PangoFontFamily ***families,
Lines 644-651 Link Here
644
663
645
  if (priv->n_families < 0)
664
  if (priv->n_families < 0)
646
    {
665
    {
666
#ifdef FC_FAMILYLANG
667
      FcObjectSet *os = FcObjectSetBuild (FC_FAMILY, FC_FAMILYLANG, FC_SPACING, NULL);
668
      const char *language = pango_language_to_string (pango_get_default_language ());
669
#else
647
      FcObjectSet *os = FcObjectSetBuild (FC_FAMILY, FC_SPACING, NULL);
670
      FcObjectSet *os = FcObjectSetBuild (FC_FAMILY, FC_SPACING, NULL);
671
#endif
648
      FcPattern *pat = FcPatternCreate ();
672
      FcPattern *pat = FcPatternCreate ();
673
649
      /* use hash table to avoid duplicate listings if different faces in
674
      /* use hash table to avoid duplicate listings if different faces in
650
       * the same family have different spacing values */
675
       * the same family have different spacing values */
651
      GHashTable *temp_family_hash;
676
      GHashTable *temp_family_hash;
Lines 664-671 Link Here
664
	  FcChar8 *s;
689
	  FcChar8 *s;
665
	  FcResult res;
690
	  FcResult res;
666
          int spacing;
691
          int spacing;
667
	  
692
693
#ifdef FC_FAMILYLANG
694
	  res = get_pattern_string_for_language (fontset->fonts[i], language, FC_FAMILY, FC_FAMILYLANG, &s);
695
#else
668
	  res = FcPatternGetString (fontset->fonts[i], FC_FAMILY, 0, (FcChar8 **) &s);
696
	  res = FcPatternGetString (fontset->fonts[i], FC_FAMILY, 0, (FcChar8 **) &s);
697
#endif
669
	  g_assert (res == FcResultMatch);
698
	  g_assert (res == FcResultMatch);
670
699
671
          res = FcPatternGetInteger (fontset->fonts[i], FC_SPACING, 0, &spacing);
700
          res = FcPatternGetInteger (fontset->fonts[i], FC_SPACING, 0, &spacing);
Lines 1689-1695 Link Here
1689
				  NULL);
1718
				  NULL);
1690
1719
1691
  g_assert (match_pattern);
1720
  g_assert (match_pattern);
1692
  
1721
1693
  result_pattern = FcFontMatch (NULL, match_pattern, &res);
1722
  result_pattern = FcFontMatch (NULL, match_pattern, &res);
1694
  if (result_pattern)
1723
  if (result_pattern)
1695
    {
1724
    {
Lines 1887-1893 Link Here
1887
	}
1916
	}
1888
      else
1917
      else
1889
	{
1918
	{
1919
#ifdef FC_STYLELANG
1920
	  FcObjectSet *os = FcObjectSetBuild (FC_STYLE, FC_STYLELANG, NULL);
1921
	  const char *language = pango_language_to_string (pango_get_default_language ());
1922
#else
1890
	  FcObjectSet *os = FcObjectSetBuild (FC_STYLE, NULL);
1923
	  FcObjectSet *os = FcObjectSetBuild (FC_STYLE, NULL);
1924
#endif
1891
	  FcPattern *pat = FcPatternBuild (NULL, 
1925
	  FcPattern *pat = FcPatternBuild (NULL, 
1892
					   FC_FAMILY, FcTypeString, fcfamily->family_name,
1926
					   FC_FAMILY, FcTypeString, fcfamily->family_name,
1893
					   NULL);
1927
					   NULL);
Lines 1905-1911 Link Here
1905
	      FcChar8 *s;
1939
	      FcChar8 *s;
1906
	      FcResult res;
1940
	      FcResult res;
1907
1941
1942
#ifdef FC_STYLELANG
1943
	      res = get_pattern_string_for_language (fontset->fonts[i], language, FC_STYLE, FC_STYLELANG, &s);
1944
#else
1908
	      res = FcPatternGetString (fontset->fonts[i], FC_STYLE, 0, &s);
1945
	      res = FcPatternGetString (fontset->fonts[i], FC_STYLE, 0, &s);
1946
#endif
1947
1909
	      if (res != FcResultMatch)
1948
	      if (res != FcResultMatch)
1910
		s = "Regular";
1949
		s = "Regular";
1911
1950
(-)pango/pango-utils.h.old (+3 lines)
Lines 95-100 Link Here
95
95
96
G_CONST_RETURN char *pango_language_get_sample_string (PangoLanguage *language);
96
G_CONST_RETURN char *pango_language_get_sample_string (PangoLanguage *language);
97
97
98
void            pango_set_default_language (PangoLanguage *language);
99
PangoLanguage * pango_get_default_language (void);
100
98
/* Unicode characters that are zero-width and should not be rendered
101
/* Unicode characters that are zero-width and should not be rendered
99
 * normally.
102
 * normally.
100
 */
103
 */
(-)pango/pango-utils.c.old (+90 lines)
Lines 24-29 Link Here
24
#include <string.h>
24
#include <string.h>
25
#include <stdlib.h>
25
#include <stdlib.h>
26
26
27
#include <locale.h>
28
27
#include "config.h"
29
#include "config.h"
28
30
29
#include "pango-font.h"
31
#include "pango-font.h"
Lines 59-64 Link Here
59
};
61
};
60
62
61
static GHashTable *pango_aliases_ht = NULL;
63
static GHashTable *pango_aliases_ht = NULL;
64
static PangoLanguage *pango_default_language = 0;
65
62
66
63
/**
67
/**
64
 * pango_trim_string:
68
 * pango_trim_string:
Lines 1224-1229 Link Here
1224
  return our_type;
1228
  return our_type;
1225
}
1229
}
1226
1230
1231
/* copy from gtk+ */
1232
static gchar *
1233
_pango_get_lc_ctype (void)
1234
{
1235
#ifdef G_OS_WIN32
1236
  /* Somebody might try to set the locale for this process using the
1237
   * LANG or LC_ environment variables. The Microsoft C library
1238
   * doesn't know anything about them. You set the locale in the
1239
   * Control Panel. Setting these env vars won't have any affect on
1240
   * locale-dependent C library functions like ctime(). But just for
1241
   * kicks, do obey LC_ALL, LC_CTYPE and LANG in GTK. (This also makes
1242
   * it easier to test GTK and Pango in various default languages, you
1243
   * don't have to clickety-click in the Control Panel, you can simply
1244
   * start the program with LC_ALL=something on the command line.)
1245
   */
1246
  gchar *p;
1247
1248
  p = getenv ("LC_ALL");
1249
  if (p != NULL)
1250
    return g_strdup (p);
1251
1252
  p = getenv ("LC_CTYPE");
1253
  if (p != NULL)
1254
    return g_strdup (p);
1255
1256
  p = getenv ("LANG");
1257
  if (p != NULL)
1258
    return g_strdup (p);
1259
1260
  return g_win32_getlocale ();
1261
#else
1262
  return g_strdup (setlocale (LC_CTYPE, NULL));
1263
#endif
1264
}
1265
1266
/**
1267
 * pango_set_default_language:
1268
 * @language: a #PangoLanguage, #NULL is allowed to clear the
1269
 *            default language setting.
1270
 *
1271
 * Set the default language, which will be used by pango when
1272
 * listing font families and faces.
1273
 **/
1274
void
1275
pango_set_default_language (PangoLanguage *language)
1276
{
1277
  pango_default_language = language;
1278
}
1279
1280
/**
1281
 * pango_get_default_language:
1282
 * 
1283
 * Get the default language, which will be used by pango when
1284
 * listing font families and faces.
1285
 *
1286
 * The default language could be set by calling
1287
 * pango_set_default_language().
1288
 *
1289
 * If no default language has been set before, the language
1290
 * corresponding to the current locale will be returned.
1291
 *
1292
 * Return value: an opaque pointer to a #PangoLanguage.
1293
 **/
1294
PangoLanguage *
1295
pango_get_default_language (void)
1296
{
1297
  if (!pango_default_language)
1298
    {
1299
      gchar *lang;
1300
      gchar *p;
1301
1302
      lang = _pango_get_lc_ctype ();
1303
      p = strchr (lang, '.');
1304
      if (p)
1305
	*p = '\0';
1306
      p = strchr (lang, '@');
1307
      if (p)
1308
	*p = '\0';
1309
1310
      pango_default_language = pango_language_from_string (lang);
1311
      g_free (lang);
1312
    }
1313
 
1314
  return pango_default_language;
1315
}
1316
1227
/**
1317
/**
1228
 * pango_language_from_string:
1318
 * pango_language_from_string:
1229
 * @language: a string representing a language tag
1319
 * @language: a string representing a language tag

Return to bug 128354