Skip to content

Commit

Permalink
Measure width of text correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
britzl committed Feb 26, 2018
1 parent fb92047 commit c810826
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion example/example.gui
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ background_color {
}
nodes {
position {
x: 113.0
x: 120.0
y: 1097.0
z: 0.0
w: 1.0
Expand Down
3 changes: 2 additions & 1 deletion richtext/richtext.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ function M.create(text, font, settings)
highest_word = math.max(highest_word, word.metrics.height)

-- adjust position and position node
if settings.width and position.x + word.metrics.width > settings.width then
local width = position.x + word.metrics.width - settings.position.x
if settings.width and width > settings.width then
position.y = position.y - highest_word
position.x = settings.position.x
highest_word = 0
Expand Down

0 comments on commit c810826

Please sign in to comment.