AmoebeLabs / swiss-army-knife-card

The versatile custom Swiss Army Knife card for Home Assistant allows you to create your unique visualization using several graphical tools, styling options and animations.
245 stars 21 forks source link

Add very simple textlength - ellipsis - functionality #128

Closed AmoebeLabs closed 2 years ago

AmoebeLabs commented 2 years ago

The Problem To Be Solved

SVG Text objects don't have the functionality to limit text to a box or to use ellipsis settings to cut off the text. This is part of the SVG 2.x specification, but that one is already years behind schedule.

Additional background:

Some states have very different text lengths, so almost impossible to handle on a card.

Related Issues (if any)

(Optional): Suggested Solution

Limit the text to a certain length in characters. This is very simple and doesn't account for kerning, size of individual characters, etc. But it does the job for now...

Add the show.ellipsis field that contains the max number of characters...

Tools affected:

(Optional): Alternative Solutions

Calculations in the DOM. But for this, the text should already be attached to the DOM... Difficult, multi-pass and SLOW!!!!