bohoomil / fontconfig-ultimate

freetype2-infinality run-time settings => infinality compatible fontconfig => infinality-bundle
453 stars 38 forks source link

set parameters through config file(s)? #47

Open RJVB opened 10 years ago

RJVB commented 10 years ago

I just noticed that the synaptic graphical package manager I use from time to time had very off-looking fonts. I traced that down to a very simple reason: it's launched in a script through pkexec, and that tool drops the environment. It does not parse source ~root/.profile, so fontconfig-ultimate finds itself run without any parameters set. I don't know how it handles that situation, but clearly not by setting a reasonable default.

So I wonder, wouldn't it be possible to override the getenv() function in the code by one that reads the corresponding variable/value from file if not set in the environment? I could even contribute a draft, because I wrote exactly such a function ages ago...

bohoomil commented 10 years ago

One of the changes/improvements I've been hoping to see in freetype2-iu is feeding it with fixed default settings when infinality-settings.sh isn't present on the system. This would prevent issues like yours from happening, at least to a certain degree. Basically we may try replacing current hard coded defaults with those from infinality-settings.sh. Of course, those new defaults could be overwritten in the same way we do it now.

Does your solution work in a similar way? I'd really like to try it out.

RJVB commented 10 years ago

On Thursday September 18 2014 09:43:39 bohoomil wrote:

Does your solution work in a similar way? I'd really like to try it out.

Yes, more or less. It works by replacing the standard getenv() (through a C macro, you can see from the code below just how old it is ... K&R ... brrr!) . Doing getenv("FOO") will search in a specific location on disk (for ".env/FOO" to be exact) if FOO doesn't exist in the environment, and then read the value from that file. I used it a lot at some point, because it also allowed me to keep my environment lean. I've copied the code as it exists; you'll see that it even has a mechanism to override an existing FOO with _FOO (I guess I didn't yet know tricks like env FOO=newvalue somecommand at the time). It's just an example, I presume the fallback database will be stored in a appropriate place like under ~/.config/fontconfig.


char Dir[256]= "./.env", *EnvDir= Dir; static char CX_env[256];

/* check if a variable of name exists