Fix for wordwrapping when there is a space then a newline
This commit is contained in:
parent
87ec4b7c77
commit
c41cbd05e9
1 changed files with 42 additions and 38 deletions
|
@ -31,7 +31,7 @@ static bool get_wordlen(const struct mf_font_s *font, mf_str *text,
|
||||||
struct wordlen_s *result)
|
struct wordlen_s *result)
|
||||||
{
|
{
|
||||||
mf_char c;
|
mf_char c;
|
||||||
mf_str prev;
|
mf_str prev = *text;
|
||||||
|
|
||||||
result->word = 0;
|
result->word = 0;
|
||||||
result->space = 0;
|
result->space = 0;
|
||||||
|
@ -42,10 +42,11 @@ static bool get_wordlen(const struct mf_font_s *font, mf_str *text,
|
||||||
{
|
{
|
||||||
result->chars++;
|
result->chars++;
|
||||||
result->word += mf_character_width(font, c);
|
result->word += mf_character_width(font, c);
|
||||||
|
|
||||||
|
prev = *text;
|
||||||
c = mf_getchar(text);
|
c = mf_getchar(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
prev = *text;
|
|
||||||
while (c && is_wrap_space(c))
|
while (c && is_wrap_space(c))
|
||||||
{
|
{
|
||||||
result->chars++;
|
result->chars++;
|
||||||
|
@ -56,8 +57,11 @@ static bool get_wordlen(const struct mf_font_s *font, mf_str *text,
|
||||||
result->space += mf_character_width(font, '-');
|
result->space += mf_character_width(font, '-');
|
||||||
else if (c == '\t')
|
else if (c == '\t')
|
||||||
result->space += mf_character_width(font, 'm') * MF_TABSIZE;
|
result->space += mf_character_width(font, 'm') * MF_TABSIZE;
|
||||||
else if (c == '\n')
|
else if (c == '\n') {
|
||||||
|
/* Special case for newlines, skip the character then break. */
|
||||||
|
prev = *text;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
prev = *text;
|
prev = *text;
|
||||||
c = mf_getchar(text);
|
c = mf_getchar(text);
|
||||||
|
|
Loading…
Add table
Reference in a new issue