|
Lines 83-88
Link Here
|
| 83 |
|
83 |
|
| 84 |
PangoFcFamily *family; |
84 |
PangoFcFamily *family; |
| 85 |
char *style; |
85 |
char *style; |
|
|
86 |
|
| 87 |
guint fake : 1; |
| 86 |
}; |
88 |
}; |
| 87 |
|
89 |
|
| 88 |
struct _PangoFcFamily |
90 |
struct _PangoFcFamily |
|
Lines 1671-1677
Link Here
|
| 1671 |
FcPattern *match_pattern; |
1673 |
FcPattern *match_pattern; |
| 1672 |
FcPattern *result_pattern; |
1674 |
FcPattern *result_pattern; |
| 1673 |
|
1675 |
|
| 1674 |
if (is_alias_family (fcfamily->family_name)) |
1676 |
if (fcface->fake) |
| 1675 |
{ |
1677 |
{ |
| 1676 |
if (strcmp (fcface->style, "Regular") == 0) |
1678 |
if (strcmp (fcface->style, "Regular") == 0) |
| 1677 |
return make_alias_description (fcfamily, FALSE, FALSE); |
1679 |
return make_alias_description (fcfamily, FALSE, FALSE); |
|
Lines 1851-1861
Link Here
|
| 1851 |
*/ |
1853 |
*/ |
| 1852 |
static PangoFcFace * |
1854 |
static PangoFcFace * |
| 1853 |
create_face (PangoFcFamily *fcfamily, |
1855 |
create_face (PangoFcFamily *fcfamily, |
| 1854 |
const char *style) |
1856 |
const char *style, |
|
|
1857 |
gboolean fake) |
| 1855 |
{ |
1858 |
{ |
| 1856 |
PangoFcFace *face = g_object_new (PANGO_FC_TYPE_FACE, NULL); |
1859 |
PangoFcFace *face = g_object_new (PANGO_FC_TYPE_FACE, NULL); |
| 1857 |
face->style = g_strdup (style); |
1860 |
face->style = g_strdup (style); |
| 1858 |
face->family = fcfamily; |
1861 |
face->family = fcfamily; |
|
|
1862 |
face->fake = fake; |
| 1859 |
|
1863 |
|
| 1860 |
return face; |
1864 |
return face; |
| 1861 |
} |
1865 |
} |
|
Lines 1880-1917
Link Here
|
| 1880 |
fcfamily->faces = g_new (PangoFcFace *, fcfamily->n_faces); |
1884 |
fcfamily->faces = g_new (PangoFcFace *, fcfamily->n_faces); |
| 1881 |
|
1885 |
|
| 1882 |
i = 0; |
1886 |
i = 0; |
| 1883 |
fcfamily->faces[i++] = create_face (fcfamily, "Regular"); |
1887 |
fcfamily->faces[i++] = create_face (fcfamily, "Regular", TRUE); |
| 1884 |
fcfamily->faces[i++] = create_face (fcfamily, "Bold"); |
1888 |
fcfamily->faces[i++] = create_face (fcfamily, "Bold", TRUE); |
| 1885 |
fcfamily->faces[i++] = create_face (fcfamily, "Italic"); |
1889 |
fcfamily->faces[i++] = create_face (fcfamily, "Italic", TRUE); |
| 1886 |
fcfamily->faces[i++] = create_face (fcfamily, "Bold Italic"); |
1890 |
fcfamily->faces[i++] = create_face (fcfamily, "Bold Italic", TRUE); |
| 1887 |
} |
1891 |
} |
| 1888 |
else |
1892 |
else |
| 1889 |
{ |
1893 |
{ |
| 1890 |
FcObjectSet *os = FcObjectSetBuild (FC_STYLE, NULL); |
1894 |
FcObjectSet *os = FcObjectSetBuild (FC_STYLE, FC_WEIGHT, FC_SLANT, NULL); |
| 1891 |
FcPattern *pat = FcPatternBuild (NULL, |
1895 |
FcPattern *pat = FcPatternBuild (NULL, |
| 1892 |
FC_FAMILY, FcTypeString, fcfamily->family_name, |
1896 |
FC_FAMILY, FcTypeString, fcfamily->family_name, |
| 1893 |
NULL); |
1897 |
NULL); |
| 1894 |
|
1898 |
|
|
|
1899 |
/* Regular, Italic, Bold, Bold Italic */ |
| 1900 |
gboolean face_state [4] = { FALSE, FALSE, FALSE, FALSE }; |
| 1901 |
PangoFcFace **tmp_faces; |
| 1902 |
gint num = 0; |
| 1903 |
|
| 1895 |
fontset = FcFontList (NULL, pat, os); |
1904 |
fontset = FcFontList (NULL, pat, os); |
| 1896 |
|
1905 |
|
| 1897 |
FcPatternDestroy (pat); |
1906 |
FcPatternDestroy (pat); |
| 1898 |
FcObjectSetDestroy (os); |
1907 |
FcObjectSetDestroy (os); |
| 1899 |
|
1908 |
|
| 1900 |
fcfamily->n_faces = fontset->nfont; |
1909 |
/* at most we have 3 additional artifical faces */ |
| 1901 |
fcfamily->faces = g_new (PangoFcFace *, fcfamily->n_faces); |
1910 |
tmp_faces = g_new (PangoFcFace *, fontset->nfont + 3); |
| 1902 |
|
1911 |
|
| 1903 |
for (i = 0; i < fontset->nfont; i++) |
1912 |
for (i = 0; i < fontset->nfont; i++) |
| 1904 |
{ |
1913 |
{ |
| 1905 |
FcChar8 *s; |
1914 |
FcChar8 *s; |
| 1906 |
FcResult res; |
1915 |
FcResult res; |
| 1907 |
|
1916 |
|
|
|
1917 |
int weight, slant; |
| 1918 |
|
| 1919 |
if (FcPatternGetInteger(fontset->fonts[i], FC_WEIGHT, 0, &weight) != FcResultMatch) |
| 1920 |
weight = FC_WEIGHT_MEDIUM; |
| 1921 |
|
| 1922 |
if (FcPatternGetInteger(fontset->fonts[i], FC_SLANT, 0, &slant) != FcResultMatch) |
| 1923 |
slant = FC_SLANT_ROMAN; |
| 1924 |
|
| 1908 |
res = FcPatternGetString (fontset->fonts[i], FC_STYLE, 0, &s); |
1925 |
res = FcPatternGetString (fontset->fonts[i], FC_STYLE, 0, &s); |
| 1909 |
if (res != FcResultMatch) |
|
|
| 1910 |
s = "Regular"; |
| 1911 |
|
1926 |
|
| 1912 |
fcfamily->faces[i] = create_face (fcfamily, s); |
1927 |
if (weight <= FC_WEIGHT_MEDIUM && slant == FC_SLANT_ROMAN) |
|
|
1928 |
{ |
| 1929 |
face_state[0] = TRUE; |
| 1930 |
if (res != FcResultMatch) s = "Regular"; |
| 1931 |
} |
| 1932 |
else if (weight <= FC_WEIGHT_MEDIUM && slant > FC_SLANT_ROMAN) |
| 1933 |
{ |
| 1934 |
face_state[1] = TRUE; |
| 1935 |
if (res != FcResultMatch) s = "Italic"; |
| 1936 |
} |
| 1937 |
else if (weight > FC_WEIGHT_MEDIUM && slant == FC_SLANT_ROMAN) |
| 1938 |
{ |
| 1939 |
face_state[2] = TRUE; |
| 1940 |
if (res != FcResultMatch) s = "Bold"; |
| 1941 |
} |
| 1942 |
else if (weight > FC_WEIGHT_MEDIUM && slant > FC_SLANT_ROMAN) |
| 1943 |
{ |
| 1944 |
face_state[3] = TRUE; |
| 1945 |
if (res != FcResultMatch) s = "Bold Italic"; |
| 1946 |
} |
| 1947 |
|
| 1948 |
tmp_faces[num++] = create_face (fcfamily, s, FALSE); |
| 1913 |
} |
1949 |
} |
| 1914 |
|
1950 |
|
|
|
1951 |
/* we need artifical Italic face */ |
| 1952 |
if (face_state[0] && !face_state[1]) |
| 1953 |
tmp_faces[num++] = create_face (fcfamily, "Italic", TRUE); |
| 1954 |
/* we need artifical Bold face */ |
| 1955 |
if (face_state[0] && !face_state[2]) |
| 1956 |
tmp_faces[num++] = create_face (fcfamily, "Bold", TRUE); |
| 1957 |
/* we need artifical Bold Italic face */ |
| 1958 |
if ((face_state[0] || face_state[1] || face_state[2]) && !face_state[3]) |
| 1959 |
tmp_faces[num++] = create_face (fcfamily, "Bold Italic", TRUE); |
| 1960 |
|
| 1961 |
fcfamily->n_faces = num; |
| 1962 |
fcfamily->faces = g_memdup (tmp_faces, num * sizeof (PangoFontFace *)); |
| 1963 |
|
| 1964 |
g_free (tmp_faces); |
| 1965 |
|
| 1915 |
FcFontSetDestroy (fontset); |
1966 |
FcFontSetDestroy (fontset); |
| 1916 |
} |
1967 |
} |
| 1917 |
} |
1968 |
} |