mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-22 12:12:35 +03:00
Put the font operations table alongside all the other core API
The netsurf core is driven from numerous operation tables most of which are now set through a common netsurf_register() interface. The font and plotting interfaces are currently separate and unlike all the other operation tables are modified for differing contexts. This change moves the font operations alongside all the other operations table and remove unnecessary interaction with the renderers font internals. Further this also removes the need for css internals to be visible in frontends.
This commit is contained in:
parent
33c6073dbe
commit
17be8cf216
@ -26,7 +26,7 @@
|
||||
#include "amiga/schedule.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "desktop/browser.h"
|
||||
#include "render/font.h"
|
||||
#include "desktop/font.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/utils.h"
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#include "desktop/printer.h"
|
||||
#include "amiga/plotters.h"
|
||||
#include "render/font.h"
|
||||
#include "desktop/font.h"
|
||||
#include "amiga/gui.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "amiga/print.h"
|
||||
|
@ -23,8 +23,6 @@
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "css/css.h"
|
||||
#include "render/font.h"
|
||||
#include "utils/utf8.h"
|
||||
|
||||
struct gui_utf8_table *atari_utf8_table;
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "css/css.h"
|
||||
#include "render/font.h"
|
||||
#include "desktop/font.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/nsoption.h"
|
||||
|
@ -50,7 +50,7 @@
|
||||
#include "desktop/browser.h"
|
||||
#include "desktop/browser_private.h"
|
||||
#include "desktop/mouse.h"
|
||||
#include "render/font.h"
|
||||
#include "desktop/font.h"
|
||||
|
||||
#include "atari/gemtk/gemtk.h"
|
||||
#include "atari/gui.h"
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include <View.h>
|
||||
extern "C" {
|
||||
#include "css/css.h"
|
||||
#include "render/font.h"
|
||||
#include "desktop/font.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/nsoption.h"
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include <Shape.h>
|
||||
extern "C" {
|
||||
#include "desktop/plotters.h"
|
||||
#include "render/font.h"
|
||||
#include "desktop/font.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/nsoption.h"
|
||||
|
@ -59,7 +59,7 @@ extern "C" {
|
||||
#include "desktop/plotters.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "render/font.h"
|
||||
#include "desktop/font.h"
|
||||
#include "render/form.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
|
@ -36,7 +36,7 @@ extern "C" {
|
||||
#include "desktop/browser.h"
|
||||
#include "desktop/thumbnail.h"
|
||||
#include "image/bitmap.h"
|
||||
#include "render/font.h"
|
||||
#include "desktop/font.h"
|
||||
#include "utils/log.h"
|
||||
}
|
||||
#include "beos/scaffolding.h"
|
||||
|
@ -29,7 +29,7 @@ extern "C" {
|
||||
#include "utils/nsoption.h"
|
||||
#include "desktop/netsurf.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "render/font.h"
|
||||
#include "desktop/font.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/types.h"
|
||||
#include "utils/utf8.h"
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
#import "css/css.h"
|
||||
#import "utils/nsoption.h"
|
||||
#import "render/font.h"
|
||||
#import "desktop/font.h"
|
||||
#import "desktop/plotters.h"
|
||||
|
||||
|
||||
@ -234,4 +234,4 @@ static inline NSDictionary *cocoa_font_attributes( const plot_font_style_t *styl
|
||||
cocoa_font_get_nsfont( style ), NSFontAttributeName,
|
||||
cocoa_convert_colour( style->foreground ), NSForegroundColorAttributeName,
|
||||
nil];
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Browser history tree (implementation).
|
||||
* Browser history tree implementation.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
@ -27,20 +27,20 @@
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "utils/log.h"
|
||||
#include "utils/nsurl.h"
|
||||
#include "utils/utils.h"
|
||||
#include "content/content.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "content/urldb.h"
|
||||
#include "css/css.h"
|
||||
#include "image/bitmap.h"
|
||||
|
||||
#include "desktop/browser_history.h"
|
||||
#include "desktop/browser_private.h"
|
||||
#include "desktop/plotters.h"
|
||||
#include "desktop/thumbnail.h"
|
||||
#include "image/bitmap.h"
|
||||
#include "render/font.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/nsurl.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
#include "desktop/font.h"
|
||||
|
||||
#define WIDTH 100
|
||||
#define HEIGHT 86
|
||||
|
97
desktop/font.h
Normal file
97
desktop/font.h
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
||||
* Copyright 2005 James Bursa <bursa@users.sourceforge.net>
|
||||
* Copyright 2004 John Tytgat <joty@netsurf-browser.org>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Font handling interface.
|
||||
*
|
||||
* These functions provide font related services. They all work on
|
||||
* UTF-8 strings with lengths given.
|
||||
*
|
||||
* Note that an interface to painting is not defined here. Painting is
|
||||
* redirected through platform-dependent plotters anyway, so there is
|
||||
* no gain in abstracting it here.
|
||||
*/
|
||||
|
||||
#ifndef _NETSURF_DESKTOP_FONT_H_
|
||||
#define _NETSURF_DESKTOP_FONT_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "desktop/plot_style.h"
|
||||
|
||||
struct font_functions
|
||||
{
|
||||
/**
|
||||
* Measure the width of a string.
|
||||
*
|
||||
* \param fstyle plot style for this text
|
||||
* \param string UTF-8 string to measure
|
||||
* \param length length of string, in bytes
|
||||
* \param width updated to width of string[0..length)
|
||||
* \return true on success, false on error and error reported
|
||||
*/
|
||||
bool (*font_width)(const plot_font_style_t *fstyle,
|
||||
const char *string, size_t length,
|
||||
int *width);
|
||||
/**
|
||||
* Find the position in a string where an x coordinate falls.
|
||||
*
|
||||
* \param fstyle style for this text
|
||||
* \param string UTF-8 string to measure
|
||||
* \param length length of string, in bytes
|
||||
* \param x x coordinate to search for
|
||||
* \param char_offset updated to offset in string of actual_x, [0..length]
|
||||
* \param actual_x updated to x coordinate of character closest to x
|
||||
* \return true on success, false on error and error reported
|
||||
*/
|
||||
bool (*font_position_in_string)(const plot_font_style_t *fstyle,
|
||||
const char *string, size_t length,
|
||||
int x, size_t *char_offset, int *actual_x);
|
||||
/**
|
||||
* Find where to split a string to make it fit a width.
|
||||
*
|
||||
* \param fstyle style for this text
|
||||
* \param string UTF-8 string to measure
|
||||
* \param length length of string, in bytes
|
||||
* \param x width available
|
||||
* \param char_offset updated to offset in string of actual_x, [1..length]
|
||||
* \param actual_x updated to x coordinate of character closest to x
|
||||
* \return true on success, false on error and error reported
|
||||
*
|
||||
* On exit, char_offset indicates first character after split point.
|
||||
*
|
||||
* Note: char_offset of 0 should never be returned.
|
||||
*
|
||||
* Returns:
|
||||
* char_offset giving split point closest to x, where actual_x <= x
|
||||
* else
|
||||
* char_offset giving split point closest to x, where actual_x > x
|
||||
*
|
||||
* Returning char_offset == length means no split possible
|
||||
*/
|
||||
bool (*font_split)(const plot_font_style_t *fstyle,
|
||||
const char *string, size_t length,
|
||||
int x, size_t *char_offset, int *actual_x);
|
||||
};
|
||||
|
||||
extern const struct font_functions nsfont;
|
||||
|
||||
#endif
|
@ -41,7 +41,7 @@
|
||||
|
||||
#include "utils/nsoption.h"
|
||||
#include "desktop/save_pdf/font_haru.h"
|
||||
#include "render/font.h"
|
||||
#include "desktop/font.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
|
||||
|
@ -26,8 +26,8 @@
|
||||
|
||||
#include <hpdf.h>
|
||||
|
||||
#include "render/font.h"
|
||||
#include "desktop/plot_style.h"
|
||||
#include "desktop/font.h"
|
||||
|
||||
bool haru_nsfont_apply_style(const plot_font_style_t *fstyle,
|
||||
HPDF_Doc doc, HPDF_Page page,
|
||||
|
@ -28,21 +28,21 @@
|
||||
#include <string.h>
|
||||
#include <dom/dom.h>
|
||||
|
||||
#include "utils/log.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/utils.h"
|
||||
#include "render/box.h"
|
||||
#include "render/form.h"
|
||||
#include "render/html_internal.h"
|
||||
#include "render/font.h"
|
||||
#include "render/textplain.h"
|
||||
|
||||
#include "desktop/browser_private.h"
|
||||
#include "desktop/gui_factory.h"
|
||||
#include "desktop/mouse.h"
|
||||
#include "desktop/plotters.h"
|
||||
#include "desktop/save_text.h"
|
||||
#include "desktop/selection.h"
|
||||
#include "render/box.h"
|
||||
#include "render/font.h"
|
||||
#include "render/form.h"
|
||||
#include "render/html_internal.h"
|
||||
#include "render/textplain.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
|
||||
/**
|
||||
* Text selection works by labelling each node in the box tree with its
|
||||
|
@ -23,18 +23,19 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "css/utils.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
#include "desktop/mouse.h"
|
||||
#include "desktop/textarea.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "desktop/plotters.h"
|
||||
#include "desktop/scrollbar.h"
|
||||
#include "desktop/font.h"
|
||||
#include "desktop/gui_factory.h"
|
||||
#include "render/font.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
#define CARET_COLOR 0x0000FF
|
||||
#define TA_ALLOC_STEP 512
|
||||
|
@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Textual input handling (implementation)
|
||||
* Textual input handling implementation
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
@ -29,21 +29,21 @@
|
||||
#include <string.h>
|
||||
#include <dom/dom.h>
|
||||
|
||||
#include "utils/log.h"
|
||||
#include "utils/talloc.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/utils.h"
|
||||
#include "render/box.h"
|
||||
#include "render/form.h"
|
||||
#include "render/html_internal.h"
|
||||
#include "render/layout.h"
|
||||
|
||||
#include "desktop/browser_private.h"
|
||||
#include "desktop/gui_factory.h"
|
||||
#include "desktop/mouse.h"
|
||||
#include "desktop/scrollbar.h"
|
||||
#include "desktop/selection.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "render/box.h"
|
||||
#include "render/font.h"
|
||||
#include "render/form.h"
|
||||
#include "render/html_internal.h"
|
||||
#include "render/layout.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/talloc.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
/* Define to enable textinput debug */
|
||||
#undef TEXTINPUT_DEBUG
|
||||
|
@ -26,16 +26,17 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "content/content.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "css/utils.h"
|
||||
#include "desktop/browser.h"
|
||||
#include "desktop/tree.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "render/font.h"
|
||||
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
#include "content/content.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "css/utils.h"
|
||||
#include "utils/nsoption.h"
|
||||
|
||||
#include "desktop/browser.h"
|
||||
#include "desktop/tree.h"
|
||||
|
||||
struct tree {
|
||||
unsigned int flags; /* Tree flags */
|
||||
|
@ -16,14 +16,15 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Treeview handling (implementation).
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Treeview handling implementation.
|
||||
*/
|
||||
|
||||
#include "utils/log.h"
|
||||
#include "css/utils.h"
|
||||
#include "image/bitmap.h"
|
||||
#include "render/font.h"
|
||||
#include "content/hlcache.h"
|
||||
|
||||
#include "desktop/system_colour.h"
|
||||
@ -31,8 +32,9 @@
|
||||
#include "desktop/plotters.h"
|
||||
#include "desktop/textarea.h"
|
||||
#include "desktop/treeview.h"
|
||||
#include "desktop/font.h"
|
||||
|
||||
/* TODO: get rid of REDRAW_MAX -- need to be able to know window size */
|
||||
/** @todo get rid of REDRAW_MAX -- need to be able to know window size */
|
||||
#define REDRAW_MAX 8000
|
||||
|
||||
struct treeview_globals {
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#include "utils/log.h"
|
||||
#include "desktop/browser.h"
|
||||
#include "render/font.h"
|
||||
#include "desktop/font.h"
|
||||
|
||||
#include "framebuffer/gui.h"
|
||||
#include "framebuffer/fbtk.h"
|
||||
|
@ -27,8 +27,8 @@
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "render/font.h"
|
||||
#include "desktop/gui.h"
|
||||
#include "desktop/font.h"
|
||||
#include "desktop/browser.h"
|
||||
|
||||
#include "framebuffer/gui.h"
|
||||
|
@ -20,12 +20,12 @@
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "utils/nsoption.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "desktop/gui.h"
|
||||
#include "css/css.h"
|
||||
#include "render/font.h"
|
||||
#include "desktop/font.h"
|
||||
|
||||
#include "framebuffer/gui.h"
|
||||
#include "framebuffer/font.h"
|
||||
|
@ -27,12 +27,13 @@
|
||||
#include <stdio.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gtk/font_pango.h"
|
||||
#include "gtk/plotters.h"
|
||||
#include "render/font.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "desktop/font.h"
|
||||
|
||||
#include "gtk/font_pango.h"
|
||||
#include "gtk/plotters.h"
|
||||
|
||||
static bool nsfont_width(const plot_font_style_t *fstyle,
|
||||
const char *string, size_t length,
|
||||
|
@ -33,7 +33,6 @@
|
||||
|
||||
#include "utils/log.h"
|
||||
#include "desktop/plotters.h"
|
||||
#include "render/font.h"
|
||||
#include "utils/nsoption.h"
|
||||
|
||||
#include "gtk/font_pango.h"
|
||||
|
@ -31,19 +31,20 @@
|
||||
#include <gdk/gdk.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "utils/log.h"
|
||||
#include "utils/utils.h"
|
||||
#include "content/content.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "desktop/plotters.h"
|
||||
#include "desktop/print.h"
|
||||
#include "desktop/printer.h"
|
||||
#include "desktop/font.h"
|
||||
|
||||
#include "gtk/font_pango.h"
|
||||
#include "gtk/bitmap.h"
|
||||
#include "gtk/print.h"
|
||||
#include "gtk/scaffolding.h"
|
||||
#include "render/font.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
/* Globals */
|
||||
cairo_t *gtk_print_current_cr;
|
||||
|
@ -44,7 +44,7 @@
|
||||
#include "desktop/save_text.h"
|
||||
#include "desktop/searchweb.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "render/font.h"
|
||||
#include "desktop/font.h"
|
||||
#include "render/html.h"
|
||||
#include "content/hlcache.h"
|
||||
|
||||
|
@ -28,19 +28,19 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
#include "utils/log.h"
|
||||
#include "utils/utils.h"
|
||||
#include "content/content.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "content/urldb.h"
|
||||
#include "desktop/plotters.h"
|
||||
#include "desktop/browser.h"
|
||||
#include "desktop/thumbnail.h"
|
||||
#include "image/bitmap.h"
|
||||
|
||||
#include "gtk/scaffolding.h"
|
||||
#include "gtk/plotters.h"
|
||||
#include "gtk/bitmap.h"
|
||||
#include "image/bitmap.h"
|
||||
#include "render/font.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
/**
|
||||
* Create a thumbnail of a page.
|
||||
|
@ -16,10 +16,9 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "render/font.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "utils/utf8.h"
|
||||
|
||||
#include "desktop/font.h"
|
||||
|
||||
static bool nsfont_width(const plot_font_style_t *fstyle,
|
||||
const char *string, size_t length,
|
||||
|
@ -25,10 +25,11 @@
|
||||
#include "desktop/browser.h"
|
||||
#include "desktop/textarea.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
#include "render/box_textarea.h"
|
||||
#include "render/font.h"
|
||||
#include "render/form.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
|
||||
bool box_textarea_keypress(html_content *html, struct box *box, uint32_t key)
|
||||
|
@ -16,62 +16,25 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Renderer internal font handling implementation.
|
||||
*/
|
||||
|
||||
#include "css/css.h"
|
||||
#include "css/utils.h"
|
||||
#include "utils/nsoption.h"
|
||||
|
||||
#include "render/font.h"
|
||||
|
||||
static plot_font_generic_family_t plot_font_generic_family(
|
||||
enum css_font_family_e css);
|
||||
static int plot_font_weight(enum css_font_weight_e css);
|
||||
static plot_font_flags_t plot_font_flags(enum css_font_style_e style,
|
||||
enum css_font_variant_e variant);
|
||||
|
||||
/**
|
||||
* Populate a font style using data from a computed CSS style
|
||||
*
|
||||
* \param css Computed style to consider
|
||||
* \param fstyle Font style to populate
|
||||
*/
|
||||
void font_plot_style_from_css(const css_computed_style *css,
|
||||
plot_font_style_t *fstyle)
|
||||
{
|
||||
lwc_string **families;
|
||||
css_fixed length = 0;
|
||||
css_unit unit = CSS_UNIT_PX;
|
||||
css_color col;
|
||||
|
||||
fstyle->family = plot_font_generic_family(
|
||||
css_computed_font_family(css, &families));
|
||||
|
||||
css_computed_font_size(css, &length, &unit);
|
||||
fstyle->size = FIXTOINT(FMUL(nscss_len2pt(length, unit),
|
||||
INTTOFIX(FONT_SIZE_SCALE)));
|
||||
|
||||
/* Clamp font size to configured minimum */
|
||||
if (fstyle->size < (nsoption_int(font_min_size) * FONT_SIZE_SCALE) / 10)
|
||||
fstyle->size = (nsoption_int(font_min_size) * FONT_SIZE_SCALE) / 10;
|
||||
|
||||
fstyle->weight = plot_font_weight(css_computed_font_weight(css));
|
||||
fstyle->flags = plot_font_flags(css_computed_font_style(css),
|
||||
css_computed_font_variant(css));
|
||||
|
||||
css_computed_color(css, &col);
|
||||
fstyle->foreground = nscss_color_to_ns(col);
|
||||
fstyle->background = 0;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Helper functions *
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Map a generic CSS font family to a generic plot font family
|
||||
*
|
||||
* \param css Generic CSS font family
|
||||
* \return Plot font family
|
||||
*/
|
||||
plot_font_generic_family_t plot_font_generic_family(
|
||||
static plot_font_generic_family_t plot_font_generic_family(
|
||||
enum css_font_family_e css)
|
||||
{
|
||||
plot_font_generic_family_t plot;
|
||||
@ -104,7 +67,7 @@ plot_font_generic_family_t plot_font_generic_family(
|
||||
* \param css CSS font weight
|
||||
* \return Plot weight
|
||||
*/
|
||||
int plot_font_weight(enum css_font_weight_e css)
|
||||
static int plot_font_weight(enum css_font_weight_e css)
|
||||
{
|
||||
int weight;
|
||||
|
||||
@ -146,12 +109,12 @@ int plot_font_weight(enum css_font_weight_e css)
|
||||
|
||||
/**
|
||||
* Map a CSS font style and font variant to plot font flags
|
||||
*
|
||||
*
|
||||
* \param style CSS font style
|
||||
* \param variant CSS font variant
|
||||
* \return Computed plot flags
|
||||
*/
|
||||
plot_font_flags_t plot_font_flags(enum css_font_style_e style,
|
||||
static plot_font_flags_t plot_font_flags(enum css_font_style_e style,
|
||||
enum css_font_variant_e variant)
|
||||
{
|
||||
plot_font_flags_t flags = FONTF_NONE;
|
||||
@ -167,3 +130,32 @@ plot_font_flags_t plot_font_flags(enum css_font_style_e style,
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
||||
/* exported function documented in render/font_internal.h */
|
||||
void font_plot_style_from_css(const css_computed_style *css,
|
||||
plot_font_style_t *fstyle)
|
||||
{
|
||||
lwc_string **families;
|
||||
css_fixed length = 0;
|
||||
css_unit unit = CSS_UNIT_PX;
|
||||
css_color col;
|
||||
|
||||
fstyle->family = plot_font_generic_family(
|
||||
css_computed_font_family(css, &families));
|
||||
|
||||
css_computed_font_size(css, &length, &unit);
|
||||
fstyle->size = FIXTOINT(FMUL(nscss_len2pt(length, unit),
|
||||
INTTOFIX(FONT_SIZE_SCALE)));
|
||||
|
||||
/* Clamp font size to configured minimum */
|
||||
if (fstyle->size < (nsoption_int(font_min_size) * FONT_SIZE_SCALE) / 10)
|
||||
fstyle->size = (nsoption_int(font_min_size) * FONT_SIZE_SCALE) / 10;
|
||||
|
||||
fstyle->weight = plot_font_weight(css_computed_font_weight(css));
|
||||
fstyle->flags = plot_font_flags(css_computed_font_style(css),
|
||||
css_computed_font_variant(css));
|
||||
|
||||
css_computed_color(css, &col);
|
||||
fstyle->foreground = nscss_color_to_ns(col);
|
||||
fstyle->background = 0;
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
||||
* Copyright 2005 James Bursa <bursa@users.sourceforge.net>
|
||||
* Copyright 2004 John Tytgat <joty@netsurf-browser.org>
|
||||
* Copyright 2014 Vincent Sanders <vince@netsurf-browser.org>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
@ -19,83 +17,23 @@
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Font handling (interface).
|
||||
*
|
||||
* These functions provide font related services. They all work on UTF-8 strings
|
||||
* with lengths given.
|
||||
* Internal font handling interfaces.
|
||||
*
|
||||
* Note that an interface to painting is not defined here. Painting is
|
||||
* redirected through platform-dependent plotters anyway, so there is no gain in
|
||||
* abstracting it here.
|
||||
* These functions provide font related services. They all work on
|
||||
* UTF-8 strings with lengths given.
|
||||
*/
|
||||
|
||||
#ifndef _NETSURF_RENDER_FONT_H_
|
||||
#define _NETSURF_RENDER_FONT_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "css/css.h"
|
||||
#include "desktop/plot_style.h"
|
||||
|
||||
struct font_functions
|
||||
{
|
||||
/**
|
||||
* Measure the width of a string.
|
||||
*
|
||||
* \param fstyle plot style for this text
|
||||
* \param string UTF-8 string to measure
|
||||
* \param length length of string, in bytes
|
||||
* \param width updated to width of string[0..length)
|
||||
* \return true on success, false on error and error reported
|
||||
*/
|
||||
bool (*font_width)(const plot_font_style_t *fstyle,
|
||||
const char *string, size_t length,
|
||||
int *width);
|
||||
/**
|
||||
* Find the position in a string where an x coordinate falls.
|
||||
*
|
||||
* \param fstyle style for this text
|
||||
* \param string UTF-8 string to measure
|
||||
* \param length length of string, in bytes
|
||||
* \param x x coordinate to search for
|
||||
* \param char_offset updated to offset in string of actual_x, [0..length]
|
||||
* \param actual_x updated to x coordinate of character closest to x
|
||||
* \return true on success, false on error and error reported
|
||||
*/
|
||||
bool (*font_position_in_string)(const plot_font_style_t *fstyle,
|
||||
const char *string, size_t length,
|
||||
int x, size_t *char_offset, int *actual_x);
|
||||
/**
|
||||
* Find where to split a string to make it fit a width.
|
||||
*
|
||||
* \param fstyle style for this text
|
||||
* \param string UTF-8 string to measure
|
||||
* \param length length of string, in bytes
|
||||
* \param x width available
|
||||
* \param char_offset updated to offset in string of actual_x, [1..length]
|
||||
* \param actual_x updated to x coordinate of character closest to x
|
||||
* \return true on success, false on error and error reported
|
||||
*
|
||||
* On exit, char_offset indicates first character after split point.
|
||||
*
|
||||
* Note: char_offset of 0 should never be returned.
|
||||
*
|
||||
* Returns:
|
||||
* char_offset giving split point closest to x, where actual_x <= x
|
||||
* else
|
||||
* char_offset giving split point closest to x, where actual_x > x
|
||||
*
|
||||
* Returning char_offset == length means no split possible
|
||||
*/
|
||||
bool (*font_split)(const plot_font_style_t *fstyle,
|
||||
const char *string, size_t length,
|
||||
int x, size_t *char_offset, int *actual_x);
|
||||
};
|
||||
|
||||
extern const struct font_functions nsfont;
|
||||
|
||||
void font_plot_style_from_css(const css_computed_style *css,
|
||||
plot_font_style_t *fstyle);
|
||||
/**
|
||||
* Populate a font style using data from a computed CSS style
|
||||
*
|
||||
* \param css Computed style to consider
|
||||
* \param fstyle Font style to populate
|
||||
*/
|
||||
void font_plot_style_from_css(const css_computed_style *css,
|
||||
plot_font_style_t *fstyle);
|
||||
|
||||
#endif
|
||||
|
@ -33,6 +33,13 @@
|
||||
#include <string.h>
|
||||
#include <dom/dom.h>
|
||||
|
||||
#include "utils/corestrings.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/talloc.h"
|
||||
#include "utils/url.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/utils.h"
|
||||
#include "content/fetch.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "css/css.h"
|
||||
@ -43,19 +50,13 @@
|
||||
#include "desktop/plotters.h"
|
||||
#include "desktop/scrollbar.h"
|
||||
#include "desktop/textarea.h"
|
||||
|
||||
#include "render/box.h"
|
||||
#include "render/font.h"
|
||||
#include "render/form.h"
|
||||
#include "render/html.h"
|
||||
#include "render/html_internal.h"
|
||||
#include "render/layout.h"
|
||||
#include "utils/corestrings.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/talloc.h"
|
||||
#include "utils/url.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
#define MAX_SELECT_HEIGHT 210
|
||||
#define SELECT_LINE_SPACING 0.2
|
||||
|
@ -47,9 +47,9 @@
|
||||
#include "image/bitmap.h"
|
||||
#include "javascript/js.h"
|
||||
#include "desktop/gui_factory.h"
|
||||
#include "desktop/font.h"
|
||||
|
||||
#include "render/box.h"
|
||||
#include "render/font.h"
|
||||
#include "render/form.h"
|
||||
#include "render/html_internal.h"
|
||||
#include "render/imagemap.h"
|
||||
|
@ -28,6 +28,10 @@
|
||||
|
||||
#include <dom/dom.h>
|
||||
|
||||
#include "utils/corestrings.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/log.h"
|
||||
#include "content/content.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "desktop/browser.h"
|
||||
@ -39,6 +43,9 @@
|
||||
#include "desktop/selection.h"
|
||||
#include "desktop/textarea.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "desktop/font.h"
|
||||
#include "javascript/js.h"
|
||||
|
||||
#include "render/box.h"
|
||||
#include "render/box_textarea.h"
|
||||
#include "render/font.h"
|
||||
@ -46,12 +53,6 @@
|
||||
#include "render/html_internal.h"
|
||||
#include "render/imagemap.h"
|
||||
#include "render/search.h"
|
||||
#include "javascript/js.h"
|
||||
#include "utils/corestrings.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
|
||||
/**
|
||||
* Get pointer shape for given box
|
||||
|
@ -22,8 +22,10 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Redraw of a CONTENT_HTML (implementation).
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Redrawing CONTENT_HTML implementation.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
@ -32,7 +34,11 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <dom/dom.h>
|
||||
|
||||
#include "utils/config.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
#include "content/content_protected.h"
|
||||
#include "css/css.h"
|
||||
#include "css/utils.h"
|
||||
@ -42,18 +48,15 @@
|
||||
#include "desktop/print.h"
|
||||
#include "desktop/scrollbar.h"
|
||||
#include "desktop/textarea.h"
|
||||
#include "desktop/font.h"
|
||||
#include "image/bitmap.h"
|
||||
|
||||
#include "render/box.h"
|
||||
#include "render/font.h"
|
||||
#include "render/form.h"
|
||||
#include "render/html_internal.h"
|
||||
#include "render/layout.h"
|
||||
#include "render/search.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
|
||||
|
||||
|
||||
bool html_redraw_debug = false;
|
||||
|
@ -41,21 +41,24 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <dom/dom.h>
|
||||
|
||||
#include "utils/log.h"
|
||||
#include "utils/talloc.h"
|
||||
#include "utils/utils.h"
|
||||
#include "css/css.h"
|
||||
#include "css/utils.h"
|
||||
#include "content/content_protected.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "desktop/scrollbar.h"
|
||||
#include "desktop/textarea.h"
|
||||
#include "desktop/font.h"
|
||||
|
||||
#include "render/box.h"
|
||||
#include "render/font.h"
|
||||
#include "render/form.h"
|
||||
#include "render/html_internal.h"
|
||||
#include "render/layout.h"
|
||||
#include "render/table.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/talloc.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
|
||||
/* Define to enable layout debugging */
|
||||
|
@ -31,6 +31,12 @@
|
||||
#include <parserutils/input/inputstream.h>
|
||||
#include <parserutils/charset/utf8.h>
|
||||
|
||||
#include "utils/corestrings.h"
|
||||
#include "utils/http.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "content/content_protected.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "css/css.h"
|
||||
@ -41,17 +47,12 @@
|
||||
#include "desktop/search.h"
|
||||
#include "desktop/selection.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "render/font.h"
|
||||
#include "desktop/font.h"
|
||||
|
||||
#include "render/search.h"
|
||||
#include "render/textplain.h"
|
||||
#include "render/html.h"
|
||||
#include "render/search.h"
|
||||
#include "utils/corestrings.h"
|
||||
#include "utils/http.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/utf8.h"
|
||||
|
||||
struct textplain_line {
|
||||
size_t start;
|
||||
|
@ -42,7 +42,6 @@
|
||||
#include "utils/utils.h"
|
||||
#include "desktop/netsurf.h"
|
||||
#include "desktop/browser.h"
|
||||
#include "render/font.h"
|
||||
|
||||
#include "riscos/configure.h"
|
||||
#include "riscos/cookies.h"
|
||||
|
@ -29,13 +29,11 @@
|
||||
#include <oslib/wimp.h>
|
||||
#include <oslib/wimpreadsysinfo.h>
|
||||
|
||||
#include "css/css.h"
|
||||
#include "css/utils.h"
|
||||
#include "render/font.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
#include "desktop/font.h"
|
||||
|
||||
#include "riscos/gui.h"
|
||||
#include "riscos/font.h"
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
#include "utils/log.h"
|
||||
#include "desktop/plotters.h"
|
||||
#include "render/font.h"
|
||||
|
||||
#include "riscos/bitmap.h"
|
||||
#include "riscos/image.h"
|
||||
@ -36,7 +35,6 @@
|
||||
#include "riscos/font.h"
|
||||
#include "riscos/oslib_pre7.h"
|
||||
|
||||
|
||||
static bool ro_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style);
|
||||
static bool ro_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style);
|
||||
static bool ro_plot_draw_path(const draw_path * const path, int width,
|
||||
|
@ -31,21 +31,21 @@
|
||||
#include "oslib/colourtrans.h"
|
||||
#include "oslib/osfile.h"
|
||||
#include "oslib/osspriteop.h"
|
||||
|
||||
#include "utils/nsoption.h"
|
||||
#include "utils/log.h"
|
||||
#include "content/content.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "content/urldb.h"
|
||||
#include "desktop/plotters.h"
|
||||
#include "desktop/thumbnail.h"
|
||||
#include "image/bitmap.h"
|
||||
#include "render/font.h"
|
||||
|
||||
#include "riscos/bitmap.h"
|
||||
#include "riscos/gui.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "riscos/oslib_pre7.h"
|
||||
#include "riscos/thumbnail.h"
|
||||
#include "riscos/tinct.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
|
||||
/* Whether we can use 32bpp sprites
|
||||
*/
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include "css/css.h"
|
||||
#include "render/font.h"
|
||||
#include "desktop/font.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "utils/utf8.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user