[pango/pango2-windows: 2/2] pangowin32-utils.c: Add aliases as from Pango-1.x
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango2-windows: 2/2] pangowin32-utils.c: Add aliases as from Pango-1.x
- Date: Fri, 1 Jul 2022 04:35:47 +0000 (UTC)
commit 46a971529d7b9df4f60c92dc17f6fed1d50d7dce
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Fri Jul 1 12:33:09 2022 +0800
pangowin32-utils.c: Add aliases as from Pango-1.x
This adds more font families for the PangoFontMap for the aliases that we are
using, as per what we did in Pango-1.x, sans the families that we share for
different Unicode needs, which would be used in fallback fontmaps.
Fallbacks would be added in a later commit, when it is clearer for how to
create a PangoFontMap for that purpose.
pango2/pangowin32-utils.c | 109 +++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 103 insertions(+), 6 deletions(-)
---
diff --git a/pango2/pangowin32-utils.c b/pango2/pangowin32-utils.c
index b44bf4765..4c974c010 100644
--- a/pango2/pangowin32-utils.c
+++ b/pango2/pangowin32-utils.c
@@ -22,20 +22,114 @@
#include "pango-impl-utils.h"
#include "pangowin32-utils-private.h"
+#define MAX_ALIAS_LENGTH 11
+#define MAX_FAMILY_LENGTH 20
+
void
pango2_win32_font_map_add_aliases_and_fallbacks (Pango2FontMap *map)
{
- /* Add generic aliases */
+ /* list referred from Pango 1.x, from pangowin32-fontmap.c */
+ const char sans_families[][MAX_FAMILY_LENGTH] =
+ {"dejavu", "sans", "arial", "tahoma",
+ "arial unicode ms", "lucida sans unicode",
+ "browallia new" };
+ const char serif_families[][MAX_FAMILY_LENGTH] =
+ {"dejavu serif", "times new roman", "georgia", "angsana new"};
+ const char mono_families[][MAX_FAMILY_LENGTH] =
+ {"dejavu sans mono", "consolas", "courier new",
+ "lucida console", "courier monothai"};
+
+ /* TODO: Add when how to populate fallback fontmap is clearer */
+ const char fallback_families[][MAX_FAMILY_LENGTH] =
+ {"simsun", "simhei", "mingliu",
+ "gulimche", "ms gothic", "sylfaen",
+ "kartika", "latha", "mangal", "raavi"};
+
+ const char sans_aliases [][MAX_ALIAS_LENGTH] = {"Sans-serif", "Sans"};
+ const char mono_aliases [][MAX_ALIAS_LENGTH] = {"Mono", "Monospace"};
+
+ /* populate families for Sans and Sans-serif aliases */
+ for (gsize i = 0; i < G_N_ELEMENTS (sans_families); i++)
+ {
+ Pango2FontFamily *family = pango2_font_map_get_family (map, sans_families[i]);
+
+ if (family)
+ {
+ for (gsize j = 0; j < G_N_ELEMENTS (sans_aliases); j++)
+ {
+ Pango2GenericFamily *alias_family;
+
+ alias_family = pango2_generic_family_new (sans_aliases[j]);
+ pango2_generic_family_add_family (alias_family, family);
+ pango2_font_map_add_family (map, PANGO2_FONT_FAMILY (alias_family));
+ }
+ }
+ }
+
+ /* populate families for Serif aliases */
+ for (gsize i = 0; i < G_N_ELEMENTS (serif_families); i++)
+ {
+ Pango2FontFamily *family = pango2_font_map_get_family (map, serif_families[i]);
+
+ if (family)
+ {
+ Pango2GenericFamily *alias_family;
+
+ alias_family = pango2_generic_family_new ("Serif");
+ pango2_generic_family_add_family (alias_family, family);
+ pango2_font_map_add_family (map, PANGO2_FONT_FAMILY (alias_family));
+ }
+ }
+
+ /* populate families for Mono and Monospace aliases */
+ for (gsize i = 0; i < G_N_ELEMENTS (mono_families); i++)
+ {
+ Pango2FontFamily *family = pango2_font_map_get_family (map, mono_families[i]);
+
+ if (family)
+ {
+ for (gsize j = 0; j < G_N_ELEMENTS (mono_aliases); j++)
+ {
+ Pango2GenericFamily *alias_family;
+
+ alias_family = pango2_generic_family_new (mono_aliases[j]);
+ pango2_generic_family_add_family (alias_family, family);
+ pango2_font_map_add_family (map, PANGO2_FONT_FAMILY (alias_family));
+ }
+ }
+ }
+
+ /* TODO: populate fallback fontmap */
+#if 0
+ for (gsize i = 0; i < G_N_ELEMENTS (fallback_families); i++)
+ {
+ Pango2FontFamily *family = pango2_font_map_get_family (map->fallback, fallback_families[i]);
+
+ if (family)
+ {
+ Pango2GenericFamily *alias_family;
+
+ alias_family = pango2_generic_family_new (fallback_families[i]);
+ pango2_generic_family_add_family (alias_family, family);
+ pango2_font_map_add_family (map->fallback, PANGO2_FONT_FAMILY (alias_family));
+ }
+ }
+#endif
+
+ /* Add other 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", "Yu Gothic UI" },
{ "System-ui", "Segoe UI" },
- { "Emoji", "Segoe UI Emoji" }
+ { "System-ui", "Meiryo" },
+ { "Emoji", "Segoe UI Emoji" },
+ { "Emoji", "Segoe UI Symbol" },
+ { "Emoji", "Segoe UI" },
+ { "Cursive", "Comic Sans MS" },
+ { "Fantasy", "Gabriola" },
+ { "Fantasy", "Impact" },
};
#if 0
@@ -57,3 +151,6 @@ pango2_win32_font_map_add_aliases_and_fallbacks (Pango2FontMap *map)
}
}
}
+
+#undef MAX_ALIAS_LENGTH
+#undef MAX_FAMILY_LENGTH
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]