2

I like the Adobe Source Serif Pro font, as available in the sourceserifpro package, but it lacks italics. I need italics, but only infrequently for some documents (mainly for the titles of books).

It seems to me that XCharter is somewhat similar to Source Serif. Is it possible for me to use XCharter's italics with Source Serif? I'd want to scale the x-height, if necessary, to match that of the main font.

A solution for pdflatex would be preferred.

An example was requested, which I can't provide, but here's a template:

\documentclass{article}
\usepackage{sourceserifpro}
\usepackage[just-italics-please,scaled=?]{XCharter} % This line does not work

\begin{document}
This is some text in Source Serif Pro.
\textit{This is some text in XCharter italics.}
\end{document}
1
  • Please provide a minimal example.
    – cfr
    Dec 9, 2016 at 2:06

2 Answers 2

2

You will need to adapt this to your usage as I had no minimal example to work with.

Note that I absolutely do not recommend you do this. If it is close enough to match, use XCharter. If not, do without italics or find another font.

Adjust the scaling by changing the factor directly or scale the main font using the relevant package option.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[proportional,lining]{sourceserifpro}

\makeatletter
\expandafter\ifx\csname XCharter@scale\endcsname\relax
    \let\XCharter@@scale\@empty
\else
    \edef\XCharter@@scale{s*[\csname XCharter@scale\endcsname]}%
\fi
\AtBeginDocument{%
  \DeclareFontShape{T1}{SourceSerifPro-LF}{m}{it}{
    <-> \XCharter@@scale XCharter-Italic-tlf-t1
  }{}%
  \DeclareFontShape{T1}{SourceSerifPro-LF}{b}{it}{
    <-> \XCharter@@scale XCharter-BoldItalic-tlf-t1
  }{}}
\makeatother
\begin{document}
  some text \itshape some italic \bfseries in bold \upshape but not italic
\end{document}

not recommended

EDIT

Your updated question includes an MWE but it does not oldstyle figures, which you now say you want. This requires the osf option or similar when loading the package and adjustments to the setting of XCharter. In light of suggestions in comments and egreg's answer, this version now uses semibold and the alternative version of the numeral 1.

Code:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[proportional,osf,semibold]{sourceserifpro}

\makeatletter
\expandafter\ifx\csname XCharter@scale\endcsname\relax
    \let\XCharter@@scale\@empty
\else
    \edef\XCharter@@scale{s*[\csname XCharter@scale\endcsname]}%
\fi
\AtBeginDocument{%
  \DeclareFontShape{T1}{SourceSerifPro-OsF}{sb}{it}{
    <-> \XCharter@@scale XCharter1-BoldItalic-tosf-t1
  }{}%
  \DeclareFontShape{T1}{SourceSerifPro-OsF}{m}{it}{
    <-> \XCharter@@scale XCharter1-Italic-tosf-t1
  }{}}
\makeatother
\begin{document}
  some text 1234567890 \itshape some italic 1234567890 \bfseries in bold 1234567890 \upshape but not italic 1234567890

  \itshape 1234567890

  1111111111

  9999999999
\end{document}

hanging figures

Note that although XCharter uses font names which suggests all figures are tabular rather than proportional, these are clearly proportional. The fonts and family are simply seemingly misnamed. Hence, you probably want proportional for the default figures, too.

Caveats

This will work for simple usage. If you want a more elaborate configuration, you will need to make further adjustments e.g. if using textcomp and the TS1 families with italic. You will also need to make additional adjustments if using the facilities of mweights, which is loaded by sourceserifpro.

Moreover, this deliberately leaves the font configuration for mathematics untouched since that is obviously a whole other can of worms.

Note that some, though not all of these concerns, would be eliminated or mitigated through use of Xe/LuaTeX rather than pdfTeX.

14
  • We collided a bit. I'm a bit scared by your "I absolutely do not recommend you do this" comment. What's the likely trouble?
    – dedded
    Dec 9, 2016 at 2:40
  • @dedded Typographical monstrosities and aesthetic tortures.
    – cfr
    Dec 9, 2016 at 2:42
  • Also, what do I use in place of "LF" if I want lower-case figures?
    – dedded
    Dec 9, 2016 at 2:42
  • @dedded OsF? Or TOsF? (But the latter always strikes me as very weird indeed.)
    – cfr
    Dec 10, 2016 at 1:18
  • So I see the T1SourceSerifPro-OsF.fd file in the same directory as the -LF file, but naively substituting it into your code yields LaTeX Error: Font family 'T1+SourceSerifPro-OsF' unknown. This kind of low-level coding is beyond my Tex knowledge, so I'm probably doing it wrong.
    – dedded
    Dec 12, 2016 at 14:16
3

You should consider using XeLaTeX or LuaLaTeX. Note I chose semibold for Source Serif Pro, because otherwise it would be much thicker than XCharter bold italic.

\documentclass{article}
\usepackage{fontspec}

\setmainfont{Source Serif Pro}[
  Numbers=OldStyle,
  BoldFont={* Semibold},
  ItalicFont={XCharter Italic},
  ItalicFeatures={Scale=MatchUppercase,Numbers=OldStyle},
]
\newfontfamily{\charter}{XCharter}[Numbers=OldStyle]

\begin{document}

Normal text: Normal 1234567890\par
Italic text: {\itshape Italic 1234567890}\par
Boldface text: {\bfseries Bold 1234567890}\par
Boldface italic text: {\bfseries\itshape Bold Italic 1234567890}

\bigskip

\charter
Check: now everything is in Charter

Normal text: Normal 1234567890\par
Italic text: {\itshape Italic 1234567890}\par
Boldface text: {\bfseries Bold 1234567890}\par
Boldface italic text: {\bfseries\itshape Bold Italic 1234567890}

\end{document}

enter image description here

3
  • This sure looks a whole lot cleaner than the pdflatex solution. But it doesn't work at all for me with xelatex (The font "Source Serif Pro" cannot be found; I believe I need to track down the actual filename--no?). And the bold italic doesn't work for me with lualatex (LaTeX Font Warning: Font shape 'EU2/SourceSerifPro(0)/bx/it' undefined), but that's actually OK--I don't need bold italic for now.
    – dedded
    Dec 13, 2016 at 4:06
  • @dedded Install the font as a system font or add the TeX font directories to your font config path. This is OS-dependent, though. How to do it, that is.
    – cfr
    Dec 13, 2016 at 4:26
  • @egreg I cannot figure out how to get 1 instead of I for the osf 1 in the XCharter italic with fontspec. Seems like it should be some sort of alternate or variant, but I couldn't find it. And the scaling doesn't work: MatchUppercase is too tall (looks OK in your example, though), and MatchLowercase is to short. I was able to get bold italic by adding a BoldItalicFont entry to the setmainfont command.
    – dedded
    Dec 14, 2016 at 0:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .