4

After upgrading my texlive, xepersian 21.9 can not load the font which is loaded without any problem by the older version 21.7.

My code is:

 \documentclass{article}
 \usepackage{xepersian}
 \settextfont[Scale=1.44]{Amiri}
 \setlatintextfont[Scale=1.44]{Psychedelia HM}
 \pagestyle{empty}
 \begin{document}
  فانت سایکیدلیا اچ‌ام. \lr{Psychedelia HM font.}
 \end{document}

and the error I get is:

 (c:/texlive/2018/texmf-dist/tex/xelatex/xepersian/loadingorder
 -xepersian.def)
 (c:/texlive/2018/texmf-dist/tex/xelatex/xepersian/footnote-xep
 ersian.def)
 (c:/texlive/2018/texmf-dist/tex/xelatex/xepersian/article-xepe
 rsian.def) (./fontspec-xepersian.def))

 ! Package xepersian Error:  The font "Psychedelia HM" cannot be loaded by                the
 (xepersian)                xepersian package. 

 For immediate help type H <return>.
  ...                                              

 l.5 \pagestyle
               {empty}
 ? h

  Select another font and rerun "xelatex". 

 ?

If this is a bug in xepersian 21.9, how can I fix it?

Please note that the file ./fontspec-xepersian.def is exactly the same as c:/texlive/2018/texmf-dist/tex/xelatex/xepersian/fontspec-xepersian.def which is one of the xepersian's configuration files. I copied the file to my working directory to fix the problem, but I couldn't. The contents of fontspec-xepersian.def is as follows:

%%
%% This is file `fontspec-xepersian.def',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% xepersian.dtx  (with options: `table,fontspec-xepersian.def')
%% 
%%   __________________________________________________
%%   Copyright (c) 2008--2018  Vafa Khalighi <persian-tex@tug.org>
%% 
%%   It may be distributed and/or modified under the LaTeX Project Public License,
%%   version 1.3c or higher (your choice). The latest version of
%%   this license is at: http://www.latex-project.org/lppl.txt
%% 
%%   This work is “author-maintained” (as per LPPL maintenance status)
%%   by Vafa Khalighi.
%% 
%% 
%% \CheckSum{10904}
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
\ProvidesFile{fontspec-xepersian.def}[2018/11/26 v0.2 fontspec changes]
\ExplSyntaxOn
\cs_new:Npn \__xepersian_error:nx    { \msg_error:nnx    {xepersian} }
\char_set_catcode_space:n {32}
\cs_new:Nn \__xepersian_msg_new:nnnn
  { \msg_new:nnxx {#1} {#2} { \tl_trim_spaces:n {#3} } { \tl_trim_spaces:n {#4} } }
\__xepersian_msg_new:nnnn {xepersian} {font-cannot-be-loaded}
 {
  The font "#1" cannot be loaded by the xepersian package.
 }
 {
  Select another font and rerun "xelatex".
 }
\char_set_catcode_ignore:n {32}
\prg_new_conditional:Nnn \__xepersian_font_if_cannot_be_loaded:Nn {p,TF,T,F}
  {
    \str_if_in:NnTF { #1 } { #2 }
    {
      \prg_return_true:
    }
    {
      \prg_return_false:
    }
  }
\cs_undefine:N \__fontspec_load_font:
\cs_new:Nn \__fontspec_load_font:
 {
  \__fontspec_primitive_font_set:Nnn \l_fontspec_font
     { \__fontspec_construct_font_call:nn { \l__fontspec_fontname_up_tl } {} } {\f@size pt}
  \__fontspec_primitive_font_if_null:NT \l_fontspec_font { \__fontspec_error:nx {font-not-found} {\l__fontspec_fontname_up_tl} }
  \__xepersian_font_if_cannot_be_loaded:NnT \l__fontspec_fontname_up_tl { HM }
  {
    \__xepersian_error:nx {font-cannot-be-loaded} {\l__fontspec_fontname_up_tl}
    \cs_gset_eq:NN \l__fontspec_fontname_up_tl \tex_nullfont:D
  }
  \__fontspec_set_font_type:N \l_fontspec_font
  \__fontspec_primitive_font_gset:Nnn \l_fontspec_font
     { \__fontspec_construct_font_call:nn { \l__fontspec_fontname_up_tl } {} } {\f@size pt}
  \l_fontspec_font % this is necessary for LuaLaTeX to check the scripts properly
 }
\cs_undefine:N \__fontspec_load_fontname:n
\cs_new:Nn \__fontspec_load_fontname:n
 {
    \__fontspec_load_external_fontoptions:Nn \l_fontspec_fontname_tl {#1}
    \prop_get:NVNF \g__fontspec_fontopts_prop \l_fontspec_fontname_tl \l__fontspec_fontopts_clist
     { \clist_clear:N \l__fontspec_fontopts_clist }
    \keys_set_groups:nnV {fontspec/fontname} {getfontname} \l__fontspec_fontopts_clist
    \__fontspec_primitive_font_set:Nnn \l_fontspec_font { \__fontspec_construct_font_call:nn {\l_fontspec_fontname_tl} {} } {\f@size pt}
    \__fontspec_primitive_font_if_null:NT \l_fontspec_font { \__fontspec_error:nx {font-not-found} {#1} }
  \__xepersian_font_if_cannot_be_loaded:NnT #1 { HM }
  {
    \__xepersian_error:nx {font-cannot-be-loaded} {#1}
    \cs_gset_eq:NN \l_fontspec_font \tex_nullfont:D
  }
 }
\ExplSyntaxOff
\endinput
%%
%% End of file `fontspec-xepersian.def'.
  • note that you have a local configuration file ./fontspec-xepersian.def so you should show the contents of that, and also say where that ffont comes from, otherwise no one can run your test – David Carlisle Nov 29 '18 at 7:59
  • also you tagged this pdftex, but you are presumably using xetex – David Carlisle Nov 29 '18 at 8:45
  • Do you have also problems with fonts available in texlive? E.g. TeX Gyre Heros? – Ulrike Fischer Nov 29 '18 at 9:06
  • @David Carlisle, I edited both the tags and the question. I also added the contents of the file ./fontspec-xepersian.def. The font "Psychedelia HM" is in the systems' font directory and as I said my code works fine with xepersian-21.7 but fails with xepersian-21.9. – Tisha Shusho Nov 29 '18 at 9:32
  • 2
    try \usepackage[fontsloadable]{xepersian} – David Carlisle Nov 29 '18 at 10:52
7

Unfortunately the package explicitly prevents loading fonts with names that contain the string HM

You can use

\usepackage[fontsloadable]{xepersian}

to disable this or it would not be unreasonable to make a local copy of the package and replace the two instances of HM by anything else, eg ZZZZZ to disable that feature.

| improve this answer | |
  • Thanks, as you said in your previous comment, setting fontsloadable=true in xepersion.sty works fine too. – Tisha Shusho Dec 1 '18 at 17:59
  • To reject all of the fonts that contain a particular string in their name is the most irresponsible design decision I have ever seen (for whatever reason the xepersian team decided to do that) – nima Jan 27 at 8:02
  • @nima I'm only the messenger.. (but yes, I wouldn't disagree) – David Carlisle Jan 27 at 8:11
  • @DavidCarlisle Yes of course :) You don't expect developers in charge of software with such a large user base to make these kinds of unprofessional decisions. It took me two days to find your solution because I didn't even think the problem would be something like this. – nima Jan 27 at 12:32
  • 1
    The problem seems to be fixed in xepersian 22.8. A huge thanks to David. – Tisha Shusho Feb 2 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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