// - Eliminate ALL references to BYTE, WORD, SBYTE, SWORD, etc.
//
// - Eliminate ALL references to BYTE, WORD, SBYTE, SWORD, etc.
//
{
SetFilePointer(file, (LONG)bytesToSkip, NULL, FILE_CURRENT);
}*/
{
SetFilePointer(file, (LONG)bytesToSkip, NULL, FILE_CURRENT);
}*/
{
fputc(word >> 8, file); // Hi byte
fputc(word & 0xFF, file); // Lo byte
{
fputc(word >> 8, file); // Hi byte
fputc(word & 0xFF, file); // Lo byte
- uint32 hi1 = table[ptr++];
- uint32 lo1 = table[ptr++];
- uint32 hi2 = table[ptr++];
- uint32 lo2 = table[ptr++];
+ uint32_t hi1 = table[ptr++];
+ uint32_t lo1 = table[ptr++];
+ uint32_t hi2 = table[ptr++];
+ uint32_t lo2 = table[ptr++];
- table[ptr++] = (uint8)(data >> 24); table[ptr++] = (uint8)(data >> 16);
- table[ptr++] = (uint8)(data >> 8); table[ptr++] = (uint8)(data & 0xFF);
+ table[ptr++] = (uint8_t)(data >> 24); table[ptr++] = (uint8_t)(data >> 16);
+ table[ptr++] = (uint8_t)(data >> 8); table[ptr++] = (uint8_t)(data & 0xFF);
}
/////////////////////////////////////////////////////////////////////////////
// Fixed point to float (& vice versa) conversions
/////////////////////////////////////////////////////////////////////////////
}
/////////////////////////////////////////////////////////////////////////////
// Fixed point to float (& vice versa) conversions
/////////////////////////////////////////////////////////////////////////////
larray[18] = &maxp_len; larray[19] = &name_len; larray[20] = &post_len;
larray[21] = &prep_len; larray[22] = &vhea_len; larray[23] = &vmtx_len;
larray[18] = &maxp_len; larray[19] = &name_len; larray[20] = &post_len;
larray[21] = &prep_len; larray[22] = &vhea_len; larray[23] = &vmtx_len;
/////////////////////////////////////////////////////////////////////////////
void TTF::ClearTables(void)
{
/////////////////////////////////////////////////////////////////////////////
void TTF::ClearTables(void)
{
char names[NUMTABS][5];
char narray[NUMTABS][5] = { "EBDT", "EBLC", "EBSC", "LTSH", "OS/2", "PCLT",
"VDMX", "cmap", "cvt ", "fpgm", "gasp", "glyf", "hdmx", "head", "hhea",
char names[NUMTABS][5];
char narray[NUMTABS][5] = { "EBDT", "EBLC", "EBSC", "LTSH", "OS/2", "PCLT",
"VDMX", "cmap", "cvt ", "fpgm", "gasp", "glyf", "hdmx", "head", "hhea",
{
// ReadFile(file, names[i], 4, &bytesRead, NULL);
fread(names[i], 1, 4, file);
{
// ReadFile(file, names[i], 4, &bytesRead, NULL);
fread(names[i], 1, 4, file);
-// *parray[j] = (uint8 *)GlobalAlloc(GMEM_FIXED, length[i]); // Allocate space
- *parray[j] = (uint8 *)malloc(length[i]); // Alloc space
+// *parray[j] = (uint8_t *)GlobalAlloc(GMEM_FIXED, length[i]); // Allocate space
+ *parray[j] = (uint8_t *)malloc(length[i]); // Alloc space
char padding[3] = { 0, 0, 0 };
// Convert this to a table of ULONGs to decrease complexity...
//wouldn't be endian safe then...
char padding[3] = { 0, 0, 0 };
// Convert this to a table of ULONGs to decrease complexity...
//wouldn't be endian safe then...
// HANDLE file = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
// NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
// HANDLE file = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
// NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
WriteWord(file, 0); // entrySelector Log2(max power of 2 <= numTables).
WriteWord(file, 0); // NumTables x 16 - searchRange.
WriteWord(file, 0); // entrySelector Log2(max power of 2 <= numTables).
WriteWord(file, 0); // NumTables x 16 - searchRange.
WriteDWord(file, offset); // Offset
WriteDWord(file, (*larray[i])); // Length
WriteDWord(file, offset); // Offset
WriteDWord(file, (*larray[i])); // Length
// file.put((*parray[i])[j]);
// WriteFile(file, *parray[i], *larray[i], &bytesWritten, NULL);
fwrite(*parray[i], 1, *larray[i], file);
// file.put((*parray[i])[j]);
// WriteFile(file, *parray[i], *larray[i], &bytesWritten, NULL);
fwrite(*parray[i], 1, *larray[i], file);
if (remainder) // i.e., it's not evenly div by 4
// for(j=remainder; j<4; j++)
// file.put((char)0); // pad it!
if (remainder) // i.e., it's not evenly div by 4
// for(j=remainder; j<4; j++)
// file.put((char)0); // pad it!
//
// This function encodes the glyph data and stores it to the 'glyf' table.
/////////////////////////////////////////////////////////////////////////////
//
// This function encodes the glyph data and stores it to the 'glyf' table.
/////////////////////////////////////////////////////////////////////////////
- uint8 flag, xbuf[4000], ybuf[4000], fbuf[2000];
- uint32 xp = 0, yp = 0, fp = 0; // Table pointers
+ uint8_t flag, xbuf[4000], ybuf[4000], fbuf[2000];
+ uint32_t xp = 0, yp = 0, fp = 0; // Table pointers
if (glyphnum < myMaxp.numGlyphs) // numofgls is 1 based ind, glyph# 0 based
{
// need to add composite encoding...
int lastx = 0, lasty = 0;
if (glyphnum < myMaxp.numGlyphs) // numofgls is 1 based ind, glyph# 0 based
{
// need to add composite encoding...
int lastx = 0, lasty = 0;
while (fbuf[i] == fbuf[++i]) count++; // Count number of repeats
i--;
fbuf[fp++] = fbuf[i] | 0x08; // Set repeat flag
while (fbuf[i] == fbuf[++i]) count++; // Count number of repeats
i--;
fbuf[fp++] = fbuf[i] | 0x08; // Set repeat flag
glyphLen[glyphnum] = newLength;
}
// And finally, store it!
glyphLen[glyphnum] = newLength;
}
// And finally, store it!
SetWord(glyph[glyphnum], gp, numberOfPolys);
SetWord(glyph[glyphnum], gp, llx);
SetWord(glyph[glyphnum], gp, lly);
SetWord(glyph[glyphnum], gp, urx);
SetWord(glyph[glyphnum], gp, ury);
SetWord(glyph[glyphnum], gp, numberOfPolys);
SetWord(glyph[glyphnum], gp, llx);
SetWord(glyph[glyphnum], gp, lly);
SetWord(glyph[glyphnum], gp, urx);
SetWord(glyph[glyphnum], gp, ury);
SetWord(glyph[glyphnum], gp, poly[i]);
SetWord(glyph[glyphnum], gp, numberOfHints);
SetWord(glyph[glyphnum], gp, poly[i]);
SetWord(glyph[glyphnum], gp, numberOfHints);
SetByte(glyph[glyphnum], gp, ybuf[i]);
retval = true; // Successfully encoded!
SetByte(glyph[glyphnum], gp, ybuf[i]);
retval = true; // Successfully encoded!
// This function decodes the glyph data and stores it to the object's
// internal array.
/////////////////////////////////////////////////////////////////////////////
// This function decodes the glyph data and stores it to the object's
// internal array.
/////////////////////////////////////////////////////////////////////////////
// glyphnum is 0 based index, while numGlyphs is 1 based
if (glyphnum >= myMaxp.numGlyphs)
// glyphnum is 0 based index, while numGlyphs is 1 based
if (glyphnum >= myMaxp.numGlyphs)
isCompositeGlyph = false; // Default is no
numberOfPolys = GetWord(glyph[glyphnum], dp); // # of polygons
isCompositeGlyph = false; // Default is no
numberOfPolys = GetWord(glyph[glyphnum], dp); // # of polygons
- llx = (int16)GetWord(glyph[glyphnum], dp); // Lower left X
- lly = (int16)GetWord(glyph[glyphnum], dp); // Lower left Y
- urx = (int16)GetWord(glyph[glyphnum], dp); // Upper right X
- ury = (int16)GetWord(glyph[glyphnum], dp); // Upper right Y
+ llx = (int16_t)GetWord(glyph[glyphnum], dp); // Lower left X
+ lly = (int16_t)GetWord(glyph[glyphnum], dp); // Lower left Y
+ urx = (int16_t)GetWord(glyph[glyphnum], dp); // Upper right X
+ ury = (int16_t)GetWord(glyph[glyphnum], dp); // Upper right Y
// Need to handle composite glyphs better here. The ways things
// are set now is a recipe for disaster...
// Need to handle composite glyphs better here. The ways things
// are set now is a recipe for disaster...
{
cmpst.flags = GetWord(glyph[glyphnum], dp);
cmpst.glyphIndex = GetWord(glyph[glyphnum], dp);
{
cmpst.flags = GetWord(glyph[glyphnum], dp);
cmpst.glyphIndex = GetWord(glyph[glyphnum], dp);
- cmpst.arg1 = (cmpst.flags & 0x01 ? (int16)GetWord(glyph[glyphnum], dp) : (int8)GetByte(glyph[glyphnum], dp));
- cmpst.arg2 = (cmpst.flags & 0x01 ? (int16)GetWord(glyph[glyphnum], dp) : (int8)GetByte(glyph[glyphnum], dp));
+ cmpst.arg1 = (cmpst.flags & 0x01 ? (int16_t)GetWord(glyph[glyphnum], dp) : (int8_t)GetByte(glyph[glyphnum], dp));
+ cmpst.arg2 = (cmpst.flags & 0x01 ? (int16_t)GetWord(glyph[glyphnum], dp) : (int8_t)GetByte(glyph[glyphnum], dp));
- cmpst.xScale = FixedToFloat((int16)GetWord(glyph[glyphnum], dp)),
- cmpst.yScale = FixedToFloat((int16)GetWord(glyph[glyphnum], dp));
+ cmpst.xScale = FixedToFloat((int16_t)GetWord(glyph[glyphnum], dp)),
+ cmpst.yScale = FixedToFloat((int16_t)GetWord(glyph[glyphnum], dp));
- cmpst.xScale = FixedToFloat((int16)GetWord(glyph[glyphnum], dp)),
- cmpst.scale01 = FixedToFloat((int16)GetWord(glyph[glyphnum], dp)),
- cmpst.scale10 = FixedToFloat((int16)GetWord(glyph[glyphnum], dp)),
- cmpst.yScale = FixedToFloat((int16)GetWord(glyph[glyphnum], dp));
+ cmpst.xScale = FixedToFloat((int16_t)GetWord(glyph[glyphnum], dp)),
+ cmpst.scale01 = FixedToFloat((int16_t)GetWord(glyph[glyphnum], dp)),
+ cmpst.scale10 = FixedToFloat((int16_t)GetWord(glyph[glyphnum], dp)),
+ cmpst.yScale = FixedToFloat((int16_t)GetWord(glyph[glyphnum], dp));
-// if ( flags & ARG_1_AND_2_ARE_uint16S) {
-// (SHORT or Fuint16) argument1;
-// (SHORT or Fuint16) argument2;
+// if ( flags & ARG_1_AND_2_ARE_uint16_tS) {
+// (SHORT or Fuint16_t) argument1;
+// (SHORT or Fuint16_t) argument2;
-//ARG_1_AND_2_ARE_uint16S 0 If this is set, the arguments are uint16s;
-// otherwise, they are uint8s.
+//ARG_1_AND_2_ARE_uint16_tS 0 If this is set, the arguments are uint16_ts;
+// otherwise, they are uint8_ts.
//ARGS_ARE_XY_VALUES 1 If this is set, the arguments are xy values;
// otherwise, they are points.
//ROUND_XY_TO_GRID 2 For the xy values if the preceding is true.
//ARGS_ARE_XY_VALUES 1 If this is set, the arguments are xy values;
// otherwise, they are points.
//ROUND_XY_TO_GRID 2 For the xy values if the preceding is true.
// We make an educated guess that num_pts = num_tokens; but if there
// is repeated data in the tokens, then we need to adjust the # of
// tokens down appropriately.
// We make an educated guess that num_pts = num_tokens; but if there
// is repeated data in the tokens, then we need to adjust the # of
// tokens down appropriately.
xx -= GetByte(glyph[glyphnum], xptr);
if ((token & 0x12) == 0x00)
xx -= GetByte(glyph[glyphnum], xptr);
if ((token & 0x12) == 0x00)
yy -= GetByte(glyph[glyphnum], yptr);
if ((token & 0x24) == 0x00)
yy -= GetByte(glyph[glyphnum], yptr);
if ((token & 0x24) == 0x00)
This function decodes the 'glyf' data for a non-composite (atomic) glyph and
returns it as a GlyphPoints object. Helper function.
*****************************************************************************/
This function decodes the 'glyf' data for a non-composite (atomic) glyph and
returns it as a GlyphPoints object. Helper function.
*****************************************************************************/
{
if (DecodeGlyph(glyphNum))
return GlyphPoints(numberOfPoints, numberOfPolys, gx, gy, onCurve, poly);
{
if (DecodeGlyph(glyphNum))
return GlyphPoints(numberOfPoints, numberOfPolys, gx, gy, onCurve, poly);
This function decodes the 'glyf' data for a composite glyph and returns
it as a GlyphPoints object.
*****************************************************************************/
This function decodes the 'glyf' data for a composite glyph and returns
it as a GlyphPoints object.
*****************************************************************************/
//
// This function returns the character name of the glyph number passed in.
/////////////////////////////////////////////////////////////////////////////
//
// This function returns the character name of the glyph number passed in.
/////////////////////////////////////////////////////////////////////////////
- uint8 * pTab = NULL;
- uint32 tabOff = 34, numGlyphs = (uint32)((post[32] << 8) | post[33]);
- uint32 index = (uint32)((post[tabOff + cNum * 2] << 8) | post[tabOff + cNum * 2 + 1]);
- uint32 nInd2;
+ uint8_t * pTab = NULL;
+ uint32_t tabOff = 34, numGlyphs = (uint32_t)((post[32] << 8) | post[33]);
+ uint32_t index = (uint32_t)((post[tabOff + cNum * 2] << 8) | post[tabOff + cNum * 2 + 1]);
+ uint32_t nInd2;
- for(uint32 i=0; i<index; i++)
- nInd2 = nInd2 + pTab[nInd2] + 1; // 1st uint8 is length of string + that uint8
+ for(uint32_t i=0; i<index; i++)
+ nInd2 = nInd2 + pTab[nInd2] + 1; // 1st uint8_t is length of string + that uint8_t
myHead.version = GetDWord(head, tp);
myHead.fontRevision = GetDWord(head, tp);
myHead.checkSumAdjustment = GetDWord(head, tp);
myHead.version = GetDWord(head, tp);
myHead.fontRevision = GetDWord(head, tp);
myHead.checkSumAdjustment = GetDWord(head, tp);
myHead.yMax = GetWord(head, tp);
myHead.macStyle = GetWord(head, tp);
myHead.lowestRecPPEM = GetWord(head, tp);
myHead.yMax = GetWord(head, tp);
myHead.macStyle = GetWord(head, tp);
myHead.lowestRecPPEM = GetWord(head, tp);
- myHead.fontDirectionHint = (int16)GetWord(head, tp);
- myHead.indexToLocFormat = (int16)GetWord(head, tp);
- myHead.glyphDataFormat = (int16)GetWord(head, tp);
+ myHead.fontDirectionHint = (int16_t)GetWord(head, tp);
+ myHead.indexToLocFormat = (int16_t)GetWord(head, tp);
+ myHead.glyphDataFormat = (int16_t)GetWord(head, tp);
myMaxp.maxComponentDepth = GetWord(maxp, tp);
tp = 0; // Reset table pointer
myMaxp.maxComponentDepth = GetWord(maxp, tp);
tp = 0; // Reset table pointer
- uint32 end = (myHead.indexToLocFormat ? GetDWord(loca, tp) : GetWord(loca, tp) << 1);
- uint32 length = end - start;
+ uint32_t end = (myHead.indexToLocFormat ? GetDWord(loca, tp) : GetWord(loca, tp) << 1);
+ uint32_t length = end - start;
glyphLen[i] = length; // Lengths are saved 'cause malloc is sloppy
if (length) // loca+start? pointer arithmetic?
{
glyphLen[i] = length; // Lengths are saved 'cause malloc is sloppy
if (length) // loca+start? pointer arithmetic?
{
/////////////////////////////////////////////////////////////////////////////
bool TTF::BuildTables(void)
{
/////////////////////////////////////////////////////////////////////////////
bool TTF::BuildTables(void)
{
SetWord(head, tp, myHead.yMax);// = GetWord(head, tp);
SetWord(head, tp, myHead.macStyle);// = GetWord(head, tp);
SetWord(head, tp, myHead.lowestRecPPEM);// = GetWord(head, tp);
SetWord(head, tp, myHead.yMax);// = GetWord(head, tp);
SetWord(head, tp, myHead.macStyle);// = GetWord(head, tp);
SetWord(head, tp, myHead.lowestRecPPEM);// = GetWord(head, tp);
- SetWord(head, tp, myHead.fontDirectionHint);// = (int16)GetWord(head, tp);
- SetWord(head, tp, myHead.indexToLocFormat);// = (int16)GetWord(head, tp);
- SetWord(head, tp, myHead.glyphDataFormat);// = (int16)GetWord(head, tp);
+ SetWord(head, tp, myHead.fontDirectionHint);// = (int16_t)GetWord(head, tp);
+ SetWord(head, tp, myHead.indexToLocFormat);// = (int16_t)GetWord(head, tp);
+ SetWord(head, tp, myHead.glyphDataFormat);// = (int16_t)GetWord(head, tp);
// internal array. If the flag isDirty is set, it also encodes the internal
// array and stores it to the 'glyf' table.
/////////////////////////////////////////////////////////////////////////////
// internal array. If the flag isDirty is set, it also encodes the internal
// array and stores it to the 'glyf' table.
/////////////////////////////////////////////////////////////////////////////
// is greater than the number of glyphs, glyph is added at end of list. This
// glyph then becomes the current glyph.
/////////////////////////////////////////////////////////////////////////////
// is greater than the number of glyphs, glyph is added at end of list. This
// glyph then becomes the current glyph.
/////////////////////////////////////////////////////////////////////////////
// This function deletes the glyph at position glyphnum. All glyphs after
// this glyph are moved down in position.
/////////////////////////////////////////////////////////////////////////////
// This function deletes the glyph at position glyphnum. All glyphs after
// this glyph are moved down in position.
/////////////////////////////////////////////////////////////////////////////
return Box(llx, lly, urx, ury);
}
return Box(llx, lly, urx, ury);
}