World: r3wp
[Postscript] Emitting Postscript from REBOL
older newer | first last |
Henrik 20-Apr-2008 [1574x5] | what I did at first was just to use the font size. that doesn't work, because it does not take the baseline into account. |
then I used Graham's method and it does practically the same thing (I forgot to test for letters like "g"), but you can successfully calculate the bbox for a text string this way, if you need it. | |
Combining Graham's method with getting the height from the entire alphabet instead of the single word would eliminate the varying height problem you mention. But the baseline problem turns up again. | |
The bbox information for the entire font is stored in each font metric file as a [llx, lly, urx, ury] coordinate set, so I shouldn't need to calculate it. This information is crucial in order to get one line of vertically centered text. I already got everything in place except that particular number. :-) | |
the source you are reading contains Graham's method | |
Geomol 20-Apr-2008 [1579] | Isn't this centered? PageSize A4 page [ font [Times 40] linewidth 0 at 0x421 "Centered text" center 595 ] |
Henrik 20-Apr-2008 [1580] | well, that's hardcoded :-) |
Geomol 20-Apr-2008 [1581] | Yes, that's what I think, you should do. Build a dialect with keywords as top, middle, bottom etc. and make that dialect know the size of the paper and correctly calculate the positions. That's the way to do it, I think. I would do it like that. |
Henrik 20-Apr-2008 [1582] | as mentioned before, that won't work, because the font information is not obtainable from inside REBOL. it has to be done inside postscript. I've already tried that method a year ago and it failed. :-) |
Geomol 20-Apr-2008 [1583x3] | Remember what kind of language, PS is. |
There is no information about font (other than Times 40) in my example. | |
The 0x421 and 595 comes from the papersize, which is 595x842 when using A4. | |
Henrik 20-Apr-2008 [1586x2] | ok, tell me then the algorithm for calculating the font height inside REBOL. :-) you cannot possibly know without reading and parsing the .PFM files yourself. |
and as mentioned at first, I already tried the font size... doesn't work. | |
Geomol 20-Apr-2008 [1588] | Why would I need the font height? I didn't need that in my example to center the text. |
Henrik 20-Apr-2008 [1589] | no, because you probably were eyeballing it. |
Geomol 20-Apr-2008 [1590] | No, I didn't! :) |
Henrik 20-Apr-2008 [1591] | center the text ... are you talking about _horizontally_ centered text? |
Geomol 20-Apr-2008 [1592x2] | When you do things like: at 100x200 "some text" the character origin of the first character in the text is at position 100x200. |
No, horiz and vert! | |
Henrik 20-Apr-2008 [1594] | where did you get 0x421 from? |
Geomol 20-Apr-2008 [1595x2] | 0 is left side of paper. 421 is height of paper divided by 2. 842 / 2 = 421. |
Then it's centered. | |
Henrik 20-Apr-2008 [1597x3] | if that's the case, let me test the theory |
what?... | |
why doesn't that work for smaller cells? | |
Geomol 20-Apr-2008 [1600x2] | PageSize A4 page [ font [Times 18] at 60x421 "abcdefg" font [Times 36] at 130x421 "abcdefg" font [Times 96] at 260x421 "abcdefg" ] |
In my example, the baseline of all the text is vertical centered on the page. | |
Henrik 20-Apr-2008 [1602x3] | now I'm reallly confused. it would mean the height of the paper is somehow misleading. I tried your method in the table cells and get top-aligned text as I expected. |
sorry | |
not top-aligned text, but text where the baseline is the center. | |
Geomol 20-Apr-2008 [1605x2] | Ok, if it does, what you need. :-) |
Do you have the psrefman.pdf document for PS second edition? Seciton 5.4 has a drawing of font positioning. | |
Henrik 20-Apr-2008 [1607] | I. Need. Vertically. Centered. Text. :-) Is that so hard to understand? :-) |
Geomol 20-Apr-2008 [1608] | LOL :) |
Henrik 20-Apr-2008 [1609x2] | Your method produces this: http://hmkdesign.dk/rebol/postscript/testsheet.ps |
That is _not_ vertically centered text. That is text that is vertically centered around the baseline. | |
Geomol 20-Apr-2008 [1611] | Eh, the baseline is centered in each cell, right? And you're asking each word to be centered within its cell with equal space above and below the text? |
Henrik 20-Apr-2008 [1612] | ... yes :-) |
Geomol 20-Apr-2008 [1613] | Because if you want that, then it'll look strange, because each line in the table will have text jumping up and down, depending on whether you have letters like 'g' and 't' or you just have letters like 'a'. And that will look less nice to me. |
Henrik 20-Apr-2008 [1614] | sigh... I've already said 4 times that I use the alphabet to prevent this! :-) |
Geomol 20-Apr-2008 [1615] | But you're right, that if you really want that, then you need to get info from each letter in the font. |
Henrik 20-Apr-2008 [1616] | yes! now you get it |
Geomol 20-Apr-2008 [1617] | :) In REBOL/View, there is things like offsets to position text within field and so. Couldn't you go with something like that? Just subtract a little from each vertical position to get the text a little down, if you want? |
Henrik 20-Apr-2008 [1618] | then I have to do that for each single individual case. with the deadline I have to produce this table, that may be my option for now, but that is definitely not optimal. |
Geomol 20-Apr-2008 [1619x2] | If you have different fontsizes in your tables, you could do something like: y-pos: y-pos - (fontsize / 10) |
Then adjust the 10 factor, until you're satisfied. And that should then work for all fontsizes. | |
Henrik 20-Apr-2008 [1621] | well, possibly. I'll see if that works for now. |
Geomol 20-Apr-2008 [1622] | Sorry, that I find it hard to understand, what you mean from time to time, my fault. I get you now. I would put things like margins, linespace, vertical position within tables, etc. in a dialect above the postscript dialect level. Doing it that way, the same postscript dialect can be used for all sorts of layout engines, because it has little restriction. |
Henrik 20-Apr-2008 [1623] | for the syntax and input yes, but if you need accuracy, you need to get the information via postscript. |
older newer | first last |