From 6bab5568278cb437efb6fb17a4a1b494e05b9549 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 10 Feb 2013 18:28:59 +0000 Subject: Make comaptible with new nsfont_split expectation. Untested, but code is same as framebuffer front end, so should work. --- atari/plot/font_freetype.c | 5 +++-- atari/plot/font_internal.c | 9 ++++++++- atari/plot/font_vdi.c | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'atari/plot') diff --git a/atari/plot/font_freetype.c b/atari/plot/font_freetype.c index 8db7cc2c0..ed850bce2 100755 --- a/atari/plot/font_freetype.c +++ b/atari/plot/font_freetype.c @@ -443,8 +443,9 @@ static int str_split( FONT_PLOTTER self, const plot_font_style_t *fstyle, last_space_idx = nxtchr; } *actual_x += glyph->advance.x >> 16; - if (*actual_x > x) { - /* string has exceeded available width return previous space*/ + if (*actual_x > x && last_space_idx != 0) { + /* string has exceeded available width and we've + * found a space; return previous space */ *actual_x = last_space_x; *char_offset = last_space_idx; return true; diff --git a/atari/plot/font_internal.c b/atari/plot/font_internal.c index 3db29eba5..2b0025a71 100644 --- a/atari/plot/font_internal.c +++ b/atari/plot/font_internal.c @@ -118,7 +118,7 @@ static int str_split( FONT_PLOTTER self, const plot_font_style_t * fstyle, const size_t length,int x, size_t *char_offset, int *actual_x ) { const struct fb_font_desc* fb_font = fb_get_font(fstyle); - *char_offset = x / fb_font->width; + int c_off = *char_offset = x / fb_font->width; if (*char_offset > length) { *char_offset = length; } else { @@ -127,6 +127,13 @@ static int str_split( FONT_PLOTTER self, const plot_font_style_t * fstyle, const break; (*char_offset)--; } + if (*char_offset == 0) { + *char_offset = c_off; + while (*char_offset < length && + string[*char_offset] != ' ') { + (*char_offset)++; + } + } } *actual_x = *char_offset * fb_font->width; return( 1 ); diff --git a/atari/plot/font_vdi.c b/atari/plot/font_vdi.c index 4ebab24fb..340759f02 100755 --- a/atari/plot/font_vdi.c +++ b/atari/plot/font_vdi.c @@ -164,7 +164,7 @@ static int str_split( FONT_PLOTTER self, const plot_font_style_t * fstyle, const last_space_idx = nxtchr; } *actual_x += cellw; - if (*actual_x > x) { + if (*actual_x > x && last_space_idx != 0) { *actual_x = last_space_x; *char_offset = last_space_idx; //printf("at: %s\n", lstr); -- cgit v1.2.3