mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-19 13:56:43 +02:00
Make shortened text in canvas take into account the ...
This commit is contained in:
+1
-1
@@ -106,7 +106,7 @@ module.exports = class CanvasUtil {
|
||||
|
||||
static shortenText(ctx, text, maxWidth) {
|
||||
let shorten = false;
|
||||
while (ctx.measureText(text).width > maxWidth) {
|
||||
while (ctx.measureText(`${text}...`).width > maxWidth) {
|
||||
if (!shorten) shorten = true;
|
||||
text = text.substr(0, text.length - 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user