diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-10-07 08:49:42 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-10-07 08:49:42 +0300 |
commit | c9ded71342f4e47b48151782a48fc488a5f63e56 (patch) | |
tree | 11b0b470f58bc3c39ad3b7d5b1715c6aed98d9b5 /src/ui/text.c | |
parent | fa79abfe8bb9fcbdd4cf9cec46e0d1856f4e7020 (diff) |
DocumentWidget: Line width based on font glyph width
The idea is that the amount of content should be the same per line regardless of the font.
Diffstat (limited to 'src/ui/text.c')
-rw-r--r-- | src/ui/text.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/ui/text.c b/src/ui/text.c index 25c79e23..8adfa019 100644 --- a/src/ui/text.c +++ b/src/ui/text.c | |||
@@ -1882,6 +1882,11 @@ int lineHeight_Text(int fontId) { | |||
1882 | return font_Text_(fontId)->height; | 1882 | return font_Text_(fontId)->height; |
1883 | } | 1883 | } |
1884 | 1884 | ||
1885 | float emRatio_Text(int fontId) { | ||
1886 | const iFont *font = font_Text_(fontId); | ||
1887 | return font->emAdvance / font->height; | ||
1888 | } | ||
1889 | |||
1885 | iTextMetrics measureRange_Text(int fontId, iRangecc text) { | 1890 | iTextMetrics measureRange_Text(int fontId, iRangecc text) { |
1886 | if (isEmpty_Range(&text)) { | 1891 | if (isEmpty_Range(&text)) { |
1887 | return (iTextMetrics){ init_Rect(0, 0, 0, lineHeight_Text(fontId)), zero_I2() }; | 1892 | return (iTextMetrics){ init_Rect(0, 0, 0, lineHeight_Text(fontId)), zero_I2() }; |