How to include .otf fonts in XeLaTeX [closed]
The code posted below is correct. I had corrupted font files, this has nothing to do with TeX.
Original Question
I am trying to use Han Sans fonts in my XeLaTeX document installed via TeXLive2018. I downloaded the *.otf files and moved them to texmf-local/font/opentype/public/SourceHanSansCN/ (for chinese) and updated the file database.
Now I tried to use the fonts via fontspec like the following example:
documentclass{article}
usepackage{fontspec}
setmainfont[
Path={C:/portable_xelatex/texmf-local/fonts/opentype/public/SourceHanSansCN/}
]{SourceHanSansCN-Normal.otf}
begin{document}
Test
end{document}
This did not work.
I read about changing setmainfont[...]{...} to setmainfont{...}[...] which didn't change anything (like expected). Also I removed the Path. I added and removed the trailling slash. I added and removed the curly brackets around the path. I changed the underscore to _. I removed the file extension. Nothing of this worked.
I always get the errors Package fontspec Error: The font "SourceHanSansCN-Normal" cannot be found. and Font TU/SourceHanSansCN-Normal.otf(0)/m/n/10=[SourceHanSansCN-Normal.otf]/OT at 10.0pt not loadable: Metric (TFM) file or installed font not found. ^^I.
After looking around in the web even more I found the texmf-var/fonts/conf/fonts.conf. I added my directory (C:/portable_xelatex/texmf-local/fonts/opentype/) to the xml file as a directory. The errors are still the same.
I also tried to put the fonts in the same directory as the .tex file. Also there I get the same error.
At last I read about fc-list. I didn't really understand the help text. I didn't get what output to expect. For me fc-list simply returns nothing. I was expecting to see all the installed fonts. But as I said I am not even sure if that is the expected output.
What am I doing wrong?
PS: I am trying to set up a portable installation which should run on linux too. If it is possbible I would like to include relative paths only. I also do not want my local fonts/ directory to be used. (If it is used it doesn't matter but the compilation should not depend on the usage of the local fonts.)
fonts xetex fontspec
closed as unclear what you're asking by Keks Dose, Stefan Pinnow, Raaja, ferahfeza, Marijn Feb 7 at 11:43
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
The code posted below is correct. I had corrupted font files, this has nothing to do with TeX.
Original Question
I am trying to use Han Sans fonts in my XeLaTeX document installed via TeXLive2018. I downloaded the *.otf files and moved them to texmf-local/font/opentype/public/SourceHanSansCN/ (for chinese) and updated the file database.
Now I tried to use the fonts via fontspec like the following example:
documentclass{article}
usepackage{fontspec}
setmainfont[
Path={C:/portable_xelatex/texmf-local/fonts/opentype/public/SourceHanSansCN/}
]{SourceHanSansCN-Normal.otf}
begin{document}
Test
end{document}
This did not work.
I read about changing setmainfont[...]{...} to setmainfont{...}[...] which didn't change anything (like expected). Also I removed the Path. I added and removed the trailling slash. I added and removed the curly brackets around the path. I changed the underscore to _. I removed the file extension. Nothing of this worked.
I always get the errors Package fontspec Error: The font "SourceHanSansCN-Normal" cannot be found. and Font TU/SourceHanSansCN-Normal.otf(0)/m/n/10=[SourceHanSansCN-Normal.otf]/OT at 10.0pt not loadable: Metric (TFM) file or installed font not found. ^^I.
After looking around in the web even more I found the texmf-var/fonts/conf/fonts.conf. I added my directory (C:/portable_xelatex/texmf-local/fonts/opentype/) to the xml file as a directory. The errors are still the same.
I also tried to put the fonts in the same directory as the .tex file. Also there I get the same error.
At last I read about fc-list. I didn't really understand the help text. I didn't get what output to expect. For me fc-list simply returns nothing. I was expecting to see all the installed fonts. But as I said I am not even sure if that is the expected output.
What am I doing wrong?
PS: I am trying to set up a portable installation which should run on linux too. If it is possbible I would like to include relative paths only. I also do not want my local fonts/ directory to be used. (If it is used it doesn't matter but the compilation should not depend on the usage of the local fonts.)
fonts xetex fontspec
closed as unclear what you're asking by Keks Dose, Stefan Pinnow, Raaja, ferahfeza, Marijn Feb 7 at 11:43
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
1
Simplysetmainfont{SourceHanSansCN-Normal.otf}should work - assuming that the name is correct (correctly cased ...), and that you perhaps need to runmktexlsrfirst.
– Ulrike Fischer
Feb 7 at 10:14
Thank your for your answer. This does not work. I copied the file name to be sure that it is the exact same. I also ranmktexlsrbut this also didn't work.
– miile7
Feb 7 at 10:18
Ok, I found it out. It was me all alone. I don't know why but somehow the font files were corrupted. I downloaded them again directly via the browser and now it is working. @UlrikeFischer Thank you for your answer and sorry for my question. Can I close it somehow?
– miile7
Feb 7 at 10:36
add a comment |
The code posted below is correct. I had corrupted font files, this has nothing to do with TeX.
Original Question
I am trying to use Han Sans fonts in my XeLaTeX document installed via TeXLive2018. I downloaded the *.otf files and moved them to texmf-local/font/opentype/public/SourceHanSansCN/ (for chinese) and updated the file database.
Now I tried to use the fonts via fontspec like the following example:
documentclass{article}
usepackage{fontspec}
setmainfont[
Path={C:/portable_xelatex/texmf-local/fonts/opentype/public/SourceHanSansCN/}
]{SourceHanSansCN-Normal.otf}
begin{document}
Test
end{document}
This did not work.
I read about changing setmainfont[...]{...} to setmainfont{...}[...] which didn't change anything (like expected). Also I removed the Path. I added and removed the trailling slash. I added and removed the curly brackets around the path. I changed the underscore to _. I removed the file extension. Nothing of this worked.
I always get the errors Package fontspec Error: The font "SourceHanSansCN-Normal" cannot be found. and Font TU/SourceHanSansCN-Normal.otf(0)/m/n/10=[SourceHanSansCN-Normal.otf]/OT at 10.0pt not loadable: Metric (TFM) file or installed font not found. ^^I.
After looking around in the web even more I found the texmf-var/fonts/conf/fonts.conf. I added my directory (C:/portable_xelatex/texmf-local/fonts/opentype/) to the xml file as a directory. The errors are still the same.
I also tried to put the fonts in the same directory as the .tex file. Also there I get the same error.
At last I read about fc-list. I didn't really understand the help text. I didn't get what output to expect. For me fc-list simply returns nothing. I was expecting to see all the installed fonts. But as I said I am not even sure if that is the expected output.
What am I doing wrong?
PS: I am trying to set up a portable installation which should run on linux too. If it is possbible I would like to include relative paths only. I also do not want my local fonts/ directory to be used. (If it is used it doesn't matter but the compilation should not depend on the usage of the local fonts.)
fonts xetex fontspec
The code posted below is correct. I had corrupted font files, this has nothing to do with TeX.
Original Question
I am trying to use Han Sans fonts in my XeLaTeX document installed via TeXLive2018. I downloaded the *.otf files and moved them to texmf-local/font/opentype/public/SourceHanSansCN/ (for chinese) and updated the file database.
Now I tried to use the fonts via fontspec like the following example:
documentclass{article}
usepackage{fontspec}
setmainfont[
Path={C:/portable_xelatex/texmf-local/fonts/opentype/public/SourceHanSansCN/}
]{SourceHanSansCN-Normal.otf}
begin{document}
Test
end{document}
This did not work.
I read about changing setmainfont[...]{...} to setmainfont{...}[...] which didn't change anything (like expected). Also I removed the Path. I added and removed the trailling slash. I added and removed the curly brackets around the path. I changed the underscore to _. I removed the file extension. Nothing of this worked.
I always get the errors Package fontspec Error: The font "SourceHanSansCN-Normal" cannot be found. and Font TU/SourceHanSansCN-Normal.otf(0)/m/n/10=[SourceHanSansCN-Normal.otf]/OT at 10.0pt not loadable: Metric (TFM) file or installed font not found. ^^I.
After looking around in the web even more I found the texmf-var/fonts/conf/fonts.conf. I added my directory (C:/portable_xelatex/texmf-local/fonts/opentype/) to the xml file as a directory. The errors are still the same.
I also tried to put the fonts in the same directory as the .tex file. Also there I get the same error.
At last I read about fc-list. I didn't really understand the help text. I didn't get what output to expect. For me fc-list simply returns nothing. I was expecting to see all the installed fonts. But as I said I am not even sure if that is the expected output.
What am I doing wrong?
PS: I am trying to set up a portable installation which should run on linux too. If it is possbible I would like to include relative paths only. I also do not want my local fonts/ directory to be used. (If it is used it doesn't matter but the compilation should not depend on the usage of the local fonts.)
fonts xetex fontspec
fonts xetex fontspec
edited Feb 7 at 14:13
miile7
asked Feb 7 at 10:06
miile7miile7
346
346
closed as unclear what you're asking by Keks Dose, Stefan Pinnow, Raaja, ferahfeza, Marijn Feb 7 at 11:43
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by Keks Dose, Stefan Pinnow, Raaja, ferahfeza, Marijn Feb 7 at 11:43
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
1
Simplysetmainfont{SourceHanSansCN-Normal.otf}should work - assuming that the name is correct (correctly cased ...), and that you perhaps need to runmktexlsrfirst.
– Ulrike Fischer
Feb 7 at 10:14
Thank your for your answer. This does not work. I copied the file name to be sure that it is the exact same. I also ranmktexlsrbut this also didn't work.
– miile7
Feb 7 at 10:18
Ok, I found it out. It was me all alone. I don't know why but somehow the font files were corrupted. I downloaded them again directly via the browser and now it is working. @UlrikeFischer Thank you for your answer and sorry for my question. Can I close it somehow?
– miile7
Feb 7 at 10:36
add a comment |
1
Simplysetmainfont{SourceHanSansCN-Normal.otf}should work - assuming that the name is correct (correctly cased ...), and that you perhaps need to runmktexlsrfirst.
– Ulrike Fischer
Feb 7 at 10:14
Thank your for your answer. This does not work. I copied the file name to be sure that it is the exact same. I also ranmktexlsrbut this also didn't work.
– miile7
Feb 7 at 10:18
Ok, I found it out. It was me all alone. I don't know why but somehow the font files were corrupted. I downloaded them again directly via the browser and now it is working. @UlrikeFischer Thank you for your answer and sorry for my question. Can I close it somehow?
– miile7
Feb 7 at 10:36
1
1
Simply
setmainfont{SourceHanSansCN-Normal.otf} should work - assuming that the name is correct (correctly cased ...), and that you perhaps need to run mktexlsr first.– Ulrike Fischer
Feb 7 at 10:14
Simply
setmainfont{SourceHanSansCN-Normal.otf} should work - assuming that the name is correct (correctly cased ...), and that you perhaps need to run mktexlsr first.– Ulrike Fischer
Feb 7 at 10:14
Thank your for your answer. This does not work. I copied the file name to be sure that it is the exact same. I also ran
mktexlsr but this also didn't work.– miile7
Feb 7 at 10:18
Thank your for your answer. This does not work. I copied the file name to be sure that it is the exact same. I also ran
mktexlsr but this also didn't work.– miile7
Feb 7 at 10:18
Ok, I found it out. It was me all alone. I don't know why but somehow the font files were corrupted. I downloaded them again directly via the browser and now it is working. @UlrikeFischer Thank you for your answer and sorry for my question. Can I close it somehow?
– miile7
Feb 7 at 10:36
Ok, I found it out. It was me all alone. I don't know why but somehow the font files were corrupted. I downloaded them again directly via the browser and now it is working. @UlrikeFischer Thank you for your answer and sorry for my question. Can I close it somehow?
– miile7
Feb 7 at 10:36
add a comment |
0
active
oldest
votes
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
1
Simply
setmainfont{SourceHanSansCN-Normal.otf}should work - assuming that the name is correct (correctly cased ...), and that you perhaps need to runmktexlsrfirst.– Ulrike Fischer
Feb 7 at 10:14
Thank your for your answer. This does not work. I copied the file name to be sure that it is the exact same. I also ran
mktexlsrbut this also didn't work.– miile7
Feb 7 at 10:18
Ok, I found it out. It was me all alone. I don't know why but somehow the font files were corrupted. I downloaded them again directly via the browser and now it is working. @UlrikeFischer Thank you for your answer and sorry for my question. Can I close it somehow?
– miile7
Feb 7 at 10:36