Comment 36 for bug 80921

Revision history for this message
In , Alexander Monakov (amonakov) wrote :

Presently, and as noted in comment #15, poppler-glib appears to use font options from the surface it was given by the caller. It is rather convenient, as it allows to implement management of subpixel rendering from the application with minimal effort. As an example, here's a patch for evince pdf backend that hard-codes horizontal rgb with slight hinting:

diff -pur evince-2.24.2-r1/work/evince-2.24.2/backend/pdf/ev-poppler.cc evince-2.24.2-r2/work/evince-2.24.2/backend/pdf/ev-poppler.cc
--- evince-2.24.2-r1/work/evince-2.24.2/backend/pdf/ev-poppler.cc 2008-11-24 22:09:30.000000000 +0300
+++ evince-2.24.2-r2/work/evince-2.24.2/backend/pdf/ev-poppler.cc 2009-01-19 01:15:15.048150478 +0300
@@ -451,14 +451,22 @@ pdf_page_render (PopplerPage *page,

 #ifdef HAVE_POPPLER_PAGE_RENDER
        cairo_t *cr;
+ cairo_font_options_t *options;

        surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
                                              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);

        cr = cairo_create (surface);
+ cairo_set_font_options (cr, options);
+ cairo_font_options_destroy (options);
        switch (rc->rotation) {
                case 90:
                        cairo_translate (cr, width, 0);

So I think poppler is already doing its job with regards to subpixel rendering.

However, I'd like to second the point from comment #17: I believe it is better to use slight hinting instead of disabling hinting altogether. What about something along these lines:

diff -pur poppler-0.10.0/poppler/CairoFontEngine.cc poppler-0.10.0-r1/poppler/CairoFontEngine.cc
--- poppler-0.10.0/poppler/CairoFontEngine.cc 2008-09-22 22:25:45.000000000 +0400
+++ poppler-0.10.0-r1/poppler/CairoFontEngine.cc 2008-10-31 14:10:27.000000000 +0300
@@ -80,7 +80,7 @@ _ft_new_face_uncached (FT_Library lib,
     return gFalse;

   font_face = cairo_ft_font_face_create_for_ft_face (face,
- FT_LOAD_NO_HINTING |
+ FT_LOAD_TARGET_LIGHT |
                                                          FT_LOAD_NO_BITMAP);
   if (cairo_font_face_set_user_data (font_face,
                                     &_ft_cairo_key,
@@ -214,7 +214,7 @@ _ft_new_face (FT_Library lib,
   _ft_open_faces = l;

   l->font_face = cairo_ft_font_face_create_for_ft_face (tmpl.face,
- FT_LOAD_NO_HINTING |
+ FT_LOAD_TARGET_LIGHT |
                                                          FT_LOAD_NO_BITMAP);
   if (cairo_font_face_set_user_data (l->font_face,
                                     &_ft_cairo_key,
@@ -481,7 +481,7 @@ CairoFont::getSubstitutionCorrection(Gfx
        cairo_matrix_t m;
        cairo_matrix_init_identity(&m);
        cairo_font_options_t *options = cairo_font_options_create();
- cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
+ cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_SLIGHT);
        cairo_font_options_set_hint_metrics(options, CAIRO_HINT_METRICS_OFF);
        cairo_scaled_font_t *scaled_font = cairo_scaled_font_create(cairo_font_face, &m, &m, options);