Open HGustavs opened 3 years ago
@a18nadma IIRC you were looking at this an hour ago or so.
The way that this type of stuff has been achieved since the 1980-s if no native measuring is available, is to go over the letters and figure out roughly how much narrower / broader each letter is compared to the standard width.
In most fonts, only a few letters differ from standard and in a rather predictable way, e.g. W is a certain proportion bigger than normal letters and M is nearly the same.
For most fonts a good-enough guess is possible without cumbersome stuff... we want something that takes up as few lines of code as possible and does not use any costly functionality.
If no other smarter text measuring functionality (making a canvas and using text measuring from html5 canvas (which is used in previous diagram version) is considered too cumbersome) is found, I suggest making similar relative measuring functionality for the capital letters also... and as a stretch goal, also supporting some other font as a parameter to the measuring function.
https://github.com/HGustavs/DiagramEngine/commit/a5022cf