[patch] add support for subpixel rendering support for cairo backend
Submitted by Yichao Zhou
Assigned to poppler-bugs
Created attachment 123900 proposed patch
The patch poppler-subpixel.patch provides a new function called poppler_page_support_subpixel_rendering for glib/cairo backend for poppler. This function checks whether a PDF page could be subpixel-rendered. The reason that subpixel rendering is not implemented in a PDF viewer is that glyphs subpixel rendering cannot easily support transparent background, i.e., the background color much be known when the glyphs are rendered. By default, PDF has a transparent background. In most case, one can fill white to the background before the rendering of glyphs to workaround this problem. However, PDF file format has a feature called blend modes. Example can be downloaded from [https://github.com/mozilla/pdf.js/blob/master/test/pdfs/blendmode.pdf]. Some blend modes will generate different results when drawing on transparent or white background. Therefore, filling color into background is incorrect in this case. The new added function poppler_page_support_subpixel_rendering checks whether it is safe to fill some color into background by traversing current page and check whether transparent background and colored background are distinguishable by checking all the blend modes used before rendering. If it returns true, the application can call cairo_paint to fill the background and cairo_font_options_set_antialias to enable the subpixel rendering for cairo.
See glib/demo/render.c for an example how to use the subpixel rendering feature.
Patch 123900, "proposed patch":