• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Putting CJK text into PostScript file

New Here ,
Apr 27, 2011 Apr 27, 2011

Copy link to clipboard

Copied

Our application, as one of several export options, generates PostScript files.  We recently added support for UNICODE text to the application - all internal text is utf16.  I am having trouble exporting asian (CJK) fonts correctly.  Before the switch to UNICODE we supported ShiftJIS for Japanese.  I know that PS does not directly support UNICODE.  So, my question is, what is the best way to proceed given the facts that I have UNICODE text and I must generate a correct PS file which will display that text?

To my pea-sized brain, it looks like there are two possible paths...

1. Convert the utf16 to ShiftJIS (or whatever code page is required) and export as before?  This seems doable, but strikes me as a hack since I would need to look at each code point and figure out which code page it is related to.

2. Re-encode the font?  But how?  I've looked at documentation for CID-keyed fonts and some sample code for re-encoding, but I admit that I have not yet had an aha! moment. I'm not even sure if I'm looking at the correct stuff.

Also, do we need to embed the font(s)?  (I realize that CJK fonts can be large, but file size is not a major consideration.)

Thanks for any help.

TOPICS
Programming

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 27, 2011 Apr 27, 2011

Copy link to clipboard

Copied

If you re-encode the fonts then you will need to embed them

or include them for the receiver of the exported PS file.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 28, 2011 Apr 28, 2011

Copy link to clipboard

Copied

Mr. Horton,

Thanks for your reply.  You said,

If you re-encode the fonts then you will need to embed them

or include them for the receiver of the exported PS file.

That is some of the information I am looking for.  By "include" do you mean that I could supply the receiver with the font file? (I really can't do that.)  Can you point me at any sample code (or pseudo code) which shows how to embed a font?

As to my first question, do you have any opinion about which path to follow?  Are they both viable?  Is one preferred?  Are there other ways to achieve what I need to do?

Thanks again for any help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 28, 2011 Apr 28, 2011

Copy link to clipboard

Copied

At this point embedding & reencoding appear to be more advantageous from what I understand of your project.

I have written PostScript drivers that embed Type 1 format fonts by converting the binary printer font (.pfb) file into a 7-bit ascii PostScript file and inserting that in the PostScript output stream. The font just needs to be inserted so that it is available in the context of when it will be used (ie. before font use and same or more significant save/restore level.

I have also reencoded font characters within a PostScript job in order to access special characters that didn't exist in an EBCDIC character table using octal codes, but I'm not sure if this will suit your solution 2 or not.

Code sourced probably sourced from Adobe Developer Kit of many years ago:

/reencsmalldict 12 dict def
/ENC
{reencsmalldict begin
/newcodesandnames exch def
/newfontname exch def
/basefontname exch def
/basefontdict basefontname findfont def
/newfont basefontdict maxlength dict def
basefontdict
{exch dup /FID ne
{dup /Encoding eq
{exch dup length array copy newfont 3 1 roll put}
{exch newfont 3 1 roll put}
ifelse
}
{pop pop}
ifelse
}forall
newfont /FontName newfontname put
newcodesandnames aload pop
newcodesandnames length 2 idiv
{newfont /Encoding get 3 1 roll put}
repeat
newfontname newfont definefont pop
end
} def
/EVEC [
8#030 /mu
8#031 /eth
8#032 /Yacute
8#033 /brokenbar
8#034 /onehalf
8#200 /Aacute
8#201 /Acircumflex
8#202 /Adieresis
8#203 /Agrave
8#204 /Aring
8#205 /Atilde
8#206 /Ccedilla
8#207 /Eacute
8#210 /Ecircumflex
8#211 /Edieresis
8#212 /Egrave
8#213 /Iacute
8#214 /Icircumflex
8#215 /Idieresis
8#216 /Igrave
8#217 /Ntilde
8#220 /Oacute
8#221 /Ocircumflex
8#222 /Odieresis
8#223 /Ograve
8#224 /Otilde
8#225 /Scaron
8#226 /Uacute
8#227 /Ucircumflex
8#230 /Udieresis
8#231 /Ugrave
8#232 /Ydieresis
8#233 /Zcaron
8#234 /copyright
8#235 /registered
8#236 /trademark
8#237 /aacute
8#240 /acircumflex
8#260 /adieresis
8#265 /agrave
8#276 /aring
8#300 /atilde
8#311 /ccedilla
8#314 /eacute
8#321 /ecircumflex
8#322 /edieresis
8#323 /egrave
8#324 /iacute
8#325 /icircumflex
8#326 /idieresis
8#327 /igrave
8#330 /ntilde
8#331 /oacute
8#332 /ocircumflex
8#333 /odieresis
8#334 /ograve
8#335 /otilde
8#336 /scaron
8#337 /uacute
8#340 /ucircumflex
8#342 /udieresis
8#344 /ugrave
8#345 /ydieresis
8#346 /zcaron
8#347 /logicalnot
8#354 /minus
8#355 /threesuperior
8#356 /thorn
8#357 /twosuperior
8#360 /yacute
8#362 /threequarters
8#363 /Eth
8#364 /onequarter
8#366 /Thorn
8#367 /divide
8#374 /plusminus
8#375 /multiply
8#376 /onesuperior
8#377 /degree
] def

/WE {EVEC ENC}def

/HLN {/HLNWE findfont}bind def
/Helvetica-Narrow /HLNWE WE

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 28, 2011 Apr 28, 2011

Copy link to clipboard

Copied

As you use Unicode, you should consider embedding CID-keyed-fonts. For more information,

see the following Adobe technotes:

Technical note 5092.CID_Overview.pdf

Technical note 5014.CMap_CIDFont_Spec.pdf

and the sections on composite fonts in the PostScript Language Reference Manual, 3rd ed.

Helge

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 06, 2011 May 06, 2011

Copy link to clipboard

Copied

LATEST

Helge, thanks for the references.  I've spent some time reading through the material.  However, since I am not well versed in PS, but probably have something between a basic & intermediate working knowledge of it, this looks like a large leap without the aid of some sample code.

So, I am looking for some help, perhaps in the form of...
- A roadmap, or source code (preferred), showing how a PS file could be created programatically, showing all the steps and including what is the correct format for the text (would it be UTF8?)

- A working example PS file which displays some CJK text - preferably Japanese.

For example, I do not understand how to put the font into the PS file.  I do know how to read/parse the font file and find the correct tables, I'm not sure what to do with them.  It also is not clear to me what to do if I have a text string which contains characters from multiple character sets, displayable by the same font.  I assume I need to include all required encodings, but how?

Thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines