Differences

This shows you the differences between two versions of the page.

Link to this comparison view

printing_unicode [2021/04/05 11:23] (current)
Line 1: Line 1:
 +====== Printing Unicode ======
  
 +Same as with displaying unicode you need to configure support for unicode on every level
 +
 +  * data (database or stream file)
 +  * program
 +  * printer file
 +  * device
 +
 +===== Data =====
 +
 +==== Database ====
 +
 +Unicode is supported by DDS and SQL. In SQL it needs to be declared as GRAPHIC or VARGRAPHIC with a corresponding CCSID. In DDS unicode field needs the graphic data type (G) and a corresponding CCSID, 1200 or 13488.
 +
 +==== Program ====
 +
 +At the program level the variables need to be defined with a corresponding '''CCSID''' keyword.
 +
 +    dcl-s buffer char(1048576) ccsid(*utf8);
 +
 +<note important>If the value should be moved to a graphic field in the display file then it value assignment to the display file field may result into a conversion error. A workaround for this is using a //ucs2// field in the RPG program and move that value to the display file graphic type field.</note>
 +
 +==== Printer File ====
 +
 +The fields in the record needs the data type GRAPHIC (G) and a corresponding CCSID, 1200 or 13488).
 +
 +As the same printer file is used for multiple languages a unicode field is configure (with GRAPHIC data type) we don't want to convert the data to the CCSID of the printer file so we neet to add the parameter ''*NOCONVERT''.
 +
 +<sxh>
 +              R I18NEXPR1
 +                LINE          60G        3SPACEB(1)
 +                                          FONTNAME('Verdana'
 +                                          (*POINTSIZE 12.0))
 +                                          CCSID(13488 *NOCONVERT)
 +</sxh>
 +
 +The printer file needs *AFPDS as the device type and for testing we want to create a PDF from it.
 +
 +    CHGPRTF FILE(I18NEXP1) DEVTYPE(*AFPDS) TOSTMF('/home/mihael/unicode-test.pdf') WSCST(*PDF)
 +
 +=== Font ===
 +
 +And now comes the tricky part. The font also needs to have a glyph for the unicode characters we used. So first a font with unicode characters is needed and the system has some requirements to it.
 +
 +There are several pages in the IBM Knowledge Center about it.
 +
 +  * [[https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/rzalu/rzalucontruetype.htm | TrueType and OpenType fonts]]
 +  * [[https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/rzau6/rzau6spectt.htm | Specifying a TrueType or OpenType font]]
 +  * [[https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/rzau6/rzau6differ.htm | How TrueType and OpenType fonts differ from AFP fonts]]
 +  * [[https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/rzakd/rzakdmstdfusc2.htm | CCSID keyword]]
 +
 +I ended up put a true type font file into a folder in the IFS , ///usr/local/fonts/ttf/// , and put that path to the env var with the following command:
 +
 +    ADDENVVAR ENVVAR(QIBM_FONT_RESOURCES_PATH) VALUE('/usr/local/fonts/ttf')
 +
 +<note>You can probably also put the font into /QIBM/UserData/OS400/Fonts/TTFonts/ but I like to keep my system clean and separate my stuff from the system stuff.</note>
 +
 +<note important>Not every TrueType font file can be used. There are some requirements on the file, see "Specifying a TrueType or OpenType font".</note>
 +
 +{{tag>ibm unicode}}