Commit d60cd1f4 authored by Matthias Clasen's avatar Matthias Clasen

font chooser: Add font features

Populate the tweak page with OpenType font features.
parent b57e10ad
......@@ -1438,6 +1438,7 @@ GLIB_PREFIX="`$PKG_CONFIG --variable=prefix glib-2.0`"
ATK_PREFIX="`$PKG_CONFIG --variable=prefix atk`"
PANGO_PREFIX="`$PKG_CONFIG --variable=prefix pango`"
CAIRO_PREFIX="`$PKG_CONFIG --variable=prefix cairo`"
ISO_CODES_PREFIX="`$PKG_CONFIG --variable=prefix iso-codes`"
AC_SUBST(GTK_PACKAGES)
AC_SUBST(GTK_PRIVATE_PACKAGES)
......@@ -1451,6 +1452,7 @@ AC_SUBST(GLIB_PREFIX)
AC_SUBST(ATK_PREFIX)
AC_SUBST(PANGO_PREFIX)
AC_SUBST(CAIRO_PREFIX)
AC_SUBST(ISO_CODES_PREFIX)
AC_SUBST(GTK_DEBUG_FLAGS)
AC_SUBST(GTK_XIM_FLAGS)
......@@ -1746,6 +1748,10 @@ PKG_CHECK_MODULES(FONTDEMO, harfbuzz >= 0.9 pangoft2, build_font_demo=yes, build
AC_SUBST(FONTDEMO_CFLAGS)
AC_SUBST(FONTDEMO_LIBS)
AM_CONDITIONAL(BUILD_FONT_DEMO, [ test "x$build_font_demo" = xyes ])
if test "x$build_font_demo" = xyes; then
AC_DEFINE([HAVE_HARFBUZZ], 1, [defines whether we have HarfBuzz])
AC_DEFINE([HAVE_PANGOFT], 1, [defines whether we have pangoft2])
fi
##################################################
# Checks for gtk-doc and docbook-tools
......
......@@ -23,6 +23,7 @@ AM_CPPFLAGS = \
$(GTK_BASE_CFLAGS_DEFINES) \
$(GTK_PLAT_CFLAGS_DEFINES) \
-DX11_DATA_PREFIX=\"$(X11_PREFIX)\" \
-DISO_CODES_PREFIX=\"$(ISO_CODES_PREFIX)\" \
-I$(top_builddir) \
-I$(top_builddir)/gtk \
-I$(top_srcdir) \
......@@ -953,7 +954,9 @@ gtk_base_c_sources = \
gtkwindowgroup.c \
gtkwin32draw.c \
gtkwin32theme.c \
gdkpixbufutils.c
gdkpixbufutils.c \
language-names.c \
script-names.c
if USE_QUARTZ
gtk_base_c_sources += \
......
......@@ -49,6 +49,7 @@ typedef gboolean (*GtkFontFilterFunc) (const PangoFontFamily *family,
* @GTK_FONT_CHOOSER_LEVEL_FAMILY: Allow selecting a font family
* @GTK_FONT_CHOOSER_LEVEL_STYLE: Allow selecting a specific font face
* @GTK_FONT_CHOOSER_LEVEL_SIZE: Allow selecting a specific font size
* @GTK_FONT_CHOOSER_LEVEL_FEATURES: Allow selecting specific OpenType font features
*
* This enumeration specifies the granularity of font selection
* that is desired in a font chooser.
......@@ -57,9 +58,10 @@ typedef gboolean (*GtkFontFilterFunc) (const PangoFontFamily *family,
* ignore unknown values.
*/
typedef enum {
GTK_FONT_CHOOSER_LEVEL_FAMILY = 0,
GTK_FONT_CHOOSER_LEVEL_STYLE = 1 << 0,
GTK_FONT_CHOOSER_LEVEL_SIZE = 1 << 1
GTK_FONT_CHOOSER_LEVEL_FAMILY = 0,
GTK_FONT_CHOOSER_LEVEL_STYLE = 1 << 0,
GTK_FONT_CHOOSER_LEVEL_SIZE = 1 << 1,
GTK_FONT_CHOOSER_LEVEL_FEATURES = 1 << 2
} GtkFontChooserLevel;
#define GTK_TYPE_FONT_CHOOSER (gtk_font_chooser_get_type ())
......
......@@ -142,6 +142,21 @@ gtk_font_chooser_dialog_key_press_event (GtkWidget *dialog,
return handled;
}
static void
update_tweak_button (GtkFontChooserDialog *dialog)
{
GtkFontChooserLevel level;
if (!dialog->priv->tweak_button)
return;
g_object_get (dialog->priv->fontchooser, "level", &level, NULL);
if ((level & GTK_FONT_CHOOSER_LEVEL_FEATURES) != 0)
gtk_widget_show (dialog->priv->tweak_button);
else
gtk_widget_hide (dialog->priv->tweak_button);
}
static void
setup_tweak_button (GtkFontChooserDialog *dialog)
{
......@@ -164,7 +179,6 @@ setup_tweak_button (GtkFontChooserDialog *dialog)
g_object_unref (actions);
button = gtk_toggle_button_new ();
gtk_widget_show (button);
gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "font.tweak");
gtk_widget_set_focus_on_click (button, FALSE);
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
......@@ -177,6 +191,7 @@ setup_tweak_button (GtkFontChooserDialog *dialog)
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
dialog->priv->tweak_button = button;
update_tweak_button (dialog);
}
}
......@@ -252,6 +267,9 @@ G_GNUC_END_IGNORE_DEPRECATIONS
g_signal_connect_swapped (priv->fontchooser, "notify::font-desc",
G_CALLBACK (update_button), fontchooserdiag);
update_button (fontchooserdiag);
g_signal_connect_swapped (priv->fontchooser, "notify::level",
G_CALLBACK (update_tweak_button), fontchooserdiag);
}
/**
......
This diff is collapsed.
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <dirent.h>
#include <locale.h>
#include <langinfo.h>
#include <sys/stat.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
#include <hb-ot.h>
#include "language-names.h"
#define ISO_CODES_DATADIR ISO_CODES_PREFIX "/share/xml/iso-codes"
#define ISO_CODES_LOCALESDIR ISO_CODES_PREFIX "/share/locale"
static GHashTable *language_map;
static char *
get_first_item_in_semicolon_list (const char *list)
{
char **items;
char *item;
items = g_strsplit (list, "; ", 2);
item = g_strdup (items[0]);
g_strfreev (items);
return item;
}
static char *
capitalize_utf8_string (const char *str)
{
char first[8] = { 0 };
if (!str)
return NULL;
g_unichar_to_utf8 (g_unichar_totitle (g_utf8_get_char (str)), first);
return g_strconcat (first, g_utf8_offset_to_pointer (str, 1), NULL);
}
static char *
get_display_name (const char *language)
{
const char *translated;
char *tmp;
char *name;
translated = dgettext ("iso_639", language);
tmp = get_first_item_in_semicolon_list (translated);
name = capitalize_utf8_string (tmp);
g_free (tmp);
return name;
}
static void
languages_parse_start_tag (GMarkupParseContext *ctx,
const char *element_name,
const char **attr_names,
const char **attr_values,
gpointer user_data,
GError **error)
{
const char *ccode_longB;
const char *ccode_longT;
const char *ccode;
const char *ccode_id;
const char *lang_name;
char *display_name;
if (!(g_str_equal (element_name, "iso_639_entry") ||
g_str_equal (element_name, "iso_639_3_entry")) ||
attr_names == NULL ||
attr_values == NULL)
return;
ccode = NULL;
ccode_longB = NULL;
ccode_longT = NULL;
ccode_id = NULL;
lang_name = NULL;
while (*attr_names && *attr_values)
{
if (g_str_equal (*attr_names, "iso_639_1_code"))
{
if (**attr_values)
{
if (strlen (*attr_values) != 2)
return;
ccode = *attr_values;
}
}
else if (g_str_equal (*attr_names, "iso_639_2B_code"))
{
if (**attr_values)
{
if (strlen (*attr_values) != 3)
return;
ccode_longB = *attr_values;
}
}
else if (g_str_equal (*attr_names, "iso_639_2T_code"))
{
if (**attr_values)
{
if (strlen (*attr_values) != 3)
return;
ccode_longT = *attr_values;
}
}
else if (g_str_equal (*attr_names, "id"))
{
if (**attr_values)
{
if (strlen (*attr_values) != 2 &&
strlen (*attr_values) != 3)
return;
ccode_id = *attr_values;
}
}
else if (g_str_equal (*attr_names, "name"))
{
lang_name = *attr_values;
}
++attr_names;
++attr_values;
}
if (lang_name == NULL)
return;
display_name = get_display_name (lang_name);
if (ccode != NULL)
g_hash_table_insert (language_map,
pango_language_from_string (ccode),
g_strdup (display_name));
if (ccode_longB != NULL)
g_hash_table_insert (language_map,
pango_language_from_string (ccode_longB),
g_strdup (display_name));
if (ccode_longT != NULL)
g_hash_table_insert (language_map,
pango_language_from_string (ccode_longT),
g_strdup (display_name));
if (ccode_id != NULL)
g_hash_table_insert (language_map,
pango_language_from_string (ccode_id),
g_strdup (display_name));
g_free (display_name);
}
static void
languages_variant_init (const char *variant)
{
gboolean res;
gsize buf_len;
g_autofree char *buf = NULL;
g_autofree char *filename = NULL;
g_autoptr (GError) error = NULL;
bindtextdomain (variant, ISO_CODES_LOCALESDIR);
bind_textdomain_codeset (variant, "UTF-8");
error = NULL;
filename = g_strconcat (ISO_CODES_DATADIR, "/", variant, ".xml", NULL);
res = g_file_get_contents (filename, &buf, &buf_len, &error);
if (res)
{
g_autoptr (GMarkupParseContext) ctx = NULL;
GMarkupParser parser = { languages_parse_start_tag, NULL, NULL, NULL, NULL };
ctx = g_markup_parse_context_new (&parser, 0, NULL, NULL);
error = NULL;
res = g_markup_parse_context_parse (ctx, buf, buf_len, &error);
if (!res)
g_warning ("Failed to parse '%s': %s\n", filename, error->message);
}
else
g_warning ("Failed to load '%s': %s\n", filename, error->message);
}
static void
languages_init (void)
{
if (language_map)
return;
language_map = g_hash_table_new_full (NULL, NULL, NULL, g_free);
languages_variant_init ("iso_639");
languages_variant_init ("iso_639_3");
}
const char *
get_language_name (PangoLanguage *language)
{
languages_init ();
return (const char *) g_hash_table_lookup (language_map, language);
}
const char *
get_language_name_for_tag (guint32 tag)
{
hb_language_t lang;
const char *s;
lang = hb_ot_tag_to_language (tag);
s = hb_language_to_string (lang);
return get_language_name (pango_language_from_string (s));
}
#ifndef LANGUAGE_NAMES_H
#define LANGUAGE_NAMES_H
#include <pango/pango.h>
G_BEGIN_DECLS
const char * get_language_name (PangoLanguage *language);
const char * get_language_name_for_tag (guint32 tag);
G_END_DECLS
#endif
/* Registered OpenType layout tags, see
* https://www.microsoft.com/typography/otspec/featuretags.htm
*/
typedef struct {
unsigned int tag;
const char *name;
} NamedTag;
#define MAKE_TAG(a,b,c,d) (unsigned int)(((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
static NamedTag open_type_layout_features[] = {
{ MAKE_TAG('a','a','l','t'), NC_("OpenType layout", "Access All Alternates") },
{ MAKE_TAG('a','b','v','f'), NC_("OpenType layout", "Above-base Forms") },
{ MAKE_TAG('a','b','v','m'), NC_("OpenType layout", "Above-base Mark Positioning") },
{ MAKE_TAG('a','b','v','s'), NC_("OpenType layout", "Above-base Substitutions") },
{ MAKE_TAG('a','f','r','c'), NC_("OpenType layout", "Alternative Fractions") },
{ MAKE_TAG('a','k','h','n'), NC_("OpenType layout", "Akhands") },
{ MAKE_TAG('b','l','w','f'), NC_("OpenType layout", "Below-base Forms") },
{ MAKE_TAG('b','l','w','m'), NC_("OpenType layout", "Below-base Mark Positioning") },
{ MAKE_TAG('b','l','w','s'), NC_("OpenType layout", "Below-base Substitutions") },
{ MAKE_TAG('c','a','l','t'), NC_("OpenType layout", "Contextual Alternates") },
{ MAKE_TAG('c','a','s','e'), NC_("OpenType layout", "Case-Sensitive Forms") },
{ MAKE_TAG('c','c','m','p'), NC_("OpenType layout", "Glyph Composition / Decomposition") },
{ MAKE_TAG('c','f','a','r'), NC_("OpenType layout", "Conjunct Form After Ro") },
{ MAKE_TAG('c','j','c','t'), NC_("OpenType layout", "Conjunct Forms") },
{ MAKE_TAG('c','l','i','g'), NC_("OpenType layout", "Contextual Ligatures") },
{ MAKE_TAG('c','p','c','t'), NC_("OpenType layout", "Centered CJK Punctuation") },
{ MAKE_TAG('c','p','s','p'), NC_("OpenType layout", "Capital Spacing") },
{ MAKE_TAG('c','s','w','h'), NC_("OpenType layout", "Contextual Swash") },
{ MAKE_TAG('c','u','r','s'), NC_("OpenType layout", "Cursive Positioning") },
{ MAKE_TAG('c','2','p','c'), NC_("OpenType layout", "Petite Capitals From Capitals") },
{ MAKE_TAG('c','2','s','c'), NC_("OpenType layout", "Small Capitals From Capitals") },
{ MAKE_TAG('d','i','s','t'), NC_("OpenType layout", "Distances") },
{ MAKE_TAG('d','l','i','g'), NC_("OpenType layout", "Discretionary Ligatures") },
{ MAKE_TAG('d','n','o','m'), NC_("OpenType layout", "Denominators") },
{ MAKE_TAG('d','t','l','s'), NC_("OpenType layout", "Dotless Forms") },
{ MAKE_TAG('e','x','p','t'), NC_("OpenType layout", "Expert Forms") },
{ MAKE_TAG('f','a','l','t'), NC_("OpenType layout", "Final Glyph on Line Alternates") },
{ MAKE_TAG('f','i','n','2'), NC_("OpenType layout", "Terminal Forms #2") },
{ MAKE_TAG('f','i','n','3'), NC_("OpenType layout", "Terminal Forms #3") },
{ MAKE_TAG('f','i','n','a'), NC_("OpenType layout", "Terminal Forms") },
{ MAKE_TAG('f','l','a','c'), NC_("OpenType layout", "Flattened accent forms") },
{ MAKE_TAG('f','r','a','c'), NC_("OpenType layout", "Fractions") },
{ MAKE_TAG('f','w','i','d'), NC_("OpenType layout", "Full Widths") },
{ MAKE_TAG('h','a','l','f'), NC_("OpenType layout", "Half Forms") },
{ MAKE_TAG('h','a','l','n'), NC_("OpenType layout", "Halant Forms") },
{ MAKE_TAG('h','a','l','t'), NC_("OpenType layout", "Alternate Half Widths") },
{ MAKE_TAG('h','i','s','t'), NC_("OpenType layout", "Historical Forms") },
{ MAKE_TAG('h','k','n','a'), NC_("OpenType layout", "Horizontal Kana Alternates") },
{ MAKE_TAG('h','l','i','g'), NC_("OpenType layout", "Historical Ligatures") },
{ MAKE_TAG('h','n','g','l'), NC_("OpenType layout", "Hangul") },
{ MAKE_TAG('h','o','j','o'), NC_("OpenType layout", "Hojo Kanji Forms") },
{ MAKE_TAG('h','w','i','d'), NC_("OpenType layout", "Half Widths") },
{ MAKE_TAG('i','n','i','t'), NC_("OpenType layout", "Initial Forms") },
{ MAKE_TAG('i','s','o','l'), NC_("OpenType layout", "Isolated Forms") },
{ MAKE_TAG('i','t','a','l'), NC_("OpenType layout", "Italics") },
{ MAKE_TAG('j','a','l','t'), NC_("OpenType layout", "Justification Alternates") },
{ MAKE_TAG('j','p','7','8'), NC_("OpenType layout", "JIS78 Forms") },
{ MAKE_TAG('j','p','8','3'), NC_("OpenType layout", "JIS83 Forms") },
{ MAKE_TAG('j','p','9','0'), NC_("OpenType layout", "JIS90 Forms") },
{ MAKE_TAG('j','p','0','4'), NC_("OpenType layout", "JIS2004 Forms") },
{ MAKE_TAG('k','e','r','n'), NC_("OpenType layout", "Kerning") },
{ MAKE_TAG('l','f','b','d'), NC_("OpenType layout", "Left Bounds") },
{ MAKE_TAG('l','i','g','a'), NC_("OpenType layout", "Standard Ligatures") },
{ MAKE_TAG('l','j','m','o'), NC_("OpenType layout", "Leading Jamo Forms") },
{ MAKE_TAG('l','n','u','m'), NC_("OpenType layout", "Lining Figures") },
{ MAKE_TAG('l','o','c','l'), NC_("OpenType layout", "Localized Forms") },
{ MAKE_TAG('l','t','r','a'), NC_("OpenType layout", "Left-to-right alternates") },
{ MAKE_TAG('l','t','r','m'), NC_("OpenType layout", "Left-to-right mirrored forms") },
{ MAKE_TAG('m','a','r','k'), NC_("OpenType layout", "Mark Positioning") },
{ MAKE_TAG('m','e','d','2'), NC_("OpenType layout", "Medial Forms #2") },
{ MAKE_TAG('m','e','d','i'), NC_("OpenType layout", "Medial Forms") },
{ MAKE_TAG('m','g','r','k'), NC_("OpenType layout", "Mathematical Greek") },
{ MAKE_TAG('m','k','m','k'), NC_("OpenType layout", "Mark to Mark Positioning") },
{ MAKE_TAG('m','s','e','t'), NC_("OpenType layout", "Mark Positioning via Substitution") },
{ MAKE_TAG('n','a','l','t'), NC_("OpenType layout", "Alternate Annotation Forms") },
{ MAKE_TAG('n','l','c','k'), NC_("OpenType layout", "NLC Kanji Forms") },
{ MAKE_TAG('n','u','k','t'), NC_("OpenType layout", "Nukta Forms") },
{ MAKE_TAG('n','u','m','r'), NC_("OpenType layout", "Numerators") },
{ MAKE_TAG('o','n','u','m'), NC_("OpenType layout", "Oldstyle Figures") },
{ MAKE_TAG('o','p','b','d'), NC_("OpenType layout", "Optical Bounds") },
{ MAKE_TAG('o','r','d','n'), NC_("OpenType layout", "Ordinals") },
{ MAKE_TAG('o','r','n','m'), NC_("OpenType layout", "Ornaments") },
{ MAKE_TAG('p','a','l','t'), NC_("OpenType layout", "Proportional Alternate Widths") },
{ MAKE_TAG('p','c','a','p'), NC_("OpenType layout", "Petite Capitals") },
{ MAKE_TAG('p','k','n','a'), NC_("OpenType layout", "Proportional Kana") },
{ MAKE_TAG('p','n','u','m'), NC_("OpenType layout", "Proportional Figures") },
{ MAKE_TAG('p','r','e','f'), NC_("OpenType layout", "Pre-Base Forms") },
{ MAKE_TAG('p','r','e','s'), NC_("OpenType layout", "Pre-base Substitutions") },
{ MAKE_TAG('p','s','t','f'), NC_("OpenType layout", "Post-base Forms") },
{ MAKE_TAG('p','s','t','s'), NC_("OpenType layout", "Post-base Substitutions") },
{ MAKE_TAG('p','w','i','d'), NC_("OpenType layout", "Proportional Widths") },
{ MAKE_TAG('q','w','i','d'), NC_("OpenType layout", "Quarter Widths") },
{ MAKE_TAG('r','a','n','d'), NC_("OpenType layout", "Randomize") },
{ MAKE_TAG('r','c','l','t'), NC_("OpenType layout", "Required Contextual Alternates") },
{ MAKE_TAG('r','k','r','f'), NC_("OpenType layout", "Rakar Forms") },
{ MAKE_TAG('r','l','i','g'), NC_("OpenType layout", "Required Ligatures") },
{ MAKE_TAG('r','p','h','f'), NC_("OpenType layout", "Reph Forms") },
{ MAKE_TAG('r','t','b','d'), NC_("OpenType layout", "Right Bounds") },
{ MAKE_TAG('r','t','l','a'), NC_("OpenType layout", "Right-to-left alternates") },
{ MAKE_TAG('r','t','l','m'), NC_("OpenType layout", "Right-to-left mirrored forms") },
{ MAKE_TAG('r','u','b','y'), NC_("OpenType layout", "Ruby Notation Forms") },
{ MAKE_TAG('r','v','r','n'), NC_("OpenType layout", "Required Variation Alternates") },
{ MAKE_TAG('s','a','l','t'), NC_("OpenType layout", "Stylistic Alternates") },
{ MAKE_TAG('s','i','n','f'), NC_("OpenType layout", "Scientific Inferiors") },
{ MAKE_TAG('s','i','z','e'), NC_("OpenType layout", "Optical size") },
{ MAKE_TAG('s','m','c','p'), NC_("OpenType layout", "Small Capitals") },
{ MAKE_TAG('s','m','p','l'), NC_("OpenType layout", "Simplified Forms") },
{ MAKE_TAG('s','s','0','1'), NC_("OpenType layout", "Stylistic Set 1") },
{ MAKE_TAG('s','s','0','2'), NC_("OpenType layout", "Stylistic Set 2") },
{ MAKE_TAG('s','s','0','3'), NC_("OpenType layout", "Stylistic Set 3") },
{ MAKE_TAG('s','s','0','4'), NC_("OpenType layout", "Stylistic Set 4") },
{ MAKE_TAG('s','s','0','5'), NC_("OpenType layout", "Stylistic Set 5") },
{ MAKE_TAG('s','s','0','6'), NC_("OpenType layout", "Stylistic Set 6") },
{ MAKE_TAG('s','s','0','7'), NC_("OpenType layout", "Stylistic Set 7") },
{ MAKE_TAG('s','s','0','8'), NC_("OpenType layout", "Stylistic Set 8") },
{ MAKE_TAG('s','s','0','9'), NC_("OpenType layout", "Stylistic Set 9") },
{ MAKE_TAG('s','s','1','0'), NC_("OpenType layout", "Stylistic Set 10") },
{ MAKE_TAG('s','s','1','1'), NC_("OpenType layout", "Stylistic Set 11") },
{ MAKE_TAG('s','s','1','2'), NC_("OpenType layout", "Stylistic Set 12") },
{ MAKE_TAG('s','s','1','3'), NC_("OpenType layout", "Stylistic Set 13") },
{ MAKE_TAG('s','s','1','4'), NC_("OpenType layout", "Stylistic Set 14") },
{ MAKE_TAG('s','s','1','5'), NC_("OpenType layout", "Stylistic Set 15") },
{ MAKE_TAG('s','s','1','6'), NC_("OpenType layout", "Stylistic Set 16") },
{ MAKE_TAG('s','s','1','7'), NC_("OpenType layout", "Stylistic Set 17") },
{ MAKE_TAG('s','s','1','8'), NC_("OpenType layout", "Stylistic Set 18") },
{ MAKE_TAG('s','s','1','9'), NC_("OpenType layout", "Stylistic Set 19") },
{ MAKE_TAG('s','s','2','0'), NC_("OpenType layout", "Stylistic Set 20") },
{ MAKE_TAG('s','s','t','y'), NC_("OpenType layout", "Math script style alternates") },
{ MAKE_TAG('s','t','c','h'), NC_("OpenType layout", "Stretching Glyph Decomposition") },
{ MAKE_TAG('s','u','b','s'), NC_("OpenType layout", "Subscript") },
{ MAKE_TAG('s','u','p','s'), NC_("OpenType layout", "Superscript") },
{ MAKE_TAG('s','w','s','h'), NC_("OpenType layout", "Swash") },
{ MAKE_TAG('t','i','t','l'), NC_("OpenType layout", "Titling") },
{ MAKE_TAG('t','j','m','o'), NC_("OpenType layout", "Trailing Jamo Forms") },
{ MAKE_TAG('t','n','a','m'), NC_("OpenType layout", "Traditional Name Forms") },
{ MAKE_TAG('t','n','u','m'), NC_("OpenType layout", "Tabular Figures") },
{ MAKE_TAG('t','r','a','d'), NC_("OpenType layout", "Traditional Forms") },
{ MAKE_TAG('t','w','i','d'), NC_("OpenType layout", "Third Widths") },
{ MAKE_TAG('u','n','i','c'), NC_("OpenType layout", "Unicase") },
{ MAKE_TAG('v','a','l','t'), NC_("OpenType layout", "Alternate Vertical Metrics") },
{ MAKE_TAG('v','a','t','u'), NC_("OpenType layout", "Vattu Variants") },
{ MAKE_TAG('v','e','r','t'), NC_("OpenType layout", "Vertical Writing") },
{ MAKE_TAG('v','h','a','l'), NC_("OpenType layout", "Alternate Vertical Half Metrics") },
{ MAKE_TAG('v','j','m','o'), NC_("OpenType layout", "Vowel Jamo Forms") },
{ MAKE_TAG('v','k','n','a'), NC_("OpenType layout", "Vertical Kana Alternates") },
{ MAKE_TAG('v','k','r','n'), NC_("OpenType layout", "Vertical Kerning") },
{ MAKE_TAG('v','p','a','l'), NC_("OpenType layout", "Proportional Alternate Vertical Metrics") },
{ MAKE_TAG('v','r','t','2'), NC_("OpenType layout", "Vertical Alternates and Rotation") },
{ MAKE_TAG('v','r','t','r'), NC_("OpenType layout", "Vertical Alternates for Rotation") },
{ MAKE_TAG('z','e','r','o'), NC_("OpenType layout", "Slashed Zero") },
};
#undef MAKE_TAG
</
#include "config.h"
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <hb-ot.h>
#include "script-names.h"
static struct {
GUnicodeScript script;
hb_script_t hb_script;
const char *name;
} scripts[] =
{
{ G_UNICODE_SCRIPT_COMMON, HB_SCRIPT_COMMON, NULL },
{ G_UNICODE_SCRIPT_INHERITED, HB_SCRIPT_INHERITED, NULL },
{ G_UNICODE_SCRIPT_ARABIC, HB_SCRIPT_ARABIC, NC_("Script", "Arabic") },
{ G_UNICODE_SCRIPT_ARMENIAN, HB_SCRIPT_ARMENIAN, NC_("Script", "Armenian") },
{ G_UNICODE_SCRIPT_BENGALI, HB_SCRIPT_BENGALI, NC_("Script", "Bengali") },
{ G_UNICODE_SCRIPT_BOPOMOFO, HB_SCRIPT_BOPOMOFO, NC_("Script", "Bopomofo") },
{ G_UNICODE_SCRIPT_CHEROKEE, HB_SCRIPT_CHEROKEE, NC_("Script", "Cherokee") },
{ G_UNICODE_SCRIPT_COPTIC, HB_SCRIPT_COPTIC, NC_("Script", "Coptic") },
{ G_UNICODE_SCRIPT_CYRILLIC, HB_SCRIPT_CYRILLIC, NC_("Script", "Cyrillic") },
{ G_UNICODE_SCRIPT_DESERET, HB_SCRIPT_DESERET, NC_("Script", "Deseret") },
{ G_UNICODE_SCRIPT_DEVANAGARI, HB_SCRIPT_DEVANAGARI, NC_("Script", "Devanagari") },
{ G_UNICODE_SCRIPT_ETHIOPIC, HB_SCRIPT_ETHIOPIC, NC_("Script", "Ethiopic") },
{ G_UNICODE_SCRIPT_GEORGIAN, HB_SCRIPT_GEORGIAN, NC_("Script", "Georgian") },
{ G_UNICODE_SCRIPT_GOTHIC, HB_SCRIPT_GOTHIC, NC_("Script", "Gothic") },
{ G_UNICODE_SCRIPT_GREEK, HB_SCRIPT_GREEK, NC_("Script", "Greek") },
{ G_UNICODE_SCRIPT_GUJARATI, HB_SCRIPT_GUJARATI, NC_("Script", "Gujarati") },
{ G_UNICODE_SCRIPT_GURMUKHI, HB_SCRIPT_GURMUKHI, NC_("Script", "Gurmukhi") },
{ G_UNICODE_SCRIPT_HAN, HB_SCRIPT_HAN, NC_("Script", "Han") },
{ G_UNICODE_SCRIPT_HANGUL, HB_SCRIPT_HANGUL, NC_("Script", "Hangul") },
{ G_UNICODE_SCRIPT_HEBREW, HB_SCRIPT_HEBREW, NC_("Script", "Hebrew") },
{ G_UNICODE_SCRIPT_HIRAGANA, HB_SCRIPT_HIRAGANA, NC_("Script", "Hiragana") },
{ G_UNICODE_SCRIPT_KANNADA, HB_SCRIPT_KANNADA, NC_("Script", "Kannada") },
{ G_UNICODE_SCRIPT_KATAKANA, HB_SCRIPT_KATAKANA, NC_("Script", "Katakana") },
{ G_UNICODE_SCRIPT_KHMER, HB_SCRIPT_KHMER, NC_("Script", "Khmer") },
{ G_UNICODE_SCRIPT_LAO, HB_SCRIPT_LAO, NC_("Script", "Lao") },
{ G_UNICODE_SCRIPT_LATIN, HB_SCRIPT_LATIN, NC_("Script", "Latin") },
{ G_UNICODE_SCRIPT_MALAYALAM, HB_SCRIPT_MALAYALAM, NC_("Script", "Malayalam") },
{ G_UNICODE_SCRIPT_MONGOLIAN, HB_SCRIPT_MONGOLIAN, NC_("Script", "Mongolian") },
{ G_UNICODE_SCRIPT_MYANMAR, HB_SCRIPT_MYANMAR, NC_("Script", "Myanmar") },
{ G_UNICODE_SCRIPT_OGHAM, HB_SCRIPT_OGHAM, NC_("Script", "Ogham") },
{ G_UNICODE_SCRIPT_OLD_ITALIC, HB_SCRIPT_OLD_ITALIC, NC_("Script", "Old Italic") },
{ G_UNICODE_SCRIPT_ORIYA, HB_SCRIPT_ORIYA, NC_("Script", "Oriya") },
{ G_UNICODE_SCRIPT_RUNIC, HB_SCRIPT_RUNIC, NC_("Script", "Runic") },
{ G_UNICODE_SCRIPT_SINHALA, HB_SCRIPT_SINHALA, NC_("Script", "Sinhala") },
{ G_UNICODE_SCRIPT_SYRIAC, HB_SCRIPT_SYRIAC, NC_("Script", "Syriac") },
{ G_UNICODE_SCRIPT_TAMIL, HB_SCRIPT_TAMIL, NC_("Script", "Tamil") },
{ G_UNICODE_SCRIPT_TELUGU, HB_SCRIPT_TELUGU, NC_("Script", "Telugu") },
{ G_UNICODE_SCRIPT_THAANA, HB_SCRIPT_THAANA, NC_("Script", "Thaana") },
{ G_UNICODE_SCRIPT_THAI, HB_SCRIPT_THAI, NC_("Script", "Thai") },
{ G_UNICODE_SCRIPT_TIBETAN, HB_SCRIPT_TIBETAN, NC_("Script", "Tibetan") },
{ G_UNICODE_SCRIPT_CANADIAN_ABORIGINAL, HB_SCRIPT_CANADIAN_ABORIGINAL, NC_("Script", "Canadian Aboriginal") },
{ G_UNICODE_SCRIPT_YI, HB_SCRIPT_YI, NC_("Script", "Yi") },
{ G_UNICODE_SCRIPT_TAGALOG, HB_SCRIPT_TAGALOG, NC_("Script", "Tagalog") },
{ G_UNICODE_SCRIPT_HANUNOO, HB_SCRIPT_HANUNOO, NC_("Script", "Hanunoo") },
{ G_UNICODE_SCRIPT_BUHID, HB_SCRIPT_BUHID, NC_("Script", "Buhid") },
{ G_UNICODE_SCRIPT_TAGBANWA, HB_SCRIPT_TAGBANWA, NC_("Script", "Tagbanwa") },
{ G_UNICODE_SCRIPT_BRAILLE, HB_SCRIPT_BRAILLE, NC_("Script", "Braille") },
{ G_UNICODE_SCRIPT_CYPRIOT, HB_SCRIPT_CYPRIOT, NC_("Script", "Cypriot") },
{ G_UNICODE_SCRIPT_LIMBU, HB_SCRIPT_LIMBU, NC_("Script", "Limbu") },
{ G_UNICODE_SCRIPT_OSMANYA, HB_SCRIPT_OSMANYA, NC_("Script", "Osmanya") },
{ G_UNICODE_SCRIPT_SHAVIAN, HB_SCRIPT_SHAVIAN, NC_("Script", "Shavian") },
{ G_UNICODE_SCRIPT_LINEAR_B, HB_SCRIPT_LINEAR_B, NC_("Script", "Linear B") },
{ G_UNICODE_SCRIPT_TAI_LE, HB_SCRIPT_TAI_LE, NC_("Script", "Tai Le") },
{ G_UNICODE_SCRIPT_UGARITIC, HB_SCRIPT_UGARITIC, NC_("Script", "Ugaritic") },
{ G_UNICODE_SCRIPT_NEW_TAI_LUE, HB_SCRIPT_NEW_TAI_LUE, NC_("Script", "New Tai Lue") },
{ G_UNICODE_SCRIPT_BUGINESE, HB_SCRIPT_BUGINESE, NC_("Script", "Buginese") },
{ G_UNICODE_SCRIPT_GLAGOLITIC, HB_SCRIPT_GLAGOLITIC, NC_("Script", "Glagolitic") },
{ G_UNICODE_SCRIPT_TIFINAGH, HB_SCRIPT_TIFINAGH, NC_("Script", "Tifinagh") },
{ G_UNICODE_SCRIPT_SYLOTI_NAGRI, HB_SCRIPT_SYLOTI_NAGRI, NC_("Script", "Syloti Nagri") },
{ G_UNICODE_SCRIPT_OLD_PERSIAN, HB_SCRIPT_OLD_PERSIAN, NC_("Script", "Old Persian") },
{ G_UNICODE_SCRIPT_KHAROSHTHI, HB_SCRIPT_KHAROSHTHI, NC_("Script", "Kharoshthi") },
{ G_UNICODE_SCRIPT_UNKNOWN, HB_SCRIPT_UNKNOWN, NC_("Script", "Unknown") },
{ G_UNICODE_SCRIPT_BALINESE, HB_SCRIPT_BALINESE, NC_("Script", "Balinese") },
{ G_UNICODE_SCRIPT_CUNEIFORM, HB_SCRIPT_CUNEIFORM, NC_("Script", "Cuneiform") },
{ G_UNICODE_SCRIPT_PHOENICIAN, HB_SCRIPT_PHOENICIAN, NC_("Script", "Phoenician") },
{ G_UNICODE_SCRIPT_PHAGS_PA, HB_SCRIPT_PHAGS_PA, NC_("Script", "Phags-pa") },
{ G_UNICODE_SCRIPT_NKO, HB_SCRIPT_NKO, NC_("Script", "N'Ko") },
{ G_UNICODE_SCRIPT_KAYAH_LI, HB_SCRIPT_KAYAH_LI, NC_("Script", "Kayah Li") },
{ G_UNICODE_SCRIPT_LEPCHA, HB_SCRIPT_LEPCHA, NC_("Script", "Lepcha") },
{ G_UNICODE_SCRIPT_REJANG, HB_SCRIPT_REJANG, NC_("Script", "Rejang") },
{ G_UNICODE_SCRIPT_SUNDANESE, HB_SCRIPT_SUNDANESE, NC_("Script", "Sundanese") },
{ G_UNICODE_SCRIPT_SAURASHTRA, HB_SCRIPT_SAURASHTRA, NC_("Script", "Saurashtra") },
{ G_UNICODE_SCRIPT_CHAM, HB_SCRIPT_CHAM, NC_("Script", "Cham") },
{ G_UNICODE_SCRIPT_OL_CHIKI, HB_SCRIPT_OL_CHIKI, NC_("Script", "Ol Chiki") },
{ G_UNICODE_SCRIPT_VAI, HB_SCRIPT_VAI, NC_("Script", "Vai") },
{ G_UNICODE_SCRIPT_CARIAN, HB_SCRIPT_CARIAN, NC_("Script", "Carian") },
{ G_UNICODE_SCRIPT_LYCIAN, HB_SCRIPT_LYCIAN, NC_("Script", "Lycian") },
{ G_UNICODE_SCRIPT_LYDIAN, HB_SCRIPT_LYDIAN, NC_("Script", "Lydian") },
{ G_UNICODE_SCRIPT_AVESTAN, HB_SCRIPT_AVESTAN, NC_("Script", "Avestan") },
{ G_UNICODE_SCRIPT_BAMUM, HB_SCRIPT_BAMUM, NC_("Script", "Bamum") },
{ G_UNICODE_SCRIPT_EGYPTIAN_HIEROGLYPHS, HB_SCRIPT_EGYPTIAN_HIEROGLYPHS, NC_("Script", "Egyptian Hieroglpyhs") },
{ G_UNICODE_SCRIPT_IMPERIAL_ARAMAIC, HB_SCRIPT_IMPERIAL_ARAMAIC, NC_("Script", "Imperial Aramaic") },
{ G_UNICODE_SCRIPT_INSCRIPTIONAL_PAHLAVI, HB_SCRIPT_INSCRIPTIONAL_PAHLAVI, NC_("Script", "Inscriptional Pahlavi") },
{ G_UNICODE_SCRIPT_INSCRIPTIONAL_PARTHIAN, HB_SCRIPT_INSCRIPTIONAL_PARTHIAN, NC_("Script", "Inscriptional Parthian") },
{ G_UNICODE_SCRIPT_JAVANESE, HB_SCRIPT_JAVANESE, NC_("Script", "Javanese") },
{ G_UNICODE_SCRIPT_KAITHI, HB_SCRIPT_KAITHI, NC_("Script", "Kaithi") },
{ G_UNICODE_SCRIPT_LISU, HB_SCRIPT_LISU, NC_("Script", "Lisu") },
{ G_UNICODE_SCRIPT_MEETEI_MAYEK, HB_SCRIPT_MEETEI_MAYEK, NC_("Script", "Meetei Mayek") },
{ G_UNICODE_SCRIPT_OLD_SOUTH_ARABIAN, HB_SCRIPT_OLD_SOUTH_ARABIAN, NC_("Script", "Old South Arabian") },
{ G_UNICODE_SCRIPT_OLD_TURKIC, HB_SCRIPT_OLD_TURKIC, NC_("Script", "Old Turkic") },
{ G_UNICODE_SCRIPT_SAMARITAN, HB_SCRIPT_SAMARITAN, NC_("Script", "Samaritan") },
{ G_UNICODE_SCRIPT_TAI_THAM, HB_SCRIPT_TAI_THAM, NC_("Script", "Tai Tham") },
{ G_UNICODE_SCRIPT_TAI_VIET, HB_SCRIPT_TAI_VIET, NC_("Script", "Tai Viet") },
{ G_UNICODE_SCRIPT_BATAK, HB_SCRIPT_BATAK, NC_("Script", "Batak") },
{ G_UNICODE_SCRIPT_BRAHMI, HB_SCRIPT_BRAHMI, NC_("Script", "Brahmi") },
{ G_UNICODE_SCRIPT_MANDAIC, HB_SCRIPT_MANDAIC, NC_("Script", "Mandaic") },
{ G_UNICODE_SCRIPT_CHAKMA, HB_SCRIPT_CHAKMA, NC_("Script", "Chakma") },
{ G_UNICODE_SCRIPT_MEROITIC_CURSIVE, HB_SCRIPT_MEROITIC_CURSIVE, NC_("Script", "Meroitic Cursive") },
{ G_UNICODE_SCRIPT_MEROITIC_HIEROGLYPHS, HB_SCRIPT_MEROITIC_HIEROGLYPHS, NC_("Script", "Meroitic Hieroglyphs") },
{ G_UNICODE_SCRIPT_MIAO, HB_SCRIPT_MIAO, NC_("Script", "Miao") },
{ G_UNICODE_SCRIPT_SHARADA, HB_SCRIPT_SHARADA, NC_("Script", "Sharada") },
{ G_UNICODE_SCRIPT_SORA_SOMPENG, HB_SCRIPT_SORA_SOMPENG, NC_("Script", "Sora Sompeng") },
{ G_UNICODE_SCRIPT_TAKRI, HB_SCRIPT_TAKRI, NC_("Script", "Takri") },
{ G_UNICODE_SCRIPT_BASSA_VAH, HB_SCRIPT_BASSA_VAH, NC_("Script", "Bassa") },
{ G_UNICODE_SCRIPT_CAUCASIAN_ALBANIAN, HB_SCRIPT_CAUCASIAN_ALBANIAN, NC_("Script", "Caucasian Albanian") },
{ G_UNICODE_SCRIPT_DUPLOYAN, HB_SCRIPT_DUPLOYAN, NC_("Script", "Duployan") },
{ G_UNICODE_SCRIPT_ELBASAN, HB_SCRIPT_ELBASAN, NC_("Script", "Elbasan") },
{ G_UNICODE_SCRIPT_GRANTHA, HB_SCRIPT_GRANTHA, NC_("Script", "Grantha") },
{ G_UNICODE_SCRIPT_KHOJKI, HB_SCRIPT_KHOJKI, NC_("Script", "Khojki") },
{ G_UNICODE_SCRIPT_KHUDAWADI, HB_SCRIPT_KHUDAWADI, NC_("Script", "Khudawadi, Sindhi") },
{ G_UNICODE_SCRIPT_LINEAR_A, HB_SCRIPT_LINEAR_A, NC_("Script", "Linear A") },
{ G_UNICODE_SCRIPT_MAHAJANI, HB_SCRIPT_MAHAJANI, NC_("Script", "Mahajani") },
{ G_UNICODE_SCRIPT_MANICHAEAN, HB_SCRIPT_MANICHAEAN, NC_("Script", "Manichaean") },
{ G_UNICODE_SCRIPT_MENDE_KIKAKUI, HB_SCRIPT_MENDE_KIKAKUI, NC_("Script", "Mende Kikakui") },
{ G_UNICODE_SCRIPT_MODI, HB_SCRIPT_MODI, NC_("Script", "Modi") },
{ G_UNICODE_SCRIPT_MRO, HB_SCRIPT_MRO, NC_("Script", "Mro") },
{ G_UNICODE_SCRIPT_NABATAEAN, HB_SCRIPT_NABATAEAN, NC_("Script", "Nabataean") },
{ G_UNICODE_SCRIPT_OLD_NORTH_ARABIAN, HB_SCRIPT_OLD_NORTH_ARABIAN, NC_("Script", "Old North Arabian") },
{ G_UNICODE_SCRIPT_OLD_PERMIC, HB_SCRIPT_OLD_PERMIC, NC_("Script", "Old Permic") },
{ G_UNICODE_SCRIPT_PAHAWH_HMONG, HB_SCRIPT_PAHAWH_HMONG, NC_("Script", "Pahawh Hmong") },
{ G_UNICODE_SCRIPT_PALMYRENE, HB_SCRIPT_PALMYRENE, NC_("Script", "Palmyrene") },
{ G_UNICODE_SCRIPT_PAU_CIN_HAU, HB_SCRIPT_PAU_CIN_HAU, NC_("Script", "Pau Cin Hau") },
{ G_UNICODE_SCRIPT_PSALTER_PAHLAVI, HB_SCRIPT_PSALTER_PAHLAVI, NC_("Script", "Psalter Pahlavi") },
{ G_UNICODE_SCRIPT_SIDDHAM, HB_SCRIPT_SIDDHAM, NC_("Script", "Siddham") },
{ G_UNICODE_SCRIPT_TIRHUTA, HB_SCRIPT_TIRHUTA, NC_("Script", "Tirhuta") },
{ G_UNICODE_SCRIPT_WARANG_CITI, HB_SCRIPT_WARANG_CITI, NC_("Script", "Warang Citi") },
{ G_UNICODE_SCRIPT_AHOM, HB_SCRIPT_AHOM, NC_("Script", "Ahom") },
{ G_UNICODE_SCRIPT_ANATOLIAN_HIEROGLYPHS, HB_SCRIPT_ANATOLIAN_HIEROGLYPHS, NC_("Script", "Anatolian Hieroglyphs") },
{ G_UNICODE_SCRIPT_HATRAN, HB_SCRIPT_HATRAN, NC_("Script", "Hatran") },
{ G_UNICODE_SCRIPT_MULTANI, HB_SCRIPT_MULTANI, NC_("Script", "Multani") },
{ G_UNICODE_SCRIPT_OLD_HUNGARIAN, HB_SCRIPT_OLD_HUNGARIAN, NC_("Script", "Old Hungarian") },
{ G_UNICODE_SCRIPT_SIGNWRITING, HB_SCRIPT_SIGNWRITING, NC_("Script", "Signwriting") },
{ G_UNICODE_SCRIPT_ADLAM, HB_SCRIPT_ADLAM, NC_("Script", "Adlam") },
{ G_UNICODE_SCRIPT_BHAIKSUKI, HB_SCRIPT_BHAIKSUKI, NC_("Script", "Bhaiksuki") },
{ G_UNICODE_SCRIPT_MARCHEN, HB_SCRIPT_MARCHEN, NC_("Script", "Marchen") },
{ G_UNICODE_SCRIPT_NEWA, HB_SCRIPT_NEWA, NC_("Script", "Newa") },
{ G_UNICODE_SCRIPT_OSAGE, HB_SCRIPT_OSAGE, NC_("Script", "Osage") },
{ G_UNICODE_SCRIPT_TANGUT, HB_SCRIPT_TANGUT, NC_("Script", "Tangut") },
{ G_UNICODE_SCRIPT_MASARAM_GONDI, HB_SCRIPT_INVALID, NC_("Script", "Masaram Gondi") },
{ G_UNICODE_SCRIPT_NUSHU, HB_SCRIPT_INVALID, NC_("Script", "Nushu") },
{ G_UNICODE_SCRIPT_SOYOMBO, HB_SCRIPT_INVALID, NC_("Script", "Soyombo") },
{ G_UNICODE_SCRIPT_ZANABAZAR_SQUARE, HB_SCRIPT_INVALID, NC_("Script", "Zanabazar Square") },
};
const char *
get_script_name (GUnicodeScript script)
{
int i;
for (i = 0; i < G_N_ELEMENTS (scripts); i++)
{
if (scripts[i].script == script)
return g_dpgettext2 (GETTEXT_PACKAGE, "Script", scripts[i].name);
}
return NULL;