diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-12-01 10:20:14 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-12-01 10:20:14 +0200 |
commit | f6e3717713d9c89d9342b30ef3eb7545aed8f053 (patch) | |
tree | 7bc76251602c1e512f36108ab2e00b7d18f32c83 | |
parent | 0df97a5c5202bb765959df87861957ca2d4f301d (diff) |
Text: Dealing with soft hyphens
With regard to gemini://gemini.conman.org/test/torture/0050.
-rw-r--r-- | src/ui/text.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/ui/text.c b/src/ui/text.c index e047bbce..25e0da34 100644 --- a/src/ui/text.c +++ b/src/ui/text.c | |||
@@ -605,7 +605,7 @@ iLocalDef iBool isWrapBoundary_(iChar prevC, iChar c) { | |||
605 | if (isSpace_Char(prevC)) { | 605 | if (isSpace_Char(prevC)) { |
606 | return iFalse; | 606 | return iFalse; |
607 | } | 607 | } |
608 | if (c == '/' || c == '-' || c == ',' || c == ';' || c == ':' || c == '.') { | 608 | if (c == '/' || c == '-' || c == ',' || c == ';' || c == ':' || c == '.' || c == 0xad) { |
609 | return iTrue; | 609 | return iTrue; |
610 | } | 610 | } |
611 | return isSpace_Char(c); | 611 | return isSpace_Char(c); |
@@ -657,6 +657,27 @@ static iRect run_Font_(iFont *d, enum iRunMode mode, iRangecc text, size_t maxLe | |||
657 | ch = nextChar_(&chPos, text.end); /* just ignore */ | 657 | ch = nextChar_(&chPos, text.end); /* just ignore */ |
658 | } | 658 | } |
659 | /* Special instructions. */ { | 659 | /* Special instructions. */ { |
660 | if (ch == 0xad) { /* soft hyphen */ | ||
661 | lastWordEnd = chPos; | ||
662 | if (isMeasuring_(mode)) { | ||
663 | if (xposLimit > 0) { | ||
664 | const char *postHyphen = chPos; | ||
665 | iChar nextCh = nextChar_(&postHyphen, text.end); | ||
666 | if ((int) xpos + glyph_Font_(d, ch)->rect[0].size.x + | ||
667 | glyph_Font_(d, nextCh)->rect[0].size.x > xposLimit) { | ||
668 | /* Wraps after hyphen, should show it. */ | ||
669 | } | ||
670 | else continue; | ||
671 | } | ||
672 | else continue; | ||
673 | } | ||
674 | else { | ||
675 | /* Only show it at the end. */ | ||
676 | if (chPos != text.end) { | ||
677 | continue; | ||
678 | } | ||
679 | } | ||
680 | } | ||
660 | if (ch == '\n') { | 681 | if (ch == '\n') { |
661 | xpos = pos.x; | 682 | xpos = pos.x; |
662 | pos.y += d->height; | 683 | pos.y += d->height; |