[pango/pango2-color-palette: 69/71] Windows: Split out code for aliases (and fallbacks)
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango2-color-palette: 69/71] Windows: Split out code for aliases (and fallbacks)
- Date: Tue, 5 Jul 2022 11:18:31 +0000 (UTC)
commit c5bd2b4ceffb6550c5a16edc8ead122b7c46aada
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Fri Jul 1 12:31:27 2022 +0800
Windows: Split out code for aliases (and fallbacks)
We want to make this code shared between the DirectWrite code and the legacy
GDI code, since we want to add aliases (and eventually, fallbacks) for all
cases, at least on Windows (well, font family names do not differ between
DirectWrite and GDI on a given Windows system :))
pango2/meson.build | 1 +
pango2/pangodwrite-fontmap.cpp | 35 ++---------------------
pango2/pangowin32-utils-private.h | 29 +++++++++++++++++++
pango2/pangowin32-utils.c | 59 +++++++++++++++++++++++++++++++++++++++
4 files changed, 91 insertions(+), 33 deletions(-)
---
diff --git a/pango2/meson.build b/pango2/meson.build
index 0a3e8d323..e0f0626db 100644
--- a/pango2/meson.build
+++ b/pango2/meson.build
@@ -170,6 +170,7 @@ if host_system == 'windows'
pango_sources += [
'pangodwrite-fontmap.cpp',
+ 'pangowin32-utils.c',
]
if cairo_dep.found()
diff --git a/pango2/pangodwrite-fontmap.cpp b/pango2/pangodwrite-fontmap.cpp
index 532c3a381..7f4ead157 100644
--- a/pango2/pangodwrite-fontmap.cpp
+++ b/pango2/pangodwrite-fontmap.cpp
@@ -29,13 +29,12 @@
#include <hb-directwrite.h>
#include "pangodwrite-fontmap.h"
-#include "pango-hbfamily-private.h"
#include "pango-fontmap-private.h"
#include "pango-hbface-private.h"
#include "pango-hbfont-private.h"
#include "pango-context.h"
-#include "pango-impl-utils.h"
#include "pango-trace-private.h"
+#include "pangowin32-utils-private.h"
/**
@@ -333,37 +332,7 @@ pango2_direct_write_font_map_populate (Pango2FontMap *map)
collection->Release ();
collection = NULL;
- /* Add generic aliases */
- struct {
- const char *alias_name;
- const char *family_name;
- } aliases[] = {
- { "Monospace", "Consolas" },
- { "Sans-serif", "Arial" },
- { "Sans", "Arial" },
- { "Serif", "Times New Roman" },
- { "System-ui", "Segoe UI" },
- { "Emoji", "Segoe UI Emoji" }
- };
-
-#if 0
- if (IsWindows11OrLater ())
- aliases[0].family_name = "Cascadia Mono";
-#endif
-
- for (gsize i = 0; i < G_N_ELEMENTS (aliases); i++)
- {
- Pango2FontFamily *family = pango2_font_map_get_family (map, aliases[i].family_name);
-
- if (family)
- {
- Pango2GenericFamily *alias_family;
-
- alias_family = pango2_generic_family_new (aliases[i].alias_name);
- pango2_generic_family_add_family (alias_family, family);
- pango2_font_map_add_family (map, PANGO2_FONT_FAMILY (alias_family));
- }
- }
+ pango2_win32_font_map_add_aliases_and_fallbacks (map);
}
/* }}} */
diff --git a/pango2/pangowin32-utils-private.h b/pango2/pangowin32-utils-private.h
new file mode 100644
index 000000000..9acebec9f
--- /dev/null
+++ b/pango2/pangowin32-utils-private.h
@@ -0,0 +1,29 @@
+/* Pango
+ * pangowin32-utils-private.h: Miscellaneous Windows-related utils
+ *
+ * Copyright (C) 2022 the GTK team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "pango-fontmap-private.h"
+
+G_BEGIN_DECLS
+
+void
+pango2_win32_font_map_add_aliases_and_fallbacks (Pango2FontMap *map);
+
+G_END_DECLS
diff --git a/pango2/pangowin32-utils.c b/pango2/pangowin32-utils.c
new file mode 100644
index 000000000..b44bf4765
--- /dev/null
+++ b/pango2/pangowin32-utils.c
@@ -0,0 +1,59 @@
+/* Pango
+ * pangowin32-utils.c: Miscellaneous Windows-related utils
+ *
+ * Copyright (C) 2022 the GTK team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "pango-impl-utils.h"
+#include "pangowin32-utils-private.h"
+
+void
+pango2_win32_font_map_add_aliases_and_fallbacks (Pango2FontMap *map)
+{
+ /* Add generic aliases */
+ struct {
+ const char *alias_name;
+ const char *family_name;
+ } aliases[] = {
+ { "Monospace", "Consolas" },
+ { "Sans-serif", "Arial" },
+ { "Sans", "Arial" },
+ { "Serif", "Times New Roman" },
+ { "System-ui", "Segoe UI" },
+ { "Emoji", "Segoe UI Emoji" }
+ };
+
+#if 0
+ if (IsWindows11OrLater ())
+ aliases[0].family_name = "Cascadia Mono";
+#endif
+
+ for (gsize i = 0; i < G_N_ELEMENTS (aliases); i++)
+ {
+ Pango2FontFamily *family = pango2_font_map_get_family (map, aliases[i].family_name);
+
+ if (family)
+ {
+ Pango2GenericFamily *alias_family;
+
+ alias_family = pango2_generic_family_new (aliases[i].alias_name);
+ pango2_generic_family_add_family (alias_family, family);
+ pango2_font_map_add_family (map, PANGO2_FONT_FAMILY (alias_family));
+ }
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]