4

Introduction

I am writing a document using the TeX Gyre Pagella font. Unfortunately, the glyph for the euro sign (UTF-8 character U+20AC) in this font does not comply with the official euro sign specification.

Luckily, the Martin Vogel symbol font does contain a symbol which glyph seems alright.

Minimum working example

euro glyphs

\setupbodyfontenvironment[default][em=italic]
\usemodule[simplefonts][size=14pt]
\setmainfontfallback[DejaVu Serif][range={greekandcoptic, greekextended}, force=yes, rscale=auto]
\setmainfont[TeX Gyre Pagella]

% Martin Vogel Symbol font for euro sign
\usesymbols[mvs]
%\definesymbol[€][{\symbol[europe][EUR]}]

\starttext
\startitemize[packed]
\item € is the glyph of the TeX Gyre Pagella font.
\item \symbol[europe][EUR]~is the glyph of the Martin Vogel symbol font.
\stopitemize
\stoptext

Question

How can I redefine the encoding for U+20AC (€) so that it corresponds to the Martin Vogel glyph?

In other words, I am looking for a preamble command so that the first line in the MWE also would show the Martin Vogel symbol glyph.

My commented-out \definesymbol[€] attempt did not work...

2

1 Answer 1

4

The problem is that the Martin Vogel font does not contain the Euro symbol in the correct slot, so you can't just use a simple font fallback as described in this answer. I don't know if there's a simple way to map a font fallback to different slots of another font without messing with virtual fonts.

Solution 1

Here is a simple workaround, which just replaces all occurences of “€” with an instruction to insert a particular glyph from another font. This is not very robust and might break unexpectedly (for instance in verbatim environments).

\usemodule [translate]
\enableinputtranslation

\translateinput
  [€]
  [\getnamedglyphdirect{marvosym.ttf}{EUR}]

\starttext
  €
\stoptext

Solution 2

Here's a second solution which is more robust than the crude input translation. It uses a regular font fallback and the new simplefonts module which is part of the core as of 2013.09.30 20:05. The euro sign is taken from the Martin Vogel font. Because the euro sign uses a wrong slot, a font feature is created using a substitution to correct the font slot. The euro sign is taken from the Martin Vogel font, although it does exist in the main font.

\startluacode
    fonts.handlers.otf.addfeature {
        name    = "euro",
        type    = "substitution",
        nocheck = true,
        data    = { [0x20AC] = "EUR" },
    }
\stopluacode

\definefontfeature
    [euro]
    [mode=node,
     euro=yes]

\definefallbackfamily [mainface] [serif] [MarVoSym] [range=0x20AC, features=euro, force=yes]
\definefontfamily     [mainface] [serif] [TeX Gyre Pagella]

\setupbodyfont [mainface]

\starttext
    The euro sign (€) is the currency sign used for the euro.
    In Unicode it is encoded at \type{U+20AC €} euro sign.
\stoptext

result

19
  • 6
    @Aditya -- the euro symbol was designed by a committee, a committee that apparently had no input from knowledgeable typographers. the shape as "designed" is found by font designers to be offensive, as it stands out from the text "background" more than necessary or desirable. therefore, most fonts do not follow the mandated design for the euro, but provide a version compatible with the style of the including font. Jan 30, 2014 at 19:25
  • 1
    @SergeStroobandt That's not possible using my hackish solution. It's like “search and replace” in your editor, just using Lua. When it reaches TeX, is has been substituted already. I have a second hack in mind (using regular fallback + feature file for marvosym to correct the slot), but no time at the moment to update my answer.
    – Marco
    Jan 30, 2014 at 20:17
  • 1
    @Aditya Here is snippet of post-modern European history: "Typographers discuss the euro." Fascinating... Jan 30, 2014 at 21:22
  • 1
    @SergeStroobandt The font does not have a glyph at index 0x00A4. I changed the example to use 0x00A7 instead.
    – Marco
    Feb 2, 2014 at 21:36
  • 1
    @SergeStroobandt ConTeXt standalone uses the current version 3.10. The unicode char U+00A7 is located in the font in slot 164 (decimal) or 0x00A4 (hex).
    – Marco
    Feb 2, 2014 at 22:14

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.