Skip to content

Commit cffab67

Browse files
committed
SText extraction speedup.
Optimise fz_glyph_entirely_outside_box. Combine ctm and trm and apply once, rather than applying twice. Saves ~1.9% of runtime when extracting pdf_reference17.pdf to text.
1 parent 459230e commit cffab67

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

source/fitz/glyphbox.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424

2525
int fz_glyph_entirely_outside_box(fz_context *ctx, fz_matrix *ctm, fz_text_span *span, fz_text_item *item, fz_rect *box)
2626
{
27-
fz_rect glyph_rect = fz_bound_glyph(ctx, span->font, item->gid, span->trm);
28-
glyph_rect.x0 += item->x;
29-
glyph_rect.y0 += item->y;
30-
glyph_rect.x1 += item->x;
31-
glyph_rect.y1 += item->y;
32-
glyph_rect = fz_transform_rect(glyph_rect, *ctm);
27+
fz_rect glyph_rect;
28+
fz_matrix trm = span->trm;
29+
trm.e += item->x;
30+
trm.f += item->y;
31+
trm = fz_concat(trm, *ctm);
32+
glyph_rect = fz_bound_glyph(ctx, span->font, item->gid, trm);
3333
if (glyph_rect.x1 <= box->x0 ||
3434
glyph_rect.y1 <= box->y0 ||
3535
glyph_rect.x0 >= box->x1 ||

0 commit comments

Comments
 (0)