Thread View: comp.lang.postscript
3 messages
3 total messages
Started by tomwest
Tue, 27 Oct 1987 18:40
Underlining and character lengths
Author: tomwest
Date: Tue, 27 Oct 1987 18:40
Date: Tue, 27 Oct 1987 18:40
29 lines
1588 bytes
1588 bytes
I am adapting our word processor to a postscript engine. However, I am not sure how to handle underlines. Is there any easy way to know where or how to underline? We use a mono-spaced font (for the most part). Can one just draw a horizontal line of the appropriate length with the same vertical position as the characters? i.e. 100 100 moveto (Hello) show ! Using Courier 10 cpi 100 100 moveto 136 100 lineto stroke As well, if we decide to get sophisticated, we would want to use non-mono fonts. Is there anywhere that we can get the length of characters in the standard fonts (Times, Helvetica and Symbols)? Thanks in advance. -- Tom West BITNET: tomwest@utorgpu.bitnet, tomwest@gpu.utcs.utoronto Internet: tomwest@gpu.utcs.toronto.edu UUCP: tomwest@utgpu utzoo, yetti, harpo, mnetor \ cbosgd, deepthot, utoronto - !utgpu!tomwest ihnp4, lsuc, sfmin, vnr-vpa /
Re: Underlining and character lengths
Author: zaphod
Date: Wed, 28 Oct 1987 14:43
Date: Wed, 28 Oct 1987 14:43
69 lines
3372 bytes
3372 bytes
In article <1987Oct27.134058.23182@gpu.utcs.toronto.edu> tomwest@gpu.utcs.toronto.edu (Tom West) writes:
>
> I am adapting our word processor to a postscript engine. However, I
>am not sure how to handle underlines. Is there any easy way to know where
>or how to underline?
yes
> We use a mono-spaced font (for the most part). Can
>one just draw a horizontal line of the appropriate length with the same
>vertical position as the characters?
no, the line will "melt" into the letters
>
> As well, if we decide to get sophisticated, we would want to use non-mono
>fonts. Is there anywhere that we can get the length of characters in the
>standard fonts (Times, Helvetica and Symbols)?
again, yes the stringwidth operator
gives you the x and y offsets if the string on the top of the
stack were printed. the y offset (for non-japanese letters)
is usually 0 and therefore popped
this code will perform the trick.
/undershow
{ currentlinewidth exch
dup show currentpoint 3 2 roll
stringwidth exch neg exch
0 -2 rmoveto rlineto 0.5 setlinewidth stroke
moveto setlinewidth
} def
(string) undershow
the code works as follows.
currentlinewidth is stored on the stack
(string) is pushed onto the stack and undershow does the following:
top of stack is duplicated and shown.
the new currentpoint is saved, the roll tucks the currentpoint under the
string-in-question.
stringwidth gives us x and y displacements, exch to access the x value
negate the x value as we will be drawing BACK under the already shown string
exch to switch back the x and y values. move down 2 dots. I have found
this to be a good amount to avoid the line from melting into the letters.
now rlineto based on the x and y still on the stack. the 0.5 linewidth
is arbitrary, again, i have found it to be nice. stroke, reset the linewidth
and moveto the stored currentpoint.
THis is the cleanest way. a gsave/grestore combination could be used
to save currentpoint, but why store the entire graphics state for only
two values?
>
> Thanks in advance.
no problem, call me at 1-519-663-3787, i actually enjoy typesetting in raw
postscript and so have tackled many of the commen problems.
I also enjoy fixing postscript on third party wordprocessors (like
micro soft word) -- but i digress
>
--
humbly yours, Lance Bailey
Univ. Western Ontario | Robart's Research Institute
Dept. of Computer Science | Clinical Trials Unit
Graduate Studies | PO Box 5015
London, Canada | London, Canada
N6A 5B7 | N6A 5K8
decvax!{utcs|utzoo|watmath}!deepthot!zaphod
-or- zaphod@deepthot.uucp
Re: Underlining and character lengths
Author: Edward J. Ede
Date: Fri, 30 Oct 1987 19:29
Date: Fri, 30 Oct 1987 19:29
30 lines
2327 bytes
2327 bytes
In article <1987Oct27.134058.23182@gpu.utcs.toronto.edu> tomwest@gpu.utcs.toronto.edu (Tom West) writes: > I am adapting our word processor to a postscript engine. However, I >am not sure how to handle underlines. Is there any easy way to know where >or how to underline? We use a mono-spaced font (for the most part). Can >one just draw a horizontal line of the appropriate length with the same >vertical position as the characters? > No. But you can get the from the AFM files provided by Adobe for you driver or in Adobe's font dictionary for a postscript procedure. In Adobe's font dictionaries, there is a dictionary called 'FontInfo'. FontInfo contains about eight items, including 'UnderlinePosition' and 'UnderlineThickness'. These are integer containing the number of units from the baseline to draw a line (the number is negative) and its width. These numbers are in the character system coordinates (1000 units to a point). So divide the number by 1000 and multiply by the current point size. See the Red book, page 93 for more info. > As well, if we decide to get sophisticated, we would want to use non-mono >fonts. Is there anywhere that we can get the length of characters in the >standard fonts (Times, Helvetica and Symbols)? Again, you can use the AFM files available from Abobe or the 'stringwidth' operator. Ted Ede -- ted@mitre-bedford.arpa -- The MITRE Corporation -- Burlington Road | -- DDD: (617) 271-2545 -- Bedford MA, 10730 -- Mail Stop B015 -- | | - this line intentionally left blank - | +---------------------------------------------------------------------------+
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads