diff options
| author | Omar Rizwan <omar@omar.website> | 2023-09-29 11:02:06 +0000 |
|---|---|---|
| committer | Omar Rizwan <omar@omar.website> | 2023-09-29 11:02:06 +0000 |
| commit | 0dbceb76d14382a0eab62f4c6c3bb5eb7e4d06eb (patch) | |
| tree | 6237c1491f123af54a47d426ab0fd5bd16f2a17d /virtual-programs | |
| parent | main,camera: Can now free things from Folk interprocess heap (diff) | |
| download | folk-0dbceb76d14382a0eab62f4c6c3bb5eb7e4d06eb.tar.gz folk-0dbceb76d14382a0eab62f4c6c3bb5eb7e4d06eb.zip | |
display: Fix text extent computation / centering
Diffstat (limited to 'virtual-programs')
| -rw-r--r-- | virtual-programs/display.folk | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/virtual-programs/display.folk b/virtual-programs/display.folk index 268e462d..e42ea621 100644 --- a/virtual-programs/display.folk +++ b/virtual-programs/display.folk @@ -218,6 +218,7 @@ On process { variable font set em [* $scale 25.0] set x 0; set y 0 + set width 0 for {set i 0} {$i < [string length $text]} {incr i} { set char [string index $text $i] if {$char eq "\n"} { @@ -231,8 +232,9 @@ On process { } lassign $glyphInfo advance planeBounds atlasBounds set x [+ $x [* $advance $em]] + if {$x > $width} { set width $x } } - return [list $x $y] + return [list $width [+ $y $em]] } proc text {x0 y0 scale text radians} { variable font |
