137 lines
4.2 KiB
Diff
137 lines
4.2 KiB
Diff
diff -ur pango-1.10.1.old/pango/pangofc-fontmap.c pango-1.10.1/pango/pangofc-fontmap.c
|
|
--- pango-1.10.1.old/pango/pangofc-fontmap.c 2005-07-23 06:39:27.000000000 +0800
|
|
+++ pango-1.10.1/pango/pangofc-fontmap.c 2005-10-20 14:48:52.000000000 +0800
|
|
@@ -83,6 +83,8 @@
|
|
|
|
PangoFcFamily *family;
|
|
char *style;
|
|
+
|
|
+ guint fake : 1;
|
|
};
|
|
|
|
struct _PangoFcFamily
|
|
@@ -1671,7 +1673,7 @@
|
|
FcPattern *match_pattern;
|
|
FcPattern *result_pattern;
|
|
|
|
- if (is_alias_family (fcfamily->family_name))
|
|
+ if (fcface->fake)
|
|
{
|
|
if (strcmp (fcface->style, "Regular") == 0)
|
|
return make_alias_description (fcfamily, FALSE, FALSE);
|
|
@@ -1851,11 +1853,13 @@
|
|
*/
|
|
static PangoFcFace *
|
|
create_face (PangoFcFamily *fcfamily,
|
|
- const char *style)
|
|
+ const char *style,
|
|
+ gboolean fake)
|
|
{
|
|
PangoFcFace *face = g_object_new (PANGO_FC_TYPE_FACE, NULL);
|
|
face->style = g_strdup (style);
|
|
face->family = fcfamily;
|
|
+ face->fake = fake;
|
|
|
|
return face;
|
|
}
|
|
@@ -1880,38 +1884,85 @@
|
|
fcfamily->faces = g_new (PangoFcFace *, fcfamily->n_faces);
|
|
|
|
i = 0;
|
|
- fcfamily->faces[i++] = create_face (fcfamily, "Regular");
|
|
- fcfamily->faces[i++] = create_face (fcfamily, "Bold");
|
|
- fcfamily->faces[i++] = create_face (fcfamily, "Italic");
|
|
- fcfamily->faces[i++] = create_face (fcfamily, "Bold Italic");
|
|
+ fcfamily->faces[i++] = create_face (fcfamily, "Regular", TRUE);
|
|
+ fcfamily->faces[i++] = create_face (fcfamily, "Bold", TRUE);
|
|
+ fcfamily->faces[i++] = create_face (fcfamily, "Italic", TRUE);
|
|
+ fcfamily->faces[i++] = create_face (fcfamily, "Bold Italic", TRUE);
|
|
}
|
|
else
|
|
{
|
|
- FcObjectSet *os = FcObjectSetBuild (FC_STYLE, NULL);
|
|
+ FcObjectSet *os = FcObjectSetBuild (FC_STYLE, FC_WEIGHT, FC_SLANT, NULL);
|
|
FcPattern *pat = FcPatternBuild (NULL,
|
|
FC_FAMILY, FcTypeString, fcfamily->family_name,
|
|
NULL);
|
|
-
|
|
+
|
|
+ /* Regular, Italic, Bold, Bold Italic */
|
|
+ gboolean face_state [4] = { FALSE, FALSE, FALSE, FALSE };
|
|
+ PangoFcFace **tmp_faces;
|
|
+ gint num = 0;
|
|
+
|
|
fontset = FcFontList (NULL, pat, os);
|
|
-
|
|
+
|
|
FcPatternDestroy (pat);
|
|
FcObjectSetDestroy (os);
|
|
-
|
|
- fcfamily->n_faces = fontset->nfont;
|
|
- fcfamily->faces = g_new (PangoFcFace *, fcfamily->n_faces);
|
|
-
|
|
+
|
|
+ /* at most we have 3 additional artifical faces */
|
|
+ tmp_faces = g_new (PangoFcFace *, fontset->nfont + 3);
|
|
+
|
|
for (i = 0; i < fontset->nfont; i++)
|
|
{
|
|
FcChar8 *s;
|
|
FcResult res;
|
|
|
|
+ int weight, slant;
|
|
+
|
|
+ if (FcPatternGetInteger(fontset->fonts[i], FC_WEIGHT, 0, &weight) != FcResultMatch)
|
|
+ weight = FC_WEIGHT_MEDIUM;
|
|
+
|
|
+ if (FcPatternGetInteger(fontset->fonts[i], FC_SLANT, 0, &slant) != FcResultMatch)
|
|
+ slant = FC_SLANT_ROMAN;
|
|
+
|
|
res = FcPatternGetString (fontset->fonts[i], FC_STYLE, 0, &s);
|
|
- if (res != FcResultMatch)
|
|
- s = "Regular";
|
|
|
|
- fcfamily->faces[i] = create_face (fcfamily, s);
|
|
+ if (weight <= FC_WEIGHT_MEDIUM && slant == FC_SLANT_ROMAN)
|
|
+ {
|
|
+ face_state[0] = TRUE;
|
|
+ if (res != FcResultMatch) s = "Regular";
|
|
+ }
|
|
+ else if (weight <= FC_WEIGHT_MEDIUM && slant > FC_SLANT_ROMAN)
|
|
+ {
|
|
+ face_state[1] = TRUE;
|
|
+ if (res != FcResultMatch) s = "Italic";
|
|
+ }
|
|
+ else if (weight > FC_WEIGHT_MEDIUM && slant == FC_SLANT_ROMAN)
|
|
+ {
|
|
+ face_state[2] = TRUE;
|
|
+ if (res != FcResultMatch) s = "Bold";
|
|
+ }
|
|
+ else if (weight > FC_WEIGHT_MEDIUM && slant > FC_SLANT_ROMAN)
|
|
+ {
|
|
+ face_state[3] = TRUE;
|
|
+ if (res != FcResultMatch) s = "Bold Italic";
|
|
+ }
|
|
+
|
|
+ tmp_faces[num++] = create_face (fcfamily, s, FALSE);
|
|
}
|
|
|
|
+ /* we need artifical Italic face */
|
|
+ if (face_state[0] && !face_state[1])
|
|
+ tmp_faces[num++] = create_face (fcfamily, "Italic", TRUE);
|
|
+ /* we need artifical Bold face */
|
|
+ if (face_state[0] && !face_state[2])
|
|
+ tmp_faces[num++] = create_face (fcfamily, "Bold", TRUE);
|
|
+ /* we need artifical Bold Italic face */
|
|
+ if ((face_state[0] || face_state[1] || face_state[2]) && !face_state[3])
|
|
+ tmp_faces[num++] = create_face (fcfamily, "Bold Italic", TRUE);
|
|
+
|
|
+ fcfamily->n_faces = num;
|
|
+ fcfamily->faces = g_memdup (tmp_faces, num * sizeof (PangoFontFace *));
|
|
+
|
|
+ g_free (tmp_faces);
|
|
+
|
|
FcFontSetDestroy (fontset);
|
|
}
|
|
}
|