[NTG-context] Alphabet & color

Hans Hagen j.hagen at xs4all.nl
Thu Jul 16 09:19:52 CEST 2020


On 7/16/2020 7:32 AM, Marcus Vinicius Mesquita wrote:
> Dear list
> 
> I need to typeset a book for kids wich contains texts where each letter 
> is assigned a fixed color, for example:
> 
> A - - > red;
> B - - > blue;
> ...
> Z - - > green.
> 
> What would be the best way to do this? TIA.
There's more ways to do this but here is one:

(1) make a file: colorfont.lfg:

return {
     name = "coloralphabet",
     colorschemes = {
         default = {
             [1] = { "a", "e" },
             [2] = { "i", "o", "u" },
         },
         whatever = {
             [1] = { "65:90" },
             [2] = { },
             [3] = { },
             [4] = { "97:122" },
         }
     }
}

There is some more possible but this wil do ...

(2) You define a font with these goodies attached:

\setupbodyfont[plex,10pt]

\definefontfeature
   [MyFeaturesA] [default]
   [goodies={colorfont},colorscheme=default,liga=no]

\definefontfeature
   [MyFeaturesB] [default]
   [goodies={colorfont},colorscheme=whatever,liga=no]

\definefont[MyFontA][Serif*MyFeaturesA]
\definefont[MyFontB][Serif*MyFeaturesB]

(3) and use it this way:

\starttext

\setfontcolorscheme[1] {\MyFontA \samplefile{tufte}}\par
\setfontcolorscheme[2] {\MyFontA \samplefile{tufte}}\par
\setfontcolorscheme[3] {\MyFontA \samplefile{tufte}}\par

\page

\setfontcolorscheme[1] {\MyFontB \samplefile{tufte}}\par
\setfontcolorscheme[2] {\MyFontB \samplefile{tufte}}\par
\setfontcolorscheme[3] {\MyFontB \samplefile{tufte}}\par

\stoptext

Now, this is pretty (more than a decade) old functionality from early 
days of mkiv/luatex when it was used for some tracing (by Idris) and it 
still works (surprise).

Today I would definitely use more recent trickery. If there is real 
demand for this I can have a look at it, after all it's "kind of fun" 
(as is most of font stuff).

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
-----------------------------------------------------------------


More information about the ntg-context mailing list