Hi, I finally decided to start an experiment that I had on my todo list for a while: dynamically scaling fonts. Below is an example of usage (plus some comment). In that example some 2*200 different font sizes are used which in mkiv demands 400 font definitions. This costs time and memory. The example below runs (on my old laptop) in less than 2 seconds and only uses two instances. I bet that our CJK users will love it. I post it because: (1) I need to discuss the impact with Wolfgang ... how do we integrate this. We can for instance define some sizes (\tfa \tfb ...) differently. (2) I want to see if average performance improves on huge documents with many fonts / sizes (that is for Massimiliano to test). (3) Are there side effects? It does work for math (rather neat trickery) but maybe we need an additional configration for that. (4) I considered several variants but for now use a low level \glyphscale command that takes a number (in goodl old tex tradition a scale of 1.0 is entered as 1000). (5) The implementation can be improved a bit (performance wise). There is a bit more overhead involved but usually I can compensate that. (6) It will not be backported to MKIV so one can only test in LMTX. it's a bit of a mix between engine and context features. (7) There can be bugs (unforseen side effects, or typos in the somewhat quick patches in the source). Consider it an experiment, but so far I'm rather satisfied, Hans %%%% EXAMPLE %%%% \setuplayout[middle] \setupbodyfont[pagella,10pt] \setupalign[verytolerant,stretch] \setupwhitespace[big] \starttext \startbuffer \definescaledfont[bfe][scale=2000,style=bf] \setuphead[chapter][style=\bfe] \dostepwiserecurse {10} {2020} {10} { \title{Here we go #1!} \start \glyphscale#1\relax \setupinterlinespace \samplefile{ward}% \bf \samplefile{ward} \par \stop \page } \stopbuffer \getbuffer \title{Scaled fonts} Although \CONTEXT\ is quite efficient with fonts there is always room for improvement. However, after years of finetuning the font mechanisms there was not that much room left. This made me think of a different approach to scaling. Nowadays fonts seldom come in design sizes. Also, in \CONTEXT\ \MKIV\ and therefore \LMTX\ we always had so called dynamic features: apply additional features locally, although that comes with a small penalty in performance, it saves additional font instances. It is a good approach for the occasional small stretch of glyphs, like small capped logos and such. We now can also do dynamic font scaling, which means that we don't need to define a new font instance when the same feature set is used. Or course in addition to this features one can still use the dynamic features. This means that for instance chapter titling can use the bodyfont instance and just apply additional scaling. Although for a normal run the number of loaded fonts is normally small, and the number of instances also isn't that impressive it can happen in a large document that you end up with a few dozen. That number can now be reduced to half a dozen. Of course there can be side effects, whcich is why it's currently tagged as experimental. There is also a small performance hit because we now need to track it but that is gained back because we load less fonts and have less glyph runs. It even works in math, although there some different trickery is needed. \typebuffer \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
When I started using ConTeXt, font management gave me headaches because I expected fonts to be indefinitely scalable and not to be designed in advance at fixed sizes. That came from using software like Word, where fonts are scalable at any size. Since I had no background in typesetting, I took vector, indefinitely scalable fonts for granted. With that mindset a 48pt font is just a 10pt font scaled 4.8 times. Then I knew about optical sizes, which were the norm with lead glyphs, because they came in heavy physical sets. And so the notion that as the font body gets bigger, the stroke gets thinner (so it's not just scaling). I like this feature because it should make playing with sizes easier for people while lighter for machines, even though fixed sizes to be designed in advance enforce discipline and consistency in documents. Massi
On 12/23/2020 11:36 AM, mf wrote:
When I started using ConTeXt, font management gave me headaches because I expected fonts to be indefinitely scalable and not to be designed in advance at fixed sizes.
That came from using software like Word, where fonts are scalable at any size. Since I had no background in typesetting, I took vector, indefinitely scalable fonts for granted. With that mindset a 48pt font is just a 10pt font scaled 4.8 times.
Then I knew about optical sizes, which were the norm with lead glyphs, because they came in heavy physical sets. And so the notion that as the font body gets bigger, the stroke gets thinner (so it's not just scaling).
I like this feature because it should make playing with sizes easier for people while lighter for machines, even though fixed sizes to be designed in advance enforce discipline and consistency in documents. Of course we can still keep the abstraction because we can define sizes, think of:
\definescaledfont[bfe][xscale=2000,yscale=6000,style=bf] (just made this feature work in two directions, not yet uploaded). But you're right, we have to educate users in this. Actually, I was wondering iif this could be abused to do vertical hz ... filling a vbox / page with subtle scaling. It should be relatively easy to implement, so when I'm bored ... Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
participants (2)
-
Hans Hagen
-
mf