summaryrefslogtreecommitdiff
path: root/src/gmdocument.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-10-15 12:08:27 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-10-15 12:08:27 +0300
commit2f3987f5e54d95658f95c6991b0644bc15eedabf (patch)
treec8b76534a2b5d758c3062603afb3b2665856a548 /src/gmdocument.c
parentf5938745dcbe567d6e52f79b63151584d2c917d8 (diff)
Text: Fixed a line wrapping issue
When the last safe break position was not in the current attributed run, the calculated wrap advance came out incorrect. This was possible when the first glyph in an attributed run didn't fit.
Diffstat (limited to 'src/gmdocument.c')
-rw-r--r--src/gmdocument.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c
index e37d585e..0adf5243 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -493,10 +493,15 @@ static iBool typesetOneLine_RunTypesetter_(iWrapText *wrap, iRangecc wrapRange,
493 int origin, int advance) { 493 int origin, int advance) {
494 iAssert(wrapRange.start <= wrapRange.end); 494 iAssert(wrapRange.start <= wrapRange.end);
495 trimEnd_Rangecc(&wrapRange); 495 trimEnd_Rangecc(&wrapRange);
496// printf("typeset: {%s}\n", cstr_Rangecc(wrapRange));
497 iRunTypesetter *d = wrap->context; 496 iRunTypesetter *d = wrap->context;
498 d->run.text = wrapRange; 497 d->run.text = wrapRange;
499 applyAttributes_RunTypesetter_(d, attrib); 498 applyAttributes_RunTypesetter_(d, attrib);
499#if 0
500 const int msr = measureRange_Text(d->run.font, wrapRange).advance.x;
501 if (iAbs(msr - advance) > 3) {
502 printf("\n[RunTypesetter] wrong wrapRange advance! actual:%d wrapped:%d\n\n", msr, advance);
503 }
504#endif
500 if (~d->run.flags & startOfLine_GmRunFlag && d->lineHeightReduction > 0.0f) { 505 if (~d->run.flags & startOfLine_GmRunFlag && d->lineHeightReduction > 0.0f) {
501 d->pos.y -= d->lineHeightReduction * lineHeight_Text(d->baseFont); 506 d->pos.y -= d->lineHeightReduction * lineHeight_Text(d->baseFont);
502 } 507 }
@@ -508,7 +513,7 @@ static iBool typesetOneLine_RunTypesetter_(iWrapText *wrap, iRangecc wrapRange,
508 d->run.visBounds = d->run.bounds; 513 d->run.visBounds = d->run.bounds;
509 d->run.visBounds.size.x = dims.x; 514 d->run.visBounds.size.x = dims.x;
510 d->run.isRTL = attrib.isBaseRTL; 515 d->run.isRTL = attrib.isBaseRTL;
511 printf("origin:%d isRTL:%d\n{%s}\n", origin, attrib.isBaseRTL, cstr_Rangecc(wrapRange)); 516// printf("origin:%d isRTL:%d\n{%s}\n", origin, attrib.isBaseRTL, cstr_Rangecc(wrapRange));
512 pushBack_Array(&d->layout, &d->run); 517 pushBack_Array(&d->layout, &d->run);
513 d->run.flags &= ~startOfLine_GmRunFlag; 518 d->run.flags &= ~startOfLine_GmRunFlag;
514 d->pos.y += lineHeight_Text(d->baseFont) * prefs_App()->lineSpacing; 519 d->pos.y += lineHeight_Text(d->baseFont) * prefs_App()->lineSpacing;