39 attribute(PangoAttribute* attr,
unsigned offset_start,
unsigned offset_end)
40 :
value_(attr, &pango_attribute_destroy)
42 attr->start_index = offset_start;
43 attr->end_index = offset_end;
57 std::unique_ptr<PangoAttribute, void(*)(PangoAttribute*)>
value_;
61 constexpr std::tuple<uint16_t, uint16_t, uint16_t> color_to_uint16(
const color_t& color)
64 color.r / 255.0 * std::numeric_limits<uint16_t>::max(),
65 color.g / 255.0 * std::numeric_limits<uint16_t>::max(),
66 color.b / 255.0 * std::numeric_limits<uint16_t>::max()
78 pango_attr_size_new_absolute(PANGO_SCALE *
size),
79 offset_start, offset_end
83 DBG_GUI_D <<
"attribute start: " << offset_start <<
" end : " << offset_end;
91 pango_attr_weight_new(weight),
92 offset_start, offset_end
96 DBG_GUI_D <<
"attribute start: " << offset_start <<
" end : " << offset_end;
104 pango_attr_style_new(style),
105 offset_start, offset_end
109 DBG_GUI_D <<
"attribute start: " << offset_start <<
" end : " << offset_end;
117 pango_attr_underline_new(underline),
118 offset_start, offset_end
122 DBG_GUI_D <<
"attribute start: " << offset_start <<
" end : " << offset_end;
129 auto [col_r, col_g, col_b] = color_to_uint16(color);
132 pango_attr_foreground_new(col_r, col_g, col_b),
133 offset_start, offset_end
137 DBG_GUI_D <<
"attribute start: " << offset_start <<
" end : " << offset_end;
138 DBG_GUI_D <<
"color: " << col_r <<
"," << col_g <<
"," << col_b;
145 auto [col_r, col_g, col_b] = color_to_uint16(color);
148 pango_attr_background_new(col_r, col_g, col_b),
149 offset_start, offset_end
152 DBG_GUI_D <<
"highlight start: " << offset_start <<
"end : " << offset_end;
153 DBG_GUI_D <<
"highlight color: " << col_r <<
"," << col_g <<
"," << col_b;
155 attr.modify_in(list);
163 pango_attr_family_new(family_name.
c_str()),
164 offset_start, offset_end
168 DBG_GUI_D <<
"attribute start: " << offset_start <<
" end : " << offset_end;
std::unique_ptr< PangoAttribute, void(*)(PangoAttribute *)> value_
Helper class to encapsulate the management of a PangoAttrList.
void modify(PangoAttribute *attr)
void insert(PangoAttribute *attr)
int font_scaled(int size)
const char * c_str() const
Define the common log macros for the gui toolkit.
family_class
Font classes for get_font_families().
void add_attribute_size(attribute_list &list, unsigned offset_start, unsigned offset_end, int size)
Add Pango font size attribute to a specific portion of text.
void add_attribute_bg_color(attribute_list &list, unsigned offset_start, unsigned offset_end, const color_t &color)
Mark a specific portion of text for highlighting.
void add_attribute_weight(attribute_list &list, unsigned offset_start, unsigned offset_end, PangoWeight weight)
Add Pango font weight attribute to a specific portion of text.
const t_string & get_font_families(family_class fclass)
Returns the currently defined fonts.
void add_attribute_underline(attribute_list &list, unsigned offset_start, unsigned offset_end, PangoUnderline underline)
Add Pango underline attribute to a specific portion of text.
void add_attribute_font_family(attribute_list &list, unsigned offset_start, unsigned offset_end, font::family_class family)
Add Pango font family attribute to a specific portion of text.
void add_attribute_style(attribute_list &list, unsigned offset_start, unsigned offset_end, PangoStyle style)
Add Pango font style attribute to a specific portion of text, used to set italic/oblique text.
void add_attribute_fg_color(attribute_list &list, unsigned offset_start, unsigned offset_end, const color_t &color)
Add Pango fg color attribute to a specific portion of text.
std::size_t size(std::string_view str)
Length in characters of a UTF-8 string.
int get_pixel_scale()
Get the current active pixel scale multiplier.
The basic class for representing 8-bit RGB or RGBA colour values.