REBOL3 - Postscript (Emitting Postscript from REBOL [web-public])

Return to Index Page
Most recent messages (300 max) are listed first.

#UserMessageDate
1742HenrikI don't know. I don't have the HP1200 anymore. :-)25-Jun 7:53
1741Grahamso does using %//prn work any better than using echo??24-Jun 20:43
1740Henrikanother advantage is that it's fairly simple to add a new method. it took 20 minutes to add Ghostscript printing via the win32pr driver and when it was added, I could print anything, which is a nice thing about this abstraction.24-Jun 14:49
1739HenrikI can release the code for you, if you're interested.24-Jun 14:47
1738Henrikit is largely oriented towards use on Win98/XP.24-Jun 14:46
1737Henrikthe downside with this system is that I'm still not using straight native windows printing. the good side is that it offers many alternative solutions for printing.24-Jun 14:46
1736Henrikthe first part can probably be replaced with your own stuff24-Jun 14:45
1735Henrikyou feed a postscript layout through a parser, which fills in dynamic values and then it's run through postscript.r and then it's fed through system-print to the appropriate printing method.24-Jun 14:45
1734HenrikThere is also a print queue system, which you can opt to use, if you don't want to print directly.

http://rebol.hmkdesign.dk/files/system-print-queue.png

24-Jun 14:43
1733HenrikIt supports currently print to file, print to LPT, print to Ghostscript, print to screen (as in screenshot), print to ethernet printer and to a custom network printer server made in REBOL for some simple printer sharing.24-Jun 14:42
1732Henrikhttp://rebol.hmkdesign.dk/files/system-print.png24-Jun 14:39
1731HenrikGeomol, I built a printer abstraction system called system-print for my apps. It's not finished, but for what it does it works sort of OK. You can choose printing method via a GUI and it auto-detects Ghostscript and uses it if necessary.24-Jun 14:37
1730Geomol"There are many printer specific bugs that require a windows printer driver to make postscript printing work properly"

Bad news for me! I'm working on a new version of a huge application for a customer, and I was about to rebuild their printing in a couple of months. I planned to use the rebol postscript dialect.

24-Jun 14:29
1729Grahamghostscript can generate pcl from postscript ... and then you can feed it to the driver24-Jun 12:21
1728Henrikif anything, perhaps that process is faster24-Jun 12:20
1727Grahamas opposed to sending PCL to the printer... well, that is my guess24-Jun 12:20
1726Grahamthe HP driver probably takes PCL and creates a bitmap and then sends it to the printer24-Jun 12:20
1725Henrikit might not24-Jun 12:18
1724GrahamMy guess is that it doesn't have any PCL engine on boad.24-Jun 12:18
1723Grahamtake the printer output and send it directly to the printer if you can .. see what happens24-Jun 12:18
1722Grahamsetup a HP printer ( eg an old laserjet ) and set the driver to print to a file24-Jun 12:17
1721Henrikand a new PC. that stupid machine just died. glorious day today.24-Jun 12:17
1720Henrikhmm... need some examples for that.24-Jun 12:17
1719Grahamwith a PCL driver24-Jun 12:17
1718GrahamIf it doesn't understand it .. then it's just a dumb printer24-Jun 12:16
1717Grahamtry sending some raw PCL to the printer to see what happens24-Jun 12:16
1716Henrikwell, as long as this one is.. :-)24-Jun 12:15
1715Grahamno24-Jun 12:15
1714Henrikyes it is. I think all HP printers are.24-Jun 12:14
1713Grahamthe product description says that the HHP 1505 is a host based PCL printer24-Jun 12:14
1712Henrikif it can that makes my task simpler.24-Jun 12:14
1711HenrikI did not know that.24-Jun 12:13
1710GrahamSince the printer driver is host based, it would be doing the same thing as well.24-Jun 12:05
1709Grahamand then you can dump the resulting prn file to the printer vs creating a bitmap??24-Jun 12:03
1708GrahamYou do know that ghostscript can convert ps to pcl ??24-Jun 12:03
1707Grahamdo you need to print as soon as possible?24-Jun 12:00
1706Henrikyes, I don't expect it to be as fast as PS, but this is like... 25-50 times slower. :-)24-Jun 11:56
1705Grahamso it will always be slower than a PS printe.24-Jun 11:55
1704Henriknow if they stopped that winprinter crap and had postscript as standard in all printers... the hardware to do that should be fairly cheap for that today.24-Jun 11:55
1703Grahamcheap host based printer24-Jun 11:55
1702Henrikyeah :-(24-Jun 11:54
1701Henrikit seems gsprint provides many more options... I will have to investigate that.24-Jun 11:54
1700Grahamyou need to create a PCL driver :)24-Jun 11:54
1699Henrikmine and budget. we can't afford a better printer.24-Jun 11:53
1698Grahamwho's decision was it to purchase that?24-Jun 11:53
1697Henrikwell, the bitmap it sends is over 2 MB in size. that's pretty huge for a pure b/w bitmap I think.24-Jun 11:53
1696HenrikHP Laserjet 1505.24-Jun 11:52
1695Grahamwhat printer do you have now?24-Jun 11:52
1694Grahamfaster PC24-Jun 11:52
1693Henrikthe only problem is the speed. I really wish I could speed it up.24-Jun 11:51
1692Henriknow with a new printer, I have to create a completely different setup with ghostscript.24-Jun 11:51
1691Grahamwell, then there is very little option except to use ghostscript24-Jun 11:51
1690HenrikI ranted about it, because I could not print directly to it, but had to use the adobe driver for that.24-Jun 11:50
1689Henriksorry if I confused you. no the HP1200 one is no longer being used24-Jun 11:50
1688Grahamthe HP 1200 ?24-Jun 11:49
1687GrahamHuh??24-Jun 11:49
1686Henrikthe problem is that the new printer is not a postscript printer.24-Jun 11:49
1685Grahamwell, if the way you're doing it now is not working ... I suggest you try my ways :)24-Jun 11:48
1684Henrikit's a confusing subject, because there are 20 different ways to print :-)24-Jun 11:48
1683Grahamso might fix your problems as well.24-Jun 11:46
1682GrahamMaybe this is even going thru the windows printer driver24-Jun 11:46
1681Grahamand so %//prn will still work ...24-Jun 11:43
1680Grahamthis is what I had to do for usb printers .. http://synapsedirect.com/forums/thread/396.aspx24-Jun 11:41
1679HenrikI've been informed that we are not using win98 anymore (yay!)24-Jun 11:40
1678Grahamit might not work under Windows 9824-Jun 11:38
1677Henrikso %prn is a DOS/win32 thing that REBOL just uses?24-Jun 11:36
1676Grahamfrom Andrew Martin

Printer: func [Text [string!] /Page] [ secure [ %//prn [allow write] ] write %//prn Text ; Append Carriage Return (CR) and Page Feed. if Page [write/binary %//prn "^(0D)^(page)"] Text ]

24-Jun 11:34
1675Graham%//lpt1 is also possible, but according to google, %//prn diverts to the first availabel printer24-Jun 11:33
1674Henrikinteresting... but ok, now my focus is to make it work on any printer. as mentioned it is fed through ghostscript. when I read about GSPrint it almost seems like it does the same thing. it even uses the same driver.24-Jun 11:31
1673GrahamBut never had a problem24-Jun 11:30
1672Grahamdunno24-Jun 11:30
1671Henrikinteresting... what decides that %//prn is LPT1?24-Jun 11:30
1670Grahamwhen printing to lpt124-Jun 11:29
1669Grahamthis is what I do ...

write %//prn content

24-Jun 11:29
1668HenrikI just echo'ed it through DOS to LPT1:.24-Jun 11:28
1667Grahamwhat was your code to send the ps to the printer??24-Jun 11:27
1666Henrikand I tried both with similar results24-Jun 11:27
1665Henrikit can use both.24-Jun 11:27
1664Grahamparallel or usb?24-Jun 11:27
1663HenrikHP Laserjet 120024-Jun 11:26
1662Grahamand which were you using?24-Jun 11:26
1661HenrikIt uses parallel/usb24-Jun 11:26
1660Grahamwhat sort of printer is it??24-Jun 11:25
1659GrahamI got some notes somewhere that async printing to a postscript printer caused me problems.24-Jun 11:25
1658Henrikdoesn't that only work for ethernet printers?24-Jun 11:25
1657Grahamso, you just writing to port 9100 ?24-Jun 11:20
1656Henriknope24-Jun 11:19
1655GrahamIs it a shared printer?24-Jun 11:19
1654HenrikI don't think it's the postscript itself that's buggy, but the transmission of the code to the printer. Perhaps they are screwing around with port settings inside the driver which we don't know about. So it may be a lower level problem.24-Jun 11:19
1653HenrikI don't use GSView at all.24-Jun 11:18
1652Grahambut I guess gswin32 should complain if there is an error in the ps code24-Jun 11:18
1651Grahamthe point of using gsview is as a debugging tool24-Jun 11:17
1650Henrikwill have a look at gsprint...24-Jun 11:17
1649HenrikI call gswin32c.exe and feed it parameters to use the win32pr driver, which sends a bitmap to the printer given as a parameter in the same call.24-Jun 11:16
1648Grahamso, you're also using gsprint?24-Jun 11:13
1647HenrikNo, ghostscript generates a bitmap for printing on any printer, which is what I have to use now. I used the adobe driver for the HP 1200.24-Jun 11:11
1646Grahamso, you send postscript to ghostscript when then generates postscript again to send to the HP printers?24-Jun 11:10
1645HenrikI don't use GSView, I use the printer with Ghostscript as passthrough.24-Jun 11:09
1644Grahamor is interpreted interactively by ghostscript?24-Jun 11:05
1643Grahamwhat happens when the code you send is rendered by gsview?24-Jun 11:04
1642HenrikI have worked for many weeks on the problem and it's unsolvable, so I went to Ghostscript instead, but I'm unhappy with its speed.24-Jun 10:59
1641Grahamand you're sure that your postscript code is correct??24-Jun 10:40
1640HenrikI've also seen a Laserjet 4500 lock completely up, when you feed it a specific postscript or PDF file.24-Jun 9:54
1639HenrikI read about the HP Laserjet 1200 and it has such a bug in its postscript implementation that is easiest worked around in the driver.24-Jun 9:54
1638HenrikI had problems with feeding postscript files generated by postscript.r directly to an HP Laserjet 1200. It would stop printing after the first job. Feeding it through Ghostscript or the adobe postscript printer driver solved the problem, but now the printer is replaced with a different one with different issues.24-Jun 9:51
1637Grahamwhat do you mean by printer specific bugs?24-Jun 9:35
1636HenrikI gave in, and have begun using ghostscript for printing postscript. There are many printer specific bugs that require a windows printer driver to make postscript printing work properly, so I now use the mswinpr2 driver. However it eats about 40 MB RAM printing one page. Anyone got ideas on how to reduce that?24-Jun 8:52
1635HenrikAnd when I say the letter is tall in Helvetica or Times, that means it may not be so in other fonts. I don't believe a font like Verdana does this. This is why when getting the absolute center for a font, you must calculate it using all glyphs in the font.20-Apr 14:19
1634Henrikit depends on the chars you use. if you use a word like "judge", the word might appear offset downward, because there are no really tall letters in that word. if you use a word like "Greg", the word might appear more centered. If you say "GGG", the word might appear offset upward, because "G" is a tall character in Helvetica or Times. But overall, if you write a long sentence like that, the words should appear centered.20-Apr 14:16
1633GeomolI can see, that text in tables in html is centered more like you want it, at least in Safari. Actually the text is much lower in Safari, so there is more space above the text than below, if you use words with 'g'. I can't judge, if they do a simple calculation or use the font box.20-Apr 14:12
1632Henrikbut I do wish that each char in a font had a center point that indicates the absolute center of a character both horizontally and vertically. horizontally, that would be individual for each char, but vertically it has to be identical for all chars, like the baseline is.20-Apr 13:57
1631Henrikadobe didn't invent the baseline20-Apr 13:54
1630Henrikthe baseline is a typographical tool. it is the place where your letters are "resting" against, just like when you were learning to write in school, you had a guide line to write characters on. but the baseline itself is completely useless for vertical centering of text.20-Apr 13:54
1629GeomolThat is the reason, that they put the baseline as they did?20-Apr 13:52
1628Henrikand the position calculation is around the baseline.20-Apr 13:52
1627Henrikit is not centered, because the baseline is not at the center of the text. if only it were :-)20-Apr 13:51
1626GeomolDon't you think, it already is centered, if you take underline into consideration? It seems weird to me, that Adobe would position text being off some amount, either up or down.20-Apr 13:51
1625Henrikbecause we are already doing it correctly using stringwidth, namely by calculating the text size accurately inside postscript. the same should count for the vertical size. it's strange that information is so hard to get.20-Apr 13:49
1624Geomolok20-Apr 13:48
1623Henrikfor the syntax and input yes, but if you need accuracy, you need to get the information via postscript.20-Apr 13:47
1622GeomolSorry, 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.20-Apr 13:45
1621Henrikwell, possibly. I'll see if that works for now.20-Apr 13:41
1620GeomolThen adjust the 10 factor, until you're satisfied. And that should then work for all fontsizes.20-Apr 13:40
1619GeomolIf you have different fontsizes in your tables, you could do something like: y-pos: y-pos - (fontsize / 10)20-Apr 13:39
1618Henrikthen 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.20-Apr 13:37
1617Geomol:) 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?20-Apr 13:36
1616Henrikyes! now you get it20-Apr 13:34
1615GeomolBut you're right, that if you really want that, then you need to get info from each letter in the font.20-Apr 13:34
1614Henriksigh... I've already said 4 times that I use the alphabet to prevent this! :-)20-Apr 13:34
1613GeomolBecause 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.20-Apr 13:33
1612Henrik... yes :-)20-Apr 13:32
1611GeomolEh, 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?20-Apr 13:32
1610HenrikThat is _not_ vertically centered text. That is text that is vertically centered around the baseline.20-Apr 13:30
1609HenrikYour method produces this:

http://hmkdesign.dk/rebol/postscript/testsheet.ps

20-Apr 13:30
1608GeomolLOL :)20-Apr 13:29
1607HenrikI. Need. Vertically. Centered. Text. :-) Is that so hard to understand? :-)20-Apr 13:29
1606GeomolDo you have the psrefman.pdf document for PS second edition? Seciton 5.4 has a drawing of font positioning.20-Apr 13:29
1605GeomolOk, if it does, what you need. :-)20-Apr 13:28
1604Henriknot top-aligned text, but text where the baseline is the center.20-Apr 13:27
1603Henriksorry20-Apr 13:26
1602Henriknow 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.20-Apr 13:26
1601GeomolIn my example, the baseline of all the text is vertical centered on the page.20-Apr 13:26
1600GeomolPageSize A4 page [ font [Times 18] at 60x421 "abcdefg" font [Times 36] at 130x421 "abcdefg" font [Times 96] at 260x421 "abcdefg" ]20-Apr 13:24
1599Henrikwhy doesn't that work for smaller cells?20-Apr 13:23
1598Henrikwhat?...20-Apr 13:23
1597Henrikif that's the case, let me test the theory20-Apr 13:21
1596GeomolThen it's centered.20-Apr 13:21
1595Geomol0 is left side of paper. 421 is height of paper divided by 2. 842 / 2 = 421.20-Apr 13:20
1594Henrikwhere did you get 0x421 from?20-Apr 13:20
1593GeomolNo, horiz and vert!20-Apr 13:20
1592GeomolWhen you do things like: at 100x200 "some text" the character origin of the first character in the text is at position 100x200.20-Apr 13:19
1591Henrik"center the text" ... are you talking about _horizontally_ centered text?20-Apr 13:19
1590GeomolNo, I didn't! :)20-Apr 13:19
1589Henrikno, because you probably were eyeballing it.20-Apr 13:19
1588GeomolWhy would I need the font height? I didn't need that in my example to center the text.20-Apr 13:18
1587Henrikand as mentioned at first, I already tried the font size... doesn't work.20-Apr 13:18
1586Henrikok, tell me then the algorithm for calculating the font height inside REBOL. :-) you cannot possibly know without reading and parsing the .PFM files yourself.20-Apr 13:18
1585GeomolThe 0x421 and 595 comes from the papersize, which is 595x842 when using A4.20-Apr 13:17
1584GeomolThere is no information about font (other than Times 40) in my example.20-Apr 13:16
1583GeomolRemember what kind of language, PS is.20-Apr 13:15
1582Henrikas 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. :-)20-Apr 13:15
1581GeomolYes, 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.20-Apr 13:14
1580Henrikwell, that's hardcoded :-)20-Apr 13:13
1579GeomolIsn't this centered?

PageSize A4 page [ font [Times 40] linewidth 0 at 0x421 "Centered text" center 595 ]

20-Apr 13:12
1578Henrikthe source you are reading contains Graham's method20-Apr 13:08
1577HenrikThe 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. :-)20-Apr 13:07
1576HenrikCombining 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.20-Apr 13:04
1575Henrikthen 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.20-Apr 13:03
1574Henrikwhat I did at first was just to use the font size. that doesn't work, because it does not take the baseline into account.20-Apr 13:01
1573Henrikaccurately vertically centered text20-Apr 13:01
1572GeomolOk, I'm a bit lost. I'm not completely sure, what you're trying to achieve.20-Apr 13:00
1571Henrikand this information shouldn't need to be calced if we can get that from FontBBox in the font dictionary. still hunting for how to obtain it. :-)20-Apr 12:59
1570Henrikthis way the height will be constant20-Apr 12:59
1569Henrikthat you solve by calculating the bbox for the entire alphabet instead of just the words you write20-Apr 12:58
1568GeomolIf your goal is, that the text is completely centered vertically, then you have a problem. Because how do you know, what characters to be written? If there is no 'g' in the word, you need to position it a bit lower, than if you had 'g' in the text, for it to be completely middle aligned.20-Apr 12:57
1567HenrikThe baseline problem is the one I'm hunting a solution for. About the font metrics, the bbox for the whole font is stored in FontBBox in the font dictionary.20-Apr 12:56
1566Henrikthe table is a different matter :-) it's already done, not yet as a dialect though. I will build one later.20-Apr 12:55
1565GeomolNo, text is rendered from the "character origin" (the baseline), which can be different than the center of the text. This should probably be taken care of, if needed. hm20-Apr 12:55
1564GeomolIf you wanna build a table, you calculate the position of each line like this, and send the precise coords to the postscript dialect. It would probably be best to build a new dialect on top of the postscript one, and in that dialect handle the calculations.20-Apr 12:53
1563Henrikthat assumes that the text is rendered from its own center point. it isn't, is it?20-Apr 12:53
1562GeomolThe y coord is 300 / 2 plus the 100 = 250.20-Apr 12:52
1561GeomolA vertical positioning would be a simple calculation. Say, you want the baseline to be positioned at the middle of a 300 point high box starting at pos (100, 100). You then start by putting text at coord (100, 250).20-Apr 12:51
1560Henrikyou still need to know the size of the bbox, don't you?20-Apr 12:51
1559GeomolSo it doesn't matter, how high the font is.20-Apr 12:49
1558GeomolIn Adobe documentation, they operate with "character origin", which is the baseline, I think. If you do: 40 50 moveto (ABC) show , the origin of the A letter is at coordinate (40, 50).20-Apr 12:48
1557Henrikso my current method is Graham's, except for calculating the entire alphabet. we should probably work on getting that information from the font metric file instead.20-Apr 12:45
1556Henrikthere is another method which is to get the bbox information from the font metric file itself. it's much faster, since it's just lookup, but I couldn't find an example of how to read it.20-Apr 12:44
1555HenrikI got it rendered now so that the vertical position is at least consistent now, but the font is offset a few points too far down. I don't know why yet, but it's probably the baseline again.20-Apr 12:42
1554HenrikThe problem is to get the height accurately for all glyphs for a font (I just got that now). Some fonts have very high tops and very low bottoms and you want that to work for any font and letter combination we throw at it. it would be harder to get that information inside REBOL than inside postscript.20-Apr 12:41
1553GeomolIf vertical position should be in the dialect, I think, it should be based on a real postscript feature. If such a thing isn't found in postscript, it should be implemented on a higher level, shouldn't it?20-Apr 12:38
1552Henrikso if the bounding box does that for a single word, we need to use all chars in the alphabet to calculate the height correctly for any char combination. it does not do that right now20-Apr 12:34
1551Henrikseems it's still not accurate :-( it still calculates the baseline incorrectly when using letters like "g"20-Apr 12:32
1550HenrikGeomol, there is some code duplication in there. Perhaps it can be optimized?20-Apr 12:30
1549Henrik(table is my own component, not part of postscript.r :-))20-Apr 12:28
1548Henrikexample of adjustments: http://hmkdesign.dk/rebol/postscript/testsheet.ps20-Apr 12:27
1547Henrikmoved the source to http://hmkdesign.dk/rebol/postscript/postscript.r20-Apr 12:26
1546GeomolI'll take a look at your changes...20-Apr 12:26
1545GeomolYes, the y width seems to be for vertical writing, like in chinese.20-Apr 12:24
1544Henrikallegedly the method graham describes is not very efficient, but it works accurately and that's what I want.20-Apr 12:24
1543Henrikupdated source code for download20-Apr 12:23
1542Henrikbut now I have margin working too. it was simple to add.20-Apr 12:21
1541Henrikit has something to do with offsetting from the glyph origin, I think20-Apr 12:21
1540HenrikI use it only for X. The Y component is not a height, but something else.20-Apr 12:20
1539GeomolI was looking at the postscript operator STRINGWIDTH. It seems to be able to take two arguments, for x and y width. Are you using that?20-Apr 12:19
1538Henriknow it would be nice with some form of margin management20-Apr 12:09
1537HenrikThe changes are:

- Stores the font size inside PS every time a new font is selected. This is not used however, but perhaps is useful in the future. - Added bottom, middle and top alignment for TEXT. Similarly to how you specify a size for LEFT, CENTER and RIGHT, you can enter a size for TOP, MIDDLE and BOTTOM:

"Some text" center 400 middle 200

Both sets are optional. The default alignment is LEFT and BOTTOM.

My changes are marked HMK in the source. I hope it is of use.

20-Apr 12:08
1536HenrikGeomol, you may find my changes here:

http://hmkdesign.dk/rebol/postscript.r

20-Apr 12:05
1535Henrikit also helps better top alignment20-Apr 11:59
1534Henrikyes! got grahams method working now. thanks.20-Apr 11:59
1533Henrikyes20-Apr 0:28
1532Grahamaren't you both in the same timezone?20-Apr 0:23
1531Henriktime for bed... Geomol can take over in the morning. :-)20-Apr 0:22
1530HenrikGot the font size to work, but it doesn't take the baseline into account.20-Apr 0:21
1529HenrikI get a postscript error.20-Apr 0:21
1528Grahamwhat do you mean it doesn't work?20-Apr 0:19
1527Henriknope, that doesn't work either20-Apr 0:14
1526Grahamfaq: http://www.postscript.org/FAQs/language/node67.html20-Apr 0:11
1525Henrikthough not in that form20-Apr 0:11
1524Henriktried that one, couldn't get it to work.20-Apr 0:10
1523Henrikhow do I call it again, with /fontsize or fontsize?20-Apr 0:10
1522GrahamThe ``charpath'' operator extracts the graphic shapes of its string operand and appends them to the current path in the graphic state. These shapes can then be processed by other PostScript operators. To get the actual size of the area touched by a character a simple approach is

gsave newpath 0 0 moveto (X) false charpath flattenpath pathbbox grestore

This code places four numbers on the stack, representing the coordinates of the lower left and upper right corners of the bounding box enclosing the character ``X'' rendered with the current point at (0,0). Leaving the flattenpath out will cause it to be less accurate, but it will take up less memory and be faster.

20-Apr 0:09
1521Grahamit's the offset from the baseline20-Apr 0:09
1520Henrikstringwidth returns the width and some form of Y value that is not the height, but something else.20-Apr 0:08
1519GrahamI seem to remember justification routines get the word size, drop the height value and just work on the width20-Apr 0:07
1518Graham/fontsize (size) def20-Apr 0:05
1517Grahamnot sure about that .. but you can set a postscript variable to hold the latest fontsize and reference that20-Apr 0:04
1516Henrikthe width of the text yes, not the height. and I may not know the font at rendering time as that may be set in a completely different part of the program.20-Apr 0:03
1515Grahamand there are postscript commands for getting the size of the text20-Apr 0:01
1514Grahamyou define the font height when you set the font.20-Apr 0:01
1513HenrikGeomol, I have the structure change needed for text to support the font height, so the vertical centering can be made, but I just can't find the postscript commands necessary to obtain the font height.20-Apr 0:00
1512Grahamhuh?20-Apr 0:00
1511Henriklooks like getting something so simple as the font height is rather difficult in postscript20-Apr 0:00
1510ReichartI'm working on displaying Qwikis (Wikis) on Cell phones.

It is a connected problem, viewing something intended for one medium on another.

My basic plan is:

- Images - make a thumbnail, then let them click on it to see a larger or a list of sizes of their choice

- Tables - Show the name of the table, and then a bias, column or row, and offer a search. Then drill down.

When printing big tables to paper you have to decide what to do if the table is simply too big for a single piece of paper.

Put the table at the end on multiple pages? Put a small version of the table (perhaps unreadable), and say "See table on Exhibit X"? Put the table on multiple pages inline? Convert the table to something else, for example more like a query result, where each row is a chunk of data in a new format?

19-Apr 17:08
1509Henrikneed it for table cells19-Apr 17:04
1508HenrikI think I have a crude way to do it for one line.19-Apr 17:03
1507ReichartThat is the big problem, basically, that as in going across pages (or being wide).19-Apr 16:49
1506GeomolNo, I don't think, I've looked at that yet. I might tomorrow.19-Apr 16:35
1505HenrikGeomol. have you been looking at vertically centered text? It could be added as a y parameter to 'text, where we already use an x parameter for the string box size.19-Apr 15:18
1504Henrik"dialect"19-Apr 10:39
1503Henrikanyone been working on a postscript table generator for the dialet?19-Apr 10:39
1502GeomolI needed the decimal! for text size in alignment, because postscript work with 72 dot pr. inch by default. Putting text on the page often need the text to be with sub-unit precision. It was possible to put the text with sub-unit before, but now also alignment can be with sub-unit precision.26-Feb 17:06
1501Henrikcool :-)26-Feb 16:24
1500GeomolYes, but it only worked with integer! text-size. I've added decimal! option, and this seems to work too. (sub-unit precision) I have a new version ready soon.26-Feb 16:24
1499Henrikit has worked fine in the past, I believe26-Feb 16:22
1498GeomolDo you use right-aligned text?26-Feb 16:03
1497HenrikI've only tried transformations for single paths, sorry.26-Feb 15:54
1496GeomolHas anyone tried the transformations? There might be an unwanted restriction in the implementation. I can't get transformations to work for a whole page, only for one path at a time.26-Feb 15:05
1495GeomolUpdated the documentation: http://home.tiscali.dk/john.niclasen/postscript/postscript.html Added describtion of comment.26-Feb 15:03
1494HenrikI'll give it a shot when I get access to the testing equipment.24-Feb 19:24
1493GeomolOutput from TextEdit printed to a PS file has this in the end:

%%Trailer %%Pages: 1 %%EOF ^D

The last char (ctrl-D) is hex 04. I think, the comment lines are according to "PostScript Language Document Structuring Conventions Specification". You can find this document on the net at Adobe. So there is a difference in how %%Pages comments are handled. And postscript.r doesn't put hex 04 in the end. You could try some of these changes, when you have the problem.

24-Feb 18:23
1492Henrika simple check: does a PS example from the internet end the same way as a postscript.r generated file?24-Feb 17:56
1491Henrikno, sorry, under Linux I also print to the device directly. LPR was when I used PDF for printing rather than PS.24-Feb 17:44
1490HenrikI've seen the bug in two separate HP laser printers24-Feb 17:41
1489Henrikwhat I do to cause the error is make a ps file with postscript.r and then feed it directly to the printer. In windows I print directly to LPT1: to produce it. Under Linux I print it via LPR.24-Feb 17:41
1488Geomolthat = what24-Feb 17:40
1487GeomolTo do anything about it, we need to be able to reproduce that error, and see if we can figure out, that might solve it. A way to test different things is to edit the ps-files by hand.24-Feb 17:39
1486Henrikan important detail: I don't think it's single print jobs of multiple pages that cause it, but rather multiple single page jobs.24-Feb 17:36
1485Henrikso for the other bug: I mentioned earlier that some printers I tried it on directly, will cause the printer to pause after the first page is printed. Then I need to press paper feed or reset the printer to get the rest out. Using Printfile for Windows solves that, but that program is really old and I don't want to rely on it in the future if my project is moved to Linux clients. I suspect there is just one char missing at the end of the PS file, but I don't truly know what causes it.24-Feb 17:34
1484GeomolYes, it works in preview now. :-)24-Feb 17:34
1483HenrikBTW: Does it work for you in preview.app?24-Feb 17:25
1482Henrikgo ahead :-)24-Feb 17:23
1481GeomolGreat! That's the version to use for now then. Maybe I should put an announce in that group?24-Feb 17:22
1480Henriktried a much bigger image. no problems at all.24-Feb 17:20
1479Henrikmuch faster now and it works24-Feb 17:19
1478Henrikoh, error 40 :-)24-Feb 17:17
1477Henrikodd, GS won't eat it24-Feb 17:17
1476GeomolHenrik, try with new version now: http://home.tiscali.dk/john.niclasen/postscript/postscript.r24-Feb 17:15
1475GeomolOk, I'll see, if I can make a faster insert...24-Feb 17:07
1474Geomolok :)24-Feb 17:07
1473Henrikdid that24-Feb 17:06
1472GeomolJust uncomment after the trim in line 213.24-Feb 17:06
1471Henriknow GS won't read the PS file, but the generation is much much faster. less than 0.5 secs24-Feb 17:06
1470HenrikI'm trying to remove that code right now to see if it improves performance.24-Feb 17:05
1469GeomolIf the inserting is the problem, then I might be able to fix that with copy to another series in stead. Problem with insert is, when you have large series, it has to move the content down the memory.24-Feb 17:04
1468Henrikyep, same thing without /update.24-Feb 17:03
1467Henrikdidn't try that with /update yet. will have to be sure24-Feb 17:03
1466Geomolok, the inserting of the newlines is the problem?24-Feb 17:03
1465Henrikso I think there should be an option to leave that out, or by default not have it. I'm guessing most people want to generate and print PS file, rather than read and edit them by hand.24-Feb 17:02
1464GeomolYou say, you tried a local file, but did you change the load-image in postscript.r?24-Feb 17:02
1463Henriknope, it's the inserting part. the rest is taking no time at all.24-Feb 17:01
1462Henrikwill try to add some profiling hints24-Feb 16:59
1461Henrikit does not, I tried a local file. 12 seconds.24-Feb 16:59
1460GeomolMy guess is, that it's the load-image/update that give you performance hit. Try change it!24-Feb 16:58
1459GeomolIt seems to work without the newlines, but then the ps file become difficult to enter with e.g. vim. That part is fast, I think. It only put in a newline for every 80 chars.24-Feb 16:58
1458Henrikdoes it need to be done?24-Feb 16:54
1457Henrikperhaps inserting in images is very slow?24-Feb 16:54
1456Henrikperhaps it's equal in speed, I don't know. odd though, I can't see what's so slow about that code, other than the newline insertion thing24-Feb 16:53
1455GeomolSo this is very simple encoding. ASCII85 encoding is a bit more difficult, but will take up less space.24-Feb 16:52
1454Henrikok24-Feb 16:50
1453Henrikwhen building the image data, how do you do that? or does ASCIIHexDecode do that?24-Feb 16:50
1452GeomolIf you look in postscript.r, I encode the image data in line 211-220. It's just normal hex written as ASCII, so you get '0'-'9' + 'A'-'F'.24-Feb 16:50
1451GeomolImages are implemented in postscript.r using ASCIIHexDecode filter, which double the size of image data. It would be better to implement ASCII85, which does a 4:5 increase only.

Also images are handled in something called dictionaries in PostScript. This require PostScript v. 2.0.

24-Feb 16:48
1450Henrikwhat do you do to translate the data? is it in mezzanine form?24-Feb 16:48
1449Henrikperhaps 12 seconds with a local palms.jpg file24-Feb 16:47
1448Henriktesting postscript generation24-Feb 16:47
1447Henrikwriting palms.jpg locally took 1 second24-Feb 16:46
1446GeomolTry take a local copy of postscript.r and change the load-image to not do a /update.24-Feb 16:44
1445Henrikwill test with a local file soon24-Feb 16:44
1444Geomolok24-Feb 16:44
1443Henriktried several times, same result.24-Feb 16:44

Return to Index Page