summaryrefslogtreecommitdiff
path: root/font-viewer
diff options
context:
space:
mode:
Diffstat (limited to 'font-viewer')
-rw-r--r--font-viewer/font-view.c205
1 files changed, 103 insertions, 102 deletions
diff --git a/font-viewer/font-view.c b/font-viewer/font-view.c
index bf4138fb..e48054c9 100644
--- a/font-viewer/font-view.c
+++ b/font-viewer/font-view.c
@@ -81,7 +81,7 @@ get_sample_string (FT_Face face)
text = pango_language_get_sample_string (NULL);
if (!check_font_contain_text (face, text)) {
- text = pango_language_get_sample_string (pango_language_from_string ("en_US"));
+ text = pango_language_get_sample_string (pango_language_from_string ("en_US"));
}
return text;
@@ -97,30 +97,30 @@ build_sizes_table (FT_Face face,
/* work out what sizes to render */
if (FT_IS_SCALABLE (face)) {
- *n_sizes = 8;
- sizes = g_new (gint, *n_sizes);
- sizes[0] = 8;
- sizes[1] = 10;
- sizes[2] = 12;
- sizes[3] = 18;
- sizes[4] = 24;
- sizes[5] = 36;
- sizes[6] = 48;
- sizes[7] = 72;
- *alpha_size = 24;
+ *n_sizes = 8;
+ sizes = g_new (gint, *n_sizes);
+ sizes[0] = 8;
+ sizes[1] = 10;
+ sizes[2] = 12;
+ sizes[3] = 18;
+ sizes[4] = 24;
+ sizes[5] = 36;
+ sizes[6] = 48;
+ sizes[7] = 72;
+ *alpha_size = 24;
} else {
- /* use fixed sizes */
- *n_sizes = face->num_fixed_sizes;
- sizes = g_new (gint, *n_sizes);
- *alpha_size = 0;
-
- for (i = 0; i < face->num_fixed_sizes; i++) {
- sizes[i] = face->available_sizes[i].height;
-
- /* work out which font size to render */
- if (face->available_sizes[i].height <= 24)
- *alpha_size = face->available_sizes[i].height;
- }
+ /* use fixed sizes */
+ *n_sizes = face->num_fixed_sizes;
+ sizes = g_new (gint, *n_sizes);
+ *alpha_size = 0;
+
+ for (i = 0; i < face->num_fixed_sizes; i++) {
+ sizes[i] = face->available_sizes[i].height;
+
+ /* work out which font size to render */
+ if (face->available_sizes[i].height <= 24)
+ *alpha_size = face->available_sizes[i].height;
+ }
}
return sizes;
@@ -166,10 +166,10 @@ realize_callback (GtkWidget *drawing_area,
pixmap_height += 8;
for (i = 0; i < n_sizes; i++) {
- cairo_set_font_size (cr, sizes[i]);
- cairo_text_extents (cr, text, &extents);
- pixmap_height += extents.height + 4;
- pixmap_width = MAX (pixmap_width, 8 + extents.width);
+ cairo_set_font_size (cr, sizes[i]);
+ cairo_text_extents (cr, text, &extents);
+ pixmap_height += extents.height + 4;
+ pixmap_width = MAX (pixmap_width, 8 + extents.width);
}
gtk_widget_set_size_request (drawing_area, pixmap_width, pixmap_height);
@@ -205,8 +205,8 @@ draw (GtkWidget *drawing_area,
pos_y += 8;
for (i = 0; i < n_sizes; i++) {
- cairo_set_font_size (cr, sizes[i]);
- draw_string (cr, text, &pos_y);
+ cairo_set_font_size (cr, sizes[i]);
+ draw_string (cr, text, &pos_y);
}
g_free (sizes);
@@ -261,8 +261,8 @@ add_row (GtkWidget *table,
#endif
if (multiline) {
- GtkWidget *label, *viewport;
- GtkScrolledWindow *swin;
+ GtkWidget *label, *viewport;
+ GtkScrolledWindow *swin;
guint flags;
label = gtk_label_new (value);
@@ -379,78 +379,79 @@ add_face_info (GtkWidget *table,
}
if (FT_IS_SFNT (face)) {
- gint i, len;
- gchar *version = NULL, *copyright = NULL, *description = NULL;
-
- len = FT_Get_Sfnt_Name_Count (face);
- for (i = 0; i < len; i++) {
- FT_SfntName sname;
-
- if (FT_Get_Sfnt_Name (face, i, &sname) != 0)
- continue;
-
- /* only handle the unicode names for US langid */
- if (!(sname.platform_id == TT_PLATFORM_MICROSOFT &&
- sname.encoding_id == TT_MS_ID_UNICODE_CS &&
- sname.language_id == TT_MS_LANGID_ENGLISH_UNITED_STATES))
- continue;
-
- switch (sname.name_id) {
- case TT_NAME_ID_COPYRIGHT:
- g_free (copyright);
- copyright = g_convert ((gchar *)sname.string, sname.string_len,
- "UTF-8", "UTF-16BE", NULL, NULL, NULL);
- break;
- case TT_NAME_ID_VERSION_STRING:
- g_free (version);
- version = g_convert ((gchar *)sname.string, sname.string_len,
- "UTF-8", "UTF-16BE", NULL, NULL, NULL);
- break;
- case TT_NAME_ID_DESCRIPTION:
- g_free (description);
- description = g_convert ((gchar *)sname.string, sname.string_len,
- "UTF-8", "UTF-16BE", NULL, NULL, NULL);
- break;
- default:
- break;
- }
- }
- if (version) {
+ gint i, len;
+ gchar *version = NULL, *copyright = NULL, *description = NULL;
+
+ len = FT_Get_Sfnt_Name_Count (face);
+ for (i = 0; i < len; i++) {
+ FT_SfntName sname;
+
+ if (FT_Get_Sfnt_Name (face, i, &sname) != 0)
+ continue;
+
+ /* only handle the unicode names for US langid */
+ if (!(sname.platform_id == TT_PLATFORM_MICROSOFT &&
+ sname.encoding_id == TT_MS_ID_UNICODE_CS &&
+ sname.language_id == TT_MS_LANGID_ENGLISH_UNITED_STATES))
+ continue;
+
+ switch (sname.name_id) {
+ case TT_NAME_ID_COPYRIGHT:
+ g_free (copyright);
+ copyright = g_convert ((gchar *)sname.string, sname.string_len,
+ "UTF-8", "UTF-16BE", NULL, NULL, NULL);
+ break;
+ case TT_NAME_ID_VERSION_STRING:
+ g_free (version);
+ version = g_convert ((gchar *)sname.string, sname.string_len,
+ "UTF-8", "UTF-16BE", NULL, NULL, NULL);
+ break;
+ case TT_NAME_ID_DESCRIPTION:
+ g_free (description);
+ description = g_convert ((gchar *)sname.string, sname.string_len,
+ "UTF-8", "UTF-16BE", NULL, NULL, NULL);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (version) {
#if GTK_CHECK_VERSION (3, 4, 0)
- add_row (grid, _("Version:"), version, FALSE, FALSE);
+ add_row (grid, _("Version:"), version, FALSE, FALSE);
#else
- add_row (table, row_p, _("Version:"), version, FALSE, FALSE);
+ add_row (table, row_p, _("Version:"), version, FALSE, FALSE);
#endif
- g_free (version);
- }
- if (copyright) {
+ g_free (version);
+ }
+ if (copyright) {
#if GTK_CHECK_VERSION (3, 4, 0)
- add_row (grid, _("Copyright:"), copyright, TRUE, TRUE);
+ add_row (grid, _("Copyright:"), copyright, TRUE, TRUE);
#else
- add_row (table, row_p, _("Copyright:"), copyright, TRUE, TRUE);
+ add_row (table, row_p, _("Copyright:"), copyright, TRUE, TRUE);
#endif
- g_free (copyright);
- }
- if (description) {
+ g_free (copyright);
+ }
+ if (description) {
#if GTK_CHECK_VERSION (3, 4, 0)
- add_row (grid, _("Description:"), description, TRUE, TRUE);
+ add_row (grid, _("Description:"), description, TRUE, TRUE);
#else
- add_row (table, row_p, _("Description:"), description, TRUE, TRUE);
+ add_row (table, row_p, _("Description:"), description, TRUE, TRUE);
#endif
- g_free (description);
- }
+ g_free (description);
+ }
} else if (FT_Get_PS_Font_Info (face, &ps_info) == 0) {
- if (ps_info.version && g_utf8_validate (ps_info.version, -1, NULL))
+ if (ps_info.version && g_utf8_validate (ps_info.version, -1, NULL))
#if GTK_CHECK_VERSION (3, 4, 0)
- add_row (grid, _("Version:"), ps_info.version, FALSE, FALSE);
+ add_row (grid, _("Version:"), ps_info.version, FALSE, FALSE);
#else
- add_row (table, row_p, _("Version:"), ps_info.version, FALSE, FALSE);
+ add_row (table, row_p, _("Version:"), ps_info.version, FALSE, FALSE);
#endif
- if (ps_info.notice && g_utf8_validate (ps_info.notice, -1, NULL))
+ if (ps_info.notice && g_utf8_validate (ps_info.notice, -1, NULL))
#if GTK_CHECK_VERSION (3, 4, 0)
- add_row (grid, _("Copyright:"), ps_info.notice, TRUE, FALSE);
+ add_row (grid, _("Copyright:"), ps_info.notice, TRUE, FALSE);
#else
- add_row (table, row_p, _("Copyright:"), ps_info.notice, TRUE, FALSE);
+ add_row (table, row_p, _("Copyright:"), ps_info.notice, TRUE, FALSE);
#endif
}
}
@@ -475,7 +476,7 @@ set_icon (GtkWindow *window,
g_object_unref (file);
if (info == NULL)
- return;
+ return;
content_type = g_file_info_get_content_type (info);
icon = g_content_type_get_icon (content_type);
@@ -487,10 +488,10 @@ set_icon (GtkWindow *window,
if (names) {
gint i;
for (i = 0; names[i]; i++) {
- if (gtk_icon_theme_has_icon (icon_theme, names[i])) {
- icon_name = names[i];
- break;
- }
+ if (gtk_icon_theme_has_icon (icon_theme, names[i])) {
+ icon_name = names[i];
+ break;
+ }
}
}
}
@@ -590,14 +591,14 @@ main (int argc,
gtk_init (&argc, &argv);
if (argc != 2) {
- g_printerr (_("Usage: %s fontfile\n"), argv[0]);
- return 1;
+ g_printerr (_("Usage: %s fontfile\n"), argv[0]);
+ return 1;
}
error = FT_Init_FreeType (&library);
if (error) {
- g_printerr("Could not initialise freetype\n");
- return 1;
+ g_printerr("Could not initialise freetype\n");
+ return 1;
}
file = g_file_new_for_commandline_arg (argv[1]);
@@ -605,14 +606,14 @@ main (int argc,
g_object_unref (file);
if (!font_file) {
- g_printerr("Could not parse argument into a URI\n");
- return 1;
+ g_printerr("Could not parse argument into a URI\n");
+ return 1;
}
error = FT_New_Face_From_URI (library, font_file, 0, &face);
if (error) {
- g_printerr("Could not load face '%s'\n", font_file);
- return 1;
+ g_printerr("Could not load face '%s'\n", font_file);
+ return 1;
}
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);