7

This question asks for an extension of this answer. Consider the code:

\documentclass[12pt]{book} 
\usepackage{xcolor}
\usepackage{cabin}
\usepackage{scalefnt}

\input pdf-trans
\font\f=qx-lmr10    at 60pt
\newbox\qbox

\def\outline#1{%
\setbox\qbox\hbox{\f #1}%
\boxgs{2 Tr .8 g}{}\copy\qbox
}%
\pagestyle{empty}
\parindent=0pt

\begin{document}
\Huge

\outline{\cabin{\scalefont{1.5}{D i f f e r e n t \, F i l l c o l o r}}}
\end{document}

which produces

enter image description here

QUESTION: How may I modify this code (without TikZ in this case) in order to change the fillcolor to, say, blue? Also, must the outline color be black? If not, how may I specify that color, as well as its thickness?

Thank you.

1

2 Answers 2

8

Using the pdfrender package mentioned in the comments looks like a nicer option, but if you just want to make minimal modifications to your code, you can adjust the fill colour using PDF code.

The code that does this at present is: 0.8 g. The number runs from 0 to 1 and the g means Grayscale. To use colour, you can use the rg operator to specify an RGB colour. You need three numbers, one for each channel, e.g.,:

0.6 0.6 1 rg

gives you a light blue colour. It's also possible to use a CMYK colour, e.g.,

0.5 0 0 0 k

gives you 50% cyan.

The outline just uses the current colour that LaTeX puts on the colour stack, so you can just add \color{???} to set the outline colour.

There's probably a better way, but you can also insert PDF code to set the width of the outline:

2 w

sets the outline width to 2 bp (big points).

MWE

\documentclass[12pt]{book} 
\usepackage{xcolor}
\usepackage{cabin}
\usepackage{scalefnt}

\input pdf-trans
\font\f=qx-lmr10    at 60pt
\newbox\qbox

\def\outline#1{%
\setbox\qbox\hbox{\f #1}%
\boxgs{2 Tr 2 w 0.25 0 0 0 k}{}\copy\qbox
}%
\pagestyle{empty}
\parindent=0pt

\begin{document}
\Huge

{\color{cyan}%
\outline{\cabin{\scalefont{1.5}{D i f f e r e n t \, F i l l c o l o r}}}%
}
\end{document}

output

6
  • Many thanks for your helpful answer; but, would you know how to change the fill color inside the blue outlining from white to something else? I have tried, say, inserting \textcolor{green} immediately after \scalefont{1.5}{ but that only changes the color of the outlining from cyan to green. May 25 at 10:48
  • @mlchristians, my answer demonstrates how to do this. You must change .8 g in your original question to something else. If you want it green then you can use 0 1 0 rg (0% red, 100% green, 0% blue). May 25 at 11:50
  • The fill colour in the image above isn't white, BTW, its 25% cyan (produced with 0.25 0 0 0 k) May 25 at 11:56
  • Yes; but when I change those four numbers to something else, say, .54 0 .95 .4, which should produce a fill color of olive green inside the light blue outline---I still get what appears to be white. Does the same happen to you, or are you able to produce an olive green fill color? May 25 at 12:16
  • @mlchristians, yes when I substitute .54 0 .95 .4 k for 0.25 0 0 0 k in my code above I get an olive green fill with a cyan outline. This is running with pdflatex. If you don't then either you have a typo somewhere or something else is wrong. May 25 at 12:22
4

You have got the kind of solution you ask for, so let me add a context/metafun one, in case some users happen to pass by.

\setupbodyfont[dejavu,ss,60pt]
\definecharacterkerning[mine][factor=0.1]
\starttext
\startMPpage[offset=1dk]
draw lmt_outline [
  text = "\setcharacterkerning[mine]Different fillcolor",
  kind = "both",
  drawcolor = "blue",
  fillcolor = "yellow",
  rulethickness = 1.75,
] ;
\stopMPpage
\stoptext

Yellow and blue outlined text

A few comments: I did not have the cabin font installed, so I used dejavu. Also, I do not think that the extra letter spacing looks good, but if one wants it, this is a cleaner way than to add spaces between the letters. Other than that, I think it is pretty straight forward.

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.