From d21447d096a320a08b3efb2b8768fad0dcdcfd64 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 5 May 2016 22:28:51 +0100 Subject: move frontends into sub directory --- frontends/amiga/font.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 frontends/amiga/font.c (limited to 'frontends/amiga/font.c') diff --git a/frontends/amiga/font.c b/frontends/amiga/font.c new file mode 100644 index 000000000..1c9702af2 --- /dev/null +++ b/frontends/amiga/font.c @@ -0,0 +1,152 @@ +/* + * Copyright 2008 - 2016 Chris Young + * + * 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 . + */ + +#include "amiga/os3support.h" + +#include +#include +#include + +#include "utils/log.h" +#include "utils/nsoption.h" +#include "desktop/browser.h" +#include "desktop/gui_layout.h" + +#include "amiga/font.h" +#include "amiga/font_bullet.h" +#include "amiga/font_diskfont.h" +#include "amiga/font_scan.h" + +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; +} + +void ami_font_setdevicedpi(int id) +{ + DisplayInfoHandle dih; + struct DisplayInfo dinfo; + + if(nsoption_bool(bitmap_fonts) == true) { + LOG("WARNING: Using diskfont.library for text. Forcing DPI to 72."); + nsoption_set_int(screen_ydpi, 72); + } + + ULONG ydpi = nsoption_int(screen_ydpi); + ULONG xdpi = nsoption_int(screen_ydpi); + browser_set_dpi(nsoption_int(screen_ydpi)); + + if(id && (nsoption_int(monitor_aspect_x) != 0) && (nsoption_int(monitor_aspect_y) != 0)) + { + if((dih = FindDisplayInfo(id))) + { + if(GetDisplayInfoData(dih, &dinfo, sizeof(struct DisplayInfo), + DTAG_DISP, 0)) + { + int xres = dinfo.Resolution.x; + int yres = dinfo.Resolution.y; + + if((nsoption_int(monitor_aspect_x) != 4) || (nsoption_int(monitor_aspect_y) != 3)) + { + /* AmigaOS sees 4:3 modes as square in the DisplayInfo database, + * so we correct other modes to "4:3 equiv" here. */ + xres = (xres * nsoption_int(monitor_aspect_x)) / 4; + yres = (yres * nsoption_int(monitor_aspect_y)) / 3; + } + + xdpi = (yres * ydpi) / xres; + + LOG("XDPI = %ld, YDPI = %ld (DisplayInfo resolution %d x %d, corrected %d x %d)", xdpi, ydpi, dinfo.Resolution.x, dinfo.Resolution.y, xres, yres); + } + } + } + + ami_xdpi = xdpi; + ami_devicedpi = (xdpi << 16) | ydpi; +} + +/* 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); +} + +/* Font initialisation */ +void ami_font_init(void) +{ + if(nsoption_bool(bitmap_fonts) == false) { + ami_font_bullet_init(); + } else { + ami_font_diskfont_init(); + } +} + +void ami_font_fini(void) +{ + if(nsoption_bool(bitmap_fonts) == false) { + ami_font_bullet_fini(); + } +} + +/* Stub entry points */ +static nserror ami_font_width(const plot_font_style_t *fstyle, + const char *string, size_t length, + int *width) +{ + if(__builtin_expect(ami_nsfont == NULL, 0)) return false; + return ami_nsfont->width(fstyle, string, length, width); +} + +static nserror ami_font_position(const plot_font_style_t *fstyle, + const char *string, size_t length, + int x, size_t *char_offset, int *actual_x) +{ + if(__builtin_expect(ami_nsfont == NULL, 0)) return false; + return ami_nsfont->posn(fstyle, string, length, x, char_offset, actual_x); +} + +static nserror ami_font_split(const plot_font_style_t *fstyle, + const char *string, size_t length, + int x, size_t *char_offset, int *actual_x) +{ + if(__builtin_expect(ami_nsfont == NULL, 0)) return false; + return ami_nsfont->split(fstyle, string, length, x, char_offset, actual_x); +} + +static struct gui_layout_table layout_table = { + .width = ami_font_width, + .position = ami_font_position, + .split = ami_font_split, +}; + +struct gui_layout_table *ami_layout_table = &layout_table; -- cgit v1.2.3