Summary: | fz_textextractspan: calculate ascender/descender per glyph | ||
---|---|---|---|
Product: | MuPDF | Reporter: | zeniko |
Component: | fitz | Assignee: | MuPDF bugs <mupdf-bugs> |
Status: | CONFIRMED --- | ||
Severity: | enhancement | CC: | sebastian.rasmussen, tor.andersson |
Priority: | P4 | ||
Version: | unspecified | ||
Hardware: | PC | ||
OS: | Windows 7 | ||
URL: | http://code.google.com/p/sumatrapdf/issues/detail?id=1191http://code.google.com/p/sumatrapdf/issues/detail?id=1191 | ||
Customer: | Word Size: | --- |
Description
zeniko
2011-01-23 15:08:28 UTC
You can now get individual bounding boxes for glyphs with fz_bound_glyph. This isn't exposed in the text device yet, but will be once I update and merge the text branch. Here is an example of using fz_bound_glyph to compute per glyph bboxes. I'm not convinced that this is better, though. Another approach would be to distrust the freetype ascender/descender fields and compute them from some standard glyph instead. --- a/fitz/dev_text.c +++ b/fitz/dev_text.c @@ -415,10 +415,14 @@ fz_text_extract(fz_context *ctx, fz_text_device *dev, fz_text *text, fz_matrix c adv = ftadv / 65536.0f; fz_unlock(ctx, FZ_LOCK_FREETYPE); +#ifdef REAL_GLYPH_BBOXES + rect = fz_bound_glyph(ctx, font, text->items[i].gid, fz_identity); +#else rect.x0 = 0; rect.y0 = descender; rect.x1 = adv; rect.y1 = ascender; +#endif (In reply to comment #2) > Here is an example of using fz_bound_glyph to compute per glyph bboxes. Thanks. An IMO better example can be found in our patchset, though, where we conditionally use fz_bound_glyph with additional fiddling to get better results than either of your two suggestions. |