Round to nearest point between chars in nsfont_position_in_string, instead of rounding down.

This commit is contained in:
Michael Drake 2012-07-31 20:41:27 +01:00
parent 941a48dabd
commit 2e4bb2d020

View File

@ -18,6 +18,7 @@
*/
#include <inttypes.h>
#include <string.h>
#include <assert.h>
#include "css/css.h"
@ -112,7 +113,7 @@ static bool nsfont_position_in_string(const plot_font_style_t *fstyle,
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;
*char_offset = (x + fb_font->width / 2) / fb_font->width;
if (*char_offset > length)
*char_offset = length;
*actual_x = *char_offset * fb_font->width;