4

I am familiar with questions 162626 and with 204822, and have followed the instructions therein, but have been unable to get a good solution. htlatex is converting all of the ligatures in a document into null bytes. MWE:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[oldstyle,proportional]{libertine}
\begin{document}
find the fly; it's difficult, but fluffy.
\end{document}

My command line:

htlatex test.tex "xhtml, -css, charset=utf-8" " -utf8 -cunihtf" "" -shell-escape;

The problem seems to be in libertine; when I don't load it, the ligatures come out fine, but when I do, the ligatures are null. This suggests the solution of simply removing the libertine package and then compiling with htlatex, but I'd really like to avoid having to modify my document in order to convert it to HTML.

Does anyone have a suggested solution to this?

4
  • Maybe tex.stackexchange.com/questions/5153/… can help you? – jarauh Oct 25 '15 at 1:43
  • Sure, it helps; but I still have to modify my document. The idea here is that I'd be able to write my document without having to worry about the eventual conversion to HTML. It might not be possible; but if it is, I know somebody here will know it. – dgoodmaniii Oct 25 '15 at 1:53
  • Well, you would only have to change your document at one place in the preamble, and afterwards it would work fine for pdf and for HTML. The alternative is to change libertine.sty. It would suffice to put a patched version of libertine.sty in the folder of your tex file. You could try to use the answers from the same question (5153) to make libertine.sty check whether htlatex is running. – jarauh Oct 25 '15 at 2:08
  • Well, as the documentation says, "It is highly recommended to leave source LaTeX and TeX files intact, and not introduce TeX4ht configurations there." I'm trying to go with that. Your suggestion is a good one, as it at least saves me from having to maintain a separate copy of the document without libertine loaded. But something config-file wise seems better to me, if there is anything. – dgoodmaniii Oct 25 '15 at 4:07
3

There is still no full support for Linux Libertine in tex4ht, as there are literally dozens fonts for various font encodings, styles, sizes and weights. But, it is not that hard to add support for basic T1 fonts, using htfgen.

You can find that some font support is missing from tex4ht command output:

tex4ht test.dvi " -cunihtf -utf8"

this will print really lot of text, because it prints contents of tex4ht.env file, which isn't exactly small. But at the beginning, you can find this:

tex4ht.c (2012-07-25-19:36 kpathsea)
tex4ht sample.dvi 
(/usr/local/texlive/2015/texmf-dist/tex4ht/base/unix/tex4ht.env)
(/usr/local/texlive/2015/texmf-dist/tex4ht/ht-fonts/iso8859/1/html/charset/unicode.4hf)
(/usr/local/texlive/2015/texmf-dist/fonts/tfm/public/libertine/LinLibertineTB-osf-t1.tfm)
(LinLibertineTB-osf-t1.htf)
Searching `LinLibertineT-osf-t1.htf' for `LinLibertineTB-osf-t1.htf'
--- warning --- Couldn't find font `LinLibertineT-osf-t1.htf' (char codes: 0--255)

----------------------------------------------------
environment file
----------------------------------------------------
% tex4ht.env-unix (2015-02-15-10:26), generated from tex4ht-env.tex

so, we need to create file LinLibertineT-osf-t1.htf, which corresponds to LinLibertineT-osf-t1.tfm. We can inspect used font encoding and whether the font is virtual or real with lstexenc command provided by htfgen project:

$ lstexenc LinLibertineT-osf-t1
LinLibertineT-osf-t1    vf      EXTENDED TEX FONT ENCODING - LATIN
  LinLibertineT-osf-t1--base    tfm     EXTENDED TEX FONT ENCODING - LATIN

so we see that it is virtual font and it uses some non-standard font encoding. It uses LinLibertineT-osf-t1--base as a base font, sometimes virtual fonts contains several fonts, so this isn't that bad.

Exact font encoding can be sometimes found in the .map file. Easiest way to find is to search with Google for fontname enc, so LinLibertineT-osf-t1--base enc in our case (yes, the enc file is provided for the base fonts. If the virtual font contain several real fonts, we need to find encodings for each one). The search finds file libertine.map, which provides encodings for all Libertine real fonts. We have to search it for LinLibertineT-osf-t1--base:

LinLibertineT-osf-t1--base LinLibertineT "AutoEnc_ulngvdga3jyvcsz3zod63p4gna ReEncodeFont" <[lbtn_ulngvd.enc <LinLibertineT.pfb

important is <[lbtn_ulngvd.enc part, which contains the encoding name, lbtn_ulngvd. Now we can create helper table for LinLibertineT-osf-t1:

tfmtochars LinLibertineT-osf-t1 lbtn_ulngvd > LinLibertineT-osf-t1.tsv

and finally to create the .htf file:

htfgen LinLibertineT-osf-t1.tsv > LinLibertineT-osf-t1.htf

the result is following:

LinLibertineT-osf-t1 0 255
'&#x0060;'  ''  grave
'&#x00B4;'  ''  acute
'&#x02C6;'  ''  circumflex
'&#x02DC;'  ''  tilde
'&#x00A8;'  ''  dieresis
'&#x02DD;'  ''  hungarumlaut
'&#x02DA;'  ''  ring
'&#x02C7;'  ''  caron
'&#x02D8;'  ''  breve
'&#x00AF;'  ''  macron
'&#x02D9;'  ''  dotaccent
'&#x00B8;'  ''  cedilla
'&#x02DB;'  ''  ogonek
'&#x201A;'  ''  quotesinglbase
'&#x2039;'  ''  guilsinglleft
'&#x203A;'  ''  guilsinglright
'&#x201C;'  ''  quotedblleft
'&#x201D;'  ''  quotedblright
'&#x201E;'  ''  quotedblbase
'&#x00AB;'  ''  guillemotleft
'&#x00BB;'  ''  guillemotright
'&#x2013;'  ''  endash
'&#x2014;'  ''  emdash
'&#xnil;'   ''  .notdef
'&#x2080;'  ''  perthousandzero
'&#x0131;'  ''  dotlessi
'&#x0237;'  ''  dotlessj
'&#xFB01;'  ''  f_i
'&#xFB03;'  ''  f_f_i
'&#xFB00;'  ''  f_f
'&#xFB02;'  ''  f_l
'&#xFB04;'  ''  f_f_l
'&#x2423;'  ''  uni2423
'&#x0021;'  ''  exclam
'&#x0022;'  ''  quotedbl
'&#x0023;'  ''  numbersign
'&#x0024;'  ''  dollar
'&#x0025;'  ''  percent
'&#x0026;'  ''  ampersand
'&#x2019;'  ''  quoteright
'&#x0028;'  ''  parenleft
'&#x0029;'  ''  parenright
'&#x002A;'  ''  asterisk
'&#x002B;'  ''  plus
'&#x002C;'  ''  comma
'&#x002D;'  ''  hyphen
'&#x002E;'  ''  period
'&#x002F;'  ''  slash
'&#xF730;'  ''  zero.oldstyle
'&#xF731;'  ''  one.oldstyle
'&#xF732;'  ''  two.oldstyle
'&#xF733;'  ''  three.oldstyle
'&#xF734;'  ''  four.oldstyle
'&#xF735;'  ''  five.oldstyle
'&#xF736;'  ''  six.oldstyle
'&#xF737;'  ''  seven.oldstyle
'&#xF64B;'  ''  eight.taboldstyle
'&#xF739;'  ''  nine.oldstyle
'&#x003A;'  ''  colon
'&#x003B;'  ''  semicolon
'&#x003C;'  ''  less
'&#x003D;'  ''  equal
'&#x003E;'  ''  greater
'&#x003F;'  ''  question
'&#x0040;'  ''  at
'&#x0041;'  ''  A
'&#x0042;'  ''  B
'&#x0043;'  ''  C
'&#x0044;'  ''  D
'&#x0045;'  ''  E
'&#x0046;'  ''  F
'&#x0047;'  ''  G
'&#x0048;'  ''  H
'&#x0049;'  ''  I
'&#x004A;'  ''  J
'&#x004B;'  ''  K
'&#x004C;'  ''  L
'&#x004D;'  ''  M
'&#x004E;'  ''  N
'&#x004F;'  ''  O
'&#x0050;'  ''  P
'&#x0051;'  ''  Q
'&#x0052;'  ''  R
'&#x0053;'  ''  S
'&#x0054;'  ''  T
'&#x0055;'  ''  U
'&#x0056;'  ''  V
'&#x0057;'  ''  W
'&#x0058;'  ''  X
'&#x0059;'  ''  Y
'&#x005A;'  ''  Z
'&#x005B;'  ''  bracketleft
'&#x005C;'  ''  backslash
'&#x005D;'  ''  bracketright
'&#x005E;'  ''  asciicircum
'&#x005F;'  ''  underscore
'&#x2018;'  ''  quoteleft
'&#x0061;'  ''  a
'&#x0062;'  ''  b
'&#x0063;'  ''  c
'&#x0064;'  ''  d
'&#x0065;'  ''  e
'&#x0066;'  ''  f
'&#x0067;'  ''  g
'&#x0068;'  ''  h
'&#x0069;'  ''  i
'&#x006A;'  ''  j
'&#x006B;'  ''  k
'&#x006C;'  ''  l
'&#x006D;'  ''  m
'&#x006E;'  ''  n
'&#x006F;'  ''  o
'&#x0070;'  ''  p
'&#x0071;'  ''  q
'&#x0072;'  ''  r
'&#x0073;'  ''  s
'&#x0074;'  ''  t
'&#x0075;'  ''  u
'&#x0076;'  ''  v
'&#x0077;'  ''  w
'&#x0078;'  ''  x
'&#x0079;'  ''  y
'&#x007A;'  ''  z
'&#x007B;'  ''  braceleft
'&#x007C;'  ''  bar
'&#x007D;'  ''  braceright
'&#x007E;'  ''  asciitilde
'&#x002D;'  ''  hyphen
'&#x0102;'  ''  Abreve
'&#x0104;'  ''  Aogonek
'&#x0106;'  ''  Cacute
'&#x010C;'  ''  Ccaron
'&#x010E;'  ''  Dcaron
'&#x011A;'  ''  Ecaron
'&#x0118;'  ''  Eogonek
'&#x011E;'  ''  Gbreve
'&#x0139;'  ''  Lacute
'&#x013D;'  ''  Lcaron
'&#x0141;'  ''  Lslash
'&#x0143;'  ''  Nacute
'&#x0147;'  ''  Ncaron
'&#x014A;'  ''  Eng
'&#x0150;'  ''  Ohungarumlaut
'&#x0154;'  ''  Racute
'&#x0158;'  ''  Rcaron
'&#x015A;'  ''  Sacute
'&#x0160;'  ''  Scaron
'&#x015E;'  ''  Scedilla
'&#x0164;'  ''  Tcaron
'&#x0162;'  ''  Tcedilla
'&#x0170;'  ''  Uhungarumlaut
'&#x016E;'  ''  Uring
'&#x0178;'  ''  Ydieresis
'&#x0179;'  ''  Zacute
'&#x017D;'  ''  Zcaron
'&#x017B;'  ''  Zdotaccent
'&#x0132;'  ''  IJ
'&#x0130;'  ''  Idotaccent
'&#x0111;'  ''  dcroat
'&#x00A7;'  ''  section
'&#x0103;'  ''  abreve
'&#x0105;'  ''  aogonek
'&#x0107;'  ''  cacute
'&#x010D;'  ''  ccaron
'&#x010F;'  ''  dcaron
'&#x011B;'  ''  ecaron
'&#x0119;'  ''  eogonek
'&#x011F;'  ''  gbreve
'&#x013A;'  ''  lacute
'&#x013E;'  ''  lcaron
'&#x0142;'  ''  lslash
'&#x0144;'  ''  nacute
'&#x0148;'  ''  ncaron
'&#x014B;'  ''  eng
'&#x0151;'  ''  ohungarumlaut
'&#x0155;'  ''  racute
'&#x0159;'  ''  rcaron
'&#x015B;'  ''  sacute
'&#x0161;'  ''  scaron
'&#x015F;'  ''  scedilla
'&#x0165;'  ''  tcaron
'&#x0163;'  ''  tcedilla
'&#x0171;'  ''  uhungarumlaut
'&#x016F;'  ''  uring
'&#x00FF;'  ''  ydieresis
'&#x017A;'  ''  zacute
'&#x017E;'  ''  zcaron
'&#x017C;'  ''  zdotaccent
'&#x0133;'  ''  ij
'&#x00A1;'  ''  exclamdown
'&#x00BF;'  ''  questiondown
'&#x00A3;'  ''  sterling
'&#x00C0;'  ''  Agrave
'&#x00C1;'  ''  Aacute
'&#x00C2;'  ''  Acircumflex
'&#x00C3;'  ''  Atilde
'&#x00C4;'  ''  Adieresis
'&#x00C5;'  ''  Aring
'&#x00C6;'  ''  AE
'&#x00C7;'  ''  Ccedilla
'&#x00C8;'  ''  Egrave
'&#x00C9;'  ''  Eacute
'&#x00CA;'  ''  Ecircumflex
'&#x00CB;'  ''  Edieresis
'&#x00CC;'  ''  Igrave
'&#x00CD;'  ''  Iacute
'&#x00CE;'  ''  Icircumflex
'&#x00CF;'  ''  Idieresis
'&#x00D0;'  ''  Eth
'&#x00D1;'  ''  Ntilde
'&#x00D2;'  ''  Ograve
'&#x00D3;'  ''  Oacute
'&#x00D4;'  ''  Ocircumflex
'&#x00D5;'  ''  Otilde
'&#x00D6;'  ''  Odieresis
'&#x0152;'  ''  OE
'&#x00D8;'  ''  Oslash
'&#x00D9;'  ''  Ugrave
'&#x00DA;'  ''  Uacute
'&#x00DB;'  ''  Ucircumflex
'&#x00DC;'  ''  Udieresis
'&#x00DD;'  ''  Yacute
'&#x00DE;'  ''  Thorn
'&#xnil;'   ''  .notdef
'&#x00E0;'  ''  agrave
'&#x00E1;'  ''  aacute
'&#x00E2;'  ''  acircumflex
'&#x00E3;'  ''  atilde
'&#x00E4;'  ''  adieresis
'&#x00E5;'  ''  aring
'&#x00E6;'  ''  ae
'&#x00E7;'  ''  ccedilla
'&#x00E8;'  ''  egrave
'&#x00E9;'  ''  eacute
'&#x00EA;'  ''  ecircumflex
'&#x00EB;'  ''  edieresis
'&#x00EC;'  ''  igrave
'&#x00ED;'  ''  iacute
'&#x00EE;'  ''  icircumflex
'&#x00EF;'  ''  idieresis
'&#x00F0;'  ''  eth
'&#x00F1;'  ''  ntilde
'&#x00F2;'  ''  ograve
'&#x00F3;'  ''  oacute
'&#x00F4;'  ''  ocircumflex
'&#x00F5;'  ''  otilde
'&#x00F6;'  ''  odieresis
'&#x0153;'  ''  oe
'&#x00F8;'  ''  oslash
'&#x00F9;'  ''  ugrave
'&#x00FA;'  ''  uacute
'&#x00FB;'  ''  ucircumflex
'&#x00FC;'  ''  udieresis
'&#x00FD;'  ''  yacute
'&#x00FE;'  ''  thorn
'&#x00DF;'  ''  germandbls
LinLibertineT-osf-t1 0 255

(you need to add blank line at the end of the file, Stack Exchange eats is)

We should also add support for bold and italics. We don't have to repeat the whole process if the fonts use the same encoding. Unfortunately, each font use different encoding, but after diff it doesn't seem that they differ substantially, so we can just create .htf files, which doesn't include all unicode values for all characters, but just link to LinLibertineT-osf-t1. This second type of the htf file looks like this:

LinLibertineTB-osf-t1.htf:

.LinLibertineT-osf-t1
htfcss:  LinLibertineTB-osf-t1  font-weight: bold; font-family: "Linux Libertine O",serif;  

LinLibertineTI-osf-t1:

.LinLibertineT-osf-t1
htfcss:  LinLibertineTI-osf-t1  font-weight: normal; font-style: italic; font-family: "Linux Libertine O",serif;  

If you haven't disabled the CSS, you would see something like:

enter image description here

As you can see, the normal font isn't styled, but bold and italics are. You can fix it with simple config file:

\Preamble{xhtml}
\Css{body{font-family: "Linux Libertine O", serif;}}
\begin{document}
\EndPreamble

Also note that unicode old-style numbers are used instead of normal ones. Final result:

enter image description here

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.