[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

giving emacs initial size of 80 x as-much-as-possible

From: Jay Berkenbilt
Subject: giving emacs initial size of 80 x as-much-as-possible
Date: Fri, 26 Jun 2009 19:58:50 -0400

I'm running 23.0.95 with client-side fonts on a GNU/Linux system.  The
distribution is not important as long as client-side fonts are
supported.  I run on Red Hat Enterprise Linux 5 at work and Debian
GNU/Linux at home, and the solution is identical.

For years, I've been calculating in advance the number of rows I need to
set in my emacs geometry based on the size of my font.  In the brave
newish world of scalable, client-side fonts, this is no longer
straightforward since the size of my font is hard to predict.  The size
of, for example, Monospace-12, depends on many factors including the
screen resolution and which font actually matches.  Is there a simple
way to know what the size of a character in a specific monospace font
will be without running emacs to find out?

I have dug through some of the code in xdisp.c and frame.c and have come
across the functions frame-char-width and frame-char-height, so I know
how to get the information about the size of the character once emacs is
running, but not how to calculate it in advance.  I see that the
information comes from the max_ascent and max_descent information from
the font, but I don't really see how to get that information reliably.
I observe that, for some scale factors, emacs and xterm don't even use
the same character size for the same font specification -- emacs
sometimes uses one pixel more vertically than xterm.  Right now, I have
a little script that runs emacs on a lisp file that saves the results of
a file, and this is meeting my needs, but it seems unfortunate to have
to do this.

Why am I doing this?  Well, maybe I'm having a hard time moving into the
modern world of session managers and so forth.  I have code in my login
that I have been using literally since 1989 that calculates the initial
geometries of my xterms and emacs based on the size of the screen and
other information.  This way, I can log in on any screen size and get as
close as possible to my usual screen parameters.  I synchronize my files
to many locations and even have this setup on my USB thumb drive.  I
don't like to have to manually resize windows or to use session managers
to save my previous state.  My method of calculating in advance has
always worked in the past, but I'm having to jump through hoops with
both emacs and xterm to get this information.  Perhaps I could write a C
program that queries the font to get the information.  Maybe I'll go
that route.  Maybe there's some way to get what I need from the output
of fc-match, but I don't see how to get the relevant information,
particularly about ascent and descent information of the font.

Anyway, I'd welcome any suggestions about how to handle this.  It's not
that big a deal though...my current solution of starting a special emacs
just to get the information only adds a few seconds to my login.  It's
still much faster than the amount of time it would take me to set it up

Jay Berkenbilt <address@hidden>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]