r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Postscript] Emitting Postscript from REBOL

Graham
18-Apr-2006
[702x4]
I've uploaded a new version with that information in the header now.
this version allows you to print to a network printer, to lpt1, or 
to a disk file, and then it calls the RoPS viewer.
A line with embedded CR is now rendered correctly in the postscript 
output.
I have a button "Edit" which imperfectly shows you the dialect source 
( strings lose their quote marks).  Not formatted though.  And save 
which is supposed to re-render any changes doesn't work .. because 
the data needs to be converted from text to a block, and without 
the quote marks for the text, it dies.  Too late for me to find a 
fix.
Anton
18-Apr-2006
[706x3]
molded ?
Yeah, "Edit data" just forms the data, mold it instead.
Starting to look very good. :)
Graham
18-Apr-2006
[709x5]
update a new version that shows the data formatted.
you can edit and save, and it redraws it.
But there is a context problem with the colours .. so I had to replace 
(red) and (black) with their tuples.
I guess I need to bind somewhere...
mold ?  Oh ... didn't think of that.
Henrik
18-Apr-2006
[714x2]
with postscript you probably can't control what tray you need to 
print from...?
graham, did you figure out how to use the parallel port and was that 
for printing?
Gabriele
18-Apr-2006
[716]
Graham: yes, and data is parsed from the Adobe Font Metrics file 
and included in pdf-maker.r for the 14 standard postscript fonts.
Graham
18-Apr-2006
[717x2]
Henrik, my latest demo has a button that prints to the parallel port. 
 As for choosing trays and paper size, I think you can set that in 
the postscript comments.
Gabriele, do you have a reference on how to use this font metric 
data ?
Henrik
18-Apr-2006
[719]
is there a method to center text?
Graham
18-Apr-2006
[720]
I used a ruler :)
Henrik
18-Apr-2006
[721]
darn it
Graham
18-Apr-2006
[722]
Ok, let's be serious
Henrik
18-Apr-2006
[723]
hmm... at least measure the size of the text
Graham
18-Apr-2006
[724x3]
You can determine the size of the text based on the current point 
size
and you know the page size
so, you can center it in draw.
Henrik
18-Apr-2006
[727]
hmm... that would give me the height of the text, but not the width
Graham
18-Apr-2006
[728x3]
isn't there a textinfo thing that tells you the width of text?
there is also a stringwidth command in postscript.
so, my approach would be to create a center dialect word, and have 
a postscript implementation and a draw implementation
Henrik
18-Apr-2006
[731]
textinfo doesn't seem to work inside draw
Graham
18-Apr-2006
[732x2]
presumably you can use it in vid and use those values.
fair enough?
Henrik
18-Apr-2006
[734x2]
quite a detour...
but OK, I only need to calculate it for two lines of text right now
Graham
18-Apr-2006
[736]
>> layout [ a: text "this is a line" font [ size: 20 ]]
>> line-list: make system/view/line-info []
>> textinfo a line-list 0
>> probe line-list
make object! [
    start: "this is a line"
    num-chars: 14
    offset: 2x2
    size: 104x23
]
>> layout [ a: text "this is a line" font [ size: 12 ]]
>> textinfo a line-list 0
>> probe line-list
make object! [
    start: "this is a line"
    num-chars: 14
    offset: 2x2
    size: 68x15
]
Henrik
18-Apr-2006
[737x2]
could be possible to simplify that...
isn't there a SIZE-TEXT function?
Graham
18-Apr-2006
[739x2]
dunno
still needs a face
Henrik
18-Apr-2006
[741]
>> size-text make face [text: "hello"]
== 29x15
Graham
18-Apr-2006
[742]
easier :)
Henrik
18-Apr-2006
[743]
throw in a font definition
Graham
18-Apr-2006
[744]
example?
Henrik
18-Apr-2006
[745x4]
well, just the one used in DRAW for the text that needs to be printed
center: func [text width font] [
  width / 2 - second size-text make face compose [
    text: (text)
    font: (font)
  ]
]
that's what it takes
but it only works sometimes.. I don't know why
Graham
18-Apr-2006
[749]
copy
Henrik
18-Apr-2006
[750]
found the bug
Graham
18-Apr-2006
[751]
compose copy [ ]