Fonts & Character Setshebrew font with fontspec

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

hebrew font with fontspec

Post by Arieh »

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:

Infominimal working example
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

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
thomasb
Posts: 134
Joined: Thu Aug 03, 2017 10:54 am

hebrew font with fontspec

Post by thomasb »

It's working here, what's wrong with you ?
Attachments
minimalHebrew.pdf
(12.69 KiB) Downloaded 478 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

hebrew font with fontspec

Post by Stefan Kottwitz »

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
LaTeX.org admin
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

hebrew font with fontspec

Post by Stefan Kottwitz »

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
LaTeX.org admin
Arieh
Posts: 4
Joined: Wed Aug 23, 2017 3:50 pm

hebrew font with fontspec

Post by Arieh »

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: 10290
Joined: Mon Mar 10, 2008 9:44 pm

hebrew font with fontspec

Post by Stefan Kottwitz »

You need to have an \end{otherlanguage},

Stefan
LaTeX.org admin
thomasb
Posts: 134
Joined: Thu Aug 03, 2017 10:54 am

hebrew font with fontspec

Post by thomasb »

Here :
  • Code: Select all

    \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
    \begin{hebrew}
      \RL{בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים}
    \end{hebrew}\\ % result: right placed vowels & diacritics 
    Text again.
    \end{document}
Arieh
Posts: 4
Joined: Wed Aug 23, 2017 3:50 pm

hebrew font with fontspec

Post by Arieh »

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).
Post Reply