Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSError: Could not locate the file 'cmr10'. #7

Closed
riku opened this issue Aug 8, 2019 · 3 comments
Closed

OSError: Could not locate the file 'cmr10'. #7

riku opened this issue Aug 8, 2019 · 3 comments

Comments

@riku
Copy link

riku commented Aug 8, 2019

When I use

text.set(text.UnicodeEngine)

got error

Traceback (most recent call last):
  File "d:/MyFiles/LearnPython/pyx-unicode.py", line 3, in <module>
    text.set(text.UnicodeEngine)
  File "C:\Python36-32bit\lib\site-packages\pyx\text.py", line 1814, in set
    defaulttextengine = engine(*args, **kwargs)
  File "C:\Python36-32bit\lib\site-packages\pyx\text.py", line 1708, in __init__
    with config.open(fontname, [config.format.type1]) as f:
    raise IOError("Could not locate the file '%s'." % filename)
OSError: Could not locate the file 'cmr10'.

How to fix it?

@riku riku changed the title Get error OSError: Could not locate the file 'cmr10'. OSError: Could not locate the file 'cmr10'. Aug 8, 2019
@wobsta
Copy link
Contributor

wobsta commented Aug 9, 2019

You need to take care of having the Type 1 fonts and PyX knowing where to find it. You can, for example, do the following (the instructions are for unix-like systems; it can be done similarly on Windows as well, but the position of the pyxrc is different and you need to generate an ls-R file somehow, depending on what you have available on your system):

  1. Download the amsfonts from http://www.ams.org/publications/authors/tex/amsfonts and extract it somewhere on your file system.

  2. In the directory where you just extracted the amsfonts, run ls -R > ls-R to create a file index.

  3. Create a .pyxrc in your home directory with the following content:

[filelocator]
methods = local internal ls-R
ls-R = /<the full path of the diretory you extracted the amsfonts zip file>/ls-R

That's it, it will work now.

@wobsta wobsta closed this as completed Aug 9, 2019
@wobsta
Copy link
Contributor

wobsta commented Aug 10, 2019

Note that you can skip step 2 if you use the recursivedir locator and use the item name recursivedir to list the path to be searched for pfb and afm files. However, this results in the directory tree being crawled (and cached) each time. You could list several subdirctories and thus deeper into the directory structure to prevent PyX from reading directories, where nothing will be found anyway ...

@djnugent
Copy link

Script that does it for you. Note: this will blow out any existing .pyxrc file

mkdir ~/amsfonts
cd ~/amsfonts
wget http://mirrors.ctan.org/install/fonts/amsfonts.tds.zip
unzip amsfonts.tds.zip
ls -R > ls-R
echo "[filelocator]" > ~/.pyxrc
echo "methods = local internal ls-R" >> ~/.pyxrc
echo "ls-R = ${HOME}/amsfonts/ls-R" >> ~/.pyxrc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants