[pango/simple-fontmap: 3/4] pango-view: Add a --font-file option




commit b89aba54e11a87a184d1f7652219d32ae3c07fe0
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Aug 31 07:47:17 2021 -0400

    pango-view: Add a --font-file option
    
    The option can be used multiple times, to create
    a simple fontmap that has exactly the given
    font files, and nothing else.
    
    If the option isn't used, behave as before
    and use a default fontmap.

 utils/viewer-pangocairo.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/utils/viewer-pangocairo.c b/utils/viewer-pangocairo.c
index 9c69647b..b3359ff7 100644
--- a/utils/viewer-pangocairo.c
+++ b/utils/viewer-pangocairo.c
@@ -27,6 +27,7 @@
 #include <pango/pangocairo.h>
 
 static int opt_annotate = 0;
+static const char **opt_font_file = NULL;
 
 typedef struct
 {
@@ -48,8 +49,16 @@ pangocairo_view_create (const PangoViewer *klass G_GNUC_UNUSED)
 
   instance->backend = cairo_viewer_iface_create (&instance->iface);
 
-  instance->fontmap = pango_cairo_font_map_new ();
-  pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (instance->fontmap), opt_dpi);
+  if (opt_font_file != NULL)
+    {
+      instance->fontmap = PANGO_FONT_MAP (pango_simple_font_map_new ());
+      pango_simple_font_map_add_file (PANGO_SIMPLE_FONT_MAP (instance->fontmap), opt_font_file[0], 0);
+    }
+  else
+    {
+      instance->fontmap = pango_cairo_font_map_new ();
+      pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (instance->fontmap), opt_dpi);
+    }
 
   instance->font_options = cairo_font_options_create ();
   if (opt_hinting != HINT_DEFAULT)
@@ -796,6 +805,7 @@ pangocairo_view_get_option_group (const PangoViewer *klass G_GNUC_UNUSED)
   GOptionEntry entries[] =
   {
     {"annotate", 0, 0, G_OPTION_ARG_CALLBACK, parse_annotate_arg, annotate_arg_help, "FLAGS"},
+    {"font-file", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &opt_font_file, "Font file to use", "FILE"},
     {NULL}
   };
   GOptionGroup *group;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]