mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Make shortened text in canvas take into account the ...
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "114.8.1",
|
||||
"version": "114.8.2",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
+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