aboutsummaryrefslogtreecommitdiff
path: root/scene/gui/item_list.cpp
diff options
context:
space:
mode:
authorRuslan Mustakov2018-03-17 15:44:34 +0700
committerRuslan Mustakov2018-05-08 13:45:24 +0700
commit5cd12f6649387f91d08fd17bf3c70e732798ab58 (patch)
treecc0e4fd2ce69997c67df9aa36b7390cb52c0534c /scene/gui/item_list.cpp
parent6e8e401359ba86d33253fb3d3241cf09a742c8e4 (diff)
downloadgodot-5cd12f6649387f91d08fd17bf3c70e732798ab58.tar.gz
godot-5cd12f6649387f91d08fd17bf3c70e732798ab58.tar.zst
godot-5cd12f6649387f91d08fd17bf3c70e732798ab58.zip
Perfect FreeType-based outlines for DynamicFonts
- Implement outlines based on FreeType Stroker API. This allows artifact-free results, similar to what you will see in Web or any text editing tools. Outline is a part of DynamicFont rather than Label, because outlines have to be baked into the font's atlas. Font has a default outline_color and a Label can specify font_outline_modulator that will be multiplied with the Font's color to get the final result. - draw_char now has to be called twice to fully render a text - first with p_outline == true for each character and then with p_outline == false for each character. - Number of draw-calls is reduced from 5 to 2 per outlined character. - Overall cleanup of DynamicFont code, extracted duplicated code pieces into separate methods. - The change is backward-compatible - Labels still have outline properties that work exactly as they worked before. Closes #16279.
Diffstat (limited to 'scene/gui/item_list.cpp')
-rw-r--r--scene/gui/item_list.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 511dc248a..602b15144 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -1121,6 +1121,7 @@ void ItemList::_notification(int p_what) {
text_ofs += base_ofs;
text_ofs += items[i].rect_cache.position;
+ FontDrawer drawer(font, Color(1, 1, 1));
for (int j = 0; j < ss; j++) {
if (j == line_limit_cache[line]) {
@@ -1129,7 +1130,7 @@ void ItemList::_notification(int p_what) {
if (line >= max_text_lines)
break;
}
- ofs += font->draw_char(get_canvas_item(), text_ofs + Vector2(ofs + (max_len - line_size_cache[line]) / 2, line * (font_height + line_separation)).floor(), items[i].text[j], items[i].text[j + 1], modulate);
+ ofs += drawer.draw_char(get_canvas_item(), text_ofs + Vector2(ofs + (max_len - line_size_cache[line]) / 2, line * (font_height + line_separation)).floor(), items[i].text[j], items[i].text[j + 1], modulate);
}
//special multiline mode