2008-08-02 18:31:32 +04:00
|
|
|
/*
|
2016-01-15 22:36:12 +03:00
|
|
|
* Copyright 2008 - 2016 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
2008-08-02 18:31:32 +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/>.
|
|
|
|
*/
|
|
|
|
|
2015-01-13 01:40:46 +03:00
|
|
|
#include "amiga/os3support.h"
|
|
|
|
|
2011-04-22 20:48:29 +04:00
|
|
|
#include <proto/diskfont.h>
|
|
|
|
#include <proto/exec.h>
|
2016-01-16 03:00:57 +03:00
|
|
|
#include <proto/graphics.h>
|
2009-01-16 23:05:21 +03:00
|
|
|
|
2014-10-16 12:55:01 +04:00
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/nsoption.h"
|
|
|
|
#include "desktop/browser.h"
|
|
|
|
#include "desktop/font.h"
|
|
|
|
|
|
|
|
#include "amiga/font.h"
|
2016-01-16 03:00:57 +03:00
|
|
|
#include "amiga/font_bullet.h"
|
|
|
|
#include "amiga/font_diskfont.h"
|
2014-10-16 12:55:01 +04:00
|
|
|
#include "amiga/font_scan.h"
|
|
|
|
|
2016-01-18 03:02:52 +03:00
|
|
|
static ULONG ami_devicedpi = 72;
|
|
|
|
static ULONG ami_xdpi = 72;
|
|
|
|
|
|
|
|
ULONG ami_font_dpi_get_devicedpi(void)
|
|
|
|
{
|
|
|
|
return ami_devicedpi;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG ami_font_dpi_get_xdpi(void)
|
|
|
|
{
|
|
|
|
return ami_xdpi;
|
|
|
|
}
|
|
|
|
|
2011-04-22 20:48:29 +04:00
|
|
|
void ami_font_setdevicedpi(int id)
|
2011-04-22 20:06:46 +04:00
|
|
|
{
|
2011-04-22 20:48:29 +04:00
|
|
|
DisplayInfoHandle dih;
|
|
|
|
struct DisplayInfo dinfo;
|
2011-04-25 21:43:22 +04:00
|
|
|
|
2016-01-16 03:00:57 +03:00
|
|
|
if(nsoption_bool(bitmap_fonts) == true) {
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("WARNING: Using diskfont.library for text. Forcing DPI to 72.");
|
2016-01-16 22:37:39 +03:00
|
|
|
nsoption_set_int(screen_ydpi, 72);
|
2015-02-22 19:50:41 +03:00
|
|
|
}
|
|
|
|
|
2016-01-18 02:40:50 +03:00
|
|
|
ULONG ydpi = nsoption_int(screen_ydpi);
|
|
|
|
ULONG xdpi = nsoption_int(screen_ydpi);
|
2014-10-13 05:34:10 +04:00
|
|
|
browser_set_dpi(nsoption_int(screen_ydpi));
|
2011-04-22 20:48:29 +04:00
|
|
|
|
2012-03-22 13:34:34 +04:00
|
|
|
if(id && (nsoption_int(monitor_aspect_x) != 0) && (nsoption_int(monitor_aspect_y) != 0))
|
2011-04-22 20:48:29 +04:00
|
|
|
{
|
2014-11-09 22:26:59 +03:00
|
|
|
if((dih = FindDisplayInfo(id)))
|
2011-04-22 20:48:29 +04:00
|
|
|
{
|
|
|
|
if(GetDisplayInfoData(dih, &dinfo, sizeof(struct DisplayInfo),
|
|
|
|
DTAG_DISP, 0))
|
|
|
|
{
|
2011-07-17 18:48:19 +04:00
|
|
|
int xres = dinfo.Resolution.x;
|
|
|
|
int yres = dinfo.Resolution.y;
|
2011-04-22 20:48:29 +04:00
|
|
|
|
2012-03-22 13:34:34 +04:00
|
|
|
if((nsoption_int(monitor_aspect_x) != 4) || (nsoption_int(monitor_aspect_y) != 3))
|
2011-07-17 18:48:19 +04:00
|
|
|
{
|
|
|
|
/* AmigaOS sees 4:3 modes as square in the DisplayInfo database,
|
2011-10-11 21:58:14 +04:00
|
|
|
* so we correct other modes to "4:3 equiv" here. */
|
2012-03-22 13:34:34 +04:00
|
|
|
xres = (xres * nsoption_int(monitor_aspect_x)) / 4;
|
|
|
|
yres = (yres * nsoption_int(monitor_aspect_y)) / 3;
|
2011-07-17 18:48:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
xdpi = (yres * ydpi) / xres;
|
|
|
|
|
2015-07-06 20:16:39 +03:00
|
|
|
LOG("XDPI = %ld, YDPI = %ld (DisplayInfo resolution %d x %d, corrected %d x %d)", xdpi, ydpi, dinfo.Resolution.x, dinfo.Resolution.y, xres, yres);
|
2011-04-22 20:48:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-04-22 20:06:46 +04:00
|
|
|
|
2011-05-02 14:33:16 +04:00
|
|
|
ami_xdpi = xdpi;
|
2011-04-22 20:48:29 +04:00
|
|
|
ami_devicedpi = (xdpi << 16) | ydpi;
|
2011-04-22 20:06:46 +04:00
|
|
|
}
|
2011-09-08 03:01:53 +04:00
|
|
|
|
|
|
|
/* The below are simple font routines which should not be used for page rendering */
|
|
|
|
|
|
|
|
struct TextFont *ami_font_open_disk_font(struct TextAttr *tattr)
|
|
|
|
{
|
|
|
|
struct TextFont *tfont = OpenDiskFont(tattr);
|
|
|
|
return tfont;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ami_font_close_disk_font(struct TextFont *tfont)
|
|
|
|
{
|
|
|
|
CloseFont(tfont);
|
|
|
|
}
|
2015-02-03 22:48:28 +03:00
|
|
|
|
2016-01-15 22:36:12 +03:00
|
|
|
/* Font initialisation */
|
|
|
|
void ami_font_init(void)
|
|
|
|
{
|
2016-01-16 03:00:57 +03:00
|
|
|
if(nsoption_bool(bitmap_fonts) == false) {
|
2016-01-15 22:36:12 +03:00
|
|
|
ami_font_bullet_init();
|
|
|
|
} else {
|
|
|
|
ami_font_diskfont_init();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ami_font_fini(void)
|
|
|
|
{
|
2016-01-16 03:00:57 +03:00
|
|
|
if(nsoption_bool(bitmap_fonts) == false) {
|
2016-01-15 22:36:12 +03:00
|
|
|
ami_font_bullet_fini();
|
|
|
|
}
|
|
|
|
}
|
2015-02-03 22:48:28 +03:00
|
|
|
|
|
|
|
/* Stub entry points */
|
|
|
|
static bool nsfont_width(const plot_font_style_t *fstyle,
|
|
|
|
const char *string, size_t length,
|
|
|
|
int *width)
|
|
|
|
{
|
2016-01-15 22:36:12 +03:00
|
|
|
if(__builtin_expect(ami_nsfont == NULL, 0)) return false;
|
|
|
|
return ami_nsfont->width(fstyle, string, length, width);
|
2015-02-03 22:48:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool nsfont_position_in_string(const plot_font_style_t *fstyle,
|
|
|
|
const char *string, size_t length,
|
|
|
|
int x, size_t *char_offset, int *actual_x)
|
|
|
|
{
|
2016-01-15 22:36:12 +03:00
|
|
|
if(__builtin_expect(ami_nsfont == NULL, 0)) return false;
|
|
|
|
return ami_nsfont->posn(fstyle, string, length, x, char_offset, actual_x);
|
2015-02-03 22:48:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool nsfont_split(const plot_font_style_t *fstyle,
|
|
|
|
const char *string, size_t length,
|
|
|
|
int x, size_t *char_offset, int *actual_x)
|
|
|
|
{
|
2016-01-15 22:36:12 +03:00
|
|
|
if(__builtin_expect(ami_nsfont == NULL, 0)) return false;
|
|
|
|
return ami_nsfont->split(fstyle, string, length, x, char_offset, actual_x);
|
2015-02-03 22:48:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const struct font_functions nsfont = {
|
|
|
|
nsfont_width,
|
|
|
|
nsfont_position_in_string,
|
|
|
|
nsfont_split
|
|
|
|
};
|
|
|
|
|