23 #include <pango/pango.h> 24 #include <pango/pangocairo.h> 158 const unsigned column,
const unsigned line = 0)
const;
179 std::string
get_token(
const point & position,
const char * delimiters =
" \n\r\t")
const;
210 std::vector<std::string>
get_lines()
const;
232 bool set_text(
const std::string& text,
const bool markedup);
269 std::unique_ptr<PangoContext, std::function<void(void*)>>
context_;
270 std::unique_ptr<PangoLayout, std::function<void(void*)>>
layout_;
386 void rerender(
const SDL_Rect& viewport);
388 void render(PangoLayout& layout,
const SDL_Rect& viewport,
const unsigned stride);
412 bool set_markup(std::string_view text, PangoLayout& layout);
414 bool validate_markup(std::string_view text,
char** raw_text, std::string& semi_escaped)
const;
void recalculate() const
Recalculates the text layout.
unsigned font_size_
The font size to draw.
family_class
Font classes for get_font_families().
std::size_t get_length() const
Gets the length of the text in bytes.
bool set_text(const std::string &text, const bool markedup)
Sets the text to render.
Collection of helper functions relating to Pango formatting.
bool set_markup(std::string_view text, PangoLayout &layout)
Sets the markup'ed text.
int get_width() const
Returns the width needed for the text.
int maximum_height_
The maximum height of the text.
unsigned characters_per_line_
The number of characters per line.
std::size_t length_
Length of the text.
std::vector< std::string > get_lines() const
Retrieves a list of strings with contents for each rendered line.
pango_text & set_link_aware(bool b)
std::size_t maximum_length_
The maximum length of the text.
void rerender(const SDL_Rect &viewport)
Renders the text.
std::size_t get_maximum_length() const
Get maximum length.
font::family_class font_class_
The font family class used.
pango_text & set_font_style(const FONT_STYLE font_style)
pango_text & get_text_renderer()
Returns a reference to a static pango_text object.
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.
pango_text & set_ellipse_mode(const PangoEllipsizeMode ellipse_mode)
pango_text & set_maximum_length(const std::size_t maximum_length)
std::vector< uint8_t > surface_buffer_
Buffer to store the image on.
bool validate_markup(std::string_view text, char **raw_text, std::string &semi_escaped) const
pango_text & set_alignment(const PangoAlignment alignment)
point get_cursor_position(const unsigned column, const unsigned line=0) const
Gets the location for the cursor.
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
std::string get_token(const point &position, const char *delimiters=" \\) const
Gets the largest collection of characters, including the token at position, and not including any cha...
point get_size() const
Returns the pixel size needed for the text.
std::unique_ptr< PangoLayout, std::function< void(void *)> > layout_
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...
SDL_Rect rendered_viewport_
The area that's cached in surface_, which is the area that was rendered when surface_dirty_ was last ...
bool is_truncated() const
Has the text been truncated? This happens if it exceeds max width or height.
int maximum_width_
The maximum width of the text.
color_t foreground_color_
The foreground color.
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...
pango_text & set_font_size(const unsigned font_size)
PangoEllipsizeMode ellipse_mode_
The way too long text is shown depends on this mode.
pango_text & set_characters_per_line(const unsigned characters_per_line)
bool markedup_text_
Does the text contain pango markup? If different render routines must be used.
PangoRectangle calculate_size(PangoLayout &layout) const
Calculates surface size.
bool surface_dirty_
The dirty state of the surface.
bool calculation_dirty_
The text has two dirty states:
unsigned insert_text(const unsigned offset, const std::string &text)
Inserts UTF-8 text.
pango_text & set_family_class(font::family_class fclass)
std::unique_ptr< PangoContext, std::function< void(void *)> > context_
bool link_aware_
Are hyperlinks in the text marked-up, and will get_link return them.
point get_column_line(const point &position) const
Gets the column of line of the character at the position.
FONT_STYLE font_style_
The style of the font, this is an orred mask of the font flags.
int get_max_glyph_height() const
Returns the maximum glyph height of a font, in pixels.
bool add_outline_
Whether to add an outline effect.
pango_text & set_link_color(const color_t &color)
int get_height() const
Returns the height needed for the text.
const std::string & text() const
color_t link_color_
The color to render links in.
pango_text & set_maximum_width(int width)
surface surface_
The SDL surface to render upon used as a cache.
surface & render()
Equivalent to render(viewport), where the viewport's top-left is at (0,0) and the area is large enoug...
pango_text & set_maximum_height(int height, bool multiline)
std::string text_
The text to draw (stored as UTF-8).
pango_text & set_foreground_color(const color_t &color)
PangoAlignment alignment_
The alignment of the text.
pango_text & set_add_outline(bool do_add)
static void copy_layout_properties(PangoLayout &src, PangoLayout &dst)
pango_text & operator=(const pango_text &)=delete