Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In continue with this question: Producing html for Chinese documents with Tex4Ht

Tex4Ht requires .htf fonts for converting Chinese documents. I've managed to make all the unisong*.htf fonts work thanks to the answer to the previous question, but the default TexLive 2011 installation doesn't seem to contain htf fonts for simhei, simkai, and all other Chinese fonts. Is there a place where I can download them, or how do I generate them if I can?

share|improve this question
    
There are .htf files for GBK encoding installed in TeX Live. So you can change the document encoding to use GBK font mappings. –  Leo Liu Mar 18 '12 at 7:10
add comment

2 Answers

up vote 3 down vote accepted

I just found the alias htf files, which makes the business of reusing the utf8song*.htf files (contributed by CTeX forumers, now shipped with tex4ht) easier.

After an initial (unsuccessful) run of tex4ht, you'd notice the errors messages like

--- warning --- Couldn't find font 'unihei7a.htf' (char codes: 0--255)

So you know you will need to map unihei*.htf files to use utf8song*.htf instead.

For each utf8song*.htf file in %TEX4HT%/ht-fonts/unicode/cjk/utf8/, create a file unihei*.htf that contains the single line .utf8song* .

The following Bash script will generate new alias unihei*.htf files from utf8song*.htf:

for file in *.htf; do alias_name=${file/utf8song/unihei}; sudo echo .${file%.htf} > $alias_name; done;

You can leave the new files in %TEX4HT%/ht-fonts/unicode/cjk/utf8/, or move them to %TEX4HT%/ht-fonts/alias/cjk/utf8/ for tidier housekeeping.

(Again, remember to check that tex4ht.dir in %TEX4HT%/tex4ht/base/unix/tex4ht.env is replaced with the correct actual path.)

Then run

htlatex test.tex "xhtml,charset=utf-8,NoFonts,fonts" " -cunihtf -utf8"

(The NoFonts directive eliminates the verbose <span>s around each CJK character. The fonts directive would put a <span> for things like \textbf, \emph with the appropriate classes, so that you can style them with CSS as you may wish.)

share|improve this answer
    
Works again! With this method I'm using utf8song all the way long, but at least the text is properly displayed. Thanks! –  Wang Dingwei Mar 18 '12 at 12:34
1  
@WangDingwei Even for English, by default all the text will be displayed in Times New Roman (or whatever the browser's default font is) :). You could still use CSS to style the fonts, e.g. .sectionHead, .textbf {font-family:黑体;} .emph {font-family:楷体;} . Note that you need to have the fonts directive when running htlatex to get the textbf, emph etc class names. (I've updated my answer accordingly.) –  LianTze Lim Mar 18 '12 at 15:36
add comment

To produce .htf files for Chinese UTF-8 fonts, you can use the script described in CTeX forum.

BTW, why not search or ask the question in Chinese forums?

share|improve this answer
    
Thanks. Actually I did see that post from the CTex BBS, but seeing it come from almost 4 years ago, I wonder if there's anything new to it. I will try ask in the CTex forum if I have more questions :) –  Wang Dingwei Mar 18 '12 at 11:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.