kl88a@ecs.soton.ac.uk (Kris Lockyear) (05/27/91)
This is a second attempt to mail this group so apologies if it appears twice! I want a short piece of code to find out the dimensions of a single character. More specifically, the height from the baseline to the top of the letter. This is because I want to occaisionally invert a letter in a word eg HELEN with the N upside down. I have written the code so that I can invert the letter, but not so I know how much upwards I have to move it ( the textheight used in scalefont is the maximum height from the tail of a letter like y to the top of a capital.) I am not a PS hacker! Please could you mail me direct. Many thanks, Kris Lockyear kl88a@uk.ac.soton.ecs kl88a@ecs.soton.ac.uk
davis@3d.enet.dec.com (Peter Davis) (05/28/91)
In article <KL88A.91May27124328@cameron.ecs.soton.ac.uk>, kl88a@ecs.soton.ac.uk (Kris Lockyear) writes... > >I want a short piece of code to find out the dimensions of a single >character. More specifically, the height from the baseline to the top >of the letter. This is because I want to occaisionally invert a >letter in a word eg HELEN with the N upside down. I have written the >code so that I can invert the letter, but not so I know how much >upwards I have to move it ( the textheight used in scalefont is the >maximum height from the tail of a letter like y to the top of a >capital.) > This is very simple: (N) true charpath flattenpath pathbbox /y2 exch def /x2 exch def /y1 exch def /x1 exch def /height y2 y1 sub def newpath If all you care about is the height, you could do: (N) true charpath flattenpath pathbbox exch pop exch sub /height exch def pop newpath Note that you must have a current point somewhere for this to work.