In response to a deleted post, here is my attempt at formulating a question to an answer:
Where does XeLaTeX look for smallcaps shapes in fonts, on an Ubuntu system?
Proper OpenType fonts with small caps support will have them as unencoded glyphs in the same font file that can be accessed by activating smcp
and/or c2sc
features. Some fonts might chose to encode them in private use area while still accessible by the features, but this is an obsolete practice once encouraged by Adobe, but no longer recommended, in either case using code from private use area directly in your document is highly discouraged.
Some older fonts have small caps in separate file, in this case you have to tell fontspec
the name of the small caps font using SmallCapsFont
key or else it will not find it, for example Latin Modern has a separate small caps font:
\documentclass{article}
\usepackage{fontspec}
\setmainfont[SmallCapsFont={Latin Modern Roman Caps}]{Latin Modern Roman}
\begin{document}
Text \textsc{Text}
\end{document}
(This used to be answer post in Use of \scshape or \textsc with fontspec/xelatex - TeX - LaTeX)
Well, I was kinda bugged by all this smallcaps business, so I'll put this as a separate post here... Essentially, what bothers me is - where are the small caps glyphs taken from?
If I search for Junicode on my system, I get:
$ find / -xdev -iname '*junicode*' 2>/dev/null | grep '\.ttf'
/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType/Junicode-BoldItalic.ttf
/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType/Junicode-Regular.ttf
/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType/Junicode-Italic.ttf
/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType/Junicode-Bold.ttf
/usr/share/fonts/truetype/ttf-junicode/Junicode-BoldItalicCondensed.ttf
/usr/share/fonts/truetype/ttf-junicode/Junicode-BoldItalic.ttf
/usr/share/fonts/truetype/ttf-junicode/Junicode-BoldCondensed.ttf
/usr/share/fonts/truetype/ttf-junicode/Junicode-Regular.ttf
/usr/share/fonts/truetype/ttf-junicode/Junicode-Italic.ttf
/usr/share/fonts/truetype/ttf-junicode/Junicode-Bold.ttf
/usr/share/fonts/truetype/ttf-junicode/Junicode-RegularCondensed.ttf
/usr/share/fonts/truetype/ttf-junicode/Junicode-ItalicCondensed.ttf
I can't really tell which exactly is used by xelatex
- but there surely isn't a special 'smallcaps' .ttf font there.
Ok, then fontspec
send this to log:
.................................................
. fontspec info: "defining-font"
.
. Font family 'Junicode(0)' created for font 'Junicode' with options
. [Ligatures=TeX,].
.
. This font family consists of the following shapes:
.
. * 'normal' with NFSS spec.:
. <->"Junicode/ICU:script=latn;language=DFLT;mapping=tex-text;"
.
. * 'small caps' with NFSS spec.:
. <->"Junicode/ICU:script=latn;language=DFLT;mapping=tex-text;+smcp;"
.
. * 'bold' with NFSS spec.:
. <->"Junicode/B/ICU:script=latn;language=DFLT;mapping=tex-text;"
.
. * 'italic' with NFSS spec.:
. <->"Junicode/I/ICU:script=latn;language=DFLT;mapping=tex-text;"
.
. * 'bold italic' with NFSS spec.:
. <->"Junicode/BI/ICU:script=latn;language=DFLT;mapping=tex-text;"
There is a bit on OpenType options in the manual fontspec.pdf; one of them is "smcp
" which should specify small caps. Then again, what does it mean?
Then by accident I copy paste the small-caps text from the PDF to the text editor scite
- and what can I see: small caps: "A" (and this shows in my Firefox too)! So, in this case, small caps are part of a Unicode mapping within a font?! So, I select the small "", look it up in gnome-character-map
, and here it is:
Also in gnome-specimen
, the small caps unicode characters can be rendered as bold:
Notice in gnome-character-map
, I have entry only for "Junicode", and can choose "bold" and "italic" for it. The small caps "A" is "", code point U+F761, from the so-called "Private Use Area". So apparently this isn't a standard, but if I see it in both Junicode in gnome-character-map
and in Firefox with unrelated font, maybe U+F761 can be seen as standard encoding for small caps A? Also found that U+F761 is known as "Asmall" in Adobe glyphlist.txt (via Glyph | Adobe Developer Connection; via Adobe Forums: OpenType small cap differences).
But I'm still puzzled - how come gnome-character-map
shows small-caps A for both normal and bold 'Junicode' font; and yet xelatex
complains?
In any case, after browsing through the fontspec.pdf manual, found another useful option, FakeBold
... And came up with an example, which finally proves to me there is no U+F761 in 'JunicodeBold':
... , but then why does gnome-character-map
show it? (maybe it too uses 'FakeBold' :)
) Indeed, font-forge
finally confirms it:
At least, now I know that every font variant (bold.ttf, italic.ttf) should have small caps character glyphs, if fontspec
should use them as respective small caps characters...
Now, I just wish I could easily tell fontspec
: "When you encounter a request for U+F761 in Junicode-Bold - please refer to U+F761 in Junicode-Regular, and use that glyph with FakeBold=2.0" :)
Anyways, here is the code:
\documentclass[letterpaper,12pt]{article}
% \typeout{ == \the\paperwidth / \the\paperheight ==}
% \typeout{ == \the\pdfpagewidth / \the\pdfpageheight ==}
\pdfpagewidth=\paperwidth \pdfpageheight=\paperheight
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Junicode}
% https://tex.stackexchange.com/a/14382/2595
\makeatletter
\newcommand{\showfont}{encoding: \f@encoding{},
family: \f@family{},
series: \f@series{},
shape: \f@shape{},
size: \f@size{}
}
\makeatother
\begin{document}
{\scshape \showfont Aa}
{\fontspec[Letters=SmallCaps]{Junicode} \showfont Aa}
{\bfseries\scshape \showfont Aa}
{\fontspec[Letters=SmallCaps,FakeBold=2.5]{Junicode} \showfont Aa}
%kpathsea: Invalid fontname `Junicode Bold', contains ' '
{\fontspec[Letters=SmallCaps]{JunicodeBold} \showfont Aa}
{\fontspec{JunicodeBold} \showfont A J}
{\fontspec{Junicode} \bfseries\showfont A J}
{\fontspec{Junicode} \showfont A J}
\end{document}
Cheers!
gnome-character-map
will render font that looks like bold smallcaps in the PUA area - even if Junicode Bold actually has nothing there! This made me believe that I am addressing xelatex
font selection wrongly, since I couldn't get Junicode Bold small caps to show (but could get regular smallcaps).Hope this explains- Cheers!
gnome-character-map
will use fake bold if the bold font lacks a character that the regular one has.
Commented
May 20, 2012 at 15:25