|
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, locale, 6); |
| 638 |
|
| 639 |
for (i = 0; i < 6; ++i) |
| 640 |
{ |
| 641 |
if (tag [i] == '_') tag [i] = '-'; |
| 642 |
else if (tag [i] == '.' || 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, idx=0; |
| 654 |
FcChar8 *lang; |
| 655 |
|
| 656 |
for (i = 1; FcPatternGetString (p, objlang, i, &lang) == FcResultMatch; ++i) |
| 657 |
if (strncmp ((const char*) language, (const char*) lang, strlen ((const char*)lang)) == 0) |
| 658 |
{ |
| 659 |
idx = i; |
| 660 |
break; |
| 661 |
} |
| 662 |
|
| 663 |
return FcPatternGetString (p, obj, idx, s); |
| 664 |
} |
| 665 |
#endif |
| 666 |
|
| 624 |
static void |
667 |
static void |
| 625 |
pango_fc_font_map_list_families (PangoFontMap *fontmap, |
668 |
pango_fc_font_map_list_families (PangoFontMap *fontmap, |
| 626 |
PangoFontFamily ***families, |
669 |
PangoFontFamily ***families, |
|
Lines 644-651
Link Here
|
| 644 |
|
687 |
|
| 645 |
if (priv->n_families < 0) |
688 |
if (priv->n_families < 0) |
| 646 |
{ |
689 |
{ |
|
|
690 |
#ifdef FC_FAMILYLANG |
| 691 |
FcObjectSet *os = FcObjectSetBuild (FC_FAMILY, FC_FAMILYLANG, FC_SPACING, NULL); |
| 692 |
const char *language = get_current_language_tag (); |
| 693 |
#else |
| 647 |
FcObjectSet *os = FcObjectSetBuild (FC_FAMILY, FC_SPACING, NULL); |
694 |
FcObjectSet *os = FcObjectSetBuild (FC_FAMILY, FC_SPACING, NULL); |
|
|
695 |
#endif |
| 648 |
FcPattern *pat = FcPatternCreate (); |
696 |
FcPattern *pat = FcPatternCreate (); |
|
|
697 |
|
| 649 |
/* use hash table to avoid duplicate listings if different faces in |
698 |
/* use hash table to avoid duplicate listings if different faces in |
| 650 |
* the same family have different spacing values */ |
699 |
* the same family have different spacing values */ |
| 651 |
GHashTable *temp_family_hash; |
700 |
GHashTable *temp_family_hash; |
|
Lines 664-671
Link Here
|
| 664 |
FcChar8 *s; |
713 |
FcChar8 *s; |
| 665 |
FcResult res; |
714 |
FcResult res; |
| 666 |
int spacing; |
715 |
int spacing; |
| 667 |
|
716 |
|
|
|
717 |
#ifdef FC_FAMILYLANG |
| 718 |
res = get_pattern_string_for_language (fontset->fonts[i], language, FC_FAMILY, FC_FAMILYLANG, &s); |
| 719 |
#else |
| 668 |
res = FcPatternGetString (fontset->fonts[i], FC_FAMILY, 0, (FcChar8 **) &s); |
720 |
res = FcPatternGetString (fontset->fonts[i], FC_FAMILY, 0, (FcChar8 **) &s); |
|
|
721 |
#endif |
| 669 |
g_assert (res == FcResultMatch); |
722 |
g_assert (res == FcResultMatch); |
| 670 |
|
723 |
|
| 671 |
res = FcPatternGetInteger (fontset->fonts[i], FC_SPACING, 0, &spacing); |
724 |
res = FcPatternGetInteger (fontset->fonts[i], FC_SPACING, 0, &spacing); |
|
Lines 1689-1695
Link Here
|
| 1689 |
NULL); |
1742 |
NULL); |
| 1690 |
|
1743 |
|
| 1691 |
g_assert (match_pattern); |
1744 |
g_assert (match_pattern); |
| 1692 |
|
1745 |
|
| 1693 |
result_pattern = FcFontMatch (NULL, match_pattern, &res); |
1746 |
result_pattern = FcFontMatch (NULL, match_pattern, &res); |
| 1694 |
if (result_pattern) |
1747 |
if (result_pattern) |
| 1695 |
{ |
1748 |
{ |
|
Lines 1887-1893
Link Here
|
| 1887 |
} |
1940 |
} |
| 1888 |
else |
1941 |
else |
| 1889 |
{ |
1942 |
{ |
|
|
1943 |
#ifdef FC_STYLELANG |
| 1944 |
FcObjectSet *os = FcObjectSetBuild (FC_STYLE, FC_STYLELANG, NULL); |
| 1945 |
const char *language = get_current_language_tag (); |
| 1946 |
#else |
| 1890 |
FcObjectSet *os = FcObjectSetBuild (FC_STYLE, NULL); |
1947 |
FcObjectSet *os = FcObjectSetBuild (FC_STYLE, NULL); |
|
|
1948 |
#endif |
| 1891 |
FcPattern *pat = FcPatternBuild (NULL, |
1949 |
FcPattern *pat = FcPatternBuild (NULL, |
| 1892 |
FC_FAMILY, FcTypeString, fcfamily->family_name, |
1950 |
FC_FAMILY, FcTypeString, fcfamily->family_name, |
| 1893 |
NULL); |
1951 |
NULL); |
|
Lines 1905-1911
Link Here
|
| 1905 |
FcChar8 *s; |
1963 |
FcChar8 *s; |
| 1906 |
FcResult res; |
1964 |
FcResult res; |
| 1907 |
|
1965 |
|
|
|
1966 |
#ifdef FC_STYLELANG |
| 1967 |
res = get_pattern_string_for_language (fontset->fonts[i], language, FC_STYLE, FC_STYLELANG, &s); |
| 1968 |
#else |
| 1908 |
res = FcPatternGetString (fontset->fonts[i], FC_STYLE, 0, &s); |
1969 |
res = FcPatternGetString (fontset->fonts[i], FC_STYLE, 0, &s); |
|
|
1970 |
#endif |
| 1971 |
|
| 1909 |
if (res != FcResultMatch) |
1972 |
if (res != FcResultMatch) |
| 1910 |
s = "Regular"; |
1973 |
s = "Regular"; |
| 1911 |
|
1974 |
|