ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <j.hagen@xs4all.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>,
	Marcus Vinicius Mesquita <marcusvinicius.mesquita@gmail.com>
Subject: Re: Alphabet & color
Date: Thu, 16 Jul 2020 09:19:52 +0200	[thread overview]
Message-ID: <2a6cafe6-95b1-a0f8-6537-1d26f6a5e3d3@xs4all.nl> (raw)
In-Reply-To: <CAK9ODgRANGparkYUwLA+wEKWUqHS6Y+HD-a9TfND91f8WR3JjA@mail.gmail.com>

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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2020-07-16  7:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-16  5:32 Marcus Vinicius Mesquita
2020-07-16  7:19 ` Hans Hagen [this message]
2020-07-16 16:41   ` Marcus Vinicius Mesquita
2020-07-16 16:57     ` Hans Hagen
2020-07-16 22:02       ` Marcus Vinicius Mesquita
2020-07-31 15:06         ` Marcus Vinicius Mesquita
2020-07-31 16:31           ` Hans Hagen
2020-07-31 18:00             ` Marcus Vinicius Mesquita
2020-07-31 20:10               ` Marcus Vinicius Mesquita
2020-08-01  9:03                 ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a6cafe6-95b1-a0f8-6537-1d26f6a5e3d3@xs4all.nl \
    --to=j.hagen@xs4all.nl \
    --cc=marcusvinicius.mesquita@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).