The Battle for Wesnoth  1.19.11+dev
text.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2025
3  by Mark de Wever <koraq@xs4all.nl>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 #include "font/font_options.hpp"
19 #include "color.hpp"
20 #include "sdl/surface.hpp"
21 #include "sdl/texture.hpp"
23 
24 #include <pango/pangocairo.h>
25 
26 
27 #include <functional>
28 #include <memory>
29 #include <string>
30 #include <vector>
31 
32 /***
33  * Note: This is the cairo-pango code path, not the SDL_TTF code path.
34  */
35 
36 struct point;
37 
38 namespace font
39 {
40 class attribute_list;
41 
42 // add background color and also font markup.
43 
44 /**
45  * Text class.
46  *
47  * This class represents text which is rendered using Pango.
48  *
49  * It takes text, as a utf-8 std::string, plus formatting options including
50  * font and color. It provides a surface object which holds the rendered text.
51  *
52  * Besides this, it can do some additional calculations using the font layout.
53  *
54  * It can take an index into the text, and convert it to pixel coordinates,
55  * so that if we want to draw a cursor in an editbox, we know where to draw it.
56  *
57  * It can also take a pixel coordinate with respect to the text layout, and
58  * translate it back to an index into the original text. This is useful if the
59  * user clicks on the text, and we want to know where to move the cursor.
60  *
61  * The get_token method takes a pixel coordinate, which we assume represents a
62  * click position, and gets the corresponding "token" from the string. The default
63  * token delimiters are whitespace " \n\r\t". So, this returns the "word" that the
64  * user clicked on.
65  *
66  * Finally, the get_link method represents special support for hyperlinks in text.
67  * A token "looks like a link" if it begins "http://" or "https://".
68  * If a text has link_aware enabled, then any such token is rendered with an
69  * underline and in a special color, see `link_color`.
70  * The get_link method calls get_token and further checks if the clicked token
71  * looks like a link.
72  *
73  * This class stores the text to draw and uses pango with the cairo backend to
74  * render the text. See http://pango.org for more info.
75  *
76  */
78 {
79 public:
80  pango_text();
81 
82  pango_text(const pango_text&) = delete;
83  pango_text& operator=(const pango_text&) = delete;
84 
85  /**
86  * Returns the cached texture, or creates a new one otherwise.
87  *
88  * texture::w() and texture::h() methods will return the expected
89  * width and height of the texture in draw space. This may differ
90  * from the real value returned by texture::get_info().
91  *
92  * In almost all cases, use w() and h() to get the size of the
93  * rendered text for drawing.
94  */
96 
97 private:
98  /**
99  * Wrapper around render_surface which sets texture::w() and texture::h()
100  * in the same way that render_and_get_texture does.
101  *
102  * The viewport rect is interpreted at the scale of render-space, not
103  * drawing-space. This function has only been made private to preserve
104  * the drawing-space encapsulation.
105  */
106  texture render_texture(const SDL_Rect& viewport);
107 
108  /**
109  * Returns the rendered text.
110  *
111  * The viewport rect is interpreted at the scale of render-space, not
112  * drawing-space. This function has only been made private to preserve
113  * the drawing-space encapsulation.
114  *
115  * @param viewport Only this area needs to be drawn - the returned
116  * surface's origin will correspond to viewport.x and viewport.y, the
117  * width and height will be at least viewport.w and viewport.h (although
118  * they may be larger).
119  */
120  surface render_surface(const SDL_Rect& viewport);
121 
122 public:
123  /** Returns the size of the text, in drawing coordinates. */
124  point get_size();
125 
126  /** Has the text been truncated? This happens if it exceeds max width or height. */
127  bool is_truncated() const;
128 
129  /**
130  * Inserts UTF-8 text.
131  *
132  * @param offset The position to insert the text.
133  * @param text The UTF-8 text to insert.
134  * @param use_markup If the text is formatted or not.
135  *
136  * @returns The number of characters inserted.
137  */
138  unsigned insert_text(const unsigned offset, const std::string& text, const bool use_markup = false);
139 
140  /***** ***** ***** ***** Font flags ***** ***** ***** *****/
141 
142  // NOTE: these values must be powers of 2 in order to be bit-unique
143  enum FONT_STYLE {
148  };
149 
150  /***** ***** ***** ***** Query details ***** ***** ***** *****/
151 
152  /**
153  * Returns the maximum glyph height of a font, in drawing coordinates.
154  *
155  * @returns The height of the tallest possible glyph for the selected
156  * font. More specifically, the result is the sum of the maximum
157  * ascent and descent lengths.
158  */
159  int get_max_glyph_height() const;
160 
161  /**
162  * Given a character index and optionally the starting line,
163  * returns the corresponding byte index.
164  * @param offset The character index of the cursor position.
165  * Can be bigger than the line, in which case it
166  * spills over to the next line and so on.
167  * @param line The line from which the offset counting should start.
168  *
169  * @returns The corresponding byte index.
170  */
171  unsigned get_byte_index(const unsigned offset, const unsigned line = 0) const;
172 
173  /**
174  * Gets the location for the cursor, in drawing coordinates.
175  *
176  * @param offset The character index of the cursor position.
177  * Can be bigger than the line, in which case it
178  * spills over to the next line and so on.
179  * @param line The line from which the offset counting should start.
180  *
181  * @returns The position of the top of the cursor. It the
182  * requested location is out of range 0,0 is
183  * returned.
184  */
185  point get_cursor_position(const unsigned offset, const unsigned line = 0) const;
186 
187  /**
188  * Gets the location for the cursor, in drawing coordinates.
189  *
190  * @param offset The byte index corresponding to the cursor position.
191  *
192  * @returns The position of the top of the cursor. It the
193  * requested location is out of range 0,0 is
194  * returned.
195  */
196  point get_cursor_pos_from_index(const unsigned offset) const;
197 
198  /**
199  * Get maximum length.
200  *
201  * @returns The maximum length of the text. The length of text
202  * should not exceed this value.
203  */
204  std::size_t get_maximum_length() const;
205 
206  /**
207  * Gets the largest collection of characters, including the token at position,
208  * and not including any characters from the delimiters set.
209  *
210  * @param position The pixel position in the text area.
211  * @param delimiters
212  *
213  * @returns The token containing position, and none of the
214  * delimiter characters. If position is out of bounds,
215  * it returns the empty string.
216  */
217  std::string get_token(const point& position, std::string_view delimiters = " \n\r\t") const;
218 
219  /**
220  * Checks if position points to a character in a link in the text, returns it
221  * if so, empty string otherwise. Link-awareness must be enabled to get results.
222  * @param position The pixel position in the text area.
223  *
224  * @returns The link if one is found, the empty string otherwise.
225  */
226  std::string get_link(const point& position) const;
227 
228  /**
229  * Gets the column of line of the character at the position.
230  *
231  * @param position The pixel position in the text area.
232  *
233  * @returns A point with the x value the column and the y
234  * value the line of the character found (or last
235  * character if not found.
236  */
237  point get_column_line(const point& position) const;
238 
239  /**
240  * Wrapper function around `pango_layout_xy_to_index`.
241  *
242  * @param position The pixel position in the text area.
243  *
244  * @returns A tuple of the format `{index, trailing, inside_bounds}`
245  * where `index` and `trailing` are as described in
246  * <a href='https://docs.gtk.org/Pango/method.Layout.xy_to_index.html'>Pango documention</a>
247  * for `pango_layout_xy_to_index`, and `inside_bounds`
248  * is `true` if the given position is inside the pango layout,
249  * and `false` otherwise.
250  */
251  std::tuple<int, int, bool> xy_to_index(const point& position) const;
252 
253  /**
254  * Retrieves a list of strings with contents for each rendered line.
255  *
256  * This method is not const because it requires rendering the text.
257  *
258  * @note This is only intended for renderer implementation details. This
259  * is a rather expensive function because it copies everything at
260  * least once.
261  */
262  std::vector<std::string> get_lines() const;
263 
264  /**
265  * Get a specific line from the pango layout
266  *
267  * @param index the line number of the line to retrieve
268  *
269  * @returns the PangoLayoutLine* corresponding to line number index
270  */
271  PangoLayoutLine* get_line(int index);
272 
273  /**
274  * Given a byte index, find out at which line the corresponding character
275  * is located. Wrapper for `pango_layout_index_to_line_x`.
276  *
277  * @param offset the byte index
278  *
279  * @param trailing which edge the counting starts from
280  * true: trailing edge, false: leading edge.
281  *
282  * @returns a pair of the form `{line, xpos}`
283  * where `line` is the line number corresponding to the given index
284  * and `xpos` is the resulting x position.
285  */
286  std::pair<int, int> index_to_line_x(const unsigned offset, const bool trailing = 0) const;
287 
288  /**
289  * Get number of lines in the text.
290  *
291  * @returns The number of lines in the text.
292  *
293  */
294  unsigned get_lines_count() const {
295  return pango_layout_get_line_count(layout_.get());
296  };
297 
298  /**
299  * Gets the length of the text in bytes.
300  *
301  * The text set is UTF-8 so the length of the string might not be the length
302  * of the text.
303  */
304  std::size_t get_length() const { return length_; }
305 
306  /**
307  * Sets the text to render.
308  *
309  * @param text The text to render.
310  * @param markedup Should the text be rendered with pango
311  * markup. If the markup is invalid it's
312  * rendered as text without markup.
313  *
314  * @returns The status, if rendered as markup and the
315  * markup contains errors, false is returned
316  * else true.
317  */
318  bool set_text(const std::string& text, const bool markedup);
319 
320  /***** ***** ***** ***** Setters / getters ***** ***** ***** *****/
321 
322  const std::string& text() const { return text_; }
323 
325 
326  pango_text& set_font_size(unsigned font_size);
327 
328  pango_text& set_font_style(const FONT_STYLE font_style);
329 
330  pango_text& set_foreground_color(const color_t& color);
331 
332  pango_text& set_maximum_width(int width);
333 
334  pango_text& set_characters_per_line(const unsigned characters_per_line);
335 
336  pango_text& set_maximum_height(int height, bool multiline);
337 
338  pango_text& set_ellipse_mode(const PangoEllipsizeMode ellipse_mode);
339 
340  pango_text& set_alignment(const PangoAlignment alignment);
341 
342  pango_text& set_maximum_length(const std::size_t maximum_length);
343 
344  bool link_aware() const { return link_aware_; }
345 
346  pango_text& set_link_aware(bool b);
347 
348  pango_text& set_link_color(const color_t& color);
349 
350  pango_text& set_add_outline(bool do_add);
351 
352  pango_text& set_line_spacing(float line_spacing)
353  {
354  pango_layout_set_line_spacing(layout_.get(), line_spacing);
355  return *this;
356  }
357 
358  void clear_attributes();
359  void apply_attributes(const font::attribute_list& attrs);
360 
361 private:
362 
363  /***** ***** ***** ***** Pango variables ***** ***** ***** *****/
364  std::unique_ptr<PangoContext, std::function<void(void*)>> context_;
365  std::unique_ptr<PangoLayout, std::function<void(void*)>> layout_;
366  mutable PangoRectangle rect_;
367 
368  /** The text to draw (stored as UTF-8). */
369  std::string text_;
370 
371  /** Does the text contain pango markup? If different render routines must be used. */
373 
374  /** Are hyperlinks in the text marked-up, and will get_link return them. */
376 
377  /**
378  * The color to render links in.
379  *
380  * Links are formatted using pango &lt;span> as follows:
381  *
382  * &lt;span underline="single" color=" + link_color_ + ">
383  */
385 
386  /** The font family class used. */
388 
389  /** The font size to draw. */
390  unsigned font_size_;
391 
392  /** The style of the font, this is an orred mask of the font flags. */
394 
395  /** The foreground color. */
397 
398  /** Whether to add an outline effect. */
400 
401  /**
402  * The maximum width of the text.
403  *
404  * Values less or equal to 0 mean no maximum and are internally stored as
405  * -1, since that's the value pango uses for it.
406  *
407  * See @ref characters_per_line_.
408  */
410 
411  /**
412  * The number of characters per line.
413  *
414  * This can be used as an alternative of @ref maximum_width_. The user can
415  * select a number of characters on a line for wrapping. When the value is
416  * non-zero it determines the maximum width based on the average character
417  * width.
418  *
419  * If both @ref maximum_width_ and @ref characters_per_line_ are set the
420  * minimum of the two will be the maximum.
421  *
422  * @note Long lines are often harder to read, setting this value can
423  * automatically wrap on a number of characters regardless of the font
424  * size. Often 66 characters is considered the optimal value for a one
425  * column text.
426  */
428 
429  /**
430  * The maximum height of the text.
431  *
432  * Values less or equal to 0 mean no maximum and are internally stored as
433  * -1, since that's the value pango uses for it.
434  */
436 
437  /** The way too long text is shown depends on this mode. */
438  PangoEllipsizeMode ellipse_mode_;
439 
440  /** The alignment of the text. */
441  PangoAlignment alignment_;
442 
443  /** The maximum length of the text. */
444  std::size_t maximum_length_;
445 
446  /**
447  * The text has two dirty states:
448  * - The setting of the state and the size calculations.
449  * - The rendering of the surface.
450  */
451 
452  /** The dirty state of the calculations. */
453  mutable bool calculation_dirty_;
454 
455  /** Length of the text. */
456  mutable std::size_t length_;
457 
458  /** The pixel scale, used to render high-DPI text. */
460 
461  /** Recalculates the text layout. */
462  void recalculate() const;
463 
464  /** Calculates surface size. */
465  PangoRectangle calculate_size(PangoLayout& layout) const;
466 
467  /**
468  * Equivalent to create_surface(viewport), where the viewport's top-left is
469  * at (0,0) and the area is large enough to contain the full text.
470  *
471  * The top-left of the viewport will be at (0,0), regardless of the values
472  * of x and y in the rect_ member variable. If the x or y co-ordinates are
473  * non-zero, then x columns and y rows of blank space are included in the
474  * amount of memory allocated.
475  */
477 
478  /**
479  * Renders the text to a surface that uses surface_buffer_ as its data store,
480  * the buffer will be allocated or reallocated as necessary.
481  *
482  * The surface's origin will correspond to viewport.x and viewport.y, the
483  * width and height will be at least viewport.w and viewport.h (although
484  * they may be larger).
485  *
486  * @param viewport The area to draw, which can be a subset of the text. This
487  * rectangle's coordinates use render-space's scale.
488  */
489  surface create_surface(const SDL_Rect& viewport);
490 
491  /**
492  * This is part of create_surface(viewport). The separation is a legacy
493  * from workarounds to the size limits of cairo_surface_t.
494  */
495  void render(PangoLayout& layout, const SDL_Rect& viewport);
496 
497  /**
498  * Buffer to store the image on.
499  *
500  * We use a cairo surface to draw on this buffer and then use the buffer as
501  * data source for the SDL_Surface. This means the buffer needs to be stored
502  * in the object, since SDL_Surface doesn't own its buffer.
503  */
504  mutable std::vector<uint8_t> surface_buffer_;
505 
506  /**
507  * Sets the markup'ed text.
508  *
509  * It tries to set the text as markup. If the markup is invalid it will try
510  * a bit harder to recover from the errors and still set the markup.
511  *
512  * @param text The text to set as markup.
513  * @param layout
514  *
515  * @returns Whether the markup was set or an
516  * unrecoverable error occurred and the text is
517  * set as plain text with an error message.
518  */
519  bool set_markup(std::string_view text, PangoLayout& layout);
520 
521  bool validate_markup(std::string_view text, char** raw_text, std::string& semi_escaped) const;
522 
523  static void copy_layout_properties(PangoLayout& src, PangoLayout& dst);
524 
525  std::string format_links(std::string_view text) const;
526 
527  /**
528  * Adjust a texture's draw-width and height according to pixel scale.
529  *
530  * As fonts are rendered at output-scale, we need to do this just
531  * before returning the rendered texture. These attributes are stored
532  * as part of the returned texture object.
533  */
534  texture with_draw_scale(const texture& t) const;
535 
536  /** Scale the given render-space size to draw-space, rounding up. */
537  int to_draw_scale(int s) const;
538 
539  /** Scale the given render-space point to draw-space, rounding up. */
540  point to_draw_scale(const point& p) const;
541 
542  /** Update pixel scale, if necessary. */
543  void update_pixel_scale();
544 };
545 
546 /**
547  * Returns a reference to a static pango_text object.
548  *
549  * Since the class is essentially a render pipeline, there's no need for individual
550  * areas of the game to own their own renderers. Not to mention it isn't a trivial
551  * class; constructing one is likely to be expensive.
552  */
554 
555 /**
556  * Returns the maximum glyph height of a font, in pixels.
557  *
558  * @param size Desired font size in pixels.
559  * @param fclass Font family to use for measurement.
560  * @param style Font style to select the correct variant for measurement.
561  *
562  * @returns The height of the tallest possible glyph for the selected
563  * font. More specifically, the result is the sum of the maximum
564  * ascent and descent lengths.
565  */
567 
568 /* Returns the default line spacing factor
569  * For now hardcoded here */
570 constexpr float get_line_spacing_factor() { return 1.3f; };
571 
572 } // namespace font
double t
Definition: astarsearch.cpp:63
Helper class to encapsulate the management of a PangoAttrList.
Definition: attributes.hpp:28
Text class.
Definition: text.hpp:78
unsigned get_lines_count() const
Get number of lines in the text.
Definition: text.hpp:294
int pixel_scale_
The pixel scale, used to render high-DPI text.
Definition: text.hpp:459
pango_text & operator=(const pango_text &)=delete
pango_text & set_font_style(const FONT_STYLE font_style)
Definition: text.cpp:381
PangoEllipsizeMode ellipse_mode_
The way too long text is shown depends on this mode.
Definition: text.hpp:438
static void copy_layout_properties(PangoLayout &src, PangoLayout &dst)
Definition: text.cpp:915
bool add_outline_
Whether to add an outline effect.
Definition: text.hpp:399
void clear_attributes()
Definition: text.cpp:319
bool validate_markup(std::string_view text, char **raw_text, std::string &semi_escaped) const
Definition: text.cpp:877
bool set_markup(std::string_view text, PangoLayout &layout)
Sets the markup'ed text.
Definition: text.cpp:814
std::size_t get_length() const
Gets the length of the text in bytes.
Definition: text.hpp:304
pango_text & set_maximum_length(const std::size_t maximum_length)
Definition: text.cpp:482
surface create_surface()
Equivalent to create_surface(viewport), where the viewport's top-left is at (0,0) and the area is lar...
Definition: text.cpp:764
PangoAlignment alignment_
The alignment of the text.
Definition: text.hpp:441
PangoRectangle rect_
Definition: text.hpp:366
int maximum_height_
The maximum height of the text.
Definition: text.hpp:435
point get_size()
Returns the size of the text, in drawing coordinates.
Definition: text.cpp:154
pango_text & set_characters_per_line(const unsigned characters_per_line)
Definition: text.cpp:416
color_t link_color_
The color to render links in.
Definition: text.hpp:384
unsigned insert_text(const unsigned offset, const std::string &text, const bool use_markup=false)
Inserts UTF-8 text.
Definition: text.cpp:169
void recalculate() const
Recalculates the text layout.
Definition: text.cpp:565
void render(PangoLayout &layout, const SDL_Rect &viewport)
This is part of create_surface(viewport).
Definition: text.cpp:709
color_t foreground_color_
The foreground color.
Definition: text.hpp:396
point get_column_line(const point &position) const
Gets the column of line of the character at the position.
Definition: text.cpp:278
std::unique_ptr< PangoContext, std::function< void(void *)> > context_
Definition: text.hpp:364
bool link_aware_
Are hyperlinks in the text marked-up, and will get_link return them.
Definition: text.hpp:375
pango_text & set_foreground_color(const color_t &color)
Definition: text.cpp:391
int to_draw_scale(int s) const
Scale the given render-space size to draw-space, rounding up.
Definition: text.cpp:143
std::string format_links(std::string_view text) const
Replaces all instances of URLs in a given string with formatted links and returns the result.
Definition: text.cpp:839
pango_text(const pango_text &)=delete
pango_text & set_line_spacing(float line_spacing)
Definition: text.hpp:352
unsigned get_byte_index(const unsigned offset, const unsigned line=0) const
Given a character index and optionally the starting line, returns the corresponding byte index.
Definition: text.cpp:189
std::string get_token(const point &position, std::string_view delimiters=" \n\r\t") const
Gets the largest collection of characters, including the token at position, and not including any cha...
Definition: text.cpp:245
PangoLayoutLine * get_line(int index)
Get a specific line from the pango layout.
Definition: text.cpp:948
unsigned characters_per_line_
The number of characters per line.
Definition: text.hpp:427
bool markedup_text_
Does the text contain pango markup? If different render routines must be used.
Definition: text.hpp:372
pango_text & set_family_class(font::family_class fclass)
Definition: text.cpp:359
font::family_class font_class_
The font family class used.
Definition: text.hpp:387
void apply_attributes(const font::attribute_list &attrs)
Definition: text.cpp:324
std::vector< std::string > get_lines() const
Retrieves a list of strings with contents for each rendered line.
Definition: text.cpp:922
void update_pixel_scale()
Update pixel scale, if necessary.
Definition: text.cpp:544
bool link_aware() const
Definition: text.hpp:344
std::tuple< int, int, bool > xy_to_index(const point &position) const
Wrapper function around pango_layout_xy_to_index.
Definition: text.cpp:308
unsigned font_size_
The font size to draw.
Definition: text.hpp:390
texture render_texture(const SDL_Rect &viewport)
Wrapper around render_surface which sets texture::w() and texture::h() in the same way that render_an...
Definition: text.cpp:117
surface render_surface(const SDL_Rect &viewport)
Returns the rendered text.
Definition: text.cpp:129
std::vector< uint8_t > surface_buffer_
Buffer to store the image on.
Definition: text.hpp:504
pango_text & set_add_outline(bool do_add)
Definition: text.cpp:514
point get_cursor_position(const unsigned offset, const unsigned line=0) const
Gets the location for the cursor, in drawing coordinates.
Definition: text.cpp:225
pango_text & set_ellipse_mode(const PangoEllipsizeMode ellipse_mode)
Definition: text.cpp:452
PangoRectangle calculate_size(PangoLayout &layout) const
Calculates surface size.
Definition: text.cpp:579
pango_text & set_alignment(const PangoAlignment alignment)
Definition: text.cpp:472
std::string text_
The text to draw (stored as UTF-8).
Definition: text.hpp:369
std::pair< int, int > index_to_line_x(const unsigned offset, const bool trailing=0) const
Given a byte index, find out at which line the corresponding character is located.
Definition: text.cpp:953
bool calculation_dirty_
The text has two dirty states:
Definition: text.hpp:453
std::unique_ptr< PangoLayout, std::function< void(void *)> > layout_
Definition: text.hpp:365
pango_text & set_font_size(unsigned font_size)
Definition: text.cpp:369
pango_text & set_link_aware(bool b)
Definition: text.cpp:495
FONT_STYLE font_style_
The style of the font, this is an orred mask of the font flags.
Definition: text.hpp:393
bool set_text(const std::string &text, const bool markedup)
Sets the text to render.
Definition: text.cpp:333
bool is_truncated() const
Has the text been truncated? This happens if it exceeds max width or height.
Definition: text.cpp:162
texture with_draw_scale(const texture &t) const
Adjust a texture's draw-width and height according to pixel scale.
Definition: text.cpp:136
std::size_t maximum_length_
The maximum length of the text.
Definition: text.hpp:444
point get_cursor_pos_from_index(const unsigned offset) const
Gets the location for the cursor, in drawing coordinates.
Definition: text.cpp:231
pango_text & set_maximum_height(int height, bool multiline)
Definition: text.cpp:427
pango_text & set_maximum_width(int width)
Definition: text.cpp:400
std::size_t get_maximum_length() const
Get maximum length.
Definition: text.cpp:240
texture render_and_get_texture()
Returns the cached texture, or creates a new one otherwise.
Definition: text.cpp:122
pango_text & set_link_color(const color_t &color)
Definition: text.cpp:504
std::string get_link(const point &position) const
Checks if position points to a character in a link in the text, returns it if so, empty string otherw...
Definition: text.cpp:268
const std::string & text() const
Definition: text.hpp:322
std::size_t length_
Length of the text.
Definition: text.hpp:456
int get_max_glyph_height() const
Returns the maximum glyph height of a font, in drawing coordinates.
Definition: text.cpp:524
int maximum_width_
The maximum width of the text.
Definition: text.hpp:409
Wrapper class to encapsulate creation and management of an SDL_Texture.
Definition: texture.hpp:33
static void layout()
void line(int from_x, int from_y, int to_x, int to_y)
Draw a line.
Definition: draw.cpp:189
Graphical text output.
pango_text & get_text_renderer()
Returns a reference to a static pango_text object.
Definition: text.cpp:960
constexpr float get_line_spacing_factor()
Definition: text.hpp:570
int get_max_height(unsigned size, font::family_class fclass, pango_text::FONT_STYLE style)
Returns the maximum glyph height of a font, in pixels.
Definition: text.cpp:966
std::size_t size(std::string_view str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:85
std::size_t index(std::string_view str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
Definition: unicode.cpp:70
rect dst
Location on the final composed sheet.
rect src
Non-transparent portion of the surface to compose.
The basic class for representing 8-bit RGB or RGBA colour values.
Definition: color.hpp:61
Holds a 2D point.
Definition: point.hpp:25
mock_party p
static map_location::direction s
#define b