[4/5] gdi32: Use AddFaceToFamily when loading from cache.
Kusanagi Kouichi
slash at ac.auone-net.jp
Tue Mar 27 05:08:30 CDT 2012
Signed-off-by: Kusanagi Kouichi <slash at ac.auone-net.jp>
---
dlls/gdi32/freetype.c | 80 ++++++++++++++++++++++--------------------------
1 files changed, 37 insertions(+), 43 deletions(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index a67859f..1bedcf8 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -1203,6 +1203,42 @@ static inline LONG reg_save_dword(HKEY hkey, const WCHAR *value, DWORD data)
return RegSetValueExW(hkey, value, 0, REG_DWORD, (BYTE*)&data, sizeof(DWORD));
}
+static int StyleOrdering(const Face *face)
+{
+ switch (face->ntmFlags & (NTM_REGULAR | NTM_BOLD | NTM_ITALIC))
+ {
+ case NTM_REGULAR:
+ return 0;
+ case NTM_BOLD:
+ return 1;
+ case NTM_ITALIC:
+ return 2;
+ case NTM_BOLD | NTM_ITALIC:
+ return 3;
+ default:
+ WARN("Don't know how to order font %s %s with flags 0x%08x\n",
+ debugstr_w(face->family->FamilyName),
+ debugstr_w(face->StyleName),
+ face->ntmFlags);
+ return 9999;
+ }
+}
+
+/* Add a style of face to a font family using an ordering of the list such
+ that regular fonts come before bold and italic, and single styles come
+ before compound styles. */
+static void AddFaceToFamily(Face *face, Family *family)
+{
+ struct list *entry;
+
+ LIST_FOR_EACH( entry, &family->faces )
+ {
+ Face *ent = LIST_ENTRY(entry, Face, entry);
+ if (StyleOrdering(face) < StyleOrdering(ent)) break;
+ }
+ list_add_before( entry, &face->entry );
+}
+
static void load_face(HKEY hkey_face, WCHAR *face_name, Family *family)
{
DWORD needed;
@@ -1270,10 +1306,7 @@ static void load_face(HKEY hkey_face, WCHAR *face_name, Family *family)
face->fs.fsUsb[0], face->fs.fsUsb[1],
face->fs.fsUsb[2], face->fs.fsUsb[3]);
- if(!italic && !bold)
- list_add_head(&family->faces, &face->entry);
- else
- list_add_tail(&family->faces, &face->entry);
+ AddFaceToFamily(face, family);
TRACE("Added font %s %s\n", debugstr_w(family->FamilyName), debugstr_w(face->StyleName));
}
@@ -1440,45 +1473,6 @@ static void add_face_to_cache(Face *face)
RegCloseKey(hkey_font_cache);
}
-static inline int TestStyles(DWORD flags, DWORD styles)
-{
- return (flags & styles) == styles;
-}
-
-static int StyleOrdering(Face *face)
-{
- if (TestStyles(face->ntmFlags, NTM_BOLD | NTM_ITALIC))
- return 3;
- if (TestStyles(face->ntmFlags, NTM_ITALIC))
- return 2;
- if (TestStyles(face->ntmFlags, NTM_BOLD))
- return 1;
- if (TestStyles(face->ntmFlags, NTM_REGULAR))
- return 0;
-
- WARN("Don't know how to order font %s %s with flags 0x%08x\n",
- debugstr_w(face->family->FamilyName),
- debugstr_w(face->StyleName),
- face->ntmFlags);
-
- return 9999;
-}
-
-/* Add a style of face to a font family using an ordering of the list such
- that regular fonts come before bold and italic, and single styles come
- before compound styles. */
-static void AddFaceToFamily(Face *face, Family *family)
-{
- struct list *entry;
-
- LIST_FOR_EACH( entry, &family->faces )
- {
- Face *ent = LIST_ENTRY(entry, Face, entry);
- if (StyleOrdering(face) < StyleOrdering(ent)) break;
- }
- list_add_before( entry, &face->entry );
-}
-
static WCHAR *prepend_at(WCHAR *family)
{
WCHAR *str;
--
1.7.9.1
More information about the wine-patches
mailing list