diff options
-rw-r--r-- | utils/viewer-pangocairo.c | 14 | ||||
-rw-r--r-- | utils/viewer-render.c | 94 | ||||
-rw-r--r-- | utils/viewer-render.h | 26 |
3 files changed, 132 insertions, 2 deletions
diff --git a/utils/viewer-pangocairo.c b/utils/viewer-pangocairo.c index 9054b9fe..f82bd72d 100644 --- a/utils/viewer-pangocairo.c +++ b/utils/viewer-pangocairo.c @@ -55,10 +55,24 @@ pangocairo_view_create (const PangoViewer *klass G_GNUC_UNUSED) { if (opt_hinting == HINT_NONE) cairo_font_options_set_hint_style (instance->font_options, CAIRO_HINT_STYLE_NONE); + else if (opt_hinting == HINT_SLIGHT || + opt_hinting == HINT_AUTO) + cairo_font_options_set_hint_style (instance->font_options, CAIRO_HINT_STYLE_SLIGHT); + else if (opt_hinting == HINT_MEDIUM) + cairo_font_options_set_hint_style (instance->font_options, CAIRO_HINT_STYLE_MEDIUM); else if (opt_hinting == HINT_FULL) cairo_font_options_set_hint_style (instance->font_options, CAIRO_HINT_STYLE_FULL); } + if (opt_subpixel_order != SUBPIXEL_DEFAULT) + cairo_font_options_set_subpixel_order (instance->font_options, (cairo_subpixel_order_t)opt_subpixel_order); + + if (opt_hint_metrics != HINT_METRICS_DEFAULT) + cairo_font_options_set_hint_metrics (instance->font_options, (cairo_hint_metrics_t)opt_hint_metrics); + + if (opt_antialias != ANTIALIAS_DEFAULT) + cairo_font_options_set_antialias (instance->font_options, (cairo_antialias_t)opt_antialias); + return instance; } diff --git a/utils/viewer-render.c b/utils/viewer-render.c index 8fd6cfaf..36cee596 100644 --- a/utils/viewer-render.c +++ b/utils/viewer-render.c @@ -60,6 +60,9 @@ PangoEllipsizeMode opt_ellipsize = PANGO_ELLIPSIZE_NONE; PangoGravity opt_gravity = PANGO_GRAVITY_SOUTH; PangoGravityHint opt_gravity_hint = PANGO_GRAVITY_HINT_NATURAL; HintMode opt_hinting = HINT_DEFAULT; +HintMetrics opt_hint_metrics = HINT_METRICS_DEFAULT; +SubpixelOrder opt_subpixel_order = SUBPIXEL_DEFAULT; +Antialias opt_antialias = ANTIALIAS_DEFAULT; PangoWrapMode opt_wrap = PANGO_WRAP_WORD_CHAR; gboolean opt_wrap_set = FALSE; static const char *opt_pangorc = NULL; /* Unused */ @@ -443,6 +446,10 @@ parse_hinting (const char *name G_GNUC_UNUSED, opt_hinting = HINT_NONE; else if (strcmp (arg, "auto") == 0) opt_hinting = HINT_AUTO; + else if (strcmp (arg, "slight") == 0) + opt_hinting = HINT_SLIGHT; + else if (strcmp (arg, "medium") == 0) + opt_hinting = HINT_MEDIUM; else if (strcmp (arg, "full") == 0) opt_hinting = HINT_FULL; else @@ -450,7 +457,7 @@ parse_hinting (const char *name G_GNUC_UNUSED, g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE, - "Argument for --hinting must be one of none/auto/full"); + "Argument for --hinting must be one of none/auto/slight/medium/full"); ret = FALSE; } @@ -458,6 +465,83 @@ parse_hinting (const char *name G_GNUC_UNUSED, } static gboolean +parse_subpixel_order (const char *name, + const char *arg, + gpointer data, + GError **error) +{ + gboolean ret = TRUE; + + if (strcmp (arg, "rgb") == 0) + opt_subpixel_order = SUBPIXEL_RGB; + else if (strcmp (arg, "bgr") == 0) + opt_subpixel_order = SUBPIXEL_BGR; + else if (strcmp (arg, "vrgb") == 0) + opt_subpixel_order = SUBPIXEL_VRGB; + else if (strcmp (arg, "vbgr") == 0) + opt_subpixel_order = SUBPIXEL_VBGR; + else + { + g_set_error (error, + G_OPTION_ERROR, + G_OPTION_ERROR_BAD_VALUE, + "Argument for --subpixel-order must be one of rgb/bgr/vrgb/vbgr"); + ret = FALSE; + } + + return ret; +} + +static gboolean +parse_hint_metrics (const char *name, + const char *arg, + gpointer data, + GError **error) +{ + gboolean ret = TRUE; + + if (strcmp (arg, "on") == 0) + opt_hint_metrics = HINT_METRICS_ON; + else if (strcmp (arg, "off") == 0) + opt_hint_metrics = HINT_METRICS_OFF; + else + { + g_set_error (error, + G_OPTION_ERROR, + G_OPTION_ERROR_BAD_VALUE, + "Argument for --hint-metrics must be one of on/off"); + ret = FALSE; + } + + return ret; +} + +static gboolean +parse_antialias (const char *name, + const char *arg, + gpointer data, + GError **error) +{ + gboolean ret = TRUE; + + if (strcmp (arg, "none") == 0) + opt_antialias = ANTIALIAS_NONE; + else if (strcmp (arg, "gray") == 0) + opt_antialias = ANTIALIAS_GRAY; + else if (strcmp (arg, "subpixel") == 0) + opt_antialias = ANTIALIAS_SUBPIXEL; + else + { + g_set_error (error, + G_OPTION_ERROR, + G_OPTION_ERROR_BAD_VALUE, + "Argument for --antialias must be one of none/gray/subpixel"); + ret = FALSE; + } + + return ret; +} +static gboolean parse_wrap (const char *name, const char *arg, gpointer data, @@ -711,7 +795,13 @@ parse_options (int argc, char *argv[]) {"height", 0, 0, G_OPTION_ARG_INT, &opt_height, "Height in points (positive) or number of lines (negative) for ellipsizing", "+points/-numlines"}, {"hinting", 0, 0, G_OPTION_ARG_CALLBACK, &parse_hinting, - "Hinting style", "none/auto/full"}, + "Hinting style", "none/auto/slight/medium/full"}, + {"antialias", 0, 0, G_OPTION_ARG_CALLBACK, &parse_antialias, + "Antialiasing", "none/gray/subpixel"}, + {"hint-metrics", 0, 0, G_OPTION_ARG_CALLBACK, &parse_hint_metrics, + "Hint metrics", "on/off"}, + {"subpixel-order", 0, 0, G_OPTION_ARG_CALLBACK, &parse_subpixel_order, + "Subpixel order", "rgb/bgr/vrgb/vbgr"}, {"indent", 0, 0, G_OPTION_ARG_INT, &opt_indent, "Width in points to indent paragraphs", "points"}, {"spacing", 0, 0, G_OPTION_ARG_INT, &opt_spacing, diff --git a/utils/viewer-render.h b/utils/viewer-render.h index ade22986..bfb50e55 100644 --- a/utils/viewer-render.h +++ b/utils/viewer-render.h @@ -29,9 +29,32 @@ typedef enum { HINT_DEFAULT, HINT_NONE, HINT_AUTO, + HINT_SLIGHT, + HINT_MEDIUM, HINT_FULL } HintMode; +typedef enum { + SUBPIXEL_DEFAULT, + SUBPIXEL_RGB, + SUBPIXEL_BGR, + SUBPIXEL_VRGB, + SUBPIXEL_VBGR +} SubpixelOrder; + +typedef enum { + ANTIALIAS_DEFAULT, + ANTIALIAS_NONE, + ANTIALIAS_GRAY, + ANTIALIAS_SUBPIXEL +} Antialias; + +typedef enum { + HINT_METRICS_DEFAULT, + HINT_METRICS_ON, + HINT_METRICS_OFF +} HintMetrics; + typedef void (*RenderCallback) (PangoLayout *layout, int x, int y, @@ -81,6 +104,9 @@ extern const PangoViewer *opt_viewer; /* handled by backend-specific code */ extern int opt_dpi; extern HintMode opt_hinting; +extern SubpixelOrder opt_subpixel_order; +extern Antialias opt_antialias; +extern HintMetrics opt_hint_metrics; extern PangoColor opt_fg_color; extern guint16 opt_fg_alpha; extern gboolean opt_bg_set; |