Hiya Fenryll… good to see you again. Interesting challenge!
Ok, have you ever studied the “em” unit-of-measure… for font-sizing?
To summarize quickly… setting a fontSize to “1.3em” means… make the fontSize 1.3 times the current size of the letter ‘m’. So, 1.3em is the same as saying… “increase font size by 30%”, yes?
But a person NEEDS a “default font size”… to accomplish that. We NEED a reference ‘m’-size… to determine what is 1em (or 100% of default fontSize). This can be challenging… and after you see the below playround… you’ll surely agree.
https://www.babylonjs-playground.com/#AYL9GV#7
Ok, up at line 88… inputText.fontSize = 25;
So, our ‘m’ is established as a size-25 ‘m’.
We’ll need to remind the setInterval() of that value… because… well… I’m not sure why, yet.
Ok, off we go, touring the PG:
- Line 122… establish a “font percentage” named fpct.
- Line 123… a change step. Our tester will be working-with +/- 10% intervals.
- Line 124… default ‘m’-size… same as the value in line 88.
Lines 126-136… an interval looper… happens every 1.5 seconds. To be brief, I am sweeping fpct in a range from 0%… to 210% (and back again)… in 10% intervals… and I’m going to “feed” that to textInput.fontSize… in STRING-based ‘em’ units-of-measure.
NOTE: textInput.fontSize MIGHT be ignoring ‘em’-based settings… and converting it to ‘px’ settings automatically… a possibility raised by the need to multiply * em in line 135. More about that… below. In short, ‘em’ units might not work… for textInput.fontSize setting, and I am only fooling myself/you/us.
- Line 133… some reports to JS console.
- Line 135… does that “poke”. See the
* em
in there? I dunno why that needs to be there, but it does. And as long as it IS in there, I don’t think my system is quite correct. But it DOES do SOMETHING… based upon a changing percentage. Even if it IS a badly-coded kludge/mess, it STILL seems to be almost working, and could maybe lead-to YOU, doing it correctly/wiser.
So, it’s just a thing … a test playground… something for you/us to poke with sticks and see what its story is. Stick-poking… may be the first stand-off investigative tool used by almost all children. So, it’s fairly famous, and a cherished best friend of mine. I still use poking-sticks often… especially when I find/examine unusual critter stools in woodlands. This PG demo might have similar smells. heh