diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-07-15 18:18:45 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-07-15 18:18:45 +0300 |
commit | aed6837cc1e1bfb9ccb238900ad7387444b624eb (patch) | |
tree | 3b502166a9b9cd69b46ea6c11949be82bedaff53 /src/ui/text.h | |
parent | 9f7bbeecba762213c7dec4555e0cbb1da2b2ea66 (diff) |
Fixing regressions text metrics, InputWidget
`run_Font_` was moving the Y cursor position twice for each line break.
Checking for the HarfBuzz UNSAFE_TO_BREAK flag leads to some unexpected behavior near edges of words.
The old `tryAdvanceNoWrap` method should return the maximum horizontal advance of the text, and not the cursor position's advance.
`draw_WrapText` used the wrong foreground color.
`TextBuf` now uses WrapText to do all the measuring and drawing, making things much simpler.
Diffstat (limited to 'src/ui/text.h')
-rw-r--r-- | src/ui/text.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/ui/text.h b/src/ui/text.h index 09d92ce0..d779dd96 100644 --- a/src/ui/text.h +++ b/src/ui/text.h | |||
@@ -159,6 +159,10 @@ struct Impl_TextMetrics { | |||
159 | iInt2 advance; /* cursor offset */ | 159 | iInt2 advance; /* cursor offset */ |
160 | }; | 160 | }; |
161 | 161 | ||
162 | iLocalDef int maxWidth_TextMetrics(const iTextMetrics d) { | ||
163 | return iMax(width_Rect(d.bounds), d.advance.x); | ||
164 | } | ||
165 | |||
162 | iTextMetrics measureRange_Text (int fontId, iRangecc text); | 166 | iTextMetrics measureRange_Text (int fontId, iRangecc text); |
163 | iTextMetrics measureWrapRange_Text (int fontId, int maxWidth, iRangecc text); | 167 | iTextMetrics measureWrapRange_Text (int fontId, int maxWidth, iRangecc text); |
164 | iTextMetrics measureN_Text (int fontId, const char *text, size_t n); /* `n` in characters */ | 168 | iTextMetrics measureN_Text (int fontId, const char *text, size_t n); /* `n` in characters */ |