patch: Unix PS symbol problems


Subject: patch: Unix PS symbol problems
From: WJCarpenter (bill-abisource@carpenter.ORG)
Date: Sun Jul 30 2000 - 02:06:57 CDT


martin> So remapGlyphs ate my bullets upon printing. Can this be
martin> fixed soon?

Heh. Interesting stuff. The attached patch, against 072500 sources,
fixes this problem, although as speculated earlier it has nothing to
do with remapGlyphs() and lots to do with the Unix PS print driver in
Abi.

As you might know, Type 1 fonts actually identify particular
characters by name. Then, there is an encoding vector which maps
numeric character codes to the character names. So, for example, when
you print a "B" in PostScript, it treats the byte containing the "B"
as a numeric value, looks up the name of the character (which also
happens to be "B"), and uses that character name to find out all about
the glyph that eventually looks like a "B" on the sheet of paper.

The encoding for most Type1 fonts is called StandardEncoding. It
looks a lot like Latin1, though there are several glyph differences.
The Unix PS print driver uses a little table to figure out what
numeric character code maps to what character name. This works pretty
well. Alas, it has the built-in assumption that all fonts use
StandardEncoding.

The standard symbol font that Abi uses, naturally, isn't encoded the
same way as the other fonts Abi uses. It has a custom encoding that
corresponds, as one would hope, to the standard symbol table that
every one expects. There is not a character named "bullet" in the
StandardEncoding, so when remapGlyph() asked the PS driver for the
width of character code 0xB7, the driver answered that it was
zero-width.

The fix was to put in a second mapping table, for the symbol font, in
the PS print driver code. Unfortunately, it's slightly a crock
because all we know is that it's a font with encoding "FontSpecific".
We don't really know for sure that it's the symbol font (except that
that's the only such font that Abi ships).

I have left a TODO: about this in the code, but I think the Unix PS
print driver is a place that needs someone to adopt it for scrubbing.

-- 
bill@carpenter.ORG (WJCarpenter)    PGP 0x91865119
38 95 1B 69 C9 C6 3D 25    73 46 32 04 69 D6 ED F3

diff -ru abi-072500-ORIG/src/af/xap/unix/xap_UnixFont.cpp abi-072500/src/af/xap/unix/xap_UnixFont.cpp --- abi-072500-ORIG/src/af/xap/unix/xap_UnixFont.cpp Sat Jun 24 18:26:50 2000 +++ abi-072500/src/af/xap/unix/xap_UnixFont.cpp Sat Jul 29 23:28:27 2000 @@ -500,6 +500,198 @@ { 0x0000, NULL } }; +const FontMappingTable sym_enc[] = { + { 32, "space" }, + { 33, "exclam" }, + { 34, "universal" }, + { 35, "numbersign" }, + { 36, "existential" }, + { 37, "percent" }, + { 38, "ampersand" }, + { 39, "suchthat" }, + { 40, "parenleft" }, + { 41, "parenright" }, + { 42, "asteriskmath" }, + { 43, "plus" }, + { 44, "comma" }, + { 45, "minus" }, + { 46, "period" }, + { 47, "slash" }, + { 48, "zero" }, + { 49, "one" }, + { 50, "two" }, + { 51, "three" }, + { 52, "four" }, + { 53, "five" }, + { 54, "six" }, + { 55, "seven" }, + { 56, "eight" }, + { 57, "nine" }, + { 58, "colon" }, + { 59, "semicolon" }, + { 60, "less" }, + { 61, "equal" }, + { 62, "greater" }, + { 63, "question" }, + { 64, "congruent" }, + { 65, "Alpha" }, + { 66, "Beta" }, + { 67, "Chi" }, + { 68, "Delta" }, + { 69, "Epsilon" }, + { 70, "Phi" }, + { 71, "Gamma" }, + { 72, "Eta" }, + { 73, "Iota" }, + { 74, "theta1" }, + { 75, "Kappa" }, + { 76, "Lambda" }, + { 77, "Mu" }, + { 78, "Nu" }, + { 79, "Omicron" }, + { 80, "Pi" }, + { 81, "Theta" }, + { 82, "Rho" }, + { 83, "Sigma" }, + { 84, "Tau" }, + { 85, "Upsilon" }, + { 86, "sigma1" }, + { 87, "Omega" }, + { 88, "Xi" }, + { 89, "Psi" }, + { 90, "Zeta" }, + { 91, "bracketleft" }, + { 92, "therefore" }, + { 93, "bracketright" }, + { 94, "perpendicular" }, + { 95, "underscore" }, + { 96, "radicalex" }, + { 97, "alpha" }, + { 98, "beta" }, + { 99, "chi" }, + { 100, "delta" }, + { 101, "epsilon" }, + { 102, "phi" }, + { 103, "gamma" }, + { 104, "eta" }, + { 105, "iota" }, + { 106, "phi1" }, + { 107, "kappa" }, + { 108, "lambda" }, + { 109, "mu" }, + { 110, "nu" }, + { 111, "omicron" }, + { 112, "pi" }, + { 113, "theta" }, + { 114, "rho" }, + { 115, "sigma" }, + { 116, "tau" }, + { 117, "upsilon" }, + { 118, "omega1" }, + { 119, "omega" }, + { 120, "xi" }, + { 121, "psi" }, + { 122, "zeta" }, + { 123, "braceleft" }, + { 124, "bar" }, + { 125, "braceright" }, + { 126, "similar" }, + { 161, "Upsilon1" }, + { 162, "minute" }, + { 163, "lessequal" }, + { 164, "fraction" }, + { 165, "infinity" }, + { 166, "florin" }, + { 167, "club" }, + { 168, "diamond" }, + { 169, "heart" }, + { 170, "spade" }, + { 171, "arrowboth" }, + { 172, "arrowleft" }, + { 173, "arrowup" }, + { 174, "arrowright" }, + { 175, "arrowdown" }, + { 176, "degree" }, + { 177, "plusminus" }, + { 178, "second" }, + { 179, "greaterequal" }, + { 180, "multiply" }, + { 181, "proportional" }, + { 182, "partialdiff" }, + { 183, "bullet" }, + { 184, "divide" }, + { 185, "notequal" }, + { 186, "equivalence" }, + { 187, "approxequal" }, + { 188, "ellipsis" }, + { 189, "arrowvertex" }, + { 190, "arrowhorizex" }, + { 191, "carriagereturn" }, + { 192, "aleph" }, + { 193, "Ifraktur" }, + { 194, "Rfraktur" }, + { 195, "weierstrass" }, + { 196, "circlemultiply" }, + { 197, "circleplus" }, + { 198, "emptyset" }, + { 199, "intersection" }, + { 200, "union" }, + { 201, "propersuperset" }, + { 202, "reflexsuperset" }, + { 203, "notsubset" }, + { 204, "propersubset" }, + { 205, "reflexsubset" }, + { 206, "element" }, + { 207, "notelement" }, + { 208, "angle" }, + { 209, "gradient" }, + { 210, "registeredserif" }, + { 211, "copyrightserif" }, + { 212, "trademarkserif" }, + { 213, "product" }, + { 214, "radical" }, + { 215, "dotmath" }, + { 216, "logicalnot" }, + { 217, "logicaland" }, + { 218, "logicalor" }, + { 219, "arrowdblboth" }, + { 220, "arrowdblleft" }, + { 221, "arrowdblup" }, + { 222, "arrowdblright" }, + { 223, "arrowdbldown" }, + { 224, "lozenge" }, + { 225, "angleleft" }, + { 226, "registeredsans" }, + { 227, "copyrightsans" }, + { 228, "trademarksans" }, + { 229, "summation" }, + { 230, "parenlefttp" }, + { 231, "parenleftex" }, + { 232, "parenleftbt" }, + { 233, "bracketlefttp" }, + { 234, "bracketleftex" }, + { 235, "bracketleftbt" }, + { 236, "bracelefttp" }, + { 237, "braceleftmid" }, + { 238, "bracelefttbt" }, + { 239, "braceex" }, + { 241, "angleright" }, + { 242, "integral" }, + { 243, "integraltp" }, + { 244, "integralex" }, + { 245, "integralbt" }, + { 246, "parenrighttp" }, + { 247, "parenrightex" }, + { 248, "parenrightbt" }, + { 249, "bracketrighttp" }, + { 250, "bracketrightex" }, + { 251, "bracketrightbt" }, + { 252, "bracerighttp" }, + { 253, "bracerightmid" }, + { 254, "bracerightbt" }, + { 0x0000, NULL } +}; + ABIFontInfo * XAP_UnixFont::getMetricsData(void) { if (m_metricsData) @@ -559,16 +751,29 @@ } // Need to mangle the cmi[i].wx variables to work right with Unicode + const FontMappingTable *the_enc = std_enc; + xxx_UT_DEBUGMSG(("PS font file: %s %d\n", m_fontfile, this)); + xxx_UT_DEBUGMSG(("PS font metrics file: %s\n", m_metricfile)); + xxx_UT_DEBUGMSG(("PS font encoding type: %s\n", m_metricsData->gfi->encodingScheme)); + if (strcmp("FontSpecific", m_metricsData->gfi->encodingScheme) == 0) + { + // TODO: This is slightly a crock since we imagine the only font + // TODO: we'll see with FontSpecific encoding is the standard symbols + // TODO: font. Sez who? What we probably ought to do is dynamically + // TODO: allocate the encoding table for the font based on the + // TODO: FontSpecific encoding. Or something. + the_enc = sym_enc; + } m_uniWidths = (UT_uint16 *) malloc (sizeof (UT_uint16) * 256); memset (m_uniWidths, 0, 256 * sizeof(UT_uint16)); // Clear array - i would hope that sizeof(UT_uint16) == 16 for (UT_sint32 i=0; i != m_metricsData->numOfChars; ++i) { UT_sint32 unicode = -1; - for (UT_uint32 j = 0; std_enc[j].type1_name != NULL; j++) + for (UT_uint32 j = 0; the_enc[j].type1_name != NULL; j++) { - if (!strcmp (m_metricsData->cmi[i].name, std_enc[j].type1_name)) + if (!strcmp (m_metricsData->cmi[i].name, the_enc[j].type1_name)) { - unicode = std_enc[j].unicode; + unicode = the_enc[j].unicode; break; } }



This archive was generated by hypermail 2b25 : Sun Jul 30 2000 - 02:12:46 CDT