Re: Font metrics question ?!
- From: "Georg C. F. Greve" <greve gnu org>
- To: Owen Taylor <otaylor redhat com>
- Subject: Re: Font metrics question ?!
- Date: 26 Aug 1998 17:46:16 +0200
-----BEGIN PGP SIGNED MESSAGE-----
Hi Owen !
Owen Taylor <otaylor@redhat.com> writes:
> "Georg C. F. Greve" <greve@gnu.org> writes:
> > Did anyone answer the font metrics question someone asked a week ago ?
> > I didn't see the answer on the list but I think it is very interesting
> > to hear what the clean way of getting the width of a certain string
> > with a certain font would be.
> gint gdk_string_width (GdkFont *font,
> const gchar *string);
> probably does what you want. (There are a large number
> of such functions in GDK, most of them rather useless -
> for instance gdk_text/string_measure seem to work out
> to slow versions of the _width functions, except perhaps
> for vertical text...)
Yeah - gdk_string_width will probably do what I need for
now... thanks.
> > This could also be the solution to the
> > size information I suggested that seemed to have passed through the
> > list without anyone taking notice.
> I did notice, though I didn't get around to responding. Yes,
> being able to specify a width in characters for entry and
> text widgets would be nice, though it is a little bit trickier than
> gdk_text_width, since the typical fonts we use are proportionally
> spaced.
Well - for those fonts you'd probably need to do the sizing as if a
string would only contain the biggest character of that font. This way
it can be guaranteed that a every string containing a certain number
of characters will fit into the widget. Another solution would be to
add another flag like:
GTK_FONT_RESIZE_MINIMAL
GTK_FONT_RESIZE_AVERAGE
GTK_FONT_RESIZE_MAXIMAL
to set either minimal width, average width (no calculations based on
usage of certain characters are neccessary there, I'd say) or maximal
widht for proportionally size fonts.
Later,
Georg
- --
Georg C. F. Greve <greve@gnu.org>
http://porter.desy.de/~greve/ - ICQ#10016966
"People who fight may lose. People who do not
fight have already lost." -- Bertolt Brecht
-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: noconv
Comment: Processed
iQCVAwUBNeQtx1ZXgZXDxqJtAQHozwP/c0gFNFeEopTrVf5dpZltmVe3VPULOSqY
ZSfm/RP882x4NWhjoe45PH1PBnt7RYnogKsZd9iCjH0hWxn0JgwwbfOmcO9CgShD
uuPuZe+ekoTv6SKsF7env6ymNlsj13nZc1hLKpB2Xz9WZx4kobh+HfCUWXDD2nBW
yfdNBt6YHG4=
=z+XC
-----END PGP SIGNATURE-----
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]