emacs menu font in GTK-2 and GTK-3

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

emacs menu font in GTK-2 and GTK-3

Nelson H. F. Beebe
I recently upgraded my desktop workstation, doubling my screen
resolution to 3840x2160 pixels, and changing from Solaris SPARC to
CentOS 7 x86-64.  The higher resolution has been welcome, but I'm
still struggling with selecting larger font sizes in several
applications, including emacs.

When emacs is linked with a GTK-2 library, such as
/usr/lib64/libgtk-x11-2.0.so.0 on CentOS 6, then a startup file of the
form

        % cat ~/.emacs.d/gtkrc
        style "menufont"
        {
            font_name = "URWPalladio          16"
        }

        widget "*emacs-menuitem*" style "menufont"

suffices to enlarge the menu bar

        File  Edit  Options  Buffers  Tools  Emacs-Lisp  Help

to a readable size.  

However, on CentOS 7, linking is to /lib64/libgtk-3.so.0.  The above
setting then has no effect, and the default menu font is too small to
be read comfortably.

A system call trace of emacs startup shows that with GTK-3, the file
~/.emacs.d/gtkrc is not even read; instead, the file
~/.config/pango/pangorc seems to be the only user-specific GTK startup
file that is read.  However, its syntax is different from that of
gtkrc, so it does not seem to be the place where emacs menu font
choices are made.

Does anyone on this list know how menu-bar font names and sizes are
chosen with GTK-3 is linked into emacs?

Once we figure this out, the doc/emacs/xresources.texi needs to be
updated to document the procedure for GTK-3 library support.

-------------------------------------------------------------------------------
- Nelson H. F. Beebe                    Tel: +1 801 581 5254                  -
- University of Utah                    FAX: +1 801 581 4148                  -
- Department of Mathematics, 110 LCB    Internet e-mail: [hidden email]  -
- 155 S 1400 E RM 233                       [hidden email]  [hidden email] -
- Salt Lake City, UT 84112-0090, USA    URL: http://www.math.utah.edu/~beebe/ -
-------------------------------------------------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: emacs menu font in GTK-2 and GTK-3

Paul Eggert
Nelson H. F. Beebe wrote:
> A system call trace of emacs startup shows that with GTK-3, the file
> ~/.emacs.d/gtkrc is not even read; instead, the file
> ~/.config/pango/pangorc seems to be the only user-specific GTK startup
> file that is read.

That's odd.  On my host (Fedora 21) Emacs also looks at:

~/.config/gtk-3.0/settings.ini
~/.config/gtk-3.0/gtk.css

and some other files.  I expect gtk.css is what you want to fiddle with.  Please
see
<http://www.gnu.org/software/emacs/manual/html_node/emacs/GTK-resources.html>
for a brief intro.  CSS styling can be a real zoo, I'm afraid.  You might want
to take a gander at:

http://superuser.com/questions/597076/gtk-3-menu-configuration-for-emacs

It'd be nice to have a concise summary of your workaround (whatever it turns out
to be) in the Emacs manual.

Reply | Threaded
Open this post in threaded view
|

Re: emacs menu font in GTK-2 and GTK-3

Nelson H. F. Beebe
In reply to this post by Nelson H. F. Beebe
Thanks to Paul Eggert's tips, and his pointer to

        http://superuser.com/questions/597076/gtk-3-menu-configuration-for-emacs

I now have a simple solution for GTK-3-based emacs builds that works for me,
and provides a larger, and more easily-readable, menu font:

    % cat ~/.config/gtk-3.0/gtk.css
    #pane #menubar,
    #pane #menubar GtkMenuShell,
    #pane #menubar GtkMenuShell *
    {
        font-family: "URWPalladio";
        font-size: 18px;
    }

I've done simple startup tests of the above initializations with

        emacs-23.4
        emacs-24.3.92
        emacs-24.3.93
        emacs-24.3.94
        emacs-24.4
        emacs-24.4.90
        emacs-24.5

on CentOS 7, and they all behave the same way: the menu bar is now
readable.


Until a few minutes ago when I did a mkdir, the directory
~/.config/gtk-3.0 did not exist on my system.

The above link suggests that such cascading-style-sheet file settings
are overly general, and apply to all GTK-based windows, instead of
restricting them to just emacs.

Perhaps other list members will have some insights on how to restrict
the initializations to just emacs.

I don't work in a Gnome window environment, so the generality does not
matter to me.  The important thing is that I can now get on with my
desktop migration from Solaris to CentOS 7, with my new
high-resolution display :^)!

-------------------------------------------------------------------------------
- Nelson H. F. Beebe                    Tel: +1 801 581 5254                  -
- University of Utah                    FAX: +1 801 581 4148                  -
- Department of Mathematics, 110 LCB    Internet e-mail: [hidden email]  -
- 155 S 1400 E RM 233                       [hidden email]  [hidden email] -
- Salt Lake City, UT 84112-0090, USA    URL: http://www.math.utah.edu/~beebe/ -
-------------------------------------------------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: emacs menu font in GTK-2 and GTK-3

Yuri Khan-2
In reply to this post by Nelson H. F. Beebe
On Tue, Aug 11, 2015 at 11:59 PM, Nelson H. F. Beebe
<[hidden email]> wrote:
> I recently upgraded my desktop workstation, doubling my screen
> resolution to 3840x2160 pixels, and changing from Solaris SPARC to
> CentOS 7 x86-64.  The higher resolution has been welcome, but I'm
> still struggling with selecting larger font sizes in several
> applications, including emacs.

What does your X server think your DPI is, what physical size is your
new monitor actually, and at what distance from it do you view it?

I recently got a 3840×2160 24in at normal distance (≈70cm). By
default, X assumed 96 dpi and everything was so damn small. In order
to bring my environment to sane size, I had to:

* Fiddle with my Xorg.conf to inform X of the physical dimensions of my monitor.
* Set Xft.dpi to 192 in my ~/.Xresources.
* Work through my GTK+2 theme and double every pixel-based size and
adjust icon sizes as well.
* In my GTK+3 theme, resize all theme images and also double every
pixel-based size.

After that, most applications display at an acceptable size, though
icons in GTK+3 applications remain too small.


I am running Ubuntu without a DE, using i3 as the window manager. Most
applications I use are based on GTK+3 or GTK+2. I set up my GTK+3
theme via the ~/.config/gtk-3.0/settings.ini file, whose
gtk-theme-name key contains the name of the theme (Clearlooks-Phenix)
which is further looked up in /usr/share/themes. (Alternatively,
themes can be installed in ~/.themes, but then they are only available
to the user.)