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);
175 PangoFontDescription *desc;
176 PangoContext *context;
178 PangoLayoutLine *
line;
180 context = gdk_pango_context_get();
181 layout = pango_layout_new(context);
184 pango_layout_set_font_description(layout, desc);
185 pango_font_description_free(desc);
187 pango_layout_set_text(layout,
string, length);
190 pango_layout_set_width(layout, x * PANGO_SCALE);
193 pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
196 pango_layout_set_single_paragraph_mode(layout, TRUE);
199 line = pango_layout_get_line_readonly(layout, 1);
203 index =
line->start_index;
206 g_object_unref(layout);
207 g_object_unref(context);
209 *char_offset = index;
230 PangoFontDescription *desc;
231 PangoLayoutLine *
line;
240 pango_font_description_free(desc);
254PangoFontDescription *
258 PangoFontDescription *desc;
259 PangoStyle style = PANGO_STYLE_NORMAL;
263 desc = pango_font_description_from_string(
nsoption_charp(font_serif));
266 desc = pango_font_description_from_string(
nsoption_charp(font_mono));
269 desc = pango_font_description_from_string(
nsoption_charp(font_cursive));
272 desc = pango_font_description_from_string(
nsoption_charp(font_fantasy));
276 desc = pango_font_description_from_string(
nsoption_charp(font_sans));
283 style = PANGO_STYLE_ITALIC;
285 style = PANGO_STYLE_OBLIQUE;
287 pango_font_description_set_style(desc, style);
289 pango_font_description_set_weight(desc, (PangoWeight) fstyle->
weight);
291 pango_font_description_set_size(desc, size);
294 pango_font_description_set_variant(desc,
295 PANGO_VARIANT_SMALL_CAPS);
297 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.