Only latin characters?
Looks like it doesn't work with non-latin characters, e.g. cyrillic.
Please make that very clear in Readme start, not in "How to contribute" section.
So that people don't waste their time.
@iliakan you can try this https://github.com/Evgenus/js-server-text-width if it is still relevant.
Looks like it doesn't work with non-latin characters, e.g. cyrillic.
Please make that very clear in Readme start, not in "How to contribute" section.
So that people don't waste their time.
I tried to add cyrillic adding this loop
for (let i = 0; i < hexArray.length; i++) {
for (let j = 0; j < hexArray.length; j++) {
let russianUnicode = `${hexArray[i]}${hexArray[j]}`.padStart(
4,
"04"
);
var russianLetter = String.fromCharCode(
parseInt(`${russianUnicode}`, 16)
);
widths[russianLetter] = [
getWidthOf(sandbox, printableLetter, name, "normal", "normal"),
getWidthOf(sandbox, printableLetter, name, "bold", "normal"),
getWidthOf(sandbox, printableLetter, name, "normal", "italic"),
getWidthOf(sandbox, printableLetter, name, "bold", "italic"),
];
}
if (hexArray[i] === "5") {
break;
}
}
just below the loop iterating for latin chars and I can have those chars included
but even adding it when I try to use it to have the getWidth of a text, it seems the width are not correctly calculated, because the result to apply a font resized based on the full text width and the container dimension where the text might fit, it doesn't work as it does for latin chars.