Use integer text position in scroll container, TextEdit and canvas editor, to ensure sharp text rendering.
Use integer font align/advance with any font scaling, to ensure sharp text rendering.
This commit is contained in:
parent
7d5a8ea0e9
commit
1adea98d07
6 changed files with 9 additions and 8 deletions
|
@ -2935,7 +2935,7 @@ void CanvasItemEditor::_draw_rulers() {
|
|||
// Draw top ruler
|
||||
viewport->draw_rect(Rect2(Point2(RULER_WIDTH, 0), Size2(viewport->get_size().x, RULER_WIDTH)), bg_color);
|
||||
for (int i = Math::ceil(first.x); i < last.x; i++) {
|
||||
Point2 position = (transform * ruler_transform * major_subdivide * minor_subdivide).xform(Point2(i, 0));
|
||||
Point2 position = (transform * ruler_transform * major_subdivide * minor_subdivide).xform(Point2(i, 0)).round();
|
||||
if (i % (major_subdivision * minor_subdivision) == 0) {
|
||||
viewport->draw_line(Point2(position.x, 0), Point2(position.x, RULER_WIDTH), graduation_color, Math::round(EDSCALE));
|
||||
float val = (ruler_transform * major_subdivide * minor_subdivide).xform(Point2(i, 0)).x;
|
||||
|
@ -2952,7 +2952,7 @@ void CanvasItemEditor::_draw_rulers() {
|
|||
// Draw left ruler
|
||||
viewport->draw_rect(Rect2(Point2(0, RULER_WIDTH), Size2(RULER_WIDTH, viewport->get_size().y)), bg_color);
|
||||
for (int i = Math::ceil(first.y); i < last.y; i++) {
|
||||
Point2 position = (transform * ruler_transform * major_subdivide * minor_subdivide).xform(Point2(0, i));
|
||||
Point2 position = (transform * ruler_transform * major_subdivide * minor_subdivide).xform(Point2(0, i)).round();
|
||||
if (i % (major_subdivision * minor_subdivision) == 0) {
|
||||
viewport->draw_line(Point2(0, position.y), Point2(RULER_WIDTH, position.y), graduation_color, Math::round(EDSCALE));
|
||||
float val = (ruler_transform * major_subdivide * minor_subdivide).xform(Point2(0, i)).y;
|
||||
|
|
|
@ -432,8 +432,8 @@ DynamicFontDataAdvanced::Character DynamicFontDataAdvanced::bitmap_to_character(
|
|||
}
|
||||
|
||||
Character chr;
|
||||
chr.align = Vector2(xofs, -yofs) * p_data->scale_color_font / oversampling;
|
||||
chr.advance = advance * p_data->scale_color_font / oversampling;
|
||||
chr.align = (Vector2(xofs, -yofs) * p_data->scale_color_font / oversampling).round();
|
||||
chr.advance = (advance * p_data->scale_color_font / oversampling).round();
|
||||
chr.texture_idx = tex_pos.index;
|
||||
chr.found = true;
|
||||
|
||||
|
|
|
@ -317,8 +317,8 @@ DynamicFontDataFallback::Character DynamicFontDataFallback::bitmap_to_character(
|
|||
}
|
||||
|
||||
Character chr;
|
||||
chr.align = Vector2(xofs, -yofs) * p_data->scale_color_font / oversampling;
|
||||
chr.advance = advance * p_data->scale_color_font / oversampling;
|
||||
chr.align = (Vector2(xofs, -yofs) * p_data->scale_color_font / oversampling).round();
|
||||
chr.advance = (advance * p_data->scale_color_font / oversampling).round();
|
||||
chr.texture_idx = tex_pos.index;
|
||||
chr.found = true;
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ void ProgressBar::_notification(int p_what) {
|
|||
if (percent_visible) {
|
||||
String txt = TS->format_number(itos(int(get_as_ratio() * 100))) + TS->percent_sign();
|
||||
TextLine tl = TextLine(txt, font, font_size);
|
||||
tl.draw(get_canvas_item(), Point2(get_size().width - tl.get_size().x, get_size().height - tl.get_size().y) / 2, font_color);
|
||||
tl.draw(get_canvas_item(), (Point2(get_size().width - tl.get_size().x, get_size().height - tl.get_size().y) / 2).round(), font_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -328,6 +328,7 @@ void ScrollContainer::_notification(int p_what) {
|
|||
if (rtl && v_scroll->is_visible_in_tree() && v_scroll->get_parent() == this) {
|
||||
r.position.x += v_scroll->get_minimum_size().x;
|
||||
}
|
||||
r.position = r.position.floor();
|
||||
fit_child_in_rect(c, r);
|
||||
}
|
||||
|
||||
|
|
|
@ -1245,7 +1245,7 @@ void TextEdit::_notification(int p_what) {
|
|||
int gl_size = visual.size();
|
||||
|
||||
ofs_y += ldata->get_line_ascent(line_wrap_index);
|
||||
float char_ofs = 0.f;
|
||||
int char_ofs = 0;
|
||||
for (int j = 0; j < gl_size; j++) {
|
||||
if (color_map.has(glyphs[j].start)) {
|
||||
current_color = color_map[glyphs[j].start].get("color");
|
||||
|
|
Loading…
Reference in a new issue