2

Wine applications load very slowly on my Kubuntu. It is common knowledge that one should autostart the Wine server to run persistently:

wineserver -p

This significantly reduces the per-program loading time, but it is not enough: on my reasonably modern computer it takes about a second to start a simple wine application after the first time, way more than it should.

Searching for solutions online yielded mainly the answer of oiaohm in this WineHQ Forum question (see also the associated duplicate bug reports here and here). The first issue oiaohm raises is that there are "too many" fonts installed, and that wine producing a very long font list leads to long startup times. It turned out that the font issue really was the reason for Wine's slow startup in my computer. Kubuntu has many fonts installed by default, see, e.g., the wide Noto fonts family. Removing fonts only because of their effect on Wine makes no sense. And even if one wanted to remove some of the fonts, doing so by removing their packages is not always possible due to dependencies. In his/her answer, oiaohm suggested to use a custom fontconfig file, but didn't elaborate.

I am thus looking for some, preferably "natural", solution to this problem. Below, as an answer, is the solution I found. Suggestions for better ones are warmly welcome.

1
  • Please split your contribution into a question and a separate answer. Use the edit button below your question.
    – DK Bose
    May 8, 2020 at 14:04

1 Answer 1

1

The purpose of this answer is to give the full details of the solution of oiaohm mentioned above based on my experience.

Fontconfig is the system-wide font configuration library. See the following man page for explanation on the font configuration customization done below.

man fonts-conf

The idea is to create a custom font configuration and have Wine use it in lieu of the default one. The steps I suggest are as follows:

  1. Find out which fonts are actually required by your Wine programs. A reasonable way to do this is running lsof -p [PID of Wine application] | grep ttf (and ditto with otf) for all Wine applications you use.
  2. Create a custom font configuration directory: mkdir ~/.wine/myfonts
  3. Create a custom font cache directory: mkdir ~/.wine/myfonts-cache
  4. Create a custom font configuration file in the custom font configuration directory. Do so by copying the system's default file: cp /etc/fonts/fonts.conf ~/.wine/myfonts and editing it as follows.
    • In the font directory list, replace all (or most) <dir> elements by ones pointing to the specific directories of the fonts you need (see Step 1). For instance, put <dir>/usr/share/fonts/truetype/unfonts-core</dir>.
    • In the font cache directory list, remove all <cachedir> elements and put only your custom font cache directory: <cachedir>~/.wine/myfonts-cache</cachedir>.
    • Importantly, in both lists remove the elements with the xdg prefix, as those require more steps to customize.
  5. Your custom font configuration file has an <include> element, which, unless changed, contains the value "conf.d". So, create a directory with this name inside your custom font configuration directory, e.g, mkdir ~/.wine/myfonts/conf.d. Then, copy to this directory the additional configuration files residing in the original conf.d directory that are required for the fonts you chose to keep. For example, cp /etc/fonts/conf.d/90-fonts-unfonts-core.conf ~/.wine/myfonts/conf.d.
  6. Environment variable changes: Wine applications should be run with the values of FONTCONFIG_FILE and FONTCONFIG_PATH set to, respectively, your custom font configuration file and custom font configuration directory. For instance, suppose you installed Wine application XYZ. Click the Application Launcher, type XYZ, right click, choose "Edit Application", and in the "Application" tab, change the "Command" field to something like
    env FONTCONFIG_FILE="~/.wine/myfonts/fonts.conf" FONTCONFIG_PATH="~/.wine/myfonts" wine C:\\windows\\command\\start.exe /Unix ~/.wine/dosdevices/c:/users/Public/Start\ Menu/Programs/XYZ.lnk
    
    Alternatively, locate the file XYZ.desktop and change it directly. This should be done for every Wine application. Actually, you only need the environment variables to be set like that the first time a Wine application is run after the Wine server loads.
  7. Generate the font cache for your custom font configuration using the same environment variables. For example:
    export FONTCONFIG_FILE=~/.wine/myfonts/fonts.conf
    export FONTCONFIG_PATH=~/.wine/myfonts
    fc-cache -fv
    
  8. Finally, either reboot or restart the Wine server:
    wineserver -k
    wineserver -p
    

One can check the font list actually processed by Wine in the following registry key. Be sure to run regedit with the required environment variables, or after having run another Wine application with them.

HKEY_CURRENT_USER\Software\Wine\Fonts\Cache

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .