Skip to content

Commit c810826

Browse files
committed
Measure width of text correctly
1 parent fb92047 commit c810826

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

example/example.gui

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ background_color {
3535
}
3636
nodes {
3737
position {
38-
x: 113.0
38+
x: 120.0
3939
y: 1097.0
4040
z: 0.0
4141
w: 1.0

richtext/richtext.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ function M.create(text, font, settings)
8686
highest_word = math.max(highest_word, word.metrics.height)
8787

8888
-- adjust position and position node
89-
if settings.width and position.x + word.metrics.width > settings.width then
89+
local width = position.x + word.metrics.width - settings.position.x
90+
if settings.width and width > settings.width then
9091
position.y = position.y - highest_word
9192
position.x = settings.position.x
9293
highest_word = 0

0 commit comments

Comments
 (0)