我偶然发现了一个问题的延续,似乎已经解决了tex.stackexchange.com/questions/162626/,但如果我使用某种形式的 Garamond 字体,问题又会出现。建议的解决方案均无效。
我在 Debian Linux 10“Buster”上使用 TeX Live 2018。
首先,这是 test.tex
\documentclass{article}
%\usepackage{garamondx}
%\usepackage{ebgaramond}
%\usepackage{urw-garamond}
%\usepackage[urw-garamond]{mathdesign}
%\usepackage{cmbright}
\usepackage{helvet}
\begin{document}
\section{Letters}
\subsection{Valid Letters}
AA Aa aA aa\\
BB Bb bB bb\\
CD Cd cD cd\\
\subsection{Invalid Letters}
FF Ff fF ff\\
FI Fi fI fi\\
\section{Strings}
a string of text\\
a fine string of text\\
a definition of an efficient and fine string of text\\
finally, the problem is solved!\\
\end{document}
现在配置文件:
\Preamble{xhtml,NoFonts, -css}
\Configure{HtmlPar}
{\EndP\Tg<p>}
{\EndP\Tg<p>}
{\HCode{</p>\Hnewline}}
{\HCode{</p>\Hnewline}}
\Configure{emph}{\ifvmode\ShowPar\fi\HCode{<em>}}{\HCode{</em>}}
\Configure{textbf}{\ifvmode\ShowPar\fi\HCode{<b>}}{\HCode{</b>}}
\Configure{textit}{\ifvmode\ShowPar\fi\HCode{<i>}}{\HCode{</i>}}
\Configure{textsc}{\ifvmode\ShowPar\fi\HCode{<font style="font-variant: small-caps">}}{\HCode{</font>}}
\begin{document}
\EndPreamble
并调用:
make4ht -u -c test -s test
答案1
问题是没有支持 EB Garamond 或您测试的其他字体的字体文件。tex4ht
需要支持htf 文件适用于 8 位字体。它们包含从字体字符到 Unicode 的映射,这对于连字或重音字母等内容尤其必要。
创建htf
文件并不容易,大多数htf
文件都是手工创建的。当找不到htf
字体时,将使用默认映射。它通常适用于基本的拉丁文本,但对于符号,尤其是连字符,它可能不起作用。
当您运行命令时,您会看到有关 EB Garamondtex4ht
缺少文件的提示:htf
tex4ht test
(/usr/local/texlive/2018/texmf-dist/fonts/tfm/public/ebgaramond/EBGaramond12-Italic-osf-sc-ot1.tfm)
--- warning --- Couldn't find font `EBGaramond12-Italic-osf-sc-ot1.htf' (char codes: 0--127)
(/usr/local/texlive/2018/texmf-dist/fonts/tfm/public/ebgaramond/EBGaramond12-Italic-osf-ot1.tfm)
--- warning --- Couldn't find font `EBGaramond12-Italic-osf-ot1.htf' (char codes: 0--146)
(/usr/local/texlive/2018/texmf-dist/fonts/tfm/public/ebgaramond/EBGaramond12-Regular-osf-ot1.tfm)
--- warning --- Couldn't find font `EBGaramond12-Regular-osf-ot1.htf' (char codes: 0--138)
我创建了一套工具,叫做赫特根用于自动htf
文件生成。以下 Lua 脚本使用提供的库Htfgen
来生成运行htf
中报告为缺失的字体的文件tex4ht
。将其保存为makehtf.lua
:
kpse.set_program_name("luatex")
local lfs = require "lfs"
local htflib = require "htflibs.htflib"
local fontobj = require "htflibs.fontobj"
-- load a map file. pdftex.map should contain all possible fonts
local fonts = fontobj("pdftex")
local function write_file(htfname, contents)
local f = io.open(htfname, "w")
f:write(contents)
f:close()
end
local function find_missing_fonts(tex4ht_output)
local missing_fonts = {}
for htf_font in tex4ht_output:gmatch("Couldn't find font `(.-)%.htf") do
table.insert(missing_fonts, htf_font)
end
return missing_fonts
end
-- make test run on the dvi/xdv file to find unsupported fonts
local function run_tex4ht(dvifile)
-- redirect stderr
local ext = dvifile:match("^.+(%..+)$")
local command = io.popen("tex4ht -" .. ext .. " " .. dvifile .. " 2>&1", "r")
local result = command:read("*all")
command:close()
return find_missing_fonts(result)
end
local missing_fonts = run_tex4ht(arg[1])
for _, fontfile in ipairs(missing_fonts) do
local fontobject
-- the virtual fonts have priority over tfm fonts
local vffile = kpse.find_file(fontfile, "vf")
if vffile then
fontobject = fonts:load_virtual_font(vffile)
else
local tfmfile = kpse.find_file(fontfile, "tfm")
if tfmfile then
fontobject = fonts:load_tfm_font(tfmfile)
end
end
if fontobject then
local htfname = fontfile .. ".htf"
print("writing " .. htfname)
write_file(htfname, htflib.fontobj_to_htf_table(fontobject).."\n" .. htflib.fontobj_get_css(fontobject) .."\n")
for _, missing in ipairs(fontobject.missing_glyphs) do
print("Missing glyph", missing)
end
end
end
可以这样执行:
texlua makehtf.lua test.dvi
它应该打印如下内容:
writing EBGaramond12-Regular-osf-sc-ot1.htf
writing EBGaramond12-Italic-osf-sc-ot1.htf
writing EBGaramond12-Italic-osf-ot1.htf
writing EBGaramond12-Regular-osf-ot1.htf
并创建这些htf
文件。我会将它们发布在这里。
EBGaramond12-常规-osf-ot1.htf:
EBGaramond12-Regular-osf-ot1 0 138
'Γ' '' Gamma 0
'Δ' '' uni0394 1
'Θ' '' Theta 2
'Λ' '' Lambda 3
'Ξ' '' Xi 4
'Π' '' Pi 5
'Σ' '' Sigma 6
'Υ' '' Upsilon 7
'Φ' '' Phi 8
'Ψ' '' Psi 9
'Ω' '' uni03A9 10
'' ''
'' ''
'' ''
'' ''
'' ''
'ı' '' dotlessi 16
'ȷ' '' uni0237 17
'`' '' grave 18
'´' '' acute 19
'ˇ' '' caron 20
'˘' '' breve 21
'¯' '' macron 22
'˚' '' ring 23
'¸' '' cedilla 24
'ß' '' germandbls 25
'æ' '' ae 26
'œ' '' oe 27
'ø' '' oslash 28
'Æ' '' AE 29
'Œ' '' OE 30
'Ø' '' Oslash 31
' ' '' space 32
'!' '' exclam 33
'”' '' quotedblright 34
'#' '' numbersign 35
'$' '' dollar 36
'%' '' percent.sc 37
'&' '' ampersand 38
'’' '' quoteright 39
'(' '' parenleft 40
')' '' parenright 41
'*' '' asterisk 42
'+' '' plus 43
',' '' comma 44
'-' '' hyphen 45
'.' '' period 46
'/' '' slash 47
'0' '' zero 48
'1' '' one 49
'2' '' two 50
'3' '' three 51
'4' '' four 52
'5' '' five 53
'6' '' six 54
'7' '' seven 55
'8' '' eight 56
'9' '' nine 57
':' '' colon 58
';' '' semicolon 59
'¡' '' exclamdown 60
'=' '' equal 61
'¿' '' questiondown 62
'?' '' question 63
'@' '' at 64
'A' '' A 65
'B' '' B 66
'C' '' C 67
'D' '' D 68
'E' '' E 69
'F' '' F 70
'G' '' G 71
'H' '' H 72
'I' '' I 73
'J' '' J 74
'K' '' K 75
'L' '' L 76
'M' '' M 77
'N' '' N 78
'O' '' O 79
'P' '' P 80
'Q' '' Q 81
'R' '' R 82
'S' '' S 83
'T' '' T 84
'U' '' U 85
'V' '' V 86
'W' '' W 87
'X' '' X 88
'Y' '' Y 89
'Z' '' Z 90
'[' '' bracketleft 91
'“' '' quotedblleft 92
']' '' bracketright 93
'ˆ' '' circumflex 94
'˙' '' dotaccent 95
'‘' '' quoteleft 96
'a' '' a 97
'b' '' b 98
'c' '' c 99
'd' '' d 100
'e' '' e 101
'f' '' f 102
'g' '' g 103
'h' '' h 104
'i' '' i 105
'j' '' j 106
'k' '' k 107
'l' '' l 108
'm' '' m 109
'n' '' n 110
'o' '' o 111
'p' '' p 112
'q' '' q 113
'r' '' r 114
's' '' s 115
't' '' t 116
'u' '' u 117
'v' '' v 118
'w' '' w 119
'x' '' x 120
'y' '' y 121
'z' '' z 122
'–' '' endash 123
'—' '' emdash 124
'˝' '' hungarumlaut 125
'˜' '' tilde 126
'¨' '' dieresis 127
'fi' '' f._i i.dotless 128
'f' '' f._f 129
'fl' '' f._asc l.f_ 130
'fj' '' f._i j.dotless 131
'fb' '' f._asc b.f_ 132
'fh' '' f._asc h.f_ 133
'fk' '' f._asc k.f_ 134
'' ''
'' ''
't' '' t.f_ 137
'Qy' '' Q_y 138
EBGaramond12-Regular-osf-ot1 0 138
htfcss: EBGaramond12-Regular-osf-ot1 font-family: 'EB Garamond 12', serif;
EBGaramond12-Italic-osf-sc-ot1.htf
EBGaramond12-Italic-osf-sc-ot1 0 127
'Γ' '' Gamma 0
'Δ' '' uni0394 1
'Θ' '' Theta 2
'Λ' '' Lambda 3
'Ξ' '' Xi 4
'Π' '' Pi 5
'Σ' '' Sigma 6
'Υ' '' Upsilon 7
'Φ' '' Phi 8
'Ψ' '' Psi 9
'Ω' '' uni03A9 10
'' ''
'' ''
'' ''
'' ''
'' ''
'ı' '' dotlessi.sc 16
'ȷ' '' uni0237 17
'`' '' grave 18
'´' '' acute 19
'ˇ' '' caron 20
'˘' '' breve 21
'¯' '' macron 22
'˚' '' ring 23
'¸' '' cedilla 24
'ss' '' s.sc s.sc 25
'æ' '' ae.sc 26
'œ' '' oe.sc 27
'ø' '' oslash.sc 28
'Æ' '' AE 29
'Œ' '' OE 30
'Ø' '' Oslash 31
' ' '' space 32
'!' '' exclam 33
'”' '' quotedblright 34
'#' '' numbersign 35
'$' '' dollar 36
'%' '' percent.sc 37
'&' '' ampersand 38
'’' '' quoteright 39
'(' '' parenleft 40
')' '' parenright 41
'*' '' asterisk 42
'+' '' plus 43
',' '' comma 44
'-' '' hyphen 45
'.' '' period 46
'/' '' slash 47
'0' '' zero 48
'1' '' one 49
'2' '' two 50
'3' '' three 51
'4' '' four 52
'5' '' five 53
'6' '' six 54
'7' '' seven 55
'8' '' eight 56
'9' '' nine 57
':' '' colon 58
';' '' semicolon 59
'¡' '' exclamdown 60
'=' '' equal 61
'¿' '' questiondown 62
'?' '' question 63
'@' '' at 64
'A' '' A 65
'B' '' B 66
'C' '' C 67
'D' '' D 68
'E' '' E 69
'F' '' F 70
'G' '' G 71
'H' '' H 72
'I' '' I 73
'J' '' J 74
'K' '' K 75
'L' '' L 76
'M' '' M 77
'N' '' N 78
'O' '' O 79
'P' '' P 80
'Q' '' Q 81
'R' '' R 82
'S' '' S 83
'T' '' T 84
'U' '' U 85
'V' '' V 86
'W' '' W 87
'X' '' X 88
'Y' '' Y 89
'Z' '' Z 90
'[' '' bracketleft 91
'“' '' quotedblleft 92
']' '' bracketright 93
'ˆ' '' circumflex 94
'˙' '' dotaccent 95
'‘' '' quoteleft 96
'a' '' a.sc 97
'b' '' b.sc 98
'c' '' c.sc 99
'd' '' d.sc 100
'e' '' e.sc 101
'f' '' f.sc 102
'g' '' g.sc 103
'h' '' h.sc 104
'i' '' i.sc 105
'j' '' j.sc 106
'k' '' k.sc 107
'l' '' l.sc 108
'm' '' m.sc 109
'n' '' n.sc 110
'o' '' o.sc 111
'p' '' p.sc 112
'q' '' q.sc 113
'r' '' r.sc 114
's' '' s.sc 115
't' '' t.sc 116
'u' '' u.sc 117
'v' '' v.sc 118
'w' '' w.sc 119
'x' '' x.sc 120
'y' '' y.sc 121
'z' '' z.sc 122
'–' '' endash 123
'—' '' emdash 124
'˝' '' hungarumlaut 125
'˜' '' tilde 126
'¨' '' dieresis 127
EBGaramond12-Italic-osf-sc-ot1 0 127
htfcss: EBGaramond12-Italic-osf-sc-ot1 font-style: italic; font-variant: small-caps; font-family: 'EB Garamond 12', serif;
EBGaramond12-Italic-osf-ot1.htf:
EBGaramond12-Italic-osf-ot1 0 146
'Γ' '' Gamma 0
'Δ' '' uni0394 1
'Θ' '' Theta 2
'Λ' '' Lambda 3
'Ξ' '' Xi 4
'Π' '' Pi 5
'Σ' '' Sigma 6
'Υ' '' Upsilon 7
'Φ' '' Phi 8
'Ψ' '' Psi 9
'Ω' '' uni03A9 10
'' ''
'' ''
'' ''
'' ''
'' ''
'ı' '' dotlessi 16
'ȷ' '' uni0237 17
'`' '' grave 18
'´' '' acute 19
'ˇ' '' caron 20
'˘' '' breve 21
'¯' '' macron 22
'˚' '' ring 23
'¸' '' cedilla 24
'ß' '' germandbls 25
'æ' '' ae 26
'œ' '' oe 27
'ø' '' oslash 28
'Æ' '' AE 29
'Œ' '' OE 30
'Ø' '' Oslash 31
' ' '' space 32
'!' '' exclam 33
'”' '' quotedblright 34
'#' '' numbersign 35
'$' '' dollar 36
'%' '' percent.sc 37
'&' '' ampersand 38
'’' '' quoteright 39
'(' '' parenleft 40
')' '' parenright 41
'*' '' asterisk 42
'+' '' plus 43
',' '' comma 44
'-' '' hyphen 45
'.' '' period 46
'/' '' slash 47
'0' '' zero 48
'1' '' one 49
'2' '' two 50
'3' '' three 51
'4' '' four 52
'5' '' five 53
'6' '' six 54
'7' '' seven 55
'8' '' eight 56
'9' '' nine 57
':' '' colon 58
';' '' semicolon 59
'¡' '' exclamdown 60
'=' '' equal 61
'¿' '' questiondown 62
'?' '' question 63
'@' '' at 64
'A' '' A 65
'B' '' B 66
'C' '' C 67
'D' '' D 68
'E' '' E 69
'F' '' F 70
'G' '' G 71
'H' '' H 72
'I' '' I 73
'J' '' J 74
'K' '' K 75
'L' '' L 76
'M' '' M 77
'N' '' N 78
'O' '' O 79
'P' '' P 80
'Q' '' Q 81
'R' '' R 82
'S' '' S 83
'T' '' T 84
'U' '' U 85
'V' '' V 86
'W' '' W 87
'X' '' X 88
'Y' '' Y 89
'Z' '' Z 90
'[' '' bracketleft 91
'“' '' quotedblleft 92
']' '' bracketright 93
'ˆ' '' circumflex 94
'˙' '' dotaccent 95
'‘' '' quoteleft 96
'a' '' a 97
'b' '' b 98
'c' '' c 99
'd' '' d 100
'e' '' e 101
'f' '' f 102
'g' '' g 103
'h' '' h 104
'i' '' i 105
'j' '' j 106
'k' '' k 107
'l' '' l 108
'm' '' m 109
'n' '' n 110
'o' '' o 111
'p' '' p 112
'q' '' q 113
'r' '' r 114
's' '' s 115
't' '' t 116
'u' '' u 117
'v' '' v 118
'w' '' w 119
'x' '' x 120
'y' '' y 121
'z' '' z 122
'–' '' endash 123
'—' '' emdash 124
'˝' '' hungarumlaut 125
'˜' '' tilde 126
'¨' '' dieresis 127
'ff' '' f_f 128
'fi' '' uniFB01 129
'fl' '' uniFB02 130
'ffi' '' uniFB03 131
'ffl' '' uniFB04 132
'fh' '' f_h 133
'fk' '' f_k 134
'fb' '' f_b 135
'ft' '' f_t 136
'fj' '' f_j 137
'gy' '' g_y 138
'gg' '' g_g 139
'gj' '' g_j 140
'ffb' '' f_f_b 141
'ffh' '' f_f_h 142
'ffj' '' f_f_j 143
'ff{' '' f_f_k 144
'fft' '' f_f_t 145
'Qy' '' Q_y 146
EBGaramond12-Italic-osf-ot1 0 146
htfcss: EBGaramond12-Italic-osf-ot1 font-style: italic; font-family: 'EB Garamond 12', serif;
EBGaramond12-常规-osf-ot1.htf:
EBGaramond12-Regular-osf-ot1 0 138
'Γ' '' Gamma 0
'Δ' '' uni0394 1
'Θ' '' Theta 2
'Λ' '' Lambda 3
'Ξ' '' Xi 4
'Π' '' Pi 5
'Σ' '' Sigma 6
'Υ' '' Upsilon 7
'Φ' '' Phi 8
'Ψ' '' Psi 9
'Ω' '' uni03A9 10
'' ''
'' ''
'' ''
'' ''
'' ''
'ı' '' dotlessi 16
'ȷ' '' uni0237 17
'`' '' grave 18
'´' '' acute 19
'ˇ' '' caron 20
'˘' '' breve 21
'¯' '' macron 22
'˚' '' ring 23
'¸' '' cedilla 24
'ß' '' germandbls 25
'æ' '' ae 26
'œ' '' oe 27
'ø' '' oslash 28
'Æ' '' AE 29
'Œ' '' OE 30
'Ø' '' Oslash 31
' ' '' space 32
'!' '' exclam 33
'”' '' quotedblright 34
'#' '' numbersign 35
'$' '' dollar 36
'%' '' percent.sc 37
'&' '' ampersand 38
'’' '' quoteright 39
'(' '' parenleft 40
')' '' parenright 41
'*' '' asterisk 42
'+' '' plus 43
',' '' comma 44
'-' '' hyphen 45
'.' '' period 46
'/' '' slash 47
'0' '' zero 48
'1' '' one 49
'2' '' two 50
'3' '' three 51
'4' '' four 52
'5' '' five 53
'6' '' six 54
'7' '' seven 55
'8' '' eight 56
'9' '' nine 57
':' '' colon 58
';' '' semicolon 59
'¡' '' exclamdown 60
'=' '' equal 61
'¿' '' questiondown 62
'?' '' question 63
'@' '' at 64
'A' '' A 65
'B' '' B 66
'C' '' C 67
'D' '' D 68
'E' '' E 69
'F' '' F 70
'G' '' G 71
'H' '' H 72
'I' '' I 73
'J' '' J 74
'K' '' K 75
'L' '' L 76
'M' '' M 77
'N' '' N 78
'O' '' O 79
'P' '' P 80
'Q' '' Q 81
'R' '' R 82
'S' '' S 83
'T' '' T 84
'U' '' U 85
'V' '' V 86
'W' '' W 87
'X' '' X 88
'Y' '' Y 89
'Z' '' Z 90
'[' '' bracketleft 91
'“' '' quotedblleft 92
']' '' bracketright 93
'ˆ' '' circumflex 94
'˙' '' dotaccent 95
'‘' '' quoteleft 96
'a' '' a 97
'b' '' b 98
'c' '' c 99
'd' '' d 100
'e' '' e 101
'f' '' f 102
'g' '' g 103
'h' '' h 104
'i' '' i 105
'j' '' j 106
'k' '' k 107
'l' '' l 108
'm' '' m 109
'n' '' n 110
'o' '' o 111
'p' '' p 112
'q' '' q 113
'r' '' r 114
's' '' s 115
't' '' t 116
'u' '' u 117
'v' '' v 118
'w' '' w 119
'x' '' x 120
'y' '' y 121
'z' '' z 122
'–' '' endash 123
'—' '' emdash 124
'˝' '' hungarumlaut 125
'˜' '' tilde 126
'¨' '' dieresis 127
'fi' '' f._i i.dotless 128
'f' '' f._f 129
'fl' '' f._asc l.f_ 130
'fj' '' f._i j.dotless 131
'fb' '' f._asc b.f_ 132
'fh' '' f._asc h.f_ 133
'fk' '' f._asc k.f_ 134
'' ''
'' ''
't' '' t.f_ 137
'Qy' '' Q_y 138
EBGaramond12-Regular-osf-ot1 0 138
htfcss: EBGaramond12-Regular-osf-ot1 font-family: 'EB Garamond 12', serif;
这是最终的 HTML:
使用的 TeX 文件:
\documentclass{article}
%\usepackage{garamondx}
\usepackage{ebgaramond}
%\usepackage{urw-garamond}
%\usepackage[urw-garamond]{mathdesign}
%\usepackage{cmbright}
% \usepackage{helvet}
\begin{document}
\section{Letters}
\subsection{Valid Letters}
AA Aa aA aa\\
BB Bb bB bb\\
CD Cd cD cd\\
\subsection{Invalid Letters}
FF Ff fF ff\\
FI Fi fI fi\\
\bgroup
\itshape
FF Ff fF ff\\
FI Fi fI fi\\
\scshape
FF Ff fF ff\\
FI Fi fI fi\\
\normalfont
\scshape
FF Ff fF ff\\
FI Fi fI fi\\
\egroup
\section{Strings}
a string of text\\
a fine string of text\\
a definition of an efficient and fine string of text\\
finally, the problem is solved!\\
\end{document}