summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2019-10-12 19:31:02 +0200
committerJulien Nabet <serval2412@yahoo.fr>2019-10-12 23:31:30 +0200
commit6f0e2cc38bbdb9fe115f3df38d7a596416d34bc2 (patch)
treee2e87c81c1732bb9cbae6200e60fedcdeefe5bdd
parentd6ea967e040d01ec69649ac689472018e477db34 (diff)
Document and replace some magic values in sft/ttcr (vcl)
Change-Id: Id9c3f96acb7b93c7ef215ae33d98ad17ef45095c Reviewed-on: https://gerrit.libreoffice.org/80719 Reviewed-by: Khaled Hosny <khaledhosny@eglug.org> Tested-by: Jenkins
-rw-r--r--vcl/inc/sft.hxx216
-rw-r--r--vcl/source/fontsubset/sft.cxx119
-rw-r--r--vcl/source/fontsubset/ttcr.cxx46
3 files changed, 293 insertions, 88 deletions
diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index aa81dcd151cb..39bc2ecfd421 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -185,6 +185,222 @@ namespace vcl
struct TrueTypeFont;
+/*
+ Some table OS/2 consts
+ quick history:
+ OpenType has been created from TrueType
+ - original TrueType had an OS/2 table with a length of 68 bytes
+ (cf https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6OS2.html)
+ - There have been 6 versions (from version 0 to 5)
+ (cf https://docs.microsoft.com/en-us/typography/opentype/otspec140/os2ver0)
+
+ For the record:
+ // From Initial TrueType version
+ TYPE NAME FROM BYTE
+ uint16 version 0
+ int16 xAvgCharWidth 2
+ uint16 usWeightClass 4
+ uint16 usWidthClass 6
+ uint16 fsType 8
+ int16 ySubscriptXSize 10
+ int16 ySubscriptYSize 12
+ int16 ySubscriptXOffset 14
+ int16 ySubscriptYOffset 16
+ int16 ySuperscriptXSize 18
+ int16 ySuperscriptYSize 20
+ int16 ySuperscriptXOffset 22
+ int16 ySuperscriptYOffset 24
+ int16 yStrikeoutSize 26
+ int16 yStrikeoutPosition 28
+ int16 sFamilyClass 30
+ uint8 panose[10] 32
+ uint32 ulUnicodeRange1 42
+ uint32 ulUnicodeRange2 46
+ uint32 ulUnicodeRange3 50
+ uint32 ulUnicodeRange4 54
+ Tag achVendID 58
+ uint16 fsSelection 62
+ uint16 usFirstCharIndex 64
+ uint16 usLastCharIndex 66
+
+ // From Version 0 of OpenType
+ int16 sTypoAscender 68
+ int16 sTypoDescender 70
+ int16 sTypoLineGap 72
+ uint16 usWinAscent 74
+ uint16 usWinDescent 76
+
+ => length for OpenType version 0 = 78 bytes
+
+ // From Version 1 of OpenType
+ uint32 ulCodePageRange1 78
+ uint32 ulCodePageRange2 82
+
+ => length for OpenType version 1 = 86 bytes
+
+ // From Version 2 of OpenType
+ // (idem for Versions 3 and 4)
+ int16 sxHeight 86
+ int16 sCapHeight 88
+ uint16 usDefaultChar 90
+ uint16 usBreakChar 92
+ uint16 usMaxContext 94
+
+ => length for OpenType version 2, 3 and 4 = 96 bytes
+
+ // From Version 5 of OpenType
+ uint16 usLowerOpticalPointSize 96
+ uint16 usUpperOpticalPointSize 98
+ END 100
+
+ => length for OS/2 table version 5 = 100 bytes
+
+*/
+static const int OS2_Legacy_length = 68;
+static const int OS2_V0_length = 78;
+static const int OS2_V1_length = 86;
+
+static const int OS2_usWeightClass_offset = 4;
+static const int OS2_usWidthClass_offset = 6;
+static const int OS2_fsType_offset = 8;
+static const int OS2_panose_offset = 32;
+static const int OS2_panoseNbBytes_offset = 10;
+static const int OS2_ulUnicodeRange1_offset = 42;
+static const int OS2_ulUnicodeRange2_offset = 46;
+static const int OS2_ulUnicodeRange3_offset = 50;
+static const int OS2_ulUnicodeRange4_offset = 54;
+static const int OS2_fsSelection_offset = 62;
+static const int OS2_typoAscender_offset = 68;
+static const int OS2_typoDescender_offset = 70;
+static const int OS2_typoLineGap_offset = 72;
+static const int OS2_winAscent_offset = 74;
+static const int OS2_winDescent_offset = 76;
+static const int OS2_ulCodePageRange1_offset = 78;
+static const int OS2_ulCodePageRange2_offset = 82;
+
+/*
+ Some table hhea consts
+ cf https://docs.microsoft.com/fr-fr/typography/opentype/spec/hhea
+ TYPE NAME FROM BYTE
+ uint16 majorVersion 0
+ uint16 minorVersion 2
+ FWORD ascender 4
+ FWORD descender 6
+ FWORD lineGap 8
+ UFWORD advanceWidthMax 10
+ FWORD minLeftSideBearing 12
+ FWORD minRightSideBearing 14
+ FWORD xMaxExtent 16
+ int16 caretSlopeRise 18
+ int16 caretSlopeRun 20
+ int16 caretOffset 22
+ int16 (reserved) 24
+ int16 (reserved) 26
+ int16 (reserved) 28
+ int16 (reserved) 30
+ int16 metricDataFormat 32
+ uint16 numberOfHMetrics 34
+ END 36
+
+ => length for hhea table = 36 bytes
+
+*/
+static const int HHEA_Length = 36;
+
+static const int HHEA_ascender_offset = 4;
+static const int HHEA_descender_offset = 6;
+static const int HHEA_lineGap_offset = 8;
+static const int HHEA_caretSlopeRise_offset = 18;
+static const int HHEA_caretSlopeRun_offset = 20;
+
+/*
+ Some table post consts
+ cf https://docs.microsoft.com/fr-fr/typography/opentype/spec/post
+ TYPE NAME FROM BYTE
+ Fixed version 0
+ Fixed italicAngle 4
+ FWord underlinePosition 8
+ FWord underlineThickness 10
+ uint32 isFixedPitch 12
+ ...
+
+*/
+static const int POST_italicAngle_offset = 4;
+static const int POST_underlinePosition_offset = 8;
+static const int POST_underlineThickness_offset = 10;
+static const int POST_isFixedPitch_offset = 12;
+
+/*
+ Some table head consts
+ cf https://docs.microsoft.com/fr-fr/typography/opentype/spec/head
+ TYPE NAME FROM BYTE
+ uit16 majorVersion 0
+ uit16 minorVersion 2
+ Fixed fontRevision 4
+ uint32 checkSumAdjustment 8
+ uint32 magicNumber 12 (= 0x5F0F3CF5)
+ uint16 flags 16
+ uint16 unitsPerEm 18
+ LONGDATETIME created 20
+ LONGDATETIME modified 28
+ int16 xMin 36
+ int16 yMin 38
+ int16 xMax 40
+ int16 yMax 42
+ uint16 macStyle 44
+ uint16 lowestRecPPEM 46
+ int16 fontDirectionHint 48
+ int16 indexToLocFormat 50
+ int16 glyphDataFormat 52
+
+ END 54
+
+ => length head table = 54 bytes
+*/
+static const int HEAD_Length_offset = 54;
+
+static const int HEAD_majorVersion_offset = 0;
+static const int HEAD_fontRevision_offset = 4;
+static const int HEAD_magicNumber_offset = 12;
+static const int HEAD_flags_offset = 16;
+static const int HEAD_unitsPerEm_offset = 18;
+static const int HEAD_created_offset = 20;
+static const int HEAD_xMin_offset = 36;
+static const int HEAD_yMin_offset = 38;
+static const int HEAD_xMax_offset = 40;
+static const int HEAD_yMax_offset = 42;
+static const int HEAD_macStyle_offset = 44;
+static const int HEAD_lowestRecPPEM_offset = 46;
+static const int HEAD_fontDirectionHint_offset = 48;
+static const int HEAD_indexToLocFormat_offset = 50;
+static const int HEAD_glyphDataFormat_offset = 52;
+
+/*
+ Some table maxp consts
+ cf https://docs.microsoft.com/fr-fr/typography/opentype/spec/maxp
+ For 0.5 version
+ TYPE NAME FROM BYTE
+ Fixed version 0
+ uint16 numGlyphs 4
+
+ For 1.0 Version
+ Fixed version 0
+ uint16 numGlyphs 4
+ uint16 maxPoints 6
+ uint16 maxContours 8
+ uint16 maxCompositePoints 10
+ uint16 maxCompositeContours 12
+ ...
+
+*/
+static const int MAXP_Version1Length_offset = 32;
+
+static const int MAXP_numGlyphs_offset = 4;
+static const int MAXP_maxPoints_offset = 6;
+static const int MAXP_maxContours_offset = 8;
+static const int MAXP_maxCompositePoints_offset = 10;
+static const int MAXP_maxCompositeContours_offset = 12;
+
/**
* @defgroup sft Sun Font Tools Exported Functions
*/
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 52b2e0360b50..9da262cf4a42 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -1639,11 +1639,11 @@ static SFErrCodes doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t )
table = getTable(t, O_head);
table_size = getTableSize(t, O_head);
- if (table_size < 52) {
+ if (table_size < HEAD_Length_offset) {
return SFErrCodes::TtFormat;
}
- t->unitsPerEm = GetUInt16(table, 18);
- int indexfmt = GetInt16(table, 50);
+ t->unitsPerEm = GetUInt16(table, HEAD_unitsPerEm_offset);
+ int indexfmt = GetInt16(table, HEAD_indexToLocFormat_offset);
if( ((indexfmt != 0) && (indexfmt != 1)) || (t->unitsPerEm <= 0) ) {
return SFErrCodes::TtFormat;
@@ -1937,7 +1937,7 @@ SFErrCodes CreateTTFromTTGlyphs(TrueTypeFont *ttf,
/** hhea **/
const sal_uInt8* p = getTable(ttf, O_hhea);
if (p) {
- hhea = TrueTypeTableNew_hhea(GetUInt16(p, 4), GetUInt16(p, 6), GetUInt16(p, 8), GetUInt16(p, 18), GetUInt16(p, 20));
+ hhea = TrueTypeTableNew_hhea(GetUInt16(p, HHEA_ascender_offset), GetUInt16(p, HHEA_descender_offset), GetUInt16(p, HHEA_lineGap_offset), GetUInt16(p, HHEA_caretSlopeRise_offset), GetUInt16(p, HHEA_caretSlopeRun_offset));
} else {
hhea = TrueTypeTableNew_hhea(0, 0, 0, 0, 0);
}
@@ -1946,13 +1946,13 @@ SFErrCodes CreateTTFromTTGlyphs(TrueTypeFont *ttf,
p = getTable(ttf, O_head);
assert(p != nullptr);
- head = TrueTypeTableNew_head(GetUInt32(p, 4),
- GetUInt16(p, 16),
- GetUInt16(p, 18),
- p+20,
- GetUInt16(p, 44),
- GetUInt16(p, 46),
- GetInt16(p, 48));
+ head = TrueTypeTableNew_head(GetUInt32(p, HEAD_fontRevision_offset),
+ GetUInt16(p, HEAD_flags_offset),
+ GetUInt16(p, HEAD_unitsPerEm_offset),
+ p+HEAD_created_offset,
+ GetUInt16(p, HEAD_macStyle_offset),
+ GetUInt16(p, HEAD_lowestRecPPEM_offset),
+ GetInt16(p, HEAD_fontDirectionHint_offset));
/** glyf **/
@@ -1988,10 +1988,10 @@ SFErrCodes CreateTTFromTTGlyphs(TrueTypeFont *ttf,
/** post **/
if ((p = getTable(ttf, O_post)) != nullptr) {
post = TrueTypeTableNew_post(0x00030000,
- GetUInt32(p, 4),
- GetUInt16(p, 8),
- GetUInt16(p, 10),
- GetUInt16(p, 12));
+ GetUInt32(p, POST_italicAngle_offset),
+ GetUInt16(p, POST_underlinePosition_offset),
+ GetUInt16(p, POST_underlineThickness_offset),
+ GetUInt16(p, POST_isFixedPitch_offset));
} else {
post = TrueTypeTableNew_post(0x00030000, 0, 0, 0, 0);
}
@@ -2364,24 +2364,21 @@ void GetTTFontMetrics(const uint8_t *pHhea, size_t nHhea,
/* There are 3 different versions of OS/2 table: original (68 bytes long),
* Microsoft old (78 bytes long) and Microsoft new (86 bytes long,)
* Apple's documentation recommends looking at the table length.
- *
- * FIXME: horribly outdated comment and horrible code that uses hard-coded
- * offsets to read the table.
*/
- if (nOs2 >= 76 + 2)
+ if (nOs2 >= OS2_V0_length)
{
- info->fsSelection = GetUInt16(pOs2, 62);
- info->typoAscender = GetInt16(pOs2, 68);
- info->typoDescender = GetInt16(pOs2, 70);
- info->typoLineGap = GetInt16(pOs2, 72);
- info->winAscent = GetUInt16(pOs2, 74);
- info->winDescent = GetUInt16(pOs2, 76);
+ info->fsSelection = GetUInt16(pOs2, OS2_fsSelection_offset);
+ info->typoAscender = GetInt16(pOs2, OS2_typoAscender_offset);
+ info->typoDescender = GetInt16(pOs2, OS2_typoDescender_offset);
+ info->typoLineGap = GetInt16(pOs2, OS2_typoLineGap_offset);
+ info->winAscent = GetUInt16(pOs2, OS2_winAscent_offset);
+ info->winDescent = GetUInt16(pOs2, OS2_winDescent_offset);
}
- if (nHhea >= 8 + 2) {
- info->ascender = GetInt16(pHhea, 4);
- info->descender = GetInt16(pHhea, 6);
- info->linegap = GetInt16(pHhea, 8);
+ if (nHhea >= HHEA_lineGap_offset + 2) {
+ info->ascender = GetInt16(pHhea, HHEA_ascender_offset);
+ info->descender = GetInt16(pHhea, HHEA_descender_offset);
+ info->linegap = GetInt16(pHhea, HHEA_lineGap_offset);
}
}
@@ -2401,50 +2398,46 @@ void GetTTGlobalFontInfo(TrueTypeFont *ttf, TTGlobalFontInfo *info)
const sal_uInt8* table = getTable(ttf, O_OS2);
sal_uInt32 table_size = getTableSize(ttf, O_OS2);
if (table && table_size >= 42) {
- info->weight = GetUInt16(table, 4);
- info->width = GetUInt16(table, 6);
-
- /* There are 3 different versions of OS/2 table: original (68 bytes long),
- * Microsoft old (78 bytes long) and Microsoft new (86 bytes long,)
- * Apple's documentation recommends looking at the table length.
- */
- if (table_size >= 78) {
- info->typoAscender = XUnits(UPEm,GetInt16(table, 68));
- info->typoDescender = XUnits(UPEm, GetInt16(table, 70));
- info->typoLineGap = XUnits(UPEm, GetInt16(table, 72));
- info->winAscent = XUnits(UPEm, GetUInt16(table, 74));
- info->winDescent = XUnits(UPEm, GetUInt16(table, 76));
+ info->weight = GetUInt16(table, OS2_usWeightClass_offset);
+ info->width = GetUInt16(table, OS2_usWidthClass_offset);
+
+ if (table_size >= OS2_V0_length) {
+ info->typoAscender = XUnits(UPEm,GetInt16(table, OS2_typoAscender_offset));
+ info->typoDescender = XUnits(UPEm, GetInt16(table, OS2_typoDescender_offset));
+ info->typoLineGap = XUnits(UPEm, GetInt16(table, OS2_typoLineGap_offset));
+ info->winAscent = XUnits(UPEm, GetUInt16(table, OS2_winAscent_offset));
+ info->winDescent = XUnits(UPEm, GetUInt16(table, OS2_winDescent_offset));
/* sanity check; some fonts treat winDescent as signed
* violating the standard */
if( info->winDescent > 5*UPEm )
- info->winDescent = XUnits(UPEm, GetInt16(table, 76));
+ info->winDescent = XUnits(UPEm, GetInt16(table, OS2_winDescent_offset));
}
- memcpy(info->panose, table + 32, 10);
- info->typeFlags = GetUInt16( table, 8 );
+ memcpy(info->panose, table + OS2_panose_offset, OS2_panoseNbBytes_offset);
+ info->typeFlags = GetUInt16( table, OS2_fsType_offset );
}
table = getTable(ttf, O_post);
if (table && getTableSize(ttf, O_post) >= 12+sizeof(sal_uInt32)) {
- info->pitch = GetUInt32(table, 12);
- info->italicAngle = GetInt32(table, 4);
+ info->pitch = GetUInt32(table, POST_isFixedPitch_offset);
+ info->italicAngle = GetInt32(table, POST_italicAngle_offset);
}
table = getTable(ttf, O_head); /* 'head' tables is always there */
table_size = getTableSize(ttf, O_head);
if (table_size >= 46) {
- info->xMin = XUnits(UPEm, GetInt16(table, 36));
- info->yMin = XUnits(UPEm, GetInt16(table, 38));
- info->xMax = XUnits(UPEm, GetInt16(table, 40));
- info->yMax = XUnits(UPEm, GetInt16(table, 42));
- info->macStyle = GetInt16(table, 44);
+ info->xMin = XUnits(UPEm, GetInt16(table, HEAD_xMin_offset));
+ info->yMin = XUnits(UPEm, GetInt16(table, HEAD_yMin_offset));
+ info->xMax = XUnits(UPEm, GetInt16(table, HEAD_xMax_offset));
+ info->yMax = XUnits(UPEm, GetInt16(table, HEAD_yMax_offset));
+ info->macStyle = GetInt16(table, HEAD_macStyle_offset);
}
table = getTable(ttf, O_hhea);
table_size = getTableSize(ttf, O_hhea);
if (table && table_size >= 10) {
- info->ascender = XUnits(UPEm, GetInt16(table, 4));
- info->descender = XUnits(UPEm, GetInt16(table, 6));
- info->linegap = XUnits(UPEm, GetInt16(table, 8));
+ info->ascender = XUnits(UPEm, GetInt16(table, HHEA_ascender_offset));
+ info->descender = XUnits(UPEm, GetInt16(table, HHEA_descender_offset));
+ info->linegap = XUnits(UPEm, GetInt16(table, HHEA_lineGap_offset));
}
table = getTable(ttf, O_vhea);
@@ -2623,19 +2616,19 @@ bool getTTCoverage(
{
bool bRet = false;
// parse OS/2 header
- if (nLength >= 58)
+ if (nLength >= OS2_Legacy_length)
{
rUnicodeRange = std::bitset<UnicodeCoverage::MAX_UC_ENUM>();
- append(rUnicodeRange.get(), 0, GetUInt32(pTable, 42));
- append(rUnicodeRange.get(), 32, GetUInt32(pTable, 46));
- append(rUnicodeRange.get(), 64, GetUInt32(pTable, 50));
- append(rUnicodeRange.get(), 96, GetUInt32(pTable, 54));
+ append(rUnicodeRange.get(), 0, GetUInt32(pTable, OS2_ulUnicodeRange1_offset));
+ append(rUnicodeRange.get(), 32, GetUInt32(pTable, OS2_ulUnicodeRange2_offset));
+ append(rUnicodeRange.get(), 64, GetUInt32(pTable, OS2_ulUnicodeRange3_offset));
+ append(rUnicodeRange.get(), 96, GetUInt32(pTable, OS2_ulUnicodeRange4_offset));
bRet = true;
- if (nLength >= 86)
+ if (nLength >= OS2_V1_length)
{
rCodePageRange = std::bitset<CodePageCoverage::MAX_CP_ENUM>();
- append(rCodePageRange.get(), 0, GetUInt32(pTable, 78));
- append(rCodePageRange.get(), 32, GetUInt32(pTable, 82));
+ append(rCodePageRange.get(), 0, GetUInt32(pTable, OS2_ulCodePageRange1_offset));
+ append(rCodePageRange.get(), 32, GetUInt32(pTable, OS2_ulCodePageRange2_offset));
}
}
return bRet;
diff --git a/vcl/source/fontsubset/ttcr.cxx b/vcl/source/fontsubset/ttcr.cxx
index b4074203d316..a52f8fda08b0 100644
--- a/vcl/source/fontsubset/ttcr.cxx
+++ b/vcl/source/fontsubset/ttcr.cxx
@@ -300,17 +300,13 @@ SFErrCodes StreamToFile(TrueTypeCreator *_this, const char* fname)
* TrueTypeTable private methods
*/
-#define TABLESIZE_head 54
-#define TABLESIZE_hhea 36
-#define TABLESIZE_maxp 32
-
/* Table data points to
* --------------------------------------------
* generic tdata_generic struct
- * 'head' TABLESIZE_head bytes of memory
- * 'hhea' TABLESIZE_hhea bytes of memory
+ * 'head' HEAD_Length_offset bytes of memory
+ * 'hhea' HHEA_Length bytes of memory
* 'loca' tdata_loca struct
- * 'maxp' TABLESIZE_maxp bytes of memory
+ * 'maxp' MAXP_Version1Length_offset bytes of memory
* 'glyf' list of GlyphData structs (defined in sft.h)
* 'name' list of NameRecord structs (defined in sft.h)
* 'post' tdata_post struct
@@ -507,7 +503,7 @@ static int GetRawData_generic(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32
static int GetRawData_head(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt32 *tag)
{
- *len = TABLESIZE_head;
+ *len = HEAD_Length_offset;
*ptr = static_cast<sal_uInt8 *>(_this->data);
*tag = T_head;
@@ -516,7 +512,7 @@ static int GetRawData_head(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le
static int GetRawData_hhea(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt32 *tag)
{
- *len = TABLESIZE_hhea;
+ *len = HHEA_Length;
*ptr = static_cast<sal_uInt8 *>(_this->data);
*tag = T_hhea;
@@ -542,7 +538,7 @@ static int GetRawData_loca(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le
static int GetRawData_maxp(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt32 *tag)
{
- *len = TABLESIZE_maxp;
+ *len = MAXP_Version1Length_offset;
*ptr = static_cast<sal_uInt8 *>(_this->data);
*tag = T_maxp;
@@ -862,7 +858,7 @@ TrueTypeTable *TrueTypeTableNew_head(sal_uInt32 fontRevision,
assert(created != nullptr);
TrueTypeTable* table = static_cast<TrueTypeTable*>(smalloc(sizeof(TrueTypeTable)));
- sal_uInt8* ptr = ttmalloc(TABLESIZE_head);
+ sal_uInt8* ptr = ttmalloc(HEAD_Length_offset);
PutUInt32(0x00010000, ptr, 0); /* version */
PutUInt32(fontRevision, ptr, 4);
@@ -890,7 +886,7 @@ TrueTypeTable *TrueTypeTableNew_hhea(sal_Int16 ascender,
sal_Int16 caretSlopeRun)
{
TrueTypeTable* table = static_cast<TrueTypeTable*>(smalloc(sizeof(TrueTypeTable)));
- sal_uInt8* ptr = ttmalloc(TABLESIZE_hhea);
+ sal_uInt8* ptr = ttmalloc(HHEA_Length);
PutUInt32(0x00010000, ptr, 0); /* version */
PutUInt16(ascender, ptr, 4);
@@ -929,10 +925,10 @@ TrueTypeTable *TrueTypeTableNew_loca()
TrueTypeTable *TrueTypeTableNew_maxp( const sal_uInt8* maxp, int size)
{
TrueTypeTable* table = static_cast<TrueTypeTable*>(smalloc(sizeof(TrueTypeTable)));
- table->data = ttmalloc(TABLESIZE_maxp);
+ table->data = ttmalloc(MAXP_Version1Length_offset);
- if (maxp && size == TABLESIZE_maxp) {
- memcpy(table->data, maxp, TABLESIZE_maxp);
+ if (maxp && size == MAXP_Version1Length_offset) {
+ memcpy(table->data, maxp, MAXP_Version1Length_offset);
}
table->tag = T_maxp;
@@ -1374,20 +1370,20 @@ static void ProcessTables(TrueTypeCreator *tt)
head = FindTable(tt, T_head);
sal_uInt8* const pHeadData = static_cast<sal_uInt8*>(head->data);
- PutInt16(xMin, pHeadData, 36);
- PutInt16(yMin, pHeadData, 38);
- PutInt16(xMax, pHeadData, 40);
- PutInt16(yMax, pHeadData, 42);
- PutInt16(indexToLocFormat, pHeadData, 50);
+ PutInt16(xMin, pHeadData, HEAD_xMin_offset);
+ PutInt16(yMin, pHeadData, HEAD_yMin_offset);
+ PutInt16(xMax, pHeadData, HEAD_xMax_offset);
+ PutInt16(yMax, pHeadData, HEAD_yMax_offset);
+ PutInt16(indexToLocFormat, pHeadData, HEAD_indexToLocFormat_offset);
maxp = FindTable(tt, T_maxp);
sal_uInt8* const pMaxpData = static_cast<sal_uInt8*>(maxp->data);
- PutUInt16(static_cast<sal_uInt16>(nGlyphs), pMaxpData, 4);
- PutUInt16(maxPoints, pMaxpData, 6);
- PutUInt16(maxContours, pMaxpData, 8);
- PutUInt16(maxCompositePoints, pMaxpData, 10);
- PutUInt16(maxCompositeContours, pMaxpData, 12);
+ PutUInt16(static_cast<sal_uInt16>(nGlyphs), pMaxpData, MAXP_numGlyphs_offset);
+ PutUInt16(maxPoints, pMaxpData, MAXP_maxPoints_offset);
+ PutUInt16(maxContours, pMaxpData, MAXP_maxContours_offset);
+ PutUInt16(maxCompositePoints, pMaxpData, MAXP_maxCompositePoints_offset);
+ PutUInt16(maxCompositeContours, pMaxpData, MAXP_maxCompositeContours_offset);
/*
* Generate an htmx table and update hhea table