LaTeX forum ⇒ Fonts & Character Setshebrew font with fontspec

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Arieh
Posts: 4
Joined: Wed Aug 23, 2017 3:50 pm

hebrew font with fontspec

Postby Arieh » Thu Aug 24, 2017 2:18 am

I am learning how to use polyglossia and fontspec to write texts in Hebrew, English and possibly other languages. I do not seem to succeed getting the Hebrew font (at this point I do not care which Hebrew font). I tried with other Hebrew fonts as well. I looked at
https://tex.stackexchange.com/questions ... ect=1&lq=1
but this does not seem to work.

I am working on Ubuntu 14.04

Here is a M(N)WE:

[MWE]
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Cardo}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguage{hebrew}
\newfontfamily\hebrewfont[Script=Hebrew]{Cardo}

\begin{document}
This hebrew text is Gen.1:1 from BHS\\
\RL{בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים}\\ % result: misplaced vowels & diacritics
\hebrew{\RL{בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים}}\\ % result: right placed vowels & diacritics
\end{document}
[/MWE]
And here is the message I got:

! fontspec error: "font-not-found"
!
! The font "Cardo" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................
l.3 \setmainfont{Cardo}
%SBL BibLit; Linux Libertine O; Cardo
|'''''''''''''''''''''''''''''''''''''''''''''''
| A font might not be found for many reasons.
| Check the spelling, where the font is installed etc. etc.
|
| When in doubt, ask someone for help!
|...............................................
.................................................
. fontspec info: "no-scripts"
.
. Font Cardo does not contain any OpenType `Script' information.
.................................................
\g_fontspec_family_Cardo_int=\count123
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "Cardo" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................
l.3 \setmainfont{Cardo}
|'''''''''''''''''''''''''''''''''''''''''''''''
| A font might not be found for many reasons.
| Check the spelling, where the font is installed etc. etc.
|
| When in doubt, ask someone for help!
|...............................................
.................................................
. fontspec info: "no-font-shape"
.
. Could not resolve font Cardo/B (it probably doesn't exist).
.................................................
.................................................
. fontspec info: "no-font-shape"
.
. Could not resolve font Cardo/I (it probably doesn't exist).
.................................................
.................................................
. fontspec info: "no-font-shape"
.
. Could not resolve font Cardo/BI (it probably doesn't exist).
.................................................
.................................................
. fontspec info: "defining-font"
.
. Font family 'Cardo(0)' created for font 'Cardo' with options [].
.
. This font family consists of the following shapes:
.
. * 'normal' with NFSS spec.:
. <->"Cardo:"
.................................................
! Font EU1/Cardo(0)/m/n/10=Cardo: at 10.0pt not loadable: Metric (TFM) file or
installed font not found.
<to be read again>
relax
l.3 \setmainfont{Cardo}
I wasn't able to read the size data for this font,
so I will ignore the font specification.
[Wizards can fix TFM files using TFtoPL/PLtoTF.]
You might try inserting a different font spec;
e.g., type `I\font<same font id>=<substitute font name>'.

How do I get the

Tags:

User avatar
thomasb
Posts: 76
Joined: Thu Aug 03, 2017 10:54 am
Location: france

Postby thomasb » Thu Aug 24, 2017 10:15 am

It's working here, what's wrong with you ?
Attachments
minimalHebrew.pdf
(12.69 KiB) Downloaded 13 times

User avatar
Stefan Kottwitz
Site Admin
Posts: 8536
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Thu Aug 24, 2017 11:34 am

Hi Arieh,

welcome to the forum!

Those errors just say that the Cardo font cannot be found, it is probably not installed. you can get it from here:

https://fonts.google.com/specimen/Cardo

I guess it's more an Ubuntu question for now, since you need to find and install a Hebrew font for Ubuntu first. Then we can continue with LaTeX.

Stefan
Site admin

User avatar
Stefan Kottwitz
Site Admin
Posts: 8536
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Thu Aug 24, 2017 11:41 am

You could also install the package texlive-lang-hebrew in addition:

apt-get install texlive-lang-hebrew

Perhaps also

apt-get install texlive-lang-other

Or via software management on Ubuntu, such as Synaptic. I have Ubuntu at home too, to test later, just not now here at work.

Stefan
Site admin

Arieh
Posts: 4
Joined: Wed Aug 23, 2017 3:50 pm

Postby Arieh » Fri Aug 25, 2017 3:41 pm

Thanks to Stefan's suggestions:
- I first installed the package texlive-lang-hebrew by

sudo apt-get install texlive-lang-hebrew

- Then I downloaded the Cardo font using the provided link and installed the files in /home/user/.fonts

- Then I compiled again the same MWE by xelatex, the font was apparently found but it said:

!Latex error: \begin{otherlanguage} on input line 12 ended by \end{document}

Any clue ?

User avatar
Stefan Kottwitz
Site Admin
Posts: 8536
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Fri Aug 25, 2017 3:46 pm

You need to have an \end{otherlanguage},

Stefan
Site admin

User avatar
thomasb
Posts: 76
Joined: Thu Aug 03, 2017 10:54 am
Location: france

Postby thomasb » Fri Aug 25, 2017 3:59 pm

Here :
    1. \documentclass{article}
    2. \usepackage{fontspec}
    3. \setmainfont{Cardo}
    4. \usepackage{polyglossia}
    5. \setdefaultlanguage{english}
    6. \setotherlanguage{hebrew}
    7. \newfontfamily\hebrewfont[Script=Hebrew]{Cardo}
    8. \begin{document}
    9. This hebrew text is Gen.1:1 from BHS\\
    10. \RL{בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים}\\ % result: misplaced vowels & diacritics
    11. \begin{hebrew}
    12. \RL{בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים}
    13. \end{hebrew}\\ % result: right placed vowels & diacritics
    14. Text again.
    15. \end{document}

Arieh
Posts: 4
Joined: Wed Aug 23, 2017 3:50 pm

Postby Arieh » Sun Aug 27, 2017 9:30 am

Many thanks to Stefan and thomasb.
So I understand that you have to either use \end{otherlanguage} or finish the document by using the main language of the document (which sounds logical).


Return to “Fonts & Character Sets”

Who is online

Users browsing this forum: No registered users and 2 guests