Nikolay Sivov : dwrite: Sort localized strings by locale name.

Alexandre Julliard julliard at winehq.org
Mon Sep 23 15:22:33 CDT 2019


Module: wine
Branch: master
Commit: c435eb5c5199e06660efc5e35add3fad848b1cb0
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=c435eb5c5199e06660efc5e35add3fad848b1cb0

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Thu Sep 19 17:41:02 2019 +0300

dwrite: Sort localized strings by locale name.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dwrite/dwrite_private.h |  1 +
 dlls/dwrite/main.c           | 14 ++++++++++++++
 dlls/dwrite/opentype.c       |  3 +++
 3 files changed, 18 insertions(+)

diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h
index 32ccd63c3e..d0fed98d6f 100644
--- a/dlls/dwrite/dwrite_private.h
+++ b/dlls/dwrite/dwrite_private.h
@@ -237,6 +237,7 @@ extern HRESULT create_localizedstrings(IDWriteLocalizedStrings**) DECLSPEC_HIDDE
 extern HRESULT add_localizedstring(IDWriteLocalizedStrings*,const WCHAR*,const WCHAR*) DECLSPEC_HIDDEN;
 extern HRESULT clone_localizedstring(IDWriteLocalizedStrings *iface, IDWriteLocalizedStrings **strings) DECLSPEC_HIDDEN;
 extern void    set_en_localizedstring(IDWriteLocalizedStrings*,const WCHAR*) DECLSPEC_HIDDEN;
+extern void    sort_localizedstrings(IDWriteLocalizedStrings*) DECLSPEC_HIDDEN;
 extern HRESULT get_system_fontcollection(IDWriteFactory5*,IDWriteFontCollection1**) DECLSPEC_HIDDEN;
 extern HRESULT get_eudc_fontcollection(IDWriteFactory5*,IDWriteFontCollection1**) DECLSPEC_HIDDEN;
 extern IDWriteTextAnalyzer *get_text_analyzer(void) DECLSPEC_HIDDEN;
diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c
index 3fe2b7eaa7..fc72013feb 100644
--- a/dlls/dwrite/main.c
+++ b/dlls/dwrite/main.c
@@ -520,6 +520,20 @@ void set_en_localizedstring(IDWriteLocalizedStrings *iface, const WCHAR *string)
     }
 }
 
+static int localizedstrings_sorting_compare(const void *left, const void *right)
+{
+    const struct localizedpair *_l = left, *_r = right;
+
+    return strcmpW(_l->locale, _r->locale);
+};
+
+void sort_localizedstrings(IDWriteLocalizedStrings *iface)
+{
+    struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface);
+
+    qsort(strings->data, strings->count, sizeof(*strings->data), localizedstrings_sorting_compare);
+}
+
 struct collectionloader
 {
     struct list entry;
diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c
index fced4b0411..efae402f91 100644
--- a/dlls/dwrite/opentype.c
+++ b/dlls/dwrite/opentype.c
@@ -2010,6 +2010,9 @@ static HRESULT opentype_get_font_strings_from_id(const void *table_data, enum OP
         }
     }
 
+    if (*strings)
+        sort_localizedstrings(*strings);
+
     return exists ? S_OK : E_FAIL;
 }
 




More information about the wine-cvs mailing list