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
[711x3]
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 [ ]
Henrik
18-Apr-2006
[752]
size-text is the limit of the size of the face as well
Graham
18-Apr-2006
[753]
oh ..
Henrik
18-Apr-2006
[754x7]
center: func [text width font] [
  (width / 2) - (first size-text make face compose copy [
    text: (text)
    font: (font)
    size: (as-pair width 100)
  ])
]
hmm... maybe a different one is better...
center: func [text size font] [
  (size/x / 2) - (first size-text make face compose copy [
    text: (text)
    font: (font)
    size: (size)
  ])
]
center: func [text size font] [
  divide subtract size/x first size-text make face compose copy [
    text: (text)
    font: (font)
    size: (size)
  ] 2
]
getting better :-)
offsets a few pixels to the left, but it seems to center the text
the offset gets bigger when using a larger font.. wonder what causes 
it