2011-01-06 00:02:22 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2010 Ole Loots <ole@monochrom.net>
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <assert.h>
|
2012-08-24 02:47:37 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Ole Loots <ole@monochrom.net>
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2014-10-13 14:56:31 +04:00
|
|
|
#include "desktop/font.h"
|
2011-01-06 00:02:22 +03:00
|
|
|
#include "utils/utf8.h"
|
|
|
|
#include "utils/log.h"
|
2013-05-26 01:46:27 +04:00
|
|
|
#include "utils/nsoption.h"
|
2011-01-06 00:02:22 +03:00
|
|
|
#include "desktop/mouse.h"
|
|
|
|
#include "desktop/plotters.h"
|
|
|
|
|
|
|
|
#include "atari/gui.h"
|
2015-04-20 00:58:13 +03:00
|
|
|
#include "atari/plot/fontplot.h"
|
2012-07-14 00:19:04 +04:00
|
|
|
#include "atari/plot/plot.h"
|
2011-01-06 00:02:22 +03:00
|
|
|
#include "atari/findfile.h"
|
2015-04-20 00:58:13 +03:00
|
|
|
#include "atari/font.h"
|
2011-01-06 00:02:22 +03:00
|
|
|
|
2012-07-14 00:19:04 +04:00
|
|
|
extern FONT_PLOTTER fplotter;
|
2011-01-06 00:02:22 +03:00
|
|
|
|
2011-11-29 03:23:28 +04:00
|
|
|
static bool atari_font_position_in_string(const plot_font_style_t * fstyle,const char *string,
|
2011-01-06 00:02:22 +03:00
|
|
|
size_t length,int x, size_t *char_offset, int *actual_x )
|
2013-12-04 05:00:45 +04:00
|
|
|
{
|
|
|
|
float scale = plot_get_scale();
|
|
|
|
|
|
|
|
if (scale != 1.0) {
|
|
|
|
plot_font_style_t newstyle = *fstyle;
|
|
|
|
newstyle.size = (int)((float)fstyle->size*scale);
|
|
|
|
fplotter->pixel_pos(fplotter, &newstyle, string, length, x, char_offset, actual_x);
|
|
|
|
} else {
|
|
|
|
fplotter->pixel_pos(fplotter, fstyle, string, length, x, char_offset, actual_x);
|
|
|
|
}
|
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
|
2011-11-29 03:23:28 +04:00
|
|
|
static bool atari_font_split( const plot_font_style_t * fstyle, const char *string,
|
2011-01-06 00:02:22 +03:00
|
|
|
size_t length,int x, size_t *char_offset, int *actual_x )
|
2013-12-04 05:00:45 +04:00
|
|
|
{
|
|
|
|
float scale = plot_get_scale();
|
|
|
|
|
|
|
|
if (scale != 1.0) {
|
|
|
|
plot_font_style_t newstyle = *fstyle;
|
|
|
|
newstyle.size = (int)((float)fstyle->size*scale);
|
|
|
|
fplotter->str_split(fplotter, &newstyle, string, length, x, char_offset,
|
|
|
|
actual_x);
|
|
|
|
} else {
|
|
|
|
fplotter->str_split(fplotter, fstyle, string, length, x, char_offset,
|
|
|
|
actual_x);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-29 03:23:28 +04:00
|
|
|
return( true );
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
|
|
|
|
2011-11-29 03:23:28 +04:00
|
|
|
static bool atari_font_width( const plot_font_style_t *fstyle, const char * str,
|
2011-01-06 00:02:22 +03:00
|
|
|
size_t length, int * width )
|
2013-12-04 05:00:45 +04:00
|
|
|
{
|
|
|
|
float scale = plot_get_scale();
|
|
|
|
|
|
|
|
if (scale != 1.0) {
|
|
|
|
plot_font_style_t newstyle = *fstyle;
|
|
|
|
newstyle.size = (int)((float)fstyle->size*scale);
|
|
|
|
fplotter->str_width(fplotter, &newstyle, str, length, width);
|
|
|
|
} else {
|
|
|
|
fplotter->str_width(fplotter, fstyle, str, length, width);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct font_functions nsfont = {
|
|
|
|
atari_font_width,
|
|
|
|
atari_font_position_in_string,
|
|
|
|
atari_font_split
|
|
|
|
};
|
|
|
|
|
|
|
|
|