Skip to content

Instantly share code, notes, and snippets.

@vtols
Created August 4, 2015 17:03
Show Gist options
  • Save vtols/31ca7f844a5d3254f695 to your computer and use it in GitHub Desktop.
Save vtols/31ca7f844a5d3254f695 to your computer and use it in GitHub Desktop.
--- backend/pdf/ev-poppler.cc 2015-03-08 11:52:50.000000000 +0300
+++ backend/pdf/ev-poppler-patched.cc 2015-08-04 19:12:48.000000000 +0300
@@ -377,6 +377,23 @@
return label;
}
+/* For some reason, cairo doesn't put this in the public header. */
+typedef enum _cairo_lcd_filter {
+ CAIRO_LCD_FILTER_DEFAULT,
+ CAIRO_LCD_FILTER_NONE,
+ CAIRO_LCD_FILTER_INTRA_PIXEL,
+ CAIRO_LCD_FILTER_FIR3,
+ CAIRO_LCD_FILTER_FIR5
+} cairo_lcd_filter_t;
+
+struct _cairo_font_options {
+ cairo_antialias_t antialias;
+ cairo_subpixel_order_t subpixel_order;
+ cairo_lcd_filter_t lcd_filter;
+ cairo_hint_style_t hint_style;
+ cairo_hint_metrics_t hint_metrics;
+};
+
static cairo_surface_t *
pdf_page_render (PopplerPage *page,
gint width,
@@ -385,12 +402,26 @@
{
cairo_surface_t *surface;
cairo_t *cr;
+ cairo_font_options_t *options;
double page_width, page_height;
double xscale, yscale;
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
width, height);
+ memset (cairo_image_surface_get_data (surface), 0xff,
+ cairo_image_surface_get_height (surface) *
+ cairo_image_surface_get_stride (surface));
+
+ options = cairo_font_options_create ();
+ cairo_surface_get_font_options (surface, options);
+ cairo_font_options_set_antialias (options, CAIRO_ANTIALIAS_SUBPIXEL);
+ cairo_font_options_set_subpixel_order (options, CAIRO_SUBPIXEL_ORDER_RGB);
+ cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_SLIGHT);
+ options->lcd_filter = CAIRO_LCD_FILTER_FIR5;
+
cr = cairo_create (surface);
+ cairo_set_font_options (cr, options);
+ cairo_font_options_destroy (options);
switch (rc->rotation) {
case 90:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment