46 NSLOG(netsurf, INFO,
"Creating nsfont_pango_context.");
51 NSLOG(netsurf, INFO,
"Creating nsfont_pango_layout.");
71 PangoFontDescription *desc;
83 pango_font_description_free(desc);
88 *
width = PANGO_PIXELS(pos.x);
90 NSLOG(netsurf, DEEPDEBUG,
91 "fstyle: %p string:\"%.*s\", length: %" PRIsizet ", width: %dpx",
92 fstyle, (
int)length,
string, length, *
width);
129 pango_layout_set_text(layout,
string, length);
136 if (pango_layout_xy_to_index(layout,
138 0, &index, 0) == FALSE) {
149 pango_layout_index_to_pos(layout, index, &pos);
150 *actual_x = PANGO_PIXELS(pos.x);
175 PangoFontDescription *desc;
182 pango_font_description_free(desc);
191 NSLOG(netsurf, DEEPDEBUG,
192 "fstyle: %p string:\"%.*s\", length: %" PRIsizet ", "
193 "search_x: %dpx, offset: %" PRIsizet ", actual_x: %dpx",
194 fstyle, (
int)length,
string, length, x, *char_offset, *actual_x);
230 PangoContext *context;
232 PangoFontDescription *desc;
238 context = gdk_pango_context_get();
239 layout = pango_layout_new(context);
242 pango_layout_set_font_description(layout, desc);
243 pango_font_description_free(desc);
256 if ((split_len < 1) || (split_len >= length)) {
257 *string_idx = length;
263 if (
string[split_len] ==
' ') {
264 *string_idx = split_len;
273 while ((
string[str_len] !=
' ') &&
281 while ((str_len < length) &&
282 (
string[str_len] !=
' ')) {
287 if ((str_len < length) && (
string[str_len] ==
' ')) {
291 *string_idx = str_len;
293 pango_layout_index_to_pos(layout, str_len, &pos);
294 *actual_x = PANGO_PIXELS(pos.x);
297 g_object_unref(layout);
298 g_object_unref(context);
300 NSLOG(netsurf, DEEPDEBUG,
301 "fstyle: %p string:\"%.*s\" / \"%.*s\", length: %" PRIsizet ", "
302 "split_x: %dpx, offset: %" PRIsizet ", actual_x: %dpx",
303 fstyle, (
int)(*string_idx),
string, (
int)(length - *string_idx),
304 string+*string_idx, length, x, *string_idx, *actual_x);
322 PangoFontDescription *desc;
323 PangoLayoutLine *
line;
332 pango_font_description_free(desc);
346PangoFontDescription *
350 PangoFontDescription *desc;
351 PangoStyle style = PANGO_STYLE_NORMAL;
355 desc = pango_font_description_from_string(
nsoption_charp(font_serif));
358 desc = pango_font_description_from_string(
nsoption_charp(font_mono));
361 desc = pango_font_description_from_string(
nsoption_charp(font_cursive));
364 desc = pango_font_description_from_string(
nsoption_charp(font_fantasy));
368 desc = pango_font_description_from_string(
nsoption_charp(font_sans));
375 style = PANGO_STYLE_ITALIC;
377 style = PANGO_STYLE_OBLIQUE;
379 pango_font_description_set_style(desc, style);
381 pango_font_description_set_weight(desc, (PangoWeight) fstyle->
weight);
383 pango_font_description_set_size(desc, size);
386 pango_font_description_set_variant(desc,
387 PANGO_VARIANT_SMALL_CAPS);
389 pango_font_description_set_variant(desc, PANGO_VARIANT_NORMAL);
nserror
Enumeration of error codes.
Target independent plotting GTK+ interface.
void nsgtk_set_colour(colour c)
Set cairo context colour to nsgtk colour.
Interface to platform-specific layout operation table.
Netsurf additional integer type formatting macros.
#define PRIsizet
c99 standard printf formatting for size_t type
static nserror nsfont_split(const plot_font_style_t *fstyle, const char *string, size_t length, int x, size_t *string_idx, int *actual_x)
Find where to split a string to make it fit a width.
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.
static PangoLayout * nsfont_pango_layout
PangoFontDescription * nsfont_style_to_description(const plot_font_style_t *fstyle)
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.
nserror nsfont_paint(int x, int y, const char *string, size_t length, const plot_font_style_t *fstyle)
Render a string.
static PangoContext * nsfont_pango_context
static struct gui_layout_table layout_table
struct gui_layout_table * nsgtk_layout_table
static nserror layout_position(PangoLayout *layout, const char *string, size_t length, int x, size_t *string_idx, int *actual_x)
Find the position in a string where an x coordinate falls.
Interface to GTK layout handling using pango.
#define NSLOG(catname, level, logmsg, args...)
plotter style interfaces, generic styles and style colour helpers.
@ PLOT_FONT_FAMILY_CURSIVE
@ PLOT_FONT_FAMILY_SANS_SERIF
@ PLOT_FONT_FAMILY_FANTASY
@ PLOT_FONT_FAMILY_MONOSPACE
#define PLOT_STYLE_SCALE
Scaling factor for plot styles.
nserror(* width)(const struct plot_font_style *fstyle, const char *string, size_t length, int *width)
Measure the width of a string.
plot_font_generic_family_t family
Generic family to plot with.
colour foreground
Colour of text.
plot_font_flags_t flags
Font flags.
plot_style_fixed size
Font size, in pt.
int weight
Font weight: value in range [100,900] as per CSS.
Option reading and saving interface.
#define nsoption_charp(OPTION)
Get the value of a string option.
static nserror line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.