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.

I use fontenc, fontspec and xelatex to load the custom font.

\usepackage[T1]{fontenc}  
\usepackage{fontspec}  
\usepackage[utf8]{inputenc}  
\usepackage{xunicode}  
\setmainfont[Mapping=Tex-Text]{Warnock Pro}  

But I have some problem about choosing char by using \char. The \char"201C is different than just type ``. `` displays correctly as what it is in glyphs. But \char"201C is very similar to \textquotedblleft (but a little bit different). That is, \char"201C is not belong to typefaces "Warnock Pro". Also, if I just type “, it is also similar to \textquotedblleft.

How to output a char by specifying \char"xxx of custom loaded font?

That is, if possible, I don't want to use [Mapping=Tex-Text], and just want to type quote, or other char, such as α directly. Most chars can be displayed right. But some of them (especially quoted-related char) can't be showed right.

--UPDATE Some chars, such as ‡ or †, it won't be displayed no matter I type † or \char"2020. (no matter I use Mapping=Tex-Text or not). Do I need to add some other parameters?

--UPDATE 2 I found out the problems happends due to I use the package \usepackage{xeCJK}. However, I need it to set up English/Forein language seperately. I seems it would make \char"xxx displays the font belongs to \setCJKmainfont.

By xeCJK, the char\"201C should use non-CJK font. But it seems it still use CJK-font now (even though I use \xeCJKsetcharclass{"2000}{"2FFF}{0}). But if I turn of xeCJK (\makexeCJKinactive then it displays correctly)

--UPDATE 3 I add the following testing code. It seems xeCJK can't work correctly?

\documentclass[a4paper,10pt]{article}
\usepackage{xeCJK}
\setCJKromanfont{Verdana}
\setromanfont{Times New Roman}
\begin{document}
--\char"201C --``--“--‘‘--\char"60--\textquoteleft\\
%output: verdana--times("60)--verdana--verdana--times--verdana
\setromanfont[Mapping=tex-text]{Times New Roman}
--\char"201C --``--“--‘‘ --\char"60--\textquoteleft\\
% output: verdana, Times ("201C)--verdana--verdana--times("2018)--verdana
\xeCJKsetcharclass{"0}{"2FFF}{0} %same
--\char"201C --``--“--‘‘ --\char"60--\textquoteleft\\
\xeCJKsetcharclass{"0}{"2FFF}{1} %same
--\char"201C --``--“--‘‘ --\char"60--\textquoteleft\\
\makexeCJKinactive %all in roman
--\char"201C --``--“--‘‘ --\char"60--\textquoteleft\\
\end{document}

Thank you!

share|improve this question
    
To be clear: you want to remap the character associated with this font to a character from a different font? –  Charles Stewart Apr 7 '11 at 6:02
    
Sorry for not clear. I mean, if doublequote mark in glyph is char"201C, then, type \char"201C is different than just typing ``. That is, `` is correct. \char"201C displays double quote mark, but this mark is not belong to Warnot Pro's font. –  Kuang-Li Huang Apr 7 '11 at 6:21
    
Would changing the " character in the input stream to be an active character that expands to `` (or, maybe, '', depending on whether the next char is a space) be an option? –  Charles Stewart Apr 7 '11 at 6:25
    
The problem bothers me because, when I use \char"xx, I will get the right char with wrong font. The problem is not a really problem, in fact. But for single/double quote, the different char make the text looked inconsistency sometimes. –  Kuang-Li Huang Apr 7 '11 at 6:47
    
@Kuang-LiHuang: You should update your xeCJK package. See also xeCJK messes with punctuation and Linebreak and \enquote. –  Leo Liu Feb 12 '12 at 5:55
add comment

1 Answer 1

Never use inputenc with XeLaTeX or LuaLaTeX. Never.

The option is actually Mapping=tex-text (but the uppercase seems to work too), or better use Ligatures=TeX, as this will work with lualatex too.

I don't have your font but \char"201C should work. If it doesn't then either your are doing something curious in the rest of your document, or the font is corrupt, or you have more then one version of the font. Compile this document on the command line with `xelatex --output-driver="xdvipdfmx -vv" and then check in the terminal and in the log-file the pathes of the fonts.

\XeTeXtracingfonts=1

\documentclass{article}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{Warnock Pro}
\begin{document}
`` ^^^^201c \char"201C
\end{document}
share|improve this answer
    
Thanks. I remove inputenc. However, the output is still something wrong. I can get the correct font by using [Mapping=Tex-Text]+`` only. [Mapping=Tex-Text]+\char"201C will get a double quote mark, but not belong to Warnock Pro. If I remove [Mapping=Tex-Text] (Warnock Pro doesn't provide Ligatures=TeX), then `` won't get double quote of font Warnock Pro (it looks like the font cmr10 or others). The font is correct (if I remove [Mapping] then it displays right). Thank you –  Kuang-Li Huang Apr 7 '11 at 14:27
    
Compile my example (exactly this example!) and put the pdf + the log-file somewhere on the net for inspection. –  Ulrike Fischer Apr 7 '11 at 14:31
    
@Ulrike Thank you. I got the problem, and update my question. Thank you so much! –  Kuang-Li Huang Apr 7 '11 at 22:03
2  
Don't send code snippets. I have neither the time nor the will to build a test case for your problem. Make a small, complete example that demonstrates the problem. Try to use fonts generally available. Use only ASCII input, input the problematic chars like I did it above with ^^^^ and \char. –  Ulrike Fischer Apr 8 '11 at 7:45
    
@Ulrike Sorry for bothering you. I put a small example and updated my question again. In my openion, all single/double quote etc. should be regarded as a non-CJK font. But only the last one line (inactive xeCJK) shows the correct output. Thank you very much! –  Kuang-Li Huang Apr 9 '11 at 6:04
show 1 more 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.