From xemacs-m  Wed Jun 11 10:50:46 1997
Received: from newman.aventail.com (root@newman.aventail.com [199.238.236.1])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id KAA17760
	for <xemacs-beta@xemacs.org>; Wed, 11 Jun 1997 10:50:45 -0500 (CDT)
Received: from kramer.in.aventail.com.aventail.com (wmperry@kramer.in.aventail.com [192.168.1.12])
	by newman.aventail.com (8.8.5/8.8.5) with SMTP id IAA01320;
	Wed, 11 Jun 1997 08:50:40 -0700 (PDT)
To: Pete Ware <ware@cis.ohio-state.edu>
Cc: xemacs-beta@xemacs.org
Subject: Re: auto-show, pixel-width of text
References: <vwmyb8hduew.fsf@calico.cis.ohio-state.edu>
Errors-to: wmperry@aventail.com
Reply-to: wmperry@aventail.com
X-Face: O~Rn;(l][/-o1sALg4A@xpE:9-"'IR[%;,,!m7</SYF`{vYQ(&RI1&EiH[FvT;J}@f!4kfz
 x_!Y#=y{Uuj9GvUi=cPuajQ(Z42R[wE@{G,sn$qGr5g/wnb*"*ktI+,CD}1Z'wxrM2ag-r0p5I6\nA
 [WJopW_J.WY;
From: wmperry@aventail.com (William M. Perry)
Date: 11 Jun 1997 08:50:40 -0700
In-Reply-To: Pete Ware's message of "11 Jun 1997 11:35:35 -0400"
Message-ID: <867mg1f8a7.fsf@kramer.in.aventail.com>
Lines: 23
X-Mailer: Gnus v5.4.56/XEmacs 20.3(beta5) - "Zagreb"

Pete Ware <ware@cis.ohio-state.edu> writes:

> I'm interested in getting auto-show (horizontal scrolling) to work
> with variable width fonts.  It'd be really, really nice if there was a 
> way to find out how wide a string is in pixels and/or where point would
> be in pixels.
> 
> I'm sure Bill Perry would like w3 to get similar info.  Anyone going
> to work on it?

  You can hack around it now, but its not pretty.  I'd love to see this in
the C code, where it belongs.

-Bill P.

(defun w3-text-pixel-width (str &optional face)
  "Return the pixel-width of a chunk of text STR with face FACE."
  (let ((glyph (make-glyph str))
	(todo (if (listp face) face (list face)))
	(max 0))
    (while (progn (set-glyph-face glyph (pop todo)) todo)
      (setq max (max (glyph-width glyph) max)))
    max))

