LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Getting the right font size in a trditional X application (Xman) (https://www.linuxquestions.org/questions/linux-software-2/getting-the-right-font-size-in-a-trditional-x-application-xman-4175710881/)

hazel 04-16-2022 05:15 AM

Getting the right font size in a trditional X application (Xman)
 
I use Xman as a simple man page reader but, when launched from my desktop, it uses too big a font and pages run over the edge even when I make it fullscreen. So I added a couple of lines to my .Xresources file as follows:
Code:

Xman.font.manualFontBold:      -*-courier-medium-o-*-*-*-50-*-*-*-*-*-*
Xman.font.manualFontItalic:    -*-courier-medium-o-*-*-*-50-*-*-*-*-*-*
Xman.font.manualFontNormal:    -*-courier-medium-r-*-*-*-50-*-*-*-*-*-*

My .xinitrc includes the lines:
Code:

userresources=$HOME/.Xresources
...
if [ -f $userresources ]; then
    xrdb -merge $userresources
fi

So as I understand it, those fonts should override the larger default fonts. They do if I launch Xman from a terminal but not when I launch it from my buttonbar app.

What am I doing wrong?

pan64 04-17-2022 08:34 AM

the usual answer is because it is overridden. I don't know your button bar, but probably that sets those resources somehow. Or your font specification is invalid and therefore some other font has been selected (which is different in the mentioned two cases).

hazel 04-17-2022 09:30 AM

The buttonbar (which I wrote myself) simply forks off graphical apps without arguments. It doesn't specify anything beyond that. The default resources for Xman are in /etc/X11/app-defaults.
Code:

*manualFontBold:                -*-courier-bold-r-*-*-*-120-*-*-*-*-*-*
*manualFontItalic:              -*-courier-medium-o-*-*-*-120-*-*-*-*-*-*
*manualFontNormal:              -*-courier-medium-r-*-*-*-120-*-*-*-*-*-*

I used those lines as a model for my version, just using a smaller font, as you will see if you compare the default with what I put in my .Xresources file. But what actually does xrdb -merge do when your local .Xresources and the default version clash?

ondoho 04-18-2022 02:05 AM

I have experienced similar problems when I ampersand too many apps in my .xinitrc, and/or put them in the wrong order.
In other words, make sure the xrdb command is near the top, and has completed, before you start barbarella?

Also, a -merge is not always sufficient as pan64 pointed out.
You can check your actually valid Xresources with
Code:

appres
appres xman
appres Xman
xprop -root


hazel 04-18-2022 04:16 AM

Code:

$ appres Xman
...
Xman.font.manualFontBold:      -*-courier-bold-r-*-*-*-50-*-*-*-*-*-*
Xman.font.manualFontItalic:    -*-courier-medium-o-*-*-*-50-*-*-*-*-*-*
Xman.font.manualFontNormal:    -*-courier-medium-r-*-*-*-50-*-*-*-*-*-*
*manualFontItalic:      -*-courier-medium-o-*-*-*-120-*-*-*-*-*-*
*input: True
......
*manualFontNormal:      -*-courier-medium-r-*-*-*-120-*-*-*-*-*-*
*manualFontBold:        -*-courier-bold-r-*-*-*-120-*-*-*-*-*-*

Interesting. There are some additional fonts that I haven't shrunk. I'll modify those too.
Code:

$ xprop -root
CUT_BUFFER0(STRING) = "RESOURCE_MANAGER(STRING) = \"XTerm.vt100.background:\\tblack\\nXTerm.vt100.foreground:\\twhite\\nXman.font.manualFontBold:\\t-*-courier-bold-r-*-*-*-50-*-*-*-*-*-*\\nXman.font.manualFontItalic:\\t-*-courier-medium-o-*-*-*-50-*-*-*-*-*-*\\nXman.font.manualFontNormal:\\t-*-courier-medium-r-*-*-*-50-*-*-*-*-*-*\\n\"\n"
...
RESOURCE_MANAGER(STRING) = "XTerm.vt100.background:\tblack\nXTerm.vt100.foreground:\twhite\nXman.font.manualFontBold:\t-*-courier-bold-r-*-*-*-50-*-*-*-*-*-*\nXman.font.manualFontItalic:\t-*-courier-medium-o-*-*-*-50-*-*-*-*-*-*\nXman.font.manualFontNormal:\t-*-courier-medium-r-*-*-*-50-*-*-*-*-*-*\n"

Still looks the same: shrunken fonts when launched from a terminal, not when launched graphically.

pan64 04-18-2022 04:28 AM

ok, here is mine, ubuntu 20.04 (without xrdb -merge):
Code:

$ appres Xman | grep -i font
*manualFontItalic:        -*-courier-medium-o-*-*-*-120-*-*-*-*-*-*
*manualFontNormal:        -*-courier-medium-r-*-*-*-120-*-*-*-*-*-*
*manualFontSymbol:        -*-symbol-*-*-*-*-*-120-*-*-*-*-*-*
*directoryFontNormal:        -*-helvetica-medium-r-*-*-*-120-*-*-*-*-*-*
*manualFontBold:        -*-courier-bold-r-*-*-*-120-*-*-*-*-*-*

And what I have also tried:
Code:

$ xman
Warning: Cannot convert string "-*-helvetica-medium-r-*-*-*-120-*-*-*-*-*-*" to type FontStruct
Warning: Cannot convert string "-*-courier-medium-r-*-*-*-120-*-*-*-*-*-*" to type FontStruct
Warning: Cannot convert string "-*-courier-bold-r-*-*-*-120-*-*-*-*-*-*" to type FontStruct
Warning: Cannot convert string "-*-courier-medium-o-*-*-*-120-*-*-*-*-*-*" to type FontStruct
Warning: Cannot convert string "-*-symbol-*-*-*-*-*-120-*-*-*-*-*-*" to type FontStruct


hazel 04-18-2022 04:38 AM

I don't get those warnings, but that's probably irrelevant.

As to the fonts, my guess is that the ones I have without the Xman prefix are the defaults from /etc/X11/app-defaults/Xman. In other words I have both the default and the prescribed versions in my merged resources database, and graphical launches continue to use the default ones. I suppose the solution is to change the defaults rather than fiddling around with a personal file and a merger. After all, a program like Xman is hardly likely to be upgraded within the lifetime of this release!

pan64 04-18-2022 08:55 AM

The warning means the font does not exist, another one will be used instead.
Xman version 1.1.5, from somewhere 1989, 1990.
By the way probably this helps (man page):
Code:

      XENVIRONMENT  to get the name of a resource file that overrides the global resources stored in the
                      RESOURCE_MANAGER property.

      XAPPLRESDIR    A string that will have ``Xman'' appended to it. This string will be the full path name of a
                      user app-defaults file to be merged into the resource database after the system  app-defaults
                      file, and before the resources that are attached to the display.
                      See X(7) for a full statement of rights and permissions.


hazel 04-18-2022 11:37 AM

I fiddled about a bit with Xman's default resources file and found that a font size of 100 is best overall. It requires a maximised window to display a readable man page (a smaller one will do for a contents list), but using a smaller font makes the page more difficult to read. The program now launches from the buttonbar in a satisfactory manner.

ondoho 04-19-2022 01:04 PM

Quote:

Originally Posted by hazel (Post 6346895)
Code:

...
Xman.font.manualFontBold:      -*-courier-bold-r-*-*-*-50-*-*-*-*-*-*
Xman.font.manualFontItalic:    -*-courier-medium-o-*-*-*-50-*-*-*-*-*-*
Xman.font.manualFontNormal:    -*-courier-medium-r-*-*-*-50-*-*-*-*-*-*
......
*manualFontNormal:      -*-courier-medium-r-*-*-*-120-*-*-*-*-*-*
*manualFontBold:        -*-courier-bold-r-*-*-*-120-*-*-*-*-*-*


AFAIU Xresources are applied by specificity, i.e. more specific settings override less specific settings.
That way you can define your font for almost everything with '*font: ...', but can still override it for specific applications: 'Xman*font: ...'.
The logic is simple for anyone who understands shell globbing.
In your example above, 'Xman.font.something' is very specific and should win - in case the resource is actually called Xman.font.something, and not e.g. 'Xman.manualFontNormal'?

hazel 04-20-2022 04:22 AM

As I've said, it does override for instances launched from the shell. But not for instances launched graphically. Maybe window managers have shell scripts to handle the resources for programs launched from their menus, but obviously I didn't put anything of the kind into barbarella. It's just a simple fork and exec. Anyway, I've changed the default resources now and that solves the problem.

ondoho 04-20-2022 11:47 PM

^ So you edited /etc/X11/app-defaults/Xman? Not very elegant. These old X apps do get updated sometimes.

If you're happy with your solution feel free to ignore me, but:
Quote:

Originally Posted by ondoho (Post 6346883)
I have experienced similar problems when I ampersand too many apps in my .xinitrc, and/or put them in the wrong order.
In other words, make sure the xrdb command is near the top, and has completed, before you start barbarella?

You haven't adressed this?

hazel 04-21-2022 04:10 AM

Good question. Barbarella isn't launched by .xinitrc but by fluxbox. There's a directory called .fluxbox/apps where you can put stuff you want to auto-launch. It allows you to specify the desktop you want the app to run on which is essential for barbarella; I want different buttonbars on different desktops because of the way I like to work.

The xrdb merge is done by .xinitrc before startfluxbox is executed. So the merge is certainly complete by then. Incidently, I have no idea where that .xinitrc file originally comes from. I copied it over from my earlier Slackware installation but I certainly didn't write it myself.


All times are GMT -5. The time now is 03:25 AM.