4

Idea (from here): I use \symbol{idx}, where idx is the glyphs index.

To determine these two glyphs' indexes I had a look into ...texmf-var\luatex-cache\generic\fonts\otf\garamondpremrpro.lua and verified the result using fontforge as well as MS Word. All three report, that "34" and "39" should be the correct indexes - please see the following screenshots:

garamondpremrpro.lua

Fontforge Screenshot

MS Word is able to access the correct glyphs

I also verified the general idea using the index of "blacksquare" (9632): Although the black square is set correctly, the quotedbl/quotesingle do not show up using the following code:

\documentclass{article}

\usepackage{fontspec}
\setmainfont{Garamond Premier Pro}

\newcommand{\blackSquare}{\symbol{9632}} %<-- works fine
\newcommand{\straightQuoteDbl}{\symbol{34}} %<-- does not work
\newcommand{\straightQuoteSingle}{\symbol{39}} %<-- does not work

\begin{document}

{\straightQuoteDbl}Hello World! \blackSquare\straightQuoteDbl

{\straightQuoteSingle}Hello World! \blackSquare\straightQuoteSingle

\end{document}

The code produces the following output:

enter image description here

Both quotes clearly differ from the results MS Word produces (see above).

System environment: Win 7 Pro 64-bit
TeX-Environment: texlive 2014 (frozen)
Font: Garamond Premier Pro Version 2.0.104

What am I doing wrong?

  • \setmainfont{Garamond Premier Pro}[RawFeature={-tlig}] or, to affect only parts of the document, \addfontfeatures{RawFeature={-tlig}} – Thérèse May 16 '15 at 16:39
  • @Thérèse: Thanks a lot - it works perfectly: \newcommand{\straightQuoteSingle}{\addfontfeatures{RawFeature={-tlig}}\symbol{39}}. You should (re)write this solution into an answer. – user74259 May 16 '15 at 16:53
2

The curly quotes appear because TeX ligatures are on by default in recent versions of fontspec. If your document consists of code only, you can disable TeX ligatures with \setmainfont, this way:

\documentclass[12pt]{article}
\usepackage{fontspec}
\setmainfont{Garamond Premier Pro}[RawFeature=-tlig]
\newcommand{\blackSquare}{\symbol{9632}}
\begin{document}
"Hello World! \blackSquare"
\end{document}

Or, as egreg suggests, you can put \defaultfontfeatures{} in the preamble; that would affect Garamond and any other font used in the document:

\documentclass[12pt]{article}
\usepackage{fontspec}
\defaultfontfeatures{RawFeature=-tlig}% put before specific fonts to affect them all
\setmainfont{Garamond Premier Pro}
\newcommand{\blackSquare}{\symbol{9632}}
\begin{document}
"Hello World! \blackSquare"
\end{document}

If you want straight quotes in only part of the document, use this approach:

\documentclass[12pt]{article}
\usepackage{fontspec}
\setmainfont{Garamond Premier Pro}
\newcommand{\blackSquare}{\symbol{9632}}
\begin{document}
``Hello, beautiful World!''

{\addfontfeatures{RawFeature=-tlig}"Hello World! \blackSquare"}
\end{document}

(You can define a macro to shorten that if you like.)

Or you can disable TeX ligatures globally, as in the two examples, and type real “, ”, ‘, ’, –, and — into your source when you need them.

| improve this answer | |
  • Or with \defaultfontfeatures{} before defining the fonts. – egreg May 16 '15 at 17:59
  • Yes, I fixed it. – egreg May 16 '15 at 18:04
  • Maybe you should mention csquotes – MaxNoe May 17 '15 at 0:04
  • @MaxNoe I’ve never had reason to use csquotes in my work, so I’m not the right person to explain how it would help here. Maybe you should add a second answer? – Thérèse May 17 '15 at 1:06
  • Did you try it out? I might bet you had a reason :D I will post an answer soon. – MaxNoe May 17 '15 at 10:03
1

You can use csquotes to define a quoting style which uses these straight quotes:

The \DeclareQuoteStyle command has 5 positional arguments, the name for the style, opening and closing marks for both outer and inner quotes:

You can then use the style with \setquotestyle{<name>}.

\documentclass[border=5pt]{standalone}

\usepackage{fontspec}
\setmainfont{Latin Modern Roman}               

\usepackage{csquotes}
\DeclareQuoteStyle{straight}%
{{\addfontfeatures{RawFeature=-tlig}\symbol{34}}}%
{{\addfontfeatures{RawFeature=-tlig}\symbol{34}}}%
{{\addfontfeatures{RawFeature=-tlig}\symbol{39}}}%
{{\addfontfeatures{RawFeature=-tlig}\symbol{39}}}     

\setquotestyle{straight}

\begin{document}
John said: \enquote{Harry said \enquote{Hello World!} yesterday}.
\end{document}

The extra curly braces are needed to make the change in fontfeatures local to the quotation mark only.

This is the result: result

| improve this answer | |
  • I defined this: \newcommand{\straightQuote}[1]{{\setquotestyle{straight}\enquote{#1}}} and use it like this: John said: \straightQuote{Harry said \enquote{Hello World!} yesterday}. – user74259 May 17 '15 at 14:32
  • That's a nice addition! – MaxNoe May 17 '15 at 14:34
  • You should add a star to the new command to allow for multi paragraph arguments – MaxNoe May 17 '15 at 14:41

Your Answer

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