XeTeXTeX fonts and Xetex...

Information and discussion about XeTeX, an alternative for pdfTeX based on e-Tex
Post Reply
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

TeX fonts and Xetex...

Post by meho_r »

Hi,

Actually, I've got two questions (for now ;)) regarding fonts in XeTeX:

1. How to use TeX fonts together with otf and ttf in XeTeX? I want to use mathpazo font with oldstyle figures and small caps for the main text and only on couple of places in my document I will be using some otf and ttf fonts?

2. How to make a command that do this, so I don't have to type all of this when inputing Arabic text:

Code: Select all

{\fontspec[Script=Arabic]{Scheherazade}
\beginR
...some Arabic Text...
\endR
}
Thanks

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Re: TeX fonts and Xetex...

Post by meho_r »

OK, the second one solved. But the first one still remains...
gvanas
Posts: 7
Joined: Thu Jul 16, 2009 11:39 am

TeX fonts and Xetex...

Post by gvanas »

Hello meho_r,

About the font selection when inputting Arabic text:
the second one solved
Actually, I am interested to know how you solved it. Can you help? :)

Thanks!
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

TeX fonts and Xetex...

Post by localghost »

gvanas wrote:[...] Actually, I am interested to know how you solved it. [...]
In case this discussion comes to nothing, the TeX Users Group (TUG) has some useful resources about XeTeX [1]. Among others there's also an entry for ArabXeTeX.

[1] XeTeX - TeX Users Group


Best regards
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

TeX fonts and Xetex...

Post by meho_r »

gvanas wrote:Hello meho_r,

About the font selection when inputting Arabic text:
the second one solved
Actually, I am interested to know how you solved it. Can you help? :)

Thanks!
I apologize for not posting it. The point is in defining a command that contains above code. For example:

Code: Select all

\newcommand{\artxt}[1]{%
{\fontspec[Script=Arabic,Scale=1.22]{Scheherazade}%
{\beginR #1}{\endR}}}
Now simply use \artxt when you need to input arabic text. One way for changing arabic font is simply defining more commands like the one above for every font and name them e.g.: \arashzd for Scheherazade, \araltf for Lateef etc.

The other way is to set the font name as a variable, e.g.

Code: Select all

\newcommand{\artxt}[2][Scheherazade]{%
{\fontspec[Script=Arabic,Scale=1.22]{#1}%
{\beginR #2}{\endR}}}
Now you enter:

Code: Select all

\artxt{Scheherazade}{<some_arabic_text>}
If you omit to enter any name and type only \artxt{<some_arabic_text>}, then Scheherazade will be used (or any other font you define in the second square brackets in the code, instead of "Scheherazade").

I prefer the first approach since the second one requires more typing :-)

I provide a complete example for you with some other tips. Hope this will help:-)

EDIT: I must mention a great help from this community regarding this matter, especially juanjo who practically solved most of the issues I had with arabic in the past. Thanks again :-)
Attachments
arabic.tex
(3.3 KiB) Downloaded 573 times
Last edited by meho_r on Fri Jul 17, 2009 12:33 pm, edited 2 times in total.
gvanas
Posts: 7
Joined: Thu Jul 16, 2009 11:39 am

Re: TeX fonts and Xetex...

Post by gvanas »

Thanks a lot for your answer! This is indeed very helpful. :D

I was wondering if we could go a step further: have XeLaTeX detect automatically the Arabic text without having to type specific commands (and it would select the right font accordingly). Maybe this is asking for too much, but in HTML or in a word processor, one can type a mix of English and Arabic text and the font and directionality are correctly selected.

What do you think?
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

TeX fonts and Xetex...

Post by meho_r »

gvanas wrote:Thanks a lot for your answer! This is indeed very helpful. :D

I was wondering if we could go a step further: have XeLaTeX detect automatically the Arabic text without having to type specific commands (and it would select the right font accordingly). Maybe this is asking for too much, but in HTML or in a word processor, one can type a mix of English and Arabic text and the font and directionality are correctly selected.

What do you think?
I don't think it's possible ATM. On the other side, I don't think this is an issue at all (remember, even for italic or bold text you have to type specific commands). XeLaTeX will pick up default font (which is Scheherazade) for arabic in case you haven't define any, but you still must tell it that it should write from right to left. For more details you may want to study ArabXeTeX Manual.

Best regards,
Meho R.
gvanas
Posts: 7
Joined: Thu Jul 16, 2009 11:39 am

Re: TeX fonts and Xetex...

Post by gvanas »

OK, I agree this isn't much of an issue.

I just wish to explain a little bit why I think it can be useful. Let us take for instance the HTML language or wiki text (when editing a page on Wikipedia). In these two examples, one can input an English text with Arabic words interleaved (or vice-versa) without further markup. The browser will use a bidi algorithm to determine what must be written left-to-right or right-to-left. I think that the preferred directionality of a Unicode character can be found in a table. Likewise, the browser can select a font based on the characters that it encounters.

Supposedly, if I write some kind of converter from HTML or wiki text or whatever to XeLaTeX, I must then require the source text to have proper markup to determine what is in Arabic and what is in English. But HTML or wiki text doesn't need that extra markup.

Much information can be found just by looking at the Unicode characters encountered and selecting whether it is an Arabic or English word can be done automatically. Extra markup means redundancy, which one usually wishes to avoid.

Now I understand that looking at the Unicode characters won't tell you if it is e.g., Arabic, Farsi or Urdu. But maybe this can be set at a higher level, e.g., with a command such as \UseLanguages{English,Farsi}.

Well, these are just some thoughts. ArabXeTeX and XeLaTeX give great results already! ;)
Post Reply