jwilk-archive / pdf2djvu

PDF to DjVu converter
GNU General Public License v2.0
94 stars 17 forks source link

Windows: generating font cache is slow (apparent hang on first run) #135

Open fair2003 opened 5 years ago

fair2003 commented 5 years ago

On my computer with Windows 10, pdf2djvu only works in version 8.0 or lower. I do not know why.

jwilk commented 5 years ago

What do you mean exactly by “does not work”? What are the symptoms?

I'm afraid I don't have access to a Windows 10 machine at the moment to try it out myself. ☹

fair2003 commented 5 years ago

It shows only:

C:\pdf2djvu_0.9.12\pdf2djvu -o 001.djvu 001.pdf 001.pdf:

and nothing else happens.

If I use pdf2djvu_0.8 or lower, everything works fine.

I noticed that when after some time I back to version 9.12, it works too. So newer versions work, but only after some time. At the beginning, something is stuttering. Maybe it is related to permissions in Windows 10?

jwilk commented 5 years ago

I've observed similar behavior on a Windows 7 machine.

I think this is what's going on:

1) fontconfig takes very long to build the font cache. This makes it look like the conversion hanged on the first page.

2) Once the cache is built, further conversions proceed without extra delay.

fontconfig stores the font cache in:

C:\Users\username\AppData\Local\fontconfig\cache

@fair2003, could you delete this directory (or rename is to something else) and see if this makes the apparent hang re-appear?

fair2003 commented 5 years ago

Sorry, I do not have such directory on Windows 10: C:\Users\username\AppData\Local\fontconfig\

jwilk commented 5 years ago

Hmm, I guess the application data directory is somewhere else on your system. The location of this directory should in the LOCALAPPDATA environment variable. So you can do this: open file explorer, type %LOCALAPPDATA%\fontconfig in the location bar and press enter.

fair2003 commented 5 years ago

I recently reinstalled the system and that is why I did not have this directory. After running pdf2djvu the directory was created. Yes, you are right. Once the cache is built, further conversions proceed without extra delay.

jwilk commented 2 years ago

Possible work-around: remove the line

<dir>WINDOWSFONTDIR</dir>

from etc\fonts\fonts.conf. This means pdf2djvu won't use system fonts, but hopefully that shouldn't matter most of the time.