pango r2644 - in trunk: . pango
- From: tml svn gnome org
- To: svn-commits-list gnome org
- Subject: pango r2644 - in trunk: . pango
- Date: Tue, 27 May 2008 23:12:56 +0000 (UTC)
Author: tml
Date: Tue May 27 23:12:56 2008
New Revision: 2644
URL: http://svn.gnome.org/viewvc/pango?rev=2644&view=rev
Log:
2008-05-28 Tor Lillqvist <tml novell com>
* pango/pangowin32-fontmap.c
(pango_win32_font_description_from_logfont)
(pango_win32_font_description_from_logfontw):
Map words that indicate weight and slant in the font name into the
corresponding Pango font description settings, and strip those
words from the family name. This maps for instance the DejaVu
Sans, DejaVu Sans Condensed and DejaVu Sans Light fonts into a
single DejaVu Sans family with styles Ultra-Light, Condensed,
Oblique Condensed, Oblique, Bold Condensed, Bold, Bold Oblique
Condensed, and Bold Oblique, which is nice.
Modified:
trunk/ChangeLog
trunk/pango/pangowin32-fontmap.c
Modified: trunk/pango/pangowin32-fontmap.c
==============================================================================
--- trunk/pango/pangowin32-fontmap.c (original)
+++ trunk/pango/pangowin32-fontmap.c Tue May 27 23:12:56 2008
@@ -237,18 +237,20 @@
(win32face->logfontw.lfPitchAndFamily & 0xF0) == FF_SWISS))
return;
- if (win32face->logfontw.lfWeight > (FW_LIGHT + FW_NORMAL) / 2 &&
- win32face->logfontw.lfWeight <= (FW_NORMAL + FW_SEMIBOLD) / 2)
+ if (pango_font_description_get_weight (win32face->description) == PANGO_WEIGHT_NORMAL &&
+ pango_font_description_get_style (win32face->description) == PANGO_STYLE_NORMAL)
variant[NORMAL] = win32face;
- if (win32face->logfontw.lfWeight > (FW_NORMAL + FW_SEMIBOLD) / 2)
+ if (pango_font_description_get_weight (win32face->description) > PANGO_WEIGHT_NORMAL &&
+ pango_font_description_get_style (win32face->description) == PANGO_STYLE_NORMAL)
variant[BOLDER] = win32face;
- if (win32face->logfontw.lfItalic)
+ if (pango_font_description_get_weight (win32face->description) == PANGO_WEIGHT_NORMAL &&
+ pango_font_description_get_style (win32face->description) >= PANGO_STYLE_OBLIQUE)
variant[SLANTED] = win32face;
- if (win32face->logfontw.lfWeight >= (FW_NORMAL + FW_SEMIBOLD) / 2 &&
- win32face->logfontw.lfItalic)
+ if (pango_font_description_get_weight (win32face->description) > PANGO_WEIGHT_NORMAL &&
+ pango_font_description_get_style (win32face->description) >= PANGO_STYLE_OBLIQUE)
variant[BOLDER+SLANTED] = win32face;
p = p->next;
@@ -1067,9 +1069,63 @@
gchar *family;
PangoStyle style;
PangoVariant variant;
- PangoWeight weight;
+ PangoWeight weight, name_weight;
PangoStretch stretch;
+ static const struct {
+ const char *marker;
+ int marker_len;
+ int remove_len;
+ PangoWeight weight;
+ } weight_names[] = {
+#define ENTRY(n, s) ENTRY2 (n, sizeof (#n) - 1, s)
+#define ENTRY2(n, l, s) ENTRY3 (n, l, l, s)
+#define ENTRY3(n, marker_len, remove_len, s) { #n, marker_len, remove_len, PANGO_WEIGHT_##s }
+ ENTRY (Ultra Light, ULTRALIGHT),
+ ENTRY (UltraLight, ULTRALIGHT),
+ ENTRY (Light, LIGHT),
+ ENTRY (Medium, NORMAL),
+ ENTRY (Demi Bold, SEMIBOLD),
+ ENTRY (Demi, SEMIBOLD),
+ ENTRY (Ultra Bold, ULTRABOLD),
+ ENTRY (Extra Bold, ULTRABOLD),
+ ENTRY (SemiBold, SEMIBOLD),
+ ENTRY (DemiBold, SEMIBOLD),
+ ENTRY (UltraBold, ULTRABOLD),
+ ENTRY (ExtraBold, ULTRABOLD),
+ ENTRY (Bold, BOLD),
+ ENTRY (Heavy, HEAVY),
+ ENTRY (Black, HEAVY),
+#undef ENTRY
+#undef ENTRY2
+#undef ENTRY3
+ };
+
+ static const struct {
+ const char *marker;
+ int marker_len;
+ PangoStretch stretch;
+ } stretch_names[] = {
+#define ENTRY(n, s) { #n, sizeof (#n) - 1, PANGO_STRETCH_##s }
+ ENTRY (Ext Condensed, EXTRA_CONDENSED),
+ ENTRY (Extra Condensed, EXTRA_CONDENSED),
+ ENTRY (UltraCondensed, ULTRA_CONDENSED),
+ ENTRY (ExtraCondensed, EXTRA_CONDENSED),
+ ENTRY (Condensed, CONDENSED),
+ ENTRY (Cond, CONDENSED),
+ ENTRY (Narrow, CONDENSED),
+ ENTRY (Ext Expanded, EXTRA_EXPANDED),
+ ENTRY (Extra Expanded, EXTRA_EXPANDED),
+ ENTRY (Ultra Expanded, ULTRA_EXPANDED),
+ ENTRY (ExtraExpanded, EXTRA_EXPANDED),
+ ENTRY (UltraExpanded, ULTRA_EXPANDED),
+ ENTRY (Expanded, EXPANDED),
+#undef ENTRY
+ };
+
+ int i;
+ char *p;
+
family = get_family_nameW (lfp);
if ((lfp->lfPitchAndFamily & 0xF0) == FF_ROMAN && lfp->lfItalic)
@@ -1102,9 +1158,51 @@
else
weight = PANGO_WEIGHT_HEAVY;
- /* XXX No idea how to figure out the stretch */
+ name_weight = 0;
+
+ p = family;
+ while ((p = strchr (p, ' ')) != NULL)
+ {
+ for (i = 0; i < G_N_ELEMENTS (weight_names); i++)
+ {
+ if (g_ascii_strncasecmp (p + 1, weight_names[i].marker, weight_names[i].marker_len) == 0 &&
+ (p[1 + weight_names[i].marker_len] == '\0' ||
+ p[1 + weight_names[i].marker_len] == ' '))
+ {
+ strcpy (p, p + 1 + weight_names[i].remove_len);
+ name_weight = weight_names[i].weight;
+ break;
+ }
+ }
+ if (i < G_N_ELEMENTS (weight_names))
+ break;
+ p++;
+ }
+
+ if (weight == PANGO_WEIGHT_NORMAL && name_weight > 0)
+ weight = name_weight;
+
stretch = PANGO_STRETCH_NORMAL;
+ p = family;
+ while ((p = strchr (p, ' ')) != NULL)
+ {
+ for (i = 0; i < G_N_ELEMENTS (stretch_names); i++)
+ {
+ if (g_ascii_strncasecmp (p + 1, stretch_names[i].marker, stretch_names[i].marker_len) == 0 &&
+ (p[1 + stretch_names[i].marker_len] == '\0' ||
+ p[1 + stretch_names[i].marker_len] == ' '))
+ {
+ strcpy (p, p + 1 + stretch_names[i].marker_len);
+ stretch = stretch_names[i].stretch;
+ break;
+ }
+ }
+ if (i < G_N_ELEMENTS (stretch_names))
+ break;
+ p++;
+ }
+
description = pango_font_description_new ();
pango_font_description_set_family (description, family);
g_free(family);
@@ -1247,7 +1345,8 @@
win32family->faces = g_slist_append (win32family->faces, win32face);
- PING (("g_slist_length(win32family->faces)=%d", g_slist_length (win32family->faces)));
+ PING (("name=%s, length(faces)=%d",
+ win32family->family_name, g_slist_length (win32family->faces)));
}
/* Given a LOGFONTW and size, make a matching LOGFONTW corresponding to
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]