* RE: char-width of a font? pixel-width of a future frame? NOT SOLVED
@ 2005-05-30 10:09 David Reitter
2005-05-30 13:55 ` Drew Adams
0 siblings, 1 reply; 2+ messages in thread
From: David Reitter @ 2005-05-30 10:09 UTC (permalink / raw)
> How do I find out either
>
> - what the (average) width of characters of a given font/
> fontset is? or
>
> `frame-char-width' or height gives the pixel width or height of the
> frame's
> default font.
Yes, but they only work with an existing frame as parameter.
I only have a font/fontset or some frame-parameters, but not a frame.
>
> - what, given a set of frame-parameters (including font and
> width and
> height), what the pixel-width and pixel-height of a frame are
> going
> to be once it is created?
>
> If the frame is to fit the buffer (you mentioned font size), then
> you need
> to calculate the line length and number of lines, then multiply
> these by the
> frame-char-width and frame-char-height. You can see code that
> calculates
> frame size from buffer size here:
> http://www.emacswiki.org/elisp/fit-frame.el.
I need to know what width a frame is going to have in pixels, before
it is created. Frames are not fitted by default, and I'm not trying
to fit frames. I'm just trying to determine a decent position to open
the frame at.
That's why I was asking for frame-char-width for a given font, to
calculate the pixel-width.
> Otherwise, what do you mean by the frame size - it could be
anything you
> want. What is the relation between the frame parameters you
mention and the
> frame size you want?
Frames are created with whatever is set in the width / height
specification of the default-frame-alist (or whatever is given to
make-frame). These specifications are in characters / lines, not
pixels. I just need to translate to pixels.
Anyone??
- D
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: char-width of a font? pixel-width of a future frame? NOT SOLVED
2005-05-30 10:09 char-width of a font? pixel-width of a future frame? NOT SOLVED David Reitter
@ 2005-05-30 13:55 ` Drew Adams
0 siblings, 0 replies; 2+ messages in thread
From: Drew Adams @ 2005-05-30 13:55 UTC (permalink / raw)
Frames are created with whatever is set in the width / height
specification of the default-frame-alist (or whatever is given to
make-frame). These specifications are in characters / lines, not
pixels. I just need to translate to pixels.
For a given frame: use frame-pixel-width / -height. You can always create a
test frame, perhaps invisible, using default-frame-alist, and get its size
in pixels.
But it sounds like you have want to know the pixel size of a frame that
would be created using default-frame-alist, without creating any such frame.
You might try one of these (untested):
- (face-attribute 'default :height t t). This can give you the height of a
font in 1/10 pt, but it can also give you a scale factor instead. To convert
points to pixels, perhaps you can use display-pixels-per-inch plus the
number of points in an inch.
- Get the pixel size from the font name - see pixelsize and x-font-regexp
in faces.el. Multiply by the height parameter in default-frame-alist.
That's all I can think of. Perhaps someone has a simple and direct solution.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-05-30 13:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-30 10:09 char-width of a font? pixel-width of a future frame? NOT SOLVED David Reitter
2005-05-30 13:55 ` Drew Adams
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.