Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Soft Font embedding in PCL File

Status
Not open for further replies.

Fireball1977

Programmer
Mar 22, 2007
1
DE
Hello, I have to write a java program that creates pcl files. Now I have to embed an external font (Arial Unicode MS) in the file. As I'm relatively new to PCL I'm stuck now with several questions. Hopefully they are easy to answer for you guys. If I refer to "the manual" I mean the "PCL 5 Printer Language Technical Reference Manual" from HP.

1.) The manual says that for unbound fonts (10 and 11) the first code / last code can be set to 0. Does this apply for TrueType (15) too? If not, what values do I have to use? From the OS/2 table for Arial Unicode MS I get 0 and 65535 as firstCharIndex and lastCharIndex?

2.) For calculating the checksum in the font header do I have to take every single byte from 64 to the last reserved byte as one single value or every "value field" as one value e.g. master underline position (0xFE, 0x67 = 2byte) => values = 254 + 103 (FE + 67) or value = 65127 (FE67)?

3.) What are the "design units" from the manual?

4.) Where do I get the font numbers from? Does it matter, if the number is set to zero?

5.) Symbol Set: The manual says it must be set to 56 for fonts 10 and 11 (unbound Intellifont scalable). => Applies for TrueType?

6.) Pitch: Where do I get this value from?

7.) Character Download: How do I determine the GlyphID?

8.) Are reserved bytes always set to 0 or doesn't it matter?

9.) The data written in the TrueType Glyph Data part is the data from the glyf table from the TrueTypeFont file?

10.) Among others I'm using escapeE from RedTitan as a PCLViewer, PCLAnalzyer. It always says that my checksum for my character download is not correct. Right now I'm converting every byte from Character Data Size, Glyph ID and TrueType Glyph Data to an unsigned integer. So the values of my bytes have a range of 0 to 255. I add all resulting integers, calculate result = sum mod 256 and convert the result back to a byte value and write it into the checksum field. Is this way right?

Hopefully someone can help me. I'm stuck with theese questions for quite a while as I don't find any precise information. Of course I searched the forum prior to posting this.

Regards

Alex
 
Some of your questions may be answered in thread286-1092001

I'll try to answer some of the others next time I log in (but this may not be for a week or so, as I shall be away).
 
Q1: The manual says that for unbound fonts (10 and 11) the first code / last code can be set to 0. Does this apply for TrueType (15) too? If not, what values do I have to use? From the OS/2 table for Arial Unicode MS I get 0 and 65535 as firstCharIndex and lastCharIndex?

A1: I would expect to set these values (usually start=0x20 and end=hex code of last character you are defining) although it is possible that some/many printers may ignore the values.

Bear in mind that TrueType fonts tend to be unbound (or, more accurately, bound to Unicode) and may include hundreds, or even thousands, of characters.
For printer fonts, you will probably want (or perhaps have no option but) to bind each font to a particular symbol set (and perhaps limit the number of characters to less than 256); otherwise you may have to download symbol set definitions to the printer as well (if you're not sure that the printer has the required definitions) in order to select characters from an unbound font.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q2: For calculating the checksum in the font header do I have to take every single byte from 64 to the last reserved byte as one single value or every "value field" as one value e.g. master underline position (0xFE, 0x67 = 2byte) => values = 254 + 103 (FE + 67) or value = 65127 (FE67)?

A2: Every single byte (I can't remember for sure if byte 64 is included or not).


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q3: What are the "design units" from the manual?

A3: Intellifont uses 'design units'; but as you are unlikely to be able to find any documentation on Intellifont, I wouldn't recommend this format (which is not supported by PCL6, by the way).
TrueType fonts use 'unitsPerEm' as part of the design mechanism; most fonts uses a value of 2048 for this, and it should anyway (for efficiency) be set to a power of 2 - but this will be a property of your 'donor' TrueType (.TTF) font, so you can't change it anyway.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q4: Where do I get the font numbers from? Does it matter, if the number is set to zero?

A4: I don't think that this is important, other than to help identify different fonts; thread286-1092001 may provide more detail.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q5: Symbol Set: The manual says it must be set to 56 for fonts 10 and 11 (unbound Intellifont scalable). => Applies for TrueType?

A5: The Kind1 value of 56 equates to a Symbol Set of 1X; this is a reserved value for 'unbound' fonts.
Type 10 is unbound Intellifont scalable, where glyph IDs are mapped to HP Master Symbol List values.
Type 11 is unbound TrueType scalable, where glyph IDs are mapped to Unicode values.

But (as mentioned in A1:) you're probably better sticking to bound fonts.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q6: Pitch: Where do I get this value from?

A6: See thread286-1092001 for detail.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q7: Character Download: How do I determine the GlyphID?

A7: A TrueType (.TTF) font defines glyphs (i.e. character shapes), each with its own ID.
Such fonts also include (one or more?) character to glyph mapping tables, most commonly (but not always?) mapping glyphs to Unicode character codes for Windows fonts.

You need to make use of the mapping tables, together with a knowledge of how 'your' symbol set maps to Unicode, in order to determine which parts of the glyph table to copy as part of each character definition.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q8: Are reserved bytes always set to 0 or doesn't it matter?

A8: You should always set reserved bytes to a (binary) zero value.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q9: The data written in the TrueType Glyph Data part is the data from the glyf table from the TrueTypeFont file?

A9: You need to refer to the TrueType (OpenType) specification, available on the Microsoft Typography web site.

In addition, HP provide some sample 'C' code to generate the PCL6 (PCL XL) equivalent of a PCL5 Format 15 (TrueType) or 16 (Universal) soft font from a 'donor' TrueType font; although the headers are obviously different, the 'body' is essentially the same, so this code should help you here.

[As an aside, it is a non-trivial mechanism!]

The sample code can be found on the same site as the PCL6 documentation (see the FAQs section in this (PCL) forum for details of where to find the documentation) under 'PCL6 Tools'.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q10: Among others I'm using escapeE from RedTitan as a PCLViewer, PCLAnalzyer. It always says that my checksum for my character download is not correct. Right now I'm converting every byte from Character Data Size, Glyph ID and TrueType Glyph Data to an unsigned integer. So the values of my bytes have a range of 0 to 255. I add all resulting integers, calculate result = sum mod 256 and convert the result back to a byte value and write it into the checksum field. Is this way right?

A10: I can't remember precisely how the checksums are calculated; the sample code referred to in A9: will provide help here.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top