4

I would like to use the Type1 libertine fonts provided by the package libertine and compile with XeLaTeX. According to the manual under section 4, this can be activated with the option type1:

\documentclass{article}
\usepackage[type1, oldstyle]{libertine}
\begin{document}
This is a test 1234567890 fi ffi fl ffl ft fft fj ffj tt
\end{document}

I would like to use the OpenType fonts, also provided by the libertine package, when I need to access glyphs not included in the Type1 fonts. As mentioned in section 5 in the manual, I can access these with the macro \libertineGlyph{}:

\documentclass{article}
\usepackage{libertine}
\begin{document}
\libertineGlyph{uni025D}
\end{document}

But how do I combine these? As said above, I'd like to stick to Type1 fonts as far as possible (as this renders ligatures and old style numbers copy- and searchable in the pdf), but switch to the OpenType fonts when I need special glyphs. Combining the type1 option with \libertineGlyph{} does not compile:

\documentclass{article}
\usepackage[type1, oldstyle]{libertine}
\begin{document}
This is a test 1234567890 fi ffi fl ffl ft fft fj ffj tt \libertineGlyph{uni025D}
\end{document}

! Undefined control sequence.

l.4 ...ffi fl ffl ft fft fj ffj tt \libertineGlyph{uni025D}?

11
  • It appears that \libertineGlyph is now only defined when the type1 option is not used. Why do you need to use it?
    – Thruston
    Commented Jun 12, 2014 at 14:27
  • @Thruston That's mentioned twice in my question: (1) "I would like to use the OpenType fonts [...] when I need to access glyphs not included in the Type1 fonts" (2) "I'd like to [...] switch to the OpenType fonts when I need special glyphs".
    – Sverre
    Commented Jun 12, 2014 at 14:35
  • OK I see. It's just that your example compiles fine here if I remove the type1 option. But I guess there are other glyphs you need.
    – Thruston
    Commented Jun 12, 2014 at 14:50
  • 1
    @Thruston Ah. Actually, the reason for wanting to use Type1 fonts whenever possible is given in my question as well: "this renders ligatures and old style numbers copy- and searchable in the pdf" :P
    – Sverre
    Commented Jun 12, 2014 at 14:59
  • 1
    The ligatures and old-style numbers from the OpenType fonts are copyable and searchable. The only times I’ve had trouble were when a font’s designer misused the Private Use Area for ligatures.
    – Thérèse
    Commented Jun 12, 2014 at 17:24

2 Answers 2

2

You'll have to combine definitions from libertine.sty:

 \documentclass{article}
\usepackage{fontspec}
\makeatletter
  \def\libertine@base{LinLibertine}
  \def\biolinum@base{LinBiolinum}
  \defaultfontfeatures{
     Ligatures = TeX ,
     Extension = .otf ,
     SmallCapsFeatures={Letters=SmallCaps} ,
  }
  \newfontfamily\libertine
        [ Numbers = {Proportional,OldStyle},
          UprightFont    = *_R,
          ItalicFont     = *_RI,
          BoldFont       = *_RB, 
          BoldItalicFont = *_RBI,
        ] {\libertine@base}
  \def\lib@fxl{LinLibertine_R}
  \def\lib@fxb{LinBiolinum_R}
  \def\lib@fxk{LinBiolinum_K}
  \def\lib@fxi{LinLibertine_I}

  \providecommand*\DeclareTextGlyphY[3]{%
      % \DeclareTextGlyphY{fxl}{s_t}{64262}
      % #1=basefont #2=glyphname, #3=position
      \def\lib@temp{#1}%
      \ifx\lib@temp\lib@fxl \@namedef{#1@#2}{{\libertine\char#3\relax}}\else%
        \ifx\lib@temp\lib@fxb \@namedef{#1@#2}{{\biolinum\char#3\relax}}\else%
          \ifx\lib@temp\lib@fxk \@namedef{#1@#2}{{\biolinumkey\char#3\relax}}\else%
            \ifx\lib@temp\lib@fxi \@namedef{#1@#2}{{\libertineInitial\char#3\relax}}\else%
      \fi\fi\fi\fi}
  %
  \input{LinLibertine_R}
  \input{LinBiolinum_R}
  \input{LinBiolinum_K}
  \input{LinLibertine_I}
  %
  \DeclareRobustCommand*\libertineGlyph[1]{\@nameuse{LinLibertine_R@#1}}
  \DeclareRobustCommand*\biolinumGlyph[1]{\@nameuse{LinBiolinum_R@#1}}
  \DeclareRobustCommand*\biolinumKeyGlyph[1]{\@nameuse{LinBiolinum_K@#1}}
  \DeclareRobustCommand*\libertineInitialGlyph[1]{\@nameuse{LinLibertine_I@#1}}
\makeatother
\usepackage[T1]{fontenc}
\usepackage[type1,oldstyle]{libertine}
\begin{document}

This is a test 1234567890 fi ffi fl ffl ft fft fj ffj tt

{\libertine\libertineGlyph{uni025D}}

\end{document}
9
  • Can you add some words about what you're doing here, and how/why it works? Also, adding \usepackage[T1]{fontenc} removes many of the ligatures included in my test line.
    – Sverre
    Commented Jun 12, 2014 at 16:26
  • I took elements from libertine.sty that support \libertineGlyph. You can use LY1 encoding if you want.
    – user51830
    Commented Jun 12, 2014 at 16:54
  • or OT1, which seems to give all the ligatures in your test line.
    – user51830
    Commented Jun 12, 2014 at 17:02
  • OT1 provides the highest number of ligatures, but it doesn't contain any characters used outside of English, so that's not really an option. I'm curious why \usepackage{fontenc} is necessary at all. It's not needed when just loading \usepackage[oldstyle]{libertine}.
    – Sverre
    Commented Jun 12, 2014 at 17:04
  • You need fontenc to define \newfontfamily, which is needed to load the otf font.
    – user51830
    Commented Jun 12, 2014 at 17:21
2

All glyphs from Type1 are in the OpenType. There is no need to use the Type1 version of Libertine:

\documentclass{article}% xelatex or lualatex
\usepackage{fontspec}
\usepackage[oldstyle]{libertine}
\begin{document}

This is a test 1234567890 fi ffi fl ffl ft fft fj ffj tt

\symbol{"025D}

\end{document}

enter image description here

6
  • Yes, all the glyphs are included in the OpenType fonts, but ligatures and oldstyle numbers won't be copy- and searchable, as mentioned in my question.
    – Sverre
    Commented Jun 12, 2014 at 16:24
  • "won't be copy- and searchable" Which pdf viewer are you using?
    – user51830
    Commented Jun 12, 2014 at 17:27
  • @user51830 Adobe Acrobat.
    – Sverre
    Commented Jun 12, 2014 at 17:29
  • "won't be copy- and searchable" What exactly do you mean by that?
    – user51830
    Commented Jun 12, 2014 at 18:31
  • I have no problem with searching except the oldstyle figures which are always lined one when copied.
    – user2478
    Commented Jun 12, 2014 at 18:39

You must log in to answer this question.

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