Skip to content

Commit

Permalink
OpTeX trick 0107 added
Browse files Browse the repository at this point in the history
  • Loading branch information
olsak committed Apr 23, 2023
1 parent 7400c8e commit 294f745
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions web/optex-tricks.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ <h2>Contents</h2>
<li><a href="#ul">Marking parts of text</a>
<li><a href="#attreffects">Font effects using attributes</a>
<li><a href="#varifonts">Using variable fonts</a>
<li><a href="#fakecaps">Small caps if font doesn't provide it</a>
</ul>

<li>Lists
Expand Down Expand Up @@ -733,6 +734,36 @@ <h2><a name="varifonts"></a>Using variable fonts</h2>
<p CLASS=datum>(0102) -- P. O. 2023-01-27<p>
<hr>

<h2><a name="fakecaps"></a>Small caps if font doesn't provide it</h2>

<p>Sometimes the font doesn't provide Caps and small caps font feature
(cmsp) but we need this feature. For example DejaVu font doesn't have small
capitals. We can do alternative small capitals using following
trick with the macro \fakecaps{Here is a Text}. Note that real small
capitals created by font designer individually for each character are much better.

<pre>
\def\fakecaps#1{\def\tmp{#1}\replstring\tmp{ }{{ }}%
{\ea\let \ea\fupper \the\font \uccode`'=`'
\setfontsize{mag.8}\setff{+upper;embolden=1.1}\setwordspace{1.25}\fontsel
\ea\foreach\tmp\do{\ifnum\uccode`##1=`##1{\fupper##1}\else ##1\fi}}}
</pre>

<p>The macro works only with a font registered in Font selection system (i.e.
implemented by font family files). The current font is set to \fupper and
then it is scaled by the magnification factor 0.8, the font features +upper and embolden=1.1
are added and the word space of the scaled font is scaled back to the value
of the original font. The macro parameter is processed token by token using
\foreach (spaces are prepared before by \replstring) and if \uccode of the
character is equal to the character code the \fupper is used. The character
' (for example in the word don't) must be printed with original font, so its
\uccode is changed.

<p>Compare solutions at <a href="https://tex.stackexchange.com/questions/682572">tex.stacexchange</a>.

<p CLASS=datum>(0107) -- P. O. 2023-04-23<p>
<hr>

<p CLASS="lmarg">Lists</p>

<h2><a name="multilist"></a>List items multi-numbered at arbitrary level</h2>
Expand Down

0 comments on commit 294f745

Please sign in to comment.