Skip to main content
Known Participant
July 22, 2008
Question

stroke and fill

  • July 22, 2008
  • 45 replies
  • 10666 views
I read in the PostScript documentation and i saw that stroke only has :
-linecap
-color
-mitterlimit
-linejoin
-thickness

I have to write an application and my class
Stroke, that i am using, has a lot of other stuff like PatternBrush, ImageBrush ,GradientBrush , etc.

Can i get this kind of options for stroke in a PostScript file?
How about Fill?
(I'm very interested in the gradient option. I haven't found so far very clear documentation about it)

Can I get a detailed explanation or(and) some reference?

[later edit]
Also, can i modify the matrix in one command (without using rotate, scale and translate).I bumped to this only when i was dealing with images and i haven't found something clear in the documentation about how can i do this just by a command. For now i just want to draw from the upper left corner of the page, but i will need it for other stuff too.

David
This topic has been closed for replies.

45 replies

Known Participant
July 27, 2008
Ok I have read from the specs and 5012 Adobe Technical Note and I don't really understand where can I get the font bytes.

I understand I have to create a snfts array, but where do I get the hexadecimal representation of those fonts.

Btw I am trying to put TrueType fonts in my ps files ... and I really don't see where can I get those bytes ...

David
Participating Frequently
July 27, 2008
Ah, a type 42 font. Be sure to make this optional, not all printers
will support it.

To get the font tables. You read the TrueType font file itself. The
TrueType font format is also published, so you can parse the TrueType
font and put the necessary information into the PostScript. Another
1000 page specification - I said it was a painful area...

Aandi Inston
Known Participant
July 25, 2008
>I suspect you are about to enter a world of pain. What do you mean by
>a "new font"? What is the overall requirement here - to allow someone
>or something to select operating system fonts and print with them? Or
>just to pick a font from those built into the printer?

No i mean a font that isn't defined in the operating system and it isn't built-in the printer.
I have an example, where a new font it's introduced in the ps file like a stream of hexadecimal numbers, like with the images ...

David.
Participating Frequently
July 25, 2008
Ok, ultimately fonts are defined using a number of PostScript
operators. Maybe eexec (for type 1 fonts), definefont (for type 3
fonts and remapped existing fonts), or others. Composite and CID fonts
are used for OpenType mapping and Japanese; these are awesomely
complicated too.

Once a font is defined it is stored in a system dictionary with a
name. Then the findfont or selectfont operator can be used to locate
that font and work with it (i.e. paint characters in the font).

If you see a font which is short bursts of hexadecimal interpersed
with PostScript, it is probably (but not necessarily) a type 3 font. A
type 3 font is a dictionary, with all sorts of entries. One of the
entries is itself a dictionary, and each entry in THAT is a procedure
which draws one letter. In a bitmap type 3 font, each character's
procedure will use imagemask (rarely image) to paint a character, and
then use some other operators.

This is fairly deep stuff, and you'll probably want to study the
chapter on fonts in some depth if you have to deal with such things.

Aandi Inston
Known Participant
July 25, 2008
I can't answer :( ...
I thought it is something mandatory, since I was asked to do so.
If you say it is no reason I will not pursue with this anymore ...
So I will just test if the image is RGB or CMYK and then use the proper colorspace.

I will ask something else :
1. How can I write Unicode characters in a PostScript file? (is there any kind of conversion I need to do?) (Ex: I have an unicode stream aabbsd and I want to write it in the file)

2.How can I define a new font in the PostScript file? Can I include the font bits in the .ps file just like I did at the image?

David
Participating Frequently
July 25, 2008
>So I will just test if the image is RGB or CMYK and then use the proper colorspace.

That is best. *IF* you are working in the area of colour management
and want to use a color manager to do profile-to-profile conversion,
you may get better results. This is a much bigger project than the one
you describe. You would probably want to use CIEBasedABC or
CIEBasedDEFG colors too, a world of pain.
>
>1. How can I write Unicode characters in a PostScript file?

You can put any characters or bytes you like in a string, but that
won't make PostScript understand Unicode. (The PS Language Reference
doesn't mention Unicode, not because it is implicit, but because it
isn't there).

To display characters in a font you have to choose a suitable font
that contains the character set you want to show, set up an encoding
to map string byte values into characters, and generate the string
accordingly. Mostly people use single byte fonts, and may partition
into character sets, switching fonts as needed. There is NO universal
Unicode font - and if there was it would add tens of megabytes to the
PostScript.
>
>2.How can I define a new font in the PostScript file?

I suspect you are about to enter a world of pain. What do you mean by
a "new font"? What is the overall requirement here - to allow someone
or something to select operating system fonts and print with them? Or
just to pick a font from those built into the printer?


Aandi Inston
Known Participant
July 25, 2008
This is my one of my tasks ...
And I have searched a lot to find something and I want to know how can I do this ... .

David.
Participating Frequently
July 25, 2008
Sorry, I don't understand, There seems no reason, if you have RGB
data, for you to convert it to CMYK. Why do you want to?

Aandi Inston
Known Participant
July 25, 2008
I made it work with image dictionary, but I still have a problem with CMYK. When I write the data in the ps file don't i have to make a conversion from the rgb to cmyk ?

I mean i still have the image represented by the rgb colors for every component.It will not interpret well .. because it will find get the first 4 bytes (that are R G B R) and it willn't work

i saw something like this:

c = (255 - red)/255;
m = (255 - green)/255;
y = (255 - blue)/255;

k = min(c,m,y,k);

So, my question is how do I write the corespondent for CMYK colors from the rgb ones?

David
Participating Frequently
July 25, 2008
Why do you want to convert RGB to CMYK? PostScript will do a job no
worse than the one you propose, sometimes much better.

Aandi Inston
Known Participant
July 24, 2008
D'oh ... thanks again

David
Known Participant
July 24, 2008
Ok ...
How do i do that?
I set the colorspace and then construct my dictionary ?
I have tried to do this on an hexadecimal encoded image that worked fine with colorimage (with 3 components)

When I tried with a dictionary, it generated an error :

%%[ Error: rangecheck; OffendingCommand: imageDistiller; ErrorInfo: Decode --nostringval-- ]%%

Stack:
-dict-

I have tried to find on the internet and don't bug you anymore, but I am hopeless :(

It seems it does that too if i change in a document that worked just fine with /DefineRGB setcolorspace with /DefineCMYK setcolorspace

I find it very hard ... is it some specific part in the documentation where i can find these things explained very good?

David
Participating Frequently
July 24, 2008
>I set the colorspace and then construct my dictionary ?

That's it. See 4.10.5.
>
>%%[ Error: rangecheck; OffendingCommand: imageDistiller; ErrorInfo: Decode --nostringval-- ]%%

The Decode array is wrong or missing.
Wrong: elements not integers or reals, or there are not exactly twice
the number of elements as color space components.

> I have tried to find on the internet

It's all in the PS Language Reference.

Aandi Inston
Known Participant
July 24, 2008
Let me get straight another thing.
When the postscript interpreter sees raw data and after that he sees
for example
(8 bits per component)
false 3 colorimage ...

He will analyze the data and associate a color to every 3 bytes(that means R G B i know 3 is for RGB)? Ex : ffff 0000 0000 => Red
With 4 => he will get a color at every 4 bytes (CMYK)?

So if I want to associate to every component a CMYK correspondent , i will have to make a conversion, ... no?
Participating Frequently
July 24, 2008
You can use colorimage, but it is a very inflexible way to define
images. The level 2 image operator with dictionary is much more
flexible. For example, you would need to use this if you wanted an
Indexed color space.

The colorimage operator just works with two color spaces, DeviceRGB
(if number of components is 3), and DeviceCMYK (if number of
components is 4).

Note that "number of components" is not at all the same as "bits per
component". With the image dictionary form there is no "number of
components" setting because it uses the current color space, and
therefore knows how many components to look for in the data.

If you feel you can do a better conversion from RGB to CMYK than
PostScript, then you can do this before using image or colorimage.
Otherwise, if you currently have no idea how to do the conversion then
you might as well let PostScript convert.

Aandi Inston
Known Participant
July 24, 2008
My question is actually the following:
How can I draw an image using 3 or 4 colors .
Actually this is my task and I don't really understand, after reading the documentation, what I have to do and I thought the answer was in the bits per component parameter.

David.
Participating Frequently
July 24, 2008
You mean that the entire image will be made up of 3 colours, such as
RGB=10%,50%,0%
RGB=70%,14%,80%
RGB=80%,80%,80%
and there will be no other colours in the image?

If so, this is an ideal case for an Indexed colour space. You could
then use just 2 bits per component.

Aandi Inston
Known Participant
July 24, 2008
My goal is to draw the images using RGB or CMYK for representing every component.

David
Participating Frequently
July 24, 2008
>My goal is to draw the images using RGB or CMYK for representing every component.

Ok... but what is the question, related to bits per component?

Aandi Inston