Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 920355 | Differences between
and this patch

Collapse All | Expand All

(-)poppler-23.09.0/glib/demo/render.c (-3 / +23 lines)
Lines 79-90 Link Here
79
static void pgd_render_start(GtkButton *button, PgdRenderDemo *demo)
79
static void pgd_render_start(GtkButton *button, PgdRenderDemo *demo)
80
{
80
{
81
    PopplerPage *page;
81
    PopplerPage *page;
82
    gboolean     subpixel_rendering;
82
    gdouble page_width, page_height;
83
    gdouble page_width, page_height;
83
    gdouble width, height;
84
    gdouble width, height;
84
    gint x, y;
85
    gint x, y;
85
    gchar *str;
86
    gchar *str;
86
    GTimer *timer;
87
    GTimer *timer;
87
    cairo_t *cr;
88
    cairo_t *cr;
89
    cairo_font_options_t *fo;
90
88
91
89
    page = poppler_document_get_page(demo->doc, demo->page);
92
    page = poppler_document_get_page(demo->doc, demo->page);
90
    if (!page) {
93
    if (!page) {
Lines 114-119 Link Here
114
    demo->surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
117
    demo->surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
115
    cr = cairo_create(demo->surface);
118
    cr = cairo_create(demo->surface);
116
119
120
    fo = cairo_font_options_create ();
121
    cairo_get_font_options (cr, fo);
122
123
    subpixel_rendering = poppler_page_support_subpixel_rendering (page);
124
    printf("subpixel_rendering %d\n", subpixel_rendering);
125
    if (subpixel_rendering) {
126
        cairo_set_source_rgb (cr, 1., 1., 1.);
127
        cairo_paint (cr);
128
        cairo_font_options_set_antialias (fo, CAIRO_ANTIALIAS_SUBPIXEL);
129
        cairo_font_options_set_subpixel_order (fo, CAIRO_SUBPIXEL_ORDER_RGB);
130
    }
131
132
    cairo_set_font_options (cr, fo);
133
    cairo_font_options_destroy (fo);
134
117
    cairo_save(cr);
135
    cairo_save(cr);
118
    switch (demo->rotate) {
136
    switch (demo->rotate) {
119
    case 90:
137
    case 90:
Lines 144-152 Link Here
144
    }
162
    }
145
    cairo_restore(cr);
163
    cairo_restore(cr);
146
164
147
    cairo_set_operator(cr, CAIRO_OPERATOR_DEST_OVER);
165
    if (!subpixel_rendering) {
148
    cairo_set_source_rgb(cr, 1., 1., 1.);
166
        cairo_set_operator(cr, CAIRO_OPERATOR_DEST_OVER);
149
    cairo_paint(cr);
167
        cairo_set_source_rgb(cr, 1., 1., 1.);
168
        cairo_paint(cr);
169
    }
150
170
151
    g_timer_stop(timer);
171
    g_timer_stop(timer);
152
172
(-)poppler-23.09.0/glib/poppler-page.cc (+10 lines)
Lines 2572-2574 Link Here
2572
2572
2573
    return g_list_reverse(attributes);
2573
    return g_list_reverse(attributes);
2574
}
2574
}
2575
2576
gboolean
2577
poppler_page_support_subpixel_rendering (PopplerPage        *page)
2578
{
2579
  CairoOutputDev *output_dev;
2580
  g_return_val_if_fail (POPPLER_IS_PAGE (page), FALSE);
2581
2582
  output_dev = page->document->output_dev;
2583
  return page->page->supportSubpixelRendering(output_dev);
2584
}
(-)poppler-23.09.0/glib/poppler-page.h (+2 lines)
Lines 112-117 Link Here
112
POPPLER_PUBLIC
112
POPPLER_PUBLIC
113
GList *poppler_page_get_text_attributes_for_area(PopplerPage *page, PopplerRectangle *area);
113
GList *poppler_page_get_text_attributes_for_area(PopplerPage *page, PopplerRectangle *area);
114
114
115
gboolean         poppler_page_support_subpixel_rendering (PopplerPage        *page);
116
115
/* A rectangle on a page, with coordinates in PDF points. */
117
/* A rectangle on a page, with coordinates in PDF points. */
116
#define POPPLER_TYPE_RECTANGLE (poppler_rectangle_get_type())
118
#define POPPLER_TYPE_RECTANGLE (poppler_rectangle_get_type())
117
/**
119
/**
(-)poppler-23.09.0/poppler/CairoFontEngine.cc (-2 / +2 lines)
Lines 114-120 Link Here
114
                cairo_matrix_t m;
114
                cairo_matrix_t m;
115
                cairo_matrix_init_identity(&m);
115
                cairo_matrix_init_identity(&m);
116
                cairo_font_options_t *options = cairo_font_options_create();
116
                cairo_font_options_t *options = cairo_font_options_create();
117
                cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
117
	cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_SLIGHT);
118
                cairo_font_options_set_hint_metrics(options, CAIRO_HINT_METRICS_OFF);
118
                cairo_font_options_set_hint_metrics(options, CAIRO_HINT_METRICS_OFF);
119
                cairo_scaled_font_t *scaled_font = cairo_scaled_font_create(cairo_font_face, &m, &m, options);
119
                cairo_scaled_font_t *scaled_font = cairo_scaled_font_create(cairo_font_face, &m, &m, options);
120
120
Lines 186-192 Link Here
186
        }
186
        }
187
    }
187
    }
188
188
189
    font_face.cairo_font_face = cairo_ft_font_face_create_for_ft_face(resource->face, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP);
189
    font_face.cairo_font_face = cairo_ft_font_face_create_for_ft_face(resource->face, FT_LOAD_TARGET_LIGHT | FT_LOAD_NO_BITMAP);
190
    if (cairo_font_face_set_user_data(font_face.cairo_font_face, &ft_cairo_key, resource, _ft_done_face)) {
190
    if (cairo_font_face_set_user_data(font_face.cairo_font_face, &ft_cairo_key, resource, _ft_done_face)) {
191
        cairo_font_face_destroy(font_face.cairo_font_face);
191
        cairo_font_face_destroy(font_face.cairo_font_face);
192
        _ft_done_face(resource);
192
        _ft_done_face(resource);
(-)poppler-23.09.0/poppler/CairoOutputDev.cc (+24 lines)
Lines 223-228 Link Here
223
    }
223
    }
224
    if (c != nullptr) {
224
    if (c != nullptr) {
225
        cairo = cairo_reference(c);
225
        cairo = cairo_reference(c);
226
        {
227
          cairo_font_options_t *options = cairo_font_options_create ();
228
          cairo_get_font_options (cairo, options);
229
          cairo_font_options_set_antialias (options, CAIRO_ANTIALIAS_SUBPIXEL);
230
          cairo_set_font_options (cairo, options);
231
          cairo_font_options_destroy (options);
232
        }
226
        /* save the initial matrix so that we can use it for type3 fonts. */
233
        /* save the initial matrix so that we can use it for type3 fonts. */
227
        // XXX: is this sufficient? could we miss changes to the matrix somehow?
234
        // XXX: is this sufficient? could we miss changes to the matrix somehow?
228
        cairo_get_matrix(cairo, &orig_matrix);
235
        cairo_get_matrix(cairo, &orig_matrix);
Lines 1519-1524 Link Here
1519
void CairoOutputDev::endString(GfxState *state)
1526
void CairoOutputDev::endString(GfxState *state)
1520
{
1527
{
1521
    int render;
1528
    int render;
1529
  GfxFontType fontType;
1522
1530
1523
    if (!currentFont) {
1531
    if (!currentFont) {
1524
        return;
1532
        return;
Lines 1544-1549 Link Here
1544
        render = 0;
1552
        render = 0;
1545
    }
1553
    }
1546
1554
1555
  fontType = state->getFont()->getType();
1556
  // Do not enable subpixel rendering for type3 font
1557
  // For some reason it does not work
1558
  if (fontType == fontType3) {
1559
      cairo_save(cairo);
1560
      cairo_font_options_t *fo;
1561
      fo = cairo_font_options_create ();
1562
      cairo_get_font_options (cairo, fo);
1563
      cairo_font_options_set_antialias (fo, CAIRO_ANTIALIAS_DEFAULT);
1564
      cairo_set_font_options (cairo, fo);
1565
  }
1566
1547
    if (!(render & 1)) {
1567
    if (!(render & 1)) {
1548
        LOG(printf("fill string\n"));
1568
        LOG(printf("fill string\n"));
1549
        cairo_set_source(cairo, fill_pattern);
1569
        cairo_set_source(cairo, fill_pattern);
Lines 1596-1601 Link Here
1596
    }
1616
    }
1597
1617
1598
finish:
1618
finish:
1619
    // pair with the previous cairo_save to disable subpixel rendering for type3 fonts
1620
    if (fontType == fontType3) {
1621
        cairo_restore(cairo);
1622
    }
1599
    gfree(glyphs);
1623
    gfree(glyphs);
1600
    glyphs = nullptr;
1624
    glyphs = nullptr;
1601
    if (use_show_text_glyphs) {
1625
    if (use_show_text_glyphs) {
(-)poppler-23.09.0/poppler/Gfx.cc (+41 lines)
Lines 4603-4608 Link Here
4603
    error(errSyntaxError, getPos(), "Bad image parameters");
4603
    error(errSyntaxError, getPos(), "Bad image parameters");
4604
}
4604
}
4605
4605
4606
bool Gfx::checkNormalBlendModeOnly(Object *str) {
4607
  printf("check blender mode start\n");
4608
  Object args[maxArgs];
4609
  int numArgs;
4610
  bool onlyNormalBlendMode;
4611
  Parser myParser(xref, str, false);
4612
4613
  numArgs = 0;
4614
  onlyNormalBlendMode = true;
4615
4616
  Object obj = myParser.getObj();
4617
  while (!obj.isEOF()) {
4618
    if (obj.isCmd()) {
4619
      const char* cmd = obj.getCmd();
4620
4621
      if (strcmp(cmd, "gs") == 0) {
4622
        GfxBlendMode mode;
4623
        Object obj1 = res->lookupGState(args[0].getName());
4624
        if (!obj1.isNull()) {
4625
          Object obj2 = obj1.dictLookup("BM");
4626
          if (!obj2.isNull()) {
4627
            if (state->parseBlendMode(&obj2, &mode)) {
4628
              printf("check blend mode: %d\n", mode);
4629
              onlyNormalBlendMode &= (mode == gfxBlendNormal);
4630
            }
4631
          }
4632
        }
4633
      }
4634
4635
      numArgs = 0;
4636
    } else if (numArgs < maxArgs) {
4637
      args[numArgs++] = obj.copy();
4638
    }
4639
4640
    obj = myParser.getObj();
4641
  }
4642
4643
  return onlyNormalBlendMode;
4644
}
4645
4646
4606
bool Gfx::checkTransparencyGroup(Dict *resDict)
4647
bool Gfx::checkTransparencyGroup(Dict *resDict)
4607
{
4648
{
4608
    // check the effect of compositing objects as a group:
4649
    // check the effect of compositing objects as a group:
(-)poppler-23.09.0/poppler/Gfx.h (+3 lines)
Lines 190-195 Link Here
190
    // Get the current graphics state object.
190
    // Get the current graphics state object.
191
    GfxState *getState() { return state; }
191
    GfxState *getState() { return state; }
192
192
193
  // Check whether a stream only contains normal blend mode (to enable subpixel rendering)
194
  bool checkNormalBlendModeOnly(Object *str);
195
193
    bool checkTransparencyGroup(Dict *resDict);
196
    bool checkTransparencyGroup(Dict *resDict);
194
197
195
    void drawForm(Object *str, Dict *resDict, const double *matrix, const double *bbox, bool transpGroup = false, bool softMask = false, GfxColorSpace *blendingColorSpace = nullptr, bool isolated = false, bool knockout = false,
198
    void drawForm(Object *str, Dict *resDict, const double *matrix, const double *bbox, bool transpGroup = false, bool softMask = false, GfxColorSpace *blendingColorSpace = nullptr, bool isolated = false, bool knockout = false,
(-)poppler-23.09.0/poppler/Page.cc (+13 lines)
Lines 344-349 Link Here
344
    return dict ? dict->copy(xrefA) : nullptr;
344
    return dict ? dict->copy(xrefA) : nullptr;
345
}
345
}
346
346
347
bool Page::supportSubpixelRendering(OutputDev *out) {
348
  bool supported = false;
349
  PDFRectangle box;
350
351
  Object obj = contents.fetch(xref);
352
  if (!obj.isNull()) {
353
    Gfx gfx(doc, out, attrs->getResourceDict(), &box, nullptr);
354
    supported = gfx.checkNormalBlendModeOnly(&obj);
355
  }
356
357
  return supported;
358
}
359
347
void Page::replaceXRef(XRef *xrefA)
360
void Page::replaceXRef(XRef *xrefA)
348
{
361
{
349
    Dict *pageDict = pageObj.getDict()->copy(xrefA);
362
    Dict *pageDict = pageObj.getDict()->copy(xrefA);
(-)poppler-23.09.0/poppler/Page.h (+3 lines)
Lines 178-183 Link Here
178
    Object *getResourceDictObject();
178
    Object *getResourceDictObject();
179
    Dict *getResourceDictCopy(XRef *xrefA);
179
    Dict *getResourceDictCopy(XRef *xrefA);
180
180
181
  // Whether the content in this page supports subpixel rendering (lcdfilter)
182
  bool supportSubpixelRendering(OutputDev *out);
183
181
    // Get annotations array.
184
    // Get annotations array.
182
    Object getAnnotsObject(XRef *xrefA = nullptr) { return annotsObj.fetch(xrefA ? xrefA : xref); }
185
    Object getAnnotsObject(XRef *xrefA = nullptr) { return annotsObj.fetch(xrefA ? xrefA : xref); }
183
    // Add a new annotation to the page
186
    // Add a new annotation to the page

Return to bug 920355