16

I've successfully downloaded and installed Hoekwater's "cow fonts" so that I can use them with pdflatex — see sample document below. In particular, I'd like brown cows!

But how can one get the colored-cow fonts (or the sheep fonts) with pdflatex? (The TUGboat article [vol. 37 (2016), no. 3, pp. 306-310] "Cowfont (koeieletters) update" by Taco Hoekwater and Hans Hagen shows how to do this with ConTeXt only.

\documentclass[extrafontsizes,48pt]{memoir}
\usepackage[T1]{fontenc}

\DeclareFontFamily{T1}{CowFont}{}
\DeclareFontShape{T1}{CowFont}{m}{n}{<-> koeieletters}{}

\begin{document}

\usefont{T1}{CowFont}{m}{n}

Moo!

\end{document}

Cows with black spots

From the Hoekwater & Hagen TUGboat article

Here's some of the code from the article that, in ConTeXt, is supposed to produce colored cows (or sheep):

\definecolor[cowred] [r=.50]
\definecolor[cowgreen] [g= . 50]
\definecolor[cowblue] [b=.50] 
\definecolor[cowyellow] [y=.25]
\definefontcolorpalette[cows]
  [cowgreen,cowyellow,cowblue,cowred] 
\adaptfontfeature[sheepcolored] [colr=cows]

\usetypescript[all] [cowsotf]
\definefontcolorpalette[cows-1] cowyellow,cowblue,cowred]
\definefontcolorpalette[cows-2] [cowred, cowyellow,cowblue,cowgreen]
\definefontcolorpalette[cows-3] [cowgreen, cowyellow,cowred,cowblue]

\definefontfeature[cows-1] [cowscolored] [colr=cows-1]
\definefontfeature[cows-2] [cowscolored] [colr=cows-2]
\definefontfeature[cows-3] [cowscolored] [colr=cows-3]

\definedfont[Cows*cows-1 at 30pt] red\quad
\definedfont[Cows*cows-2 at 30 pt] green\quad
\definedfont[Cows*cows-3 at 30pt] blue

The output is supposed to be:

red, green, blue cows

I do not know ConTeXt. And the article does not sufficiently distinguish [at least for me) between what is in the package(s) involved, on the one hand, and what goes into the user's document, on the other hand — a fault all too common in TeX documentation!]. So I don't know which part of the preceding code has to go in the actual document, nor what other code has to be included so as to make working ConTeXt document.

And then, just to confuse things totally (for me), at the very end of the article it says the following.

"To make a quick start with these fonts, you can use one of:

\setupbodyfont[koeieletters]
\setupbodyfont[cows] 
\setupbodyfont[coloredcows] 
\setupbodyfont[sheep] 
\setupbodyfont[coloredsheep]

where the koeieletters variant equals sheep."

  • 1
    I don't think just using \textcolor is what the Hoekwater & Hagen TUGboat article would indicate: that makes the entire cow -- outline and spots -- red. The article seems to indicate there's an entirely different font that, with ConTeXt, is loaded by \setupbodyfont[coloredcows]; and there are also separate sheep and coloredsheep fonts, loaded similarly. – murray Dec 7 '16 at 15:50
  • Oh I wondered if that was the case (didn't have tugboat to hand) I'll delete the comment then, I didn't think luatex could handle any of the coloured font proposals. If you post a context example someone should be able to translate to doing same in latex should be easy enough. – David Carlisle Dec 7 '16 at 16:41
  • @DavidCarlisle: please see added section of my OP. – murray Dec 8 '16 at 16:14
  • I understood the article so that this color feature was exclusive to ConTeXt. Maybe in LaTeX you can layer the contour font in one color and the regular one in another? – Raphael Jan 27 '17 at 20:15
  • 1
    Do you really mean pdfLaTeX as opposed to, say, LuaLaTeX? I can see it my be doable with fontspec but I would question even @DavidCarlisle asserting that it should be 'easy enough' to translate into LaTeX, if that means pdfLaTeX, as the question asks. Maybe you could layer it, but that would not be a simple translation, as I understand it. (I don't recall the details, but the article was definitely make-the-most-of-new-features and that's not likely to be easy to do with traditional fonts, else they wouldn't be new. – cfr Aug 18 '17 at 1:44
17
+50

I managed the following.

Requirements

  • LuaTeX, Version 1.06.0. The binary I got from w32tex.org, happily I already had a setup to use it without disturbing my normal tex system.
  • A new fontloader: get luatex-fonts-merged-lua from a current context minimals and tell luaotfload to use it as fontloader with a luaotfload.conf file. (Older fontloaders gave errors).
  • a changed luaotfload-letterspace.lua, as the default one doesn't work with a new font loader (I had it already from earlier tests.)
  • and naturally the fonts. The emoj font was somewhere in my system, the cow-font I copied from a context minimals (perhaps it is somewhere in texlive too).

Addition

I uploaded to CTAN a package fontloader-luaotfload which contains alternative fontloaders, the changed luaotfload-letterspace.lua and in the documentation some tipps how a development luatex can be used.

The result

I appologize for the colors, but it isn't easy to find out how to change them to something more beautiful.

\documentclass{article}

\directlua{fonts.handlers.otf.registerpalette("demo", {
        { g = 0 },
        { g =0.5 },
        { r = 1  },
        { r = 1, b= 1},
    }
    )}


\begin{document}
\font\Emoj={file:seguiemj.ttf:mode=node;colr=yes;}
     \Emoj \char"2661 \char"1F34D \char"1F986
\font\Emoj={file:seguiemj.ttf:mode=node;colr=demo;}
     \Emoj \char"2661 \char"1F34D \char"1F986

\font\cow={file:koeielettersot.ttf:mode=node;colr=demo;} at 30pt
    \cow ABC

\end{document}    

enter image description here

Addition

I'm getting the hang of the colors. The second entry is for the body of the cow, the fourth for the spots and for the color in the emoij-font. It is the best to set all rgb-values. So this here give orange with blue:

\directlua{fonts.handlers.otf.registerpalette("demo", {
        { g = 0 },
        { g = 0.5, b=0, r=1 },
        { r = 1  },
        { r = 0, b= 1, g= 0},
    }
    )}

enter image description here

  • I tried LuaLaTeX from TeXLive 2017 with the orange-with-blue cows and without an emoji. Failed to work. Log errors: luaotfload | db : Reload initiated (formats: otf,ttf,ttc); reason: "File not fou nd: koeielettersot.". ./cows.tex:14: Font \cow=file:koeielettersot.ttf:mode=node;colr=demo; at 30pt no t loadable: metric data not found or bad. <to be read again> \cow l.14 \cow ABC – murray Aug 19 '17 at 17:14
  • @murray As I wrote in the requirements: you need (at least for the colors) a newer luatex and a newer fontloader. And you naturally need the fonts too (I got them from a context installation). – Ulrike Fischer Aug 19 '17 at 22:03
  • Very impressive :-). So the multi-coloured pineapple and duck are pre-coloured - is that right? The bi-coloured ones are your colourings? – cfr Aug 20 '17 at 1:25
  • @cfr yes, but the emoji was only a side result from the tests. – Ulrike Fischer Aug 20 '17 at 7:41
  • 1
    @murray It won't work with pdflatex. pdflatex can't handle this features of the fonts. – Ulrike Fischer Aug 20 '17 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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