diff options
author | Tor Lillqvist <tml@novell.com> | 2007-02-27 09:20:21 +0000 |
---|---|---|
committer | Tor Lillqvist <tml@src.gnome.org> | 2007-02-27 09:20:21 +0000 |
commit | b6ca70f02bdc2bcb2e978e5d2d271cb6eafa863f (patch) | |
tree | 28485b81d6406839be7013c66b3b9732a50902a6 | |
parent | 087d149c8f3051c49e9bbe9f45d59dccdbaa7ea3 (diff) | |
download | pango-b6ca70f02bdc2bcb2e978e5d2d271cb6eafa863f.tar.gz |
Fix brokenness in the code that tries to ensure that all fonts also have
2007-02-26 Tor Lillqvist <tml@novell.com>
* pango/pangowin32-fontmap.c: Fix brokenness in the code that
tries to ensure that all fonts also have italic variants. Now the
code hopefully actually does what it was supposed to. (Which is
not necessarily the right thing to do, though. It can be argued
that we should not list synthesized italic font styles, we should
just silently generate them if asked for. We don't want
synthesized italic (or synthesized bold) styles showing up in the
font selector. They don't show up when using a fontconfig-based
Pango backend either.) (#110521)
(logfont_nosize_hash, logfont_nosize_equal): Don't use the
lfItalic field as such, just its nonzeroness. When being
enumerated, italic fonts show up with lfItalic=255, but our code
looks up italic versions of fonts by passing a key LOGFONT with
lfItalic=1.
(first_match): Not needed any more, see below.
(ensure_italic): This is now called on the entries in the
size_infos hash table, not families. The code used to randomly
look for the first matching font in size_infoswith the family name
being handled.
(pango_win32_font_map_init): Iterate through the size_infos hash
table with ensure_italic, not through the families table.
* pango/pangowin32-fontcache.c
(logfont_hash, logfont_equal): Look at just nonzeroness of
lfItalic here, too.
svn path=/branches/pango-1-14/; revision=2205
-rw-r--r-- | ChangeLog | 28 | ||||
-rw-r--r-- | pango/pangowin32-fontcache.c | 4 | ||||
-rw-r--r-- | pango/pangowin32-fontmap.c | 57 |
3 files changed, 50 insertions, 39 deletions
@@ -1,3 +1,31 @@ +2007-02-26 Tor Lillqvist <tml@novell.com> + + * pango/pangowin32-fontmap.c: Fix brokenness in the code that + tries to ensure that all fonts also have italic variants. Now the + code hopefully actually does what it was supposed to. (Which is + not necessarily the right thing to do, though. It can be argued + that we should not list synthesized italic font styles, we should + just silently generate them if asked for. We don't want + synthesized italic (or synthesized bold) styles showing up in the + font selector. They don't show up when using a fontconfig-based + Pango backend either.) (#110521) + (logfont_nosize_hash, logfont_nosize_equal): Don't use the + lfItalic field as such, just its nonzeroness. When being + enumerated, italic fonts show up with lfItalic=255, but our code + looks up italic versions of fonts by passing a key LOGFONT with + lfItalic=1. + (first_match): Not needed any more, see below. + (ensure_italic): This is now called on the entries in the + size_infos hash table, not families. The code used to randomly + look for the first matching font in size_infoswith the family name + being handled. + (pango_win32_font_map_init): Iterate through the size_infos hash + table with ensure_italic, not through the families table. + + * pango/pangowin32-fontcache.c + (logfont_hash, logfont_equal): Look at just nonzeroness of + lfItalic here, too. + 2007-02-13 Owen Taylor <otaylor@redhat.com> * pango/pangowin32-fontmap.c (pango_win32_insert_font): If diff --git a/pango/pangowin32-fontcache.c b/pango/pangowin32-fontcache.c index cec852f2..3e98a074 100644 --- a/pango/pangowin32-fontcache.c +++ b/pango/pangowin32-fontcache.c @@ -92,7 +92,7 @@ logfont_hash (gconstpointer v) const LOGFONT *lfp = v; return g_str_hash (lfp->lfFaceName) + - lfp->lfItalic + + (lfp->lfItalic != 0) + lfp->lfWeight/10 + lfp->lfOrientation + abs (lfp->lfHeight) * 10; @@ -108,7 +108,7 @@ logfont_equal (gconstpointer v1, && lfp1->lfPitchAndFamily == lfp2->lfPitchAndFamily && lfp1->lfStrikeOut == lfp2->lfStrikeOut && lfp1->lfUnderline == lfp2->lfUnderline - && lfp1->lfItalic == lfp2->lfItalic + && (lfp1->lfItalic != 0) == (lfp2->lfItalic != 0) && lfp1->lfWeight == lfp2->lfWeight && lfp1->lfOrientation == lfp2->lfOrientation && lfp1->lfEscapement == lfp2->lfEscapement diff --git a/pango/pangowin32-fontmap.c b/pango/pangowin32-fontmap.c index e615d349..dd2d312e 100644 --- a/pango/pangowin32-fontmap.c +++ b/pango/pangowin32-fontmap.c @@ -124,7 +124,7 @@ case_insensitive_equal (const char *key1, static guint logfont_nosize_hash (const LOGFONT *lfp) { - return case_insensitive_hash (lfp->lfFaceName) + lfp->lfItalic + lfp->lfWeight; + return case_insensitive_hash (lfp->lfFaceName) + (lfp->lfItalic != 0) + lfp->lfWeight; } /* Ditto comparison function */ @@ -133,7 +133,7 @@ logfont_nosize_equal (const LOGFONT *lfp1, const LOGFONT *lfp2) { return (case_insensitive_equal (lfp1->lfFaceName, lfp2->lfFaceName) - && lfp1->lfItalic == lfp2->lfItalic + && (lfp1->lfItalic != 0) == (lfp2->lfItalic != 0) && lfp1->lfWeight == lfp2->lfWeight); } @@ -176,20 +176,6 @@ pango_win32_enum_proc (LOGFONT *lfp, return 1; } -static gboolean -first_match (gpointer key, - gpointer value, - gpointer user_data) -{ - LOGFONT *lfp = (LOGFONT *)key; - LOGFONT *lfp2 = (LOGFONT *)((PangoWin32SizeInfo *)value)->logfonts->data; - gchar *name = (gchar *)user_data; - - if (strcmp (lfp->lfFaceName, name) == 0 && lfp->lfWeight == lfp2->lfWeight) - return TRUE; - return FALSE; -} - typedef struct _ItalicHelper { PangoWin32FontMap *fontmap; @@ -202,30 +188,27 @@ ensure_italic (gpointer key, gpointer user_data) { ItalicHelper *helper = (ItalicHelper *)user_data; - /* PangoWin32Family *win32family = (PangoWin32Family *)value; */ + PangoWin32SizeInfo *sip = (PangoWin32SizeInfo *) value; + GSList *list = sip->logfonts; - PangoWin32SizeInfo *sip = (PangoWin32SizeInfo *)g_hash_table_find (helper->fontmap->size_infos, first_match, key); - if (sip) + while (list) { - GSList *list = sip->logfonts; - - while (list) - { - LOGFONT *lfp = (LOGFONT *)list->data; - if (!lfp->lfItalic) - { - /* we have a non italic variant, look if there is an italic */ - LOGFONT logfont = *lfp; - logfont.lfItalic = 1; - sip = (PangoWin32SizeInfo *)g_hash_table_find (helper->fontmap->size_infos, first_match, &logfont); - if (!sip) - { - /* remember the non italic variant to be added later as italic */ - helper->list = g_slist_append (helper->list, lfp); - } + LOGFONT *lfp = (LOGFONT *)list->data; + PING(("%s it=%d wt=%ld", lfp->lfFaceName, lfp->lfItalic, lfp->lfWeight)); + if (!lfp->lfItalic) + { + /* we have a non italic variant, look if there is an italic */ + LOGFONT logfont = *lfp; + logfont.lfItalic = 1; + sip = (PangoWin32SizeInfo *)g_hash_table_lookup (helper->fontmap->size_infos, &logfont); + if (!sip) + { + /* remember the non italic variant to be added later as italic */ + PING(("synthesizing italic")); + helper->list = g_slist_append (helper->list, lfp); } - list = list->next; } + list = list->next; } } @@ -253,7 +236,7 @@ pango_win32_font_map_init (PangoWin32FontMap *win32fontmap) ItalicHelper helper = { win32fontmap, NULL }; GSList *list; - g_hash_table_foreach (win32fontmap->families, ensure_italic, &helper); + g_hash_table_foreach (win32fontmap->size_infos, ensure_italic, &helper); /* cant modify while iterating */ list = helper.list; while (list) |