22 #include <pango/pango.h> 23 #include <pango/pangocairo.h> 132 const unsigned offset,
const std::u32string& unicode);
157 const unsigned column,
const unsigned line = 0)
const;
178 std::string
get_token(
const point & position,
const char * delimiters =
" \n\r\t")
const;
220 bool set_text(
const std::string& text,
const bool markedup);
257 std::unique_ptr<PangoContext, std::function<void(void*)>>
context_;
258 std::unique_ptr<PangoLayout, std::function<void(void*)>>
layout_;
378 void rerender(
const bool force =
false);
380 void render(PangoLayout& layout,
const PangoRectangle& rect,
381 const std::size_t surface_buffer_offset,
const unsigned stride);
405 bool set_markup(std::string_view text, PangoLayout& layout);
407 bool validate_markup(std::string_view text,
char** raw_text, std::string& semi_escaped)
const;
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.
Note: Specific to sdl_ttf.
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.
pango_text & set_link_aware(bool b)
std::size_t maximum_length_
The maximum length of the text.
void recalculate(const bool force=false) const
Recalculates the text layout.
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.
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::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...
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.
void rerender(const bool force=false)
Renders 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)
bool insert_unicode(const unsigned offset, char32_t unicode)
Inserts a unicode char.
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.
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()
Returns the rendered text.
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