From 224684d1ba9cc7583992746adbce3b2273bc112e Mon Sep 17 00:00:00 2001 From: raveit65 Date: Wed, 8 Mar 2017 13:45:32 +0100 Subject: font-viewer font-thumbnailer: Extract face index from URI The URI passed to gnome-thumbnail-font can now have a face index, embedded as a URI fragment. The fragment part is parsed as a 32-bit integer, and it may include a "0x" prefix, to support FreeType extension for GX fonts: http://freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_Open_Face https://bugzilla.gnome.org/show_bug.cgi?id=752005 taken from: https://git.gnome.org/browse/gnome-font-viewer/commit/?id=920c834 --- font-viewer/font-thumbnailer.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'font-viewer') diff --git a/font-viewer/font-thumbnailer.c b/font-viewer/font-thumbnailer.c index 74b135d0..e2a2d3be 100644 --- a/font-viewer/font-thumbnailer.c +++ b/font-viewer/font-thumbnailer.c @@ -183,6 +183,8 @@ main (int argc, cairo_font_face_t *font; gchar *str = NULL; gdouble scale, scale_x, scale_y; + gint face_index = 0; + gchar *fragment; const GOptionEntry options[] = { { "text", 't', 0, G_OPTION_ARG_STRING, &thumbstr_utf8, @@ -233,11 +235,15 @@ main (int argc, totem_resources_monitor_start (arguments[0], 30 * G_USEC_PER_SEC); + fragment = strrchr (arguments[0], '#'); + if (fragment) + face_index = strtol (fragment + 1, NULL, 0); + file = g_file_new_for_commandline_arg (arguments[0]); uri = g_file_get_uri (file); g_object_unref (file); - face = sushi_new_ft_face_from_uri (library, uri, 0, &contents, &gerror); + face = sushi_new_ft_face_from_uri (library, uri, face_index, &contents, &gerror); if (gerror) { g_printerr ("Could not load face '%s': %s\n", uri, gerror->message); -- cgit v1.2.1