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

World: r3wp

[Postscript] Emitting Postscript from REBOL

Anton
18-Apr-2006
[688x5]
For example, from code that scale-draw produces:
font1: make object! [
		name: "Nimbus Roman No9 L"
		style: none
		size: 33
		color: 255.0.0
		offset: 2x2
		space: 0x0
		align: 'center
		valign: 'center
		shadow: none
	]

font2: make object! [
		name: "Nimbus Roman No9 L"
		style: none
		size: 13
		color: 0.0.0
		offset: 2x2
		space: 0x0
		align: 'center
		valign: 'center
		shadow: none
	]

view layout [box 500x700 white effect [draw [
	box 0x0 493x698 
	fill-pen none 
	box 0x0 493x698 
	line-width 0 

 font font1 pen 255.0.0 text vectorial "REBOL PostScript Dialect" 
 59x68 
	pen 0.0.0 line 59x104 431x104 

 font font2 pen 0.0.0 text vectorial {With this dialect it's possible 
 to easily produce PostScript output.} 79x121
]]]
The second text does not appear for me on View1.3.2.3.1
but it does when font/size is at 15 instead of 13.....
Maybe my fonts are not so complete.
Gabriele
18-Apr-2006
[693]
graham, i don't think you want to look at the code (still too ugly), 
but the pdf maker does kerning.
Graham
18-Apr-2006
[694x6]
Anton, did you download that font pack I pointed to ?
When I look at the scaling, the only text that does funny things 
is the one that says "transformations"
I see both texts on my system.
as they are true type fonts, they should appear at all sizes.
Gabriele, do you use the kerning for all text placement in pdf-maker?
and where do you get the hint data from?  Is it read from the font 
somehow?
Anton
18-Apr-2006
[700x2]
Graham, oh no I didn't, sorry I missed that.
Good idea to put a link to the font pack into the ps2draw.r header.
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
[737]
could be possible to simplify that...