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. Marcus Vinicius
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 -----------------------------------------------------------------
Thank you, Hans for your answer.
I tried your code and it works fine. But where do the color schemes default
and whatever come from? How can they be changed?
Best regards
Marcus Vinicius
On Thu, Jul 16, 2020, 04:19 Hans Hagen
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 -----------------------------------------------------------------
On 7/16/2020 6:41 PM, Marcus Vinicius Mesquita wrote
I tried your code and it works fine. But where do the color schemes default and whatever come from? How can they be changed? defauls is defined in the example .. colorshemes have numbers:
\definecolor[colorscheme:1:1][s=.75] \definecolor[colorscheme:1:2][r=.75] \definecolor[colorscheme:1:3][g=.75] \definecolor[colorscheme:1:4][b=.75] \definecolor[colorscheme:1:5][c=.75] \definecolor[colorscheme:1:6][m=.75] \definecolor[colorscheme:1:7][y=.75] 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 -----------------------------------------------------------------
I got it. Thanks.
Marcus Vinicius
On Thu, Jul 16, 2020, 13:57 Hans Hagen
On 7/16/2020 6:41 PM, Marcus Vinicius Mesquita wrote
I tried your code and it works fine. But where do the color schemes default and whatever come from? How can they be changed? defauls is defined in the example .. colorshemes have numbers:
\definecolor[colorscheme:1:1][s=.75] \definecolor[colorscheme:1:2][r=.75] \definecolor[colorscheme:1:3][g=.75] \definecolor[colorscheme:1:4][b=.75] \definecolor[colorscheme:1:5][c=.75] \definecolor[colorscheme:1:6][m=.75] \definecolor[colorscheme:1:7][y=.75]
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 -----------------------------------------------------------------
Hi, again With the suggestions you gave I managed to obtain the functionality I need, almost. Somehow letters with accents like á ã é ó õ and also ç don't get the same color of the base letters given in the colorfont.lfg below: return { name = "coloralphabet", colorschemes = { default = { [1] = { "A", "a", "á", "ã", "å", "à", "ä" }, [2] = { "b", "B" }, [3] = { "c", "ç", "C", "Ç" }, [4] = { "d", "D" }, [5] = { "e", "E" }, [6] = { "f", "F" }, [7] = { "g", "G" }, [8] = { "h", "H" }, [9] = { "i", "í", "ì", "I", "Í", "Ì" }, [10] = { "j", "J" }, [11] = { "k", "K" }, [12] = { "l", "L" }, [13] = { "m", "M" }, [14] = { "n", "ñ", "N", "Ñ" }, [15] = { "o", "ó", "õ", "ö", "O", "Ó", "Õ", "Ö" }, [16] = { "p", "P" }, [17] = { "q", "Q" }, [18] = { "r", "R" }, [19] = { "s", "S" }, [20] = { "t", "T" }, [21] = { "u", "ù", "ú", "ü", "U", "Ù", "Ú", "Ü" }, [22] = { "v", "V" }, [23] = { "w", "W" }, [24] = { "x", "X" }, [25] = { "y", "Y" }, [26] = { "z", "Z" }, }, } } The MWE follows below: \setupbodyfont[plex,22pt] \definecolor[colorscheme:1:1][h=002776] % a \definecolor[colorscheme:1:2][h=009c3b] % b \definecolor[colorscheme:1:3][h=17737e] % c \definecolor[colorscheme:1:4][h=ff5733] % d \definecolor[colorscheme:1:5][h=493367] % e \definecolor[colorscheme:1:6][h=7c6d11] % f \definecolor[colorscheme:1:7][h=117c2a] % g \definecolor[colorscheme:1:8][h=6d109d] % h \definecolor[colorscheme:1:9][h=08d11a] % i \definecolor[colorscheme:1:10][h=a81163] % j \definecolor[colorscheme:1:11][h=7d2830] % k \definecolor[colorscheme:1:12][h=2868d1] % l \definecolor[colorscheme:1:13][h=2c11da] % m \definecolor[colorscheme:1:14][h=cf47bb] % n \definecolor[colorscheme:1:15][h=27bde2] % o \definecolor[colorscheme:1:16][h=dc5777] % p \definecolor[colorscheme:1:17][h=c28201] % q \definecolor[colorscheme:1:18][h=ffdf00] % r \definecolor[colorscheme:1:19][h=30a777] % s \definecolor[colorscheme:1:20][h=722548] % t \definecolor[colorscheme:1:21][h=ff00ff] % u \definecolor[colorscheme:1:22][h=e0115f] % v \definecolor[colorscheme:1:23][h=004c4c] % w \definecolor[colorscheme:1:24][h=ae0001] % x \definecolor[colorscheme:1:25][h=696966] % y \definecolor[colorscheme:1:26][h=7bb3ff] % z \definefontfeature [MyFeaturesA] [default] [goodies={colorfont},colorscheme=default] \definefont[MyFontA][SerifBold*MyFeaturesA] \starttext \setfontcolorscheme[1] {\MyFontA BRASIL brasil órfão ÓRFÃO mão MÃO bênção} \stoptext What needs to be changed? Greetings Marcus Vinicius
On 7/31/2020 5:06 PM, Marcus Vinicius Mesquita wrote:
Hi, again
With the suggestions you gave I managed to obtain the functionality I need, almost. Somehow letters with accents like á ã é ó õ and also ç don't get the same color of the base letters given in the colorfont.lfg below:
return { name = "coloralphabet", colorschemes = { default = { [1] = { "A", "a", "á", "ã", "å", "à", "ä" }, [2] = { "b", "B" }, [3] = { "c", "ç", "C", "Ç" }, [4] = { "d", "D" }, [5] = { "e", "E" }, [6] = { "f", "F" }, [7] = { "g", "G" }, [8] = { "h", "H" }, [9] = { "i", "í", "ì", "I", "Í", "Ì" }, [10] = { "j", "J" }, [11] = { "k", "K" }, [12] = { "l", "L" }, [13] = { "m", "M" }, [14] = { "n", "ñ", "N", "Ñ" }, [15] = { "o", "ó", "õ", "ö", "O", "Ó", "Õ", "Ö" }, [16] = { "p", "P" }, [17] = { "q", "Q" }, [18] = { "r", "R" }, [19] = { "s", "S" }, [20] = { "t", "T" }, [21] = { "u", "ù", "ú", "ü", "U", "Ù", "Ú", "Ü" }, [22] = { "v", "V" }, [23] = { "w", "W" }, [24] = { "x", "X" }, [25] = { "y", "Y" }, [26] = { "z", "Z" }, }, } }
The MWE follows below:
\setupbodyfont[plex,22pt]
\definecolor[colorscheme:1:1][h=002776] % a \definecolor[colorscheme:1:2][h=009c3b] % b \definecolor[colorscheme:1:3][h=17737e] % c \definecolor[colorscheme:1:4][h=ff5733] % d \definecolor[colorscheme:1:5][h=493367] % e \definecolor[colorscheme:1:6][h=7c6d11] % f \definecolor[colorscheme:1:7][h=117c2a] % g \definecolor[colorscheme:1:8][h=6d109d] % h \definecolor[colorscheme:1:9][h=08d11a] % i \definecolor[colorscheme:1:10][h=a81163] % j \definecolor[colorscheme:1:11][h=7d2830] % k \definecolor[colorscheme:1:12][h=2868d1] % l \definecolor[colorscheme:1:13][h=2c11da] % m \definecolor[colorscheme:1:14][h=cf47bb] % n \definecolor[colorscheme:1:15][h=27bde2] % o \definecolor[colorscheme:1:16][h=dc5777] % p \definecolor[colorscheme:1:17][h=c28201] % q \definecolor[colorscheme:1:18][h=ffdf00] % r \definecolor[colorscheme:1:19][h=30a777] % s \definecolor[colorscheme:1:20][h=722548] % t \definecolor[colorscheme:1:21][h=ff00ff] % u \definecolor[colorscheme:1:22][h=e0115f] % v \definecolor[colorscheme:1:23][h=004c4c] % w \definecolor[colorscheme:1:24][h=ae0001] % x \definecolor[colorscheme:1:25][h=696966] % y \definecolor[colorscheme:1:26][h=7bb3ff] % z
\definefontfeature [MyFeaturesA] [default] [goodies={colorfont},colorscheme=default]
\definefont[MyFontA][SerifBold*MyFeaturesA]
\starttext
\setfontcolorscheme[1] {\MyFontA BRASIL brasil órfão ÓRFÃO mão MÃO bênção}
\stoptext
What needs to be changed?
glyph names ... "oacute" etc as used in plex
Greetings
Marcus Vinicius
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Ok, after changing the glyph names in colorfont.lfg things run smoothly but for six glyphs: uacute, ucircumflex, udieresis, Uacute, Ucircumflex, Udieresis Have I hit a bug? Regards, Marcus Vinicius On Fri, Jul 31, 2020 at 3:00 PM Marcus Vinicius Mesquita < marcusvinicius.mesquita@gmail.com> wrote:
Thank you, that was very helpful.
Marcus Vinicius
-- Todas as coisas fatigam o corpo, salvo a música, que não fatiga nem o corpo nem seus membros, por ser descanso da alma, primavera do coração, distração do aflito, entretenimento do solitário, e viático do viajante. Kunnâsh al-Hâ'ik (Cancioneiro de al-Hâ'ik)
On 7/31/2020 10:10 PM, Marcus Vinicius Mesquita wrote:
Ok, after changing the glyph names in colorfont.lfg things run smoothly but for six glyphs:
uacute, ucircumflex, udieresis, Uacute, Ucircumflex, Udieresis
Have I hit a bug?
Some font oddness ... use "uhungarumlaut", "Uhungarumlaut", 0x1DC, 0x144, 0xFA, 0xFB, 0xFC, 0xDA, 0xDB, 0xDC }, Maybe use numbers for all instead. All is revealed by: \usemodule[fonts-complete] \setupbodyfont[6pt] \starttext \ShowCompleteFont{name:IBMPlexSerif}{10pt}{1} \stoptext I'll send you a 'context' way of doing it ... . 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 -----------------------------------------------------------------
participants (2)
-
Hans Hagen
-
Marcus Vinicius Mesquita