Scaling can be a real PITA in HUG, as you, Barry and others have observed. Recently, I solved the problem of calculating required pixels for width and height using libpango: http://basic-converter.proboards.com/index.cgi?board=doc&action=display&thread=314&page=3. It is towards the bottom of the page. You would have to get the user's current DPI settings (there are routines somewhere), set those in a HUGOPTION and then dynamically set your other w and h dimensions using the results of my function. I have a demo there on the BaCon site. It can be surely done, but it ain't that easy and transparent.

And you can use the following code snippet to get some info about the user's settings:

Thanks vovchik, it seems hideously complicated to do this accurately (I've just read a four page post here http://basic-converter.proboards.com/index.cgi?board=doc&action=display&thread=314&page=2 that several PL forum members have posted in).

In a language that offered a simple getpixel() function (or the address of the window's buffer!) I'd take the ultra-crude/pragmatic route and blit a white 'W' or 'M' on a black background, get the white pixel with the maximum x value and use that as the character width. Unfortunately that's not an appropriate technique in this case. It might be better to build a few different versions of the program for use on systems with differing dpi settings instead!

I have inserted HUGOPTIONS("BASEXFTDPI 66") and compiled. See the result, your original and mine

Why 66 ?

Do not know why. I only know that it has given the good result.

Posted on 29 Mar 2013, 8:06 by BarryK wrote:

re hug dpi
L18L,
I don't see any problem.
I solved that problem a long time ago:

http://bkhome.org/bacon/hug/layout.htm

Both /usr/share/doc/welcome1stboot.bac and /usr/local/simple_network_setup/proxy-setup.bac in Woof use that method.

So did I by using 66.
And don't know why because PaulR has used 78.

Shame on all of us except BarryK

who wrote:

The same thing as shown above could also happen if a different GTK theme with larger font is chosen (see menu Desktop -> GTK theme chooser). Different users are going to have their own theme preference, but it isn't so good if a theme has bigger font sizes which cause our example window to be messed up.

There is also a simple solution to this. Peter introduced a feature that allows a font to be specified in the program, that overrides the GTK default. This will apply to all widgets. Put this near the beginning of the program:

HUGOPTIONS("FONT DejaVu Sans 12")

...with whatever font you want. DejaVu Sans is available in all puppies.

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum