Skip to content

Commit 843ffdf

Browse files
author
Jay
committed
Dont render CR
1 parent 63bc05e commit 843ffdf

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

build.zig.zon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.{
22
.name = .engine,
3-
.version = "0.2.6",
3+
.version = "0.2.7",
44
.fingerprint = 0xe8a81a8d0aa558d5,
55
.minimum_zig_version = "0.14.1",
66
.dependencies = .{

src/engine.zig

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,9 +2049,10 @@ inline fn draw_text_elements(
20492049
var current_line_start: usize = 0;
20502050

20512051
for (children, 0..) |*item, i| {
2052+
const is_cr = item.text != null and item.text.?.len == 1 and item.text.?[0] == '\n';
20522053
const size = text_size(display, item.texture, text_height);
20532054
// Would drawing this word overflow?
2054-
if (x + size.width > x_ending and line_word_count > 0) {
2055+
if ((x + size.width > x_ending and line_word_count > 0) or is_cr) {
20552056
element.do_word_alignment(x_start, x, x_ending, children[current_line_start..i], display);
20562057
// Wrap to next line
20572058
x = element.rect.x + element.pad.left;
@@ -2060,17 +2061,17 @@ inline fn draw_text_elements(
20602061
line_word_count = 0;
20612062
current_line_start = i;
20622063
}
2063-
if (line_word_count > 0) {
2064+
if (line_word_count > 0 and !is_cr) {
20642065
x += word_spacing;
20652066
}
20662067
item.location = .{
20672068
.x = @round(x + scroll_offset.x),
20682069
.y = @round(y + scroll_offset.y),
2069-
.width = size.width,
2070+
.width = if (is_cr) 0 else size.width,
20702071
.height = size.height,
20712072
};
2072-
line_word_count += 1;
2073-
x += size.width;
2073+
if (!is_cr) x += size.width;
2074+
if (!is_cr) line_word_count += 1;
20742075
}
20752076

20762077
if (children.len > 0) {

0 commit comments

Comments
 (0)