2003-06-30 16:44:03 +04:00
|
|
|
/*
|
|
|
|
* This file is part of NetSurf, http://netsurf.sourceforge.net/
|
|
|
|
* Licensed under the GNU General Public License,
|
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
2005-04-17 14:15:52 +04:00
|
|
|
* Copyright 2005 James Bursa <bursa@users.sourceforge.net>
|
2003-06-21 17:18:00 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include "netsurf/css/css.h"
|
2003-07-18 03:01:02 +04:00
|
|
|
#include "netsurf/render/font.h"
|
2003-06-21 17:18:00 +04:00
|
|
|
|
2003-07-18 03:01:02 +04:00
|
|
|
|
2005-04-17 14:15:52 +04:00
|
|
|
bool nsfont_width(const struct css_style *style,
|
|
|
|
const char *string, size_t length,
|
|
|
|
int *width)
|
2003-06-21 17:18:00 +04:00
|
|
|
{
|
2005-04-17 14:15:52 +04:00
|
|
|
assert(style);
|
|
|
|
assert(string);
|
2003-06-21 17:18:00 +04:00
|
|
|
|
2005-04-17 14:15:52 +04:00
|
|
|
*width = length * 10;
|
2005-01-02 06:58:21 +03:00
|
|
|
return true;
|
2003-06-21 17:18:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-17 14:15:52 +04:00
|
|
|
bool nsfont_position_in_string(const struct css_style *style,
|
|
|
|
const char *string, size_t length,
|
|
|
|
int x, size_t *char_offset, int *actual_x)
|
2003-06-21 17:18:00 +04:00
|
|
|
{
|
2005-04-17 14:15:52 +04:00
|
|
|
assert(style);
|
|
|
|
assert(string);
|
2003-06-21 17:18:00 +04:00
|
|
|
|
2005-04-17 14:15:52 +04:00
|
|
|
*char_offset = (x + 5) / 10;
|
|
|
|
if (length < *char_offset)
|
|
|
|
*char_offset = length;
|
|
|
|
*actual_x = *char_offset * 10;
|
|
|
|
return true;
|
2003-06-21 17:18:00 +04:00
|
|
|
}
|
|
|
|
|
2004-06-03 01:01:01 +04:00
|
|
|
|
2005-04-17 14:15:52 +04:00
|
|
|
bool nsfont_split(const struct css_style *style,
|
|
|
|
const char *string, size_t length,
|
|
|
|
int x, size_t *char_offset, int *actual_x)
|
2004-06-03 01:01:01 +04:00
|
|
|
{
|
2005-04-17 14:15:52 +04:00
|
|
|
assert(style);
|
|
|
|
assert(string);
|
2005-01-02 06:58:21 +03:00
|
|
|
|
2005-04-17 14:15:52 +04:00
|
|
|
*char_offset = x / 10;
|
|
|
|
if (length < *char_offset)
|
|
|
|
*char_offset = length;
|
|
|
|
while (*char_offset && string[*char_offset] != ' ')
|
|
|
|
(*char_offset)--;
|
|
|
|
*actual_x = *char_offset * 10;
|
2005-01-02 06:58:21 +03:00
|
|
|
return true;
|
2004-06-03 01:01:01 +04:00
|
|
|
}
|