NetSurf
|
GTK implementation of layout handling using pango. More...
#include <assert.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include "utils/log.h"
#include "utils/nsoption.h"
#include "netsurf/inttypes.h"
#include "netsurf/layout.h"
#include "netsurf/plot_style.h"
#include "gtk/layout_pango.h"
#include "gtk/plotters.h"
Go to the source code of this file.
Functions | |
static void | nsfont_pango_check (void) |
static nserror | nsfont_width (const plot_font_style_t *fstyle, const char *string, size_t length, int *width) |
Measure the width of a string. More... | |
static nserror | 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) |
Find the position in a string where an x coordinate falls. More... | |
static nserror | nsfont_split (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. More... | |
nserror | nsfont_paint (int x, int y, const char *string, size_t length, const plot_font_style_t *fstyle) |
Render a string. More... | |
PangoFontDescription * | nsfont_style_to_description (const plot_font_style_t *fstyle) |
Variables | |
static PangoContext * | nsfont_pango_context = NULL |
static PangoLayout * | nsfont_pango_layout = NULL |
static struct gui_layout_table | layout_table |
struct gui_layout_table * | nsgtk_layout_table = &layout_table |
GTK implementation of layout handling using pango.
Pango is used handle and render fonts.
Definition in file layout_pango.c.
nserror nsfont_paint | ( | int | x, |
int | y, | ||
const char * | string, | ||
size_t | length, | ||
const plot_font_style_t * | fstyle | ||
) |
Render a string.
x | x coordinate |
y | y coordinate |
string | UTF-8 string to measure |
length | length of string |
fstyle | plot style for this text |
Definition at line 235 of file layout_pango.c.
References current_cr, plot_font_style::foreground, line(), NSERROR_OK, nsfont_pango_check(), nsfont_pango_layout, nsfont_style_to_description(), and nsgtk_set_colour().
|
inlinestatic |
Definition at line 43 of file layout_pango.c.
References nsfont_pango_context, nsfont_pango_layout, and NSLOG.
Referenced by nsfont_paint(), nsfont_position_in_string(), and nsfont_width().
|
static |
Find the position in a string where an x coordinate falls.
[in] | fstyle | style for this text |
[in] | string | UTF-8 string to measure |
[in] | length | length of string, in bytes |
[in] | x | coordinate to search for |
[out] | char_offset | updated to offset in string of actual_x, [0..length] |
[out] | actual_x | updated to x coordinate of character closest to x |
Definition at line 110 of file layout_pango.c.
References NSERROR_OK, nsfont_pango_check(), nsfont_pango_layout, nsfont_style_to_description(), NSLOG, and PRIsizet.
|
static |
Find where to split a string to make it fit a width.
[in] | fstyle | style for this text |
[in] | string | UTF-8 string to measure |
[in] | length | length of string, in bytes |
[in] | x | width available |
[out] | char_offset | updated to offset in string of actual_x, [1..length] |
[out] | actual_x | updated to x coordinate of character closest to x |
On exit, char_offset indicates first character after split point.
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
Definition at line 171 of file layout_pango.c.
References line(), NSERROR_OK, nsfont_style_to_description(), nsfont_width(), NSLOG, and PRIsizet.
PangoFontDescription * nsfont_style_to_description | ( | const plot_font_style_t * | fstyle | ) |
Definition at line 263 of file layout_pango.c.
References plot_font_style::family, plot_font_style::flags, FONTF_ITALIC, FONTF_OBLIQUE, FONTF_SMALLCAPS, nsoption_charp, PLOT_FONT_FAMILY_CURSIVE, PLOT_FONT_FAMILY_FANTASY, PLOT_FONT_FAMILY_MONOSPACE, PLOT_FONT_FAMILY_SANS_SERIF, PLOT_FONT_FAMILY_SERIF, PLOT_STYLE_SCALE, plot_font_style::size, and plot_font_style::weight.
Referenced by gtk_print_font_paint(), nsfont_paint(), nsfont_position_in_string(), nsfont_split(), and nsfont_width().
|
static |
Measure the width of a string.
[in] | fstyle | plot style for this text |
[in] | string | UTF-8 string to measure |
[in] | length | length of string, in bytes |
[out] | width | updated to width of string[0..length) |
Definition at line 66 of file layout_pango.c.
References NSERROR_OK, nsfont_pango_check(), nsfont_pango_layout, nsfont_style_to_description(), NSLOG, PRIsizet, and width.
Referenced by nsfont_split().
|
static |
Definition at line 311 of file layout_pango.c.
|
static |
Definition at line 40 of file layout_pango.c.
Referenced by nsfont_pango_check().
|
static |
Definition at line 41 of file layout_pango.c.
Referenced by nsfont_paint(), nsfont_pango_check(), nsfont_position_in_string(), and nsfont_width().
struct gui_layout_table* nsgtk_layout_table = &layout_table |
Definition at line 317 of file layout_pango.c.
Referenced by gtk_print_signal_begin_print(), main(), and print_button_clicked_cb().