[NTG-context] Is it possible to automatically determine font size to fit text to a given space?

Hans Hagen pragma at wxs.nl
Fri Dec 2 16:30:00 CET 2005


Wolfgang Zillig wrote:

> Could't it be done by metapost?
>
no, that is overkill, but what can be done is:

\startbuffer
the label
\stopbuffer

\externalfigure[buffer][factor=max]

or

\scale[factor=max]{\framed[align=normal]{the label text}}
 
that would scale each label to fit best

but it would look funny (all those different sizes)

a more clever solution would choose different sizes for different label 
components depending on the result

(there is a rudimentary strategy mechanism, one day i will perfect that, 
which can be used to optimize whole documents, think of manipulating the 
distance in columns, or fontsizes in order to stick within a certain 
amount of pages; pretty old and rusty code btw)

> Wolfgang
>
> Hans Hagen schrieb:
>
>> Daniel Pittman wrote:
>>
>>> Hints about that, or a native TeX method[1], would be very much
>>> appreciated.  At the moment it is a relatively slow process of manual
>>> trial and error.
>>>  
>>>
>> this is something tex is pretty good at and it runs as fast as normal
>>
>> how does your current code look? (the solution depends a bit it); 
>> think of something
>>
>> \doloop{
>>  \setbox\scratchbox=\vbox
>>     {the content of the label}
>>   \ifx\ht\scratchbox>10cm
>>       \switchtobodyfont[small]   \else
>>       \unvbox\scratchbox
>>       \exitloop
>>   \fi
>> }
>>
>> Hans
>> _______________________________________________
>> ntg-context mailing list
>> ntg-context at ntg.nl
>> http://www.ntg.nl/mailman/listinfo/ntg-context
>>
>
> _______________________________________________
> ntg-context mailing list
> ntg-context at ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context




More information about the ntg-context mailing list