Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using Plain TeX (and eplain, if that matters). I would like to be able to generically scale the current font, no matter how the current font has been set. For example, I want to write a macro

\def\VandV{V\hskip-3pt{\abitsmallerthanthecurrentfont\&\hskip-3ptV}

and I want \abitsmallerthanthecurrentfont to make the ampersand a bit smaller.

IIRC, In LaTeX, without packages, one can use \Large and \tiny and such to affect the size of the current font. But I'm not using LaTeX.

Can this be done in a straightforward way without oodles of modifications to Plain TeX?

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

I'd use a completely different approach:

\input eplain
\beginpackages
  \usepackage{graphicx}
\endpackages

\def\smallampersand{\scalebox{.8}{\&}}
\def\VandV{V\kern-.4ex\smallampersand\kern-.4ex V}

\font\my="Linux Libertine O" at 36pt

\my\VandV

enter image description here


Note that for a logo \kern should be used, or an \hbox around the construction, as \hskip introduces a break point.

share|improve this answer
    
This is the right way to do what I want to do (the V&V logo). Thanks! –  EfForEffort Feb 28 '12 at 2:43
add comment

I have a similar approach to @morbusg's: examine the \fontname. The following code retrieves the current font name and its size/scaling factor, then modifies the latter and declares a temporary font with the new size. The font is scaled by 1.2 in both directions. As a result the macro can be used recursively to get relatively bigger/smaller sizes. The font manipulation is done in a group to not accumulate the computational error.

\newcount\fontscale
\newdimen\fontsize

\def\discard#1\relax{}
\def\processfont#1 #2#3 #4 {%
  \def\fname{#1}%
  % Can't normally compare to 'at' here, because \fontname returns
  % characters of catcode 12
  \if a#2%
    \fontsize=#4
  \else
    \fontscale=#4
  \fi
  \discard}
\def\scalefont#1#2#3{%
  \begingroup
    \edef\x{\fontname\font\space scaled 1000 \relax}%
    \fontscale=0
    \expandafter\processfont\x
    \ifnum\fontscale=0
      % We have the "at" syntax
      \multiply\fontsize by #1
      \divide\fontsize by #2
      \font\tmpfont=\fname\space at \the\fontsize
    \else
      % We have the "scaled" syntax
      \multiply\fontscale by #1
      \divide\fontscale by #2
      \font\tmpfont=\fname\space scaled \the\fontscale
    \fi
    \tmpfont #3%
  \endgroup}
\def\smaller#1{\scalefont{5}{6}{#1}}
\def\bigger#1{\scalefont{6}{5}{#1}}


test \bigger{test \bigger{test \bigger{test}}}

test \smaller{test \smaller{test \smaller{test}}}

\bye

enter image description here

However, this approach can't use different optical font sizes, which are the key to finest typesetting. Accounting for the optical sizes would require infrastructure that needs to know the different available optical sizes of the particular font in use, much like LaTeX already does. Therefore you might achieve better results with LaTeX and, for example, the relsize package.

share|improve this answer
add comment

I had such a clever idea: to use the result of \fontname\font as the input for a macro which loads \dimexpred smaller font. But unfortunately it has issues (I used plain XeTeX):

\font\test="Myriad Pro" at 16pt
\test
\def\smaller{%
  \def\loadnewfont"##1" ##2 ##3\relax{%
    \font\test="##1" at \the\dimexpr##3-1pt\relax\test}
  \expandafter\loadnewfont\fontname\font\relax\&}
\fontname\font
\smaller \fontname\font \smaller \fontname\font
\smaller \fontname\font \smaller \fontname\font
\smaller \fontname\font % the size has vanished with the last call!?
\bye

enter image description here

share|improve this answer
    
NOTE: It seems that the 11pt rule only applies to, e.g., Minion Pro and Myriad Pro, but not to, e.g., TeX Gyre Pagella, so that would need another test in there somewhere. –  morbusg Feb 25 '12 at 9:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.