[gs-cvs] rev 6919 - trunk/gs/src
leonardo at ghostscript.com
leonardo at ghostscript.com
Mon Jul 17 12:11:34 PDT 2006
Author: leonardo
Date: 2006-07-17 12:11:34 -0700 (Mon, 17 Jul 2006)
New Revision: 6919
Modified:
trunk/gs/src/gdevpsft.c
trunk/gs/src/gxttf.h
Log:
Fix (pdfwrite) : Support OS/2 table version 2 in True Type fonts.
DETASILS :
We don't use the new fields in the 96-byte structure and continue to
create 86-byre structures. The extra space is used as a buffer when
we copy the structure intact.
Bug 688536 "/invalidfont in --show-- when trying to convert the PDF file".
Patch from Alex with an improvement against regressions.
DIFFERENCES :
None.
Modified: trunk/gs/src/gdevpsft.c
===================================================================
--- trunk/gs/src/gdevpsft.c 2006-07-13 21:35:15 UTC (rev 6918)
+++ trunk/gs/src/gdevpsft.c 2006-07-17 19:11:34 UTC (rev 6919)
@@ -479,7 +479,8 @@
/* ------ OS/2 ------ */
/* Write a generated OS/2 table. */
-#define OS_2_LENGTH sizeof(ttf_OS_2_t)
+#define OS_2_LENGTH1 offset_of(ttf_OS_2_t, sxHeight[0]) /* OS/2 version 1. */
+#define OS_2_LENGTH2 sizeof(ttf_OS_2_t) /* OS/2 version 2. */
private void
update_OS_2(ttf_OS_2_t *pos2, uint first_glyph, int num_glyphs)
{
@@ -504,15 +505,16 @@
* We don't bother to set most of the fields. The really important
* ones, which affect character mapping, are usFirst/LastCharIndex.
* We also need to set usWeightClass and usWidthClass to avoid
- * crashing ttfdump.
+ * crashing ttfdump. Version 1 86-byte structure has all the fields
+ * we need.
*/
memset(&os2, 0, sizeof(os2));
put_u16(os2.version, 1);
put_u16(os2.usWeightClass, 400); /* Normal */
put_u16(os2.usWidthClass, 5); /* Normal */
update_OS_2(&os2, first_glyph, num_glyphs);
- stream_write(s, &os2, sizeof(os2));
- put_pad(s, sizeof(os2));
+ stream_write(s, &os2, offset_of(ttf_OS_2_t, sxHeight[0]));
+ put_pad(s, offset_of(ttf_OS_2_t, sxHeight[0]));
}
/* ------ post ------ */
@@ -688,7 +690,7 @@
int have_hvhea[2];
uint cmap_length = 0;
ulong OS_2_start = 0;
- uint OS_2_length = OS_2_LENGTH;
+ uint OS_2_length = OS_2_LENGTH1;
int code;
have_hvhea[0] = have_hvhea[1] = 0;
@@ -755,7 +757,7 @@
if (writing_cid)
continue;
have_OS_2 = true;
- if (length > OS_2_LENGTH)
+ if (length > OS_2_LENGTH2)
return_error(gs_error_invalidfont);
OS_2_start = start;
OS_2_length = length;
Modified: trunk/gs/src/gxttf.h
===================================================================
--- trunk/gs/src/gxttf.h 2006-07-13 21:35:15 UTC (rev 6918)
+++ trunk/gs/src/gxttf.h 2006-07-17 19:11:34 UTC (rev 6919)
@@ -134,7 +134,13 @@
sTypoLineGap[2],
usWinAscent[2],
usWinDescent[2],
- ulCodePageRanges[8];
+ ulCodePageRanges[8],
+
+ sxHeight[2], /* version 2 */
+ sCapHeight[2],
+ usDefaultChar[2],
+ usBreakChar[2],
+ usMaxContext[2];
} ttf_OS_2_t;
/* ------ vhea ------ */
More information about the gs-cvs
mailing list