46 NSLOG(netsurf, INFO,
"Creating nsfont_pango_context.");
51 NSLOG(netsurf, INFO,
"Creating nsfont_pango_layout.");
71 PangoFontDescription *desc;
82 pango_font_description_free(desc);
88 NSLOG(netsurf, DEEPDEBUG,
89 "fstyle: %p string:\"%.*s\", length: %" PRIsizet ", width: %dpx",
90 fstyle, (
int)length,
string, length, *
width);
118 PangoFontDescription *desc;
125 pango_font_description_free(desc);
131 0, &index, 0) == FALSE) {
137 *char_offset = index;
138 *actual_x = PANGO_PIXELS(pos.x);
140 NSLOG(netsurf, DEEPDEBUG,
141 "fstyle: %p string:\"%.*s\", length: %" PRIsizet ", "
142 "search_x: %dpx, offset: %" PRIsizet ", actual_x: %dpx",
143 fstyle, (
int)length,
string, length, x, *char_offset, *actual_x);
179 PangoFontDescription *desc;
180 PangoContext *context;
182 PangoLayoutLine *
line;
184 context = gdk_pango_context_get();
185 layout = pango_layout_new(context);
188 pango_layout_set_font_description(layout, desc);
189 pango_font_description_free(desc);
191 pango_layout_set_text(layout,
string, length);
194 pango_layout_set_width(layout, x * PANGO_SCALE);
197 pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
200 pango_layout_set_single_paragraph_mode(layout, TRUE);
203 line = pango_layout_get_line_readonly(layout, 1);
207 index =
line->start_index;
210 g_object_unref(layout);
211 g_object_unref(context);
213 *char_offset = index;
217 NSLOG(netsurf, DEEPDEBUG,
218 "fstyle: %p string:\"%.*s\", length: %" PRIsizet ", "
219 "split_x: %dpx, offset: %" PRIsizet ", actual_x: %dpx",
220 fstyle, (
int)length,
string, length, x, *char_offset, *actual_x);
238 PangoFontDescription *desc;
239 PangoLayoutLine *
line;
248 pango_font_description_free(desc);
262PangoFontDescription *
266 PangoFontDescription *desc;
267 PangoStyle style = PANGO_STYLE_NORMAL;
271 desc = pango_font_description_from_string(
nsoption_charp(font_serif));
274 desc = pango_font_description_from_string(
nsoption_charp(font_mono));
277 desc = pango_font_description_from_string(
nsoption_charp(font_cursive));
280 desc = pango_font_description_from_string(
nsoption_charp(font_fantasy));
284 desc = pango_font_description_from_string(
nsoption_charp(font_sans));
291 style = PANGO_STYLE_ITALIC;
293 style = PANGO_STYLE_OBLIQUE;
295 pango_font_description_set_style(desc, style);
297 pango_font_description_set_weight(desc, (PangoWeight) fstyle->
weight);
299 pango_font_description_set_size(desc, size);
302 pango_font_description_set_variant(desc,
303 PANGO_VARIANT_SMALL_CAPS);
305 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_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 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.
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.