hascall@cs.iastate.edu (John Hascall) (07/16/90)
Greetings fellow PSers, How does one determine the left side bearing of a character (in a particular font)? I am looking at section 5.5, "Font Metric Information", of the Red Book, (pp 95-96), which says: "The sequence charpath flattenpath pathbbox may be used to determine character bounding boxes and side bearings." Well, I can see how it gives you the bounding box, but how do you get the (left) side bearing? Thanks, John Hascall / hascall@atansoff.cs.iastate.edu For those wondering what the devil I'm trying to do: I am trying to position a character so that the characters actual left edge is at a certain location.
hascall@cs.iastate.edu (John Hascall) (07/16/90)
Greetings fellow PSers, How does one determine the left side bearing of a character (in a particular font)? I am looking at section 5.5, "Font Metric Information", of the Red Book, (pp 95-96), which says: "The sequence charpath flattenpath pathbbox may be used to determine character bounding boxes and side bearings." Well, I can see how it gives you the bounding box, but how do you get the (left) side bearing? Thanks, John Hascall / hascall@atanasoff.cs.iastate.edu For those wondering what the devil I'm trying to do: I am trying to position a character so that the characters actual left edge is at a certain location.
glenn@heaven.woodside.ca.us (Glenn Reid) (07/17/90)
In article <2260@dino.cs.iastate.edu> hascall@cs.iastate.edu (John Hascall) writes: >Greetings fellow PSers, > > How does one determine the left side bearing of a character (in a >particular font)? I am looking at section 5.5, "Font Metric Information", >of the Red Book, (pp 95-96), which says: "The sequence > > charpath flattenpath pathbbox > >may be used to determine character bounding boxes and side bearings." The left side bearing is the difference in X between the lower-left corner of the bounding box and the origin of the character. The right side bearing is the difference in X between the upper-right corner of the bounding box and (origin + width) of the character. Assuming that the origin is at zero, the left side bearing is just the llX value of the bounding box, and the right side bearing is (width - urX). /Glenn -- Glenn Reid PostScript/NeXT consultant glenn@heaven.woodside.ca.us Independent Software Developer ..{adobe,next}!heaven!glenn 415-851-1785
woody@chinacat.Unicom.COM (Woody Baker @ Eagle Signal) (07/18/90)
In article <2259@dino.cs.iastate.edu>, hascall@cs.iastate.edu (John Hascall) writes: > How does one determine the left side bearing of a character (in a > > charpath flattenpath pathbbox > > may be used to determine character bounding boxes and side bearings." > > Well, I can see how it gives you the bounding box, but how do you > get the (left) side bearing? Well, it turns out that the lower left x coordinate IS the left sidebearing. Since bounding box just encloses the character, if the character is offset from the current position (i.e. the leftmost point of the character) either positive or negative, it will show up as a positive or negative number, which is the sidebearing. After struggling for better than 9 months, and after not getting replies to several inquires, I am now prepared to state that the RED book appears to be FLAT WRONG when it says that the metrics entry can be an array, that includes the left sidebearing and the width. The width part works, but regardless of what you put in the other element, it does not work. Adobe has a major gap between documentation and implemtation. IF some one can prove me wrong on this, I'll gladly retract this statement. To do so, send me or post a fragment of code that clearly demonstrates teh altering of the sidebearing. Print some letters in say Times Roman, especially 'j' and 'l' and 'W', then alter the the width, and print them again, then alter the sidebearing and the width and print them again. The application is monospacing the proportional fonts. By measuring the width of say a "W", and taking that to be the cell width, computing the bounding box for a character, subtracting it from the cell width, dividing the result by 2, one can get an offset that you need to shift the left sidebearing by inorder to make the character sit squarely in the "cell" width. In addition, you have to set the character width to the value computed from "W". If you just change the character widths to the value obtained by "W", and then print the text, it becomes very obvious that while the "escapement" of the characters has been changed, the characters are NOT centered in the cell. Computing the diffrence, and altering the sidebearing should fix the problem. I have not gotten it to work, inspite of many hours (so far over 20) of hacking at it, and working on it. Cheers Woody
phillips@tegra.COM (Steve Phillips) (07/24/90)
In article <2259@dino.cs.iastate.edu> hascall@cs.iastate.edu (John Hascall) writes: > How does one determine the left side bearing of a character (in a >particular font)? I am looking at section 5.5, "Font Metric Information", >of the Red Book, (pp 95-96), which says: "The sequence > > charpath flattenpath pathbbox > >may be used to determine character bounding boxes and side bearings." > > Well, I can see how it gives you the bounding box, but how do you >get the (left) side bearing? > Render the character at 1000 points starting at (0,0): /FontName findfont 1000 scalefont setfont 0 0 moveto (A) charpatah flattenpath pathbbox Now the X coordinate of the left edge of the path bounding box will be the left sidebearing in 1000th's of an em. What you're doing is positioning the em-square at the origin, so the pathbbox will give you the relative position of the character outline within the em-square. Hope this helps... - Steve -- ============================================================================ Steve Phillips Tegra-Varityper, Inc. tegra!phillips@uunet.com Billerica, MA ============================================================================