2003-06-30 16:44:03 +04:00
|
|
|
/*
|
2005-04-17 14:15:52 +04:00
|
|
|
* Copyright 2005 James Bursa <bursa@users.sourceforge.net>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-06-21 17:18:00 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "css/css.h"
|
|
|
|
#include "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
|
|
|
}
|