Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Text Width

0 views
Skip to first unread message

Javier Serra Callejo

unread,
Apr 6, 1998, 3:00:00 AM4/6/98
to

Does anybody know how to get the length in inches of selected text in WP
after a specific font has been applied to it (in my case the font would
normally be times new roman and the size 12)?

I need to know it for a macro, inspired by one developed by Gordon
McComb, which counts lines in a document, but must consider as one every
two lines whose length is bigger than 15,33 inches (one third of a
16-inch line).

I cannot base calculations on number of characters because I must use
variable-pitch fonts, in order to save space.

Any hint would be warmly welcome.


Gordon McComb

unread,
Apr 10, 1998, 3:00:00 AM4/10/98
to

You need to access Windows API functions in order to read the metrics of
the font. Are you up to that... <g>

To tell you the truth, I haven't done this since Windows 3.x days.
Windows 95 uses more data structures for its API calls. And though
WPWin 8 is supposed to be able to pass structures to Windows API calls,
I have never gotten that bum Dan Broadhead, who works in the
PerfectScript group, to send me an example of how it works. If Win95
now does this win structures, it's going to complicate things. Time to
get out the Win32 API book...

(The "bum" comment is for Paul, Ray, or Steve who might forward this to
Dan; maybe I'll get that example now... <g>)

-- Gordon

Gordon McComb

unread,
Apr 12, 1998, 3:00:00 AM4/12/98
to

I re-looked at the Windows API for this and a structure is required for
the one call that would probably do it all.

But...I wonder if testing the actual width of the line is really
necessary. If it's character counting, the macro could select a line of
text, poick it up with ?SelectedText, and test its length (there's also
a system var just for returning the length of the selection; may be
faster than using ?SelectedText).

You could then use that value with the ?FontSize system variable to
determine the general metrics of the font. It's not completely
accurate, though, because some proportional fonts are wider or narrower
than "normal" proportional fonts.

If ?FontSize won't work, then perhaps the ?Pos system variable might.
It would tell you the position of the insertion point, in WPUnits.

-- Gordon

0 new messages