Is it possible to change wine fonts by bash script?

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
Bamm
Level 4
Level 4
Posts: 136
Joined: Thu May 22, 2008 3:18 am

Is it possible to change wine fonts by bash script?

Post by Bamm »

Hi, I am aware that the wine fonts can be changed manually via the winecfg dialog. My question is, can the fonts used in a prefix be changed via a command line? If not, is it possible to write a script (bash, perl, etc.) that will do this? Thanks for any answers.
leniviy
Level 2
Level 2
Posts: 39
Joined: Sat Jun 27, 2009 3:19 pm

Re: Is it possible to change wine fonts by bash script?

Post by leniviy »

Such settings are usually stored in registry. Change some font settings in winecfg and compare registry before and after. Then write a *.reg file for your needs and feed it to wine regedit or wine reg in your script.
leniviy
Level 2
Level 2
Posts: 39
Joined: Sat Jun 27, 2009 3:19 pm

Post by leniviy »

For example,

Code: Select all

REGEDIT4

[HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics]
"StatusFont"=hex:f8,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,90,01,00,00,\
  00,00,00,00,00,00,00,22,41,00,72,00,69,00,61,00,6c,00,20,00,42,00,6c,00,61,\
  00,63,00,6b,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
changes the setting "ToolTip Text" Font to Arial Black.
This font will be used in the status bar of regedit.
Bamm
Level 4
Level 4
Posts: 136
Joined: Thu May 22, 2008 3:18 am

Post by Bamm »

Thanks leniviy!

I've been searching the registry for this in vain. Thanks to you I finally found the key. What I did in the past was to set the font to some strangely named font and then search it in the registry, but the search always gave no results. Now I now why - it's encoded in ASCII!

I also like your tip about comparing the registry before and after. Why didn't I think of that? It's so simple. Haha! :)

Thanks again. Solved.
vitamin
Moderator
Moderator
Posts: 6605
Joined: Sat Feb 23, 2008 2:29 pm

Post by vitamin »

Bamm wrote:Now I now why - it's encoded in ASCII!
Except it doesn't. That key is a binary data of specific format.
Bamm
Level 4
Level 4
Posts: 136
Joined: Thu May 22, 2008 3:18 am

Post by Bamm »

Unfortunately it turns out my problem isn't solved. This method did not allow me to change the font to a specified font by script, only to a predetermined font. What I was trying to do was read the font from gconf and import it into a wine prefix.
leniviy
Level 2
Level 2
Posts: 39
Joined: Sat Jun 27, 2009 3:19 pm

Post by leniviy »

printf %s "Arial Black" | hexdump -e '1/1 "%02x,00,"'

But the correct way is to write a winelib program that uses both gconf and windows registry API
Bamm
Level 4
Level 4
Posts: 136
Joined: Thu May 22, 2008 3:18 am

Post by Bamm »

Thanks leniviy!
vitamin
Moderator
Moderator
Posts: 6605
Joined: Sat Feb 23, 2008 2:29 pm

Post by vitamin »

leniviy wrote:But the correct way is to write a winelib program that uses both gconf and windows registry API
Don't really have to write a winelib app. Just something that can create a LOGFONTW structure and print it in a format suitable for regedit.
Bamm
Level 4
Level 4
Posts: 136
Joined: Thu May 22, 2008 3:18 am

Post by Bamm »

leniviy, the output of the hexdump is much shorter than the registry entry. do i need to add anything else?
Bamm
Level 4
Level 4
Posts: 136
Joined: Thu May 22, 2008 3:18 am

Post by Bamm »

Is there a utility that already does this which I can just call?
leniviy
Level 2
Level 2
Posts: 39
Joined: Sat Jun 27, 2009 3:19 pm

Post by leniviy »

As vitamin said, this registry entry represents the LOGFONTW structure.

You can hardcode the beginning part:

Code: Select all

"f8,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,90,01,00,00,00,00,00,00,00,00,00,22,"
in your script. It contains font properties like size and charset. They will probably be the same for different fonts.
Font name is in the end of the structure and has the length 64 bytes (32 characters). You should pad it with zeros using -n option of hexdump:

Code: Select all

printf '%s\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0' "Arial Black" | hexdump -v -n 32 -e '1/1 "%02x,00,"' ; echo
P.S. In my previous post I forgot the important '-v' option for hexdump
Bamm
Level 4
Level 4
Posts: 136
Joined: Thu May 22, 2008 3:18 am

Post by Bamm »

Thanks so much for the explanation! I understand now and I can do the rest. Thanks again leniviy and vitamin for taking time to answer my questions. :)
lmn40227
Newbie
Newbie
Posts: 3
Joined: Mon Apr 16, 2012 8:00 pm

Post by lmn40227 »

Thanks leniviy!

i'm looking for it long time..
bantayso02
Newbie
Newbie
Posts: 1
Joined: Thu Apr 12, 2012 10:11 pm

Post by bantayso02 »

thanks a lots Leniviy.
You are awesome
Locked