summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/pcf/pcfread.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/freetype/src/pcf/pcfread.c')
-rw-r--r--src/3rdparty/freetype/src/pcf/pcfread.c137
1 files changed, 64 insertions, 73 deletions
diff --git a/src/3rdparty/freetype/src/pcf/pcfread.c b/src/3rdparty/freetype/src/pcf/pcfread.c
index 2ffe22d71c..f167bcb8ae 100644
--- a/src/3rdparty/freetype/src/pcf/pcfread.c
+++ b/src/3rdparty/freetype/src/pcf/pcfread.c
@@ -25,11 +25,10 @@ THE SOFTWARE.
*/
-#include <ft2build.h>
-#include FT_INTERNAL_DEBUG_H
-#include FT_INTERNAL_STREAM_H
-#include FT_INTERNAL_OBJECTS_H
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/internal/ftobjs.h>
#include "pcf.h"
#include "pcfread.h"
@@ -122,13 +121,13 @@ THE SOFTWARE.
toc->count > 9 )
{
FT_TRACE0(( "pcf_read_TOC: adjusting number of tables"
- " (from %d to %d)\n",
+ " (from %ld to %ld)\n",
toc->count,
FT_MIN( stream->size >> 4, 9 ) ));
toc->count = FT_MIN( stream->size >> 4, 9 );
}
- if ( FT_NEW_ARRAY( face->toc.tables, toc->count ) )
+ if ( FT_QNEW_ARRAY( face->toc.tables, toc->count ) )
return error;
tables = face->toc.tables;
@@ -239,10 +238,10 @@ THE SOFTWARE.
{
for ( j = 0; j < sizeof ( tableNames ) / sizeof ( tableNames[0] );
j++ )
- if ( tables[i].type == (FT_UInt)( 1 << j ) )
+ if ( tables[i].type == 1UL << j )
name = tableNames[j];
- FT_TRACE4(( " %d: type=%s, format=0x%X,"
+ FT_TRACE4(( " %d: type=%s, format=0x%lX,"
" size=%ld (0x%lX), offset=%ld (0x%lX)\n",
i, name,
tables[i].format,
@@ -502,8 +501,8 @@ THE SOFTWARE.
if ( FT_READ_ULONG_LE( format ) )
goto Bail;
- FT_TRACE4(( "pcf_get_properties:\n"
- " format: 0x%lX (%s)\n",
+ FT_TRACE4(( "pcf_get_properties:\n" ));
+ FT_TRACE4(( " format: 0x%lX (%s)\n",
format,
PCF_BYTE_ORDER( format ) == MSBFirst ? "MSB" : "LSB" ));
@@ -541,7 +540,7 @@ THE SOFTWARE.
face->nprops = (int)nprops;
- if ( FT_NEW_ARRAY( props, nprops ) )
+ if ( FT_QNEW_ARRAY( props, nprops ) )
goto Bail;
for ( i = 0; i < nprops; i++ )
@@ -608,13 +607,13 @@ THE SOFTWARE.
}
/* allocate one more byte so that we have a final null byte */
- if ( FT_NEW_ARRAY( strings, string_size + 1 ) )
+ if ( FT_QALLOC( strings, string_size + 1 ) ||
+ FT_STREAM_READ( strings, string_size ) )
goto Bail;
- error = FT_Stream_Read( stream, (FT_Byte*)strings, string_size );
- if ( error )
- goto Bail;
+ strings[string_size] = '\0';
+ /* zero out in case of failure */
if ( FT_NEW_ARRAY( properties, nprops ) )
goto Bail;
@@ -661,7 +660,7 @@ THE SOFTWARE.
{
properties[i].value.l = props[i].value;
- FT_TRACE4(( " %d\n", properties[i].value.l ));
+ FT_TRACE4(( " %ld\n", properties[i].value.l ));
}
}
@@ -698,8 +697,8 @@ THE SOFTWARE.
if ( FT_READ_ULONG_LE( format ) )
goto Bail;
- FT_TRACE4(( "pcf_get_metrics:\n"
- " format: 0x%lX (%s, %s)\n",
+ FT_TRACE4(( "pcf_get_metrics:\n" ));
+ FT_TRACE4(( " format: 0x%lX (%s, %s)\n",
format,
PCF_BYTE_ORDER( format ) == MSBFirst ? "MSB" : "LSB",
PCF_FORMAT_MATCH( format, PCF_COMPRESSED_METRICS ) ?
@@ -768,7 +767,7 @@ THE SOFTWARE.
face->nmetrics = nmetrics + 1;
- if ( FT_NEW_ARRAY( face->metrics, face->nmetrics ) )
+ if ( FT_QNEW_ARRAY( face->metrics, face->nmetrics ) )
return error;
/* we handle glyph index 0 later on */
@@ -798,7 +797,7 @@ THE SOFTWARE.
metrics->descent = 0;
FT_TRACE0(( "pcf_get_metrics:"
- " invalid metrics for glyph %d\n", i ));
+ " invalid metrics for glyph %ld\n", i ));
}
}
@@ -841,17 +840,16 @@ THE SOFTWARE.
FT_Stream_ExitFrame( stream );
- FT_TRACE4(( "pcf_get_bitmaps:\n"
- " format: 0x%lX\n"
- " (%s, %s,\n"
- " padding=%d bit%s, scanning=%d bit%s)\n",
- format,
+ FT_TRACE4(( "pcf_get_bitmaps:\n" ));
+ FT_TRACE4(( " format: 0x%lX\n", format ));
+ FT_TRACE4(( " (%s, %s,\n",
PCF_BYTE_ORDER( format ) == MSBFirst
? "most significant byte first"
: "least significant byte first",
PCF_BIT_ORDER( format ) == MSBFirst
? "most significant bit first"
- : "least significant bit first",
+ : "least significant bit first" ));
+ FT_TRACE4(( " padding=%d bit%s, scanning=%d bit%s)\n",
8 << PCF_GLYPH_PAD_INDEX( format ),
( 8 << PCF_GLYPH_PAD_INDEX( format ) ) == 1 ? "" : "s",
8 << PCF_SCAN_UNIT_INDEX( format ),
@@ -918,11 +916,11 @@ THE SOFTWARE.
sizebitmaps = bitmapSizes[PCF_GLYPH_PAD_INDEX( format )];
- FT_TRACE4(( " %ld-bit padding implies a size of %lu\n",
+ FT_TRACE4(( " %d-bit padding implies a size of %lu\n",
8 << i, bitmapSizes[i] ));
}
- FT_TRACE4(( " %lu bitmaps, using %ld-bit padding\n",
+ FT_TRACE4(( " %lu bitmaps, using %d-bit padding\n",
nbitmaps,
8 << PCF_GLYPH_PAD_INDEX( format ) ));
FT_TRACE4(( " bitmap size: %lu\n", sizebitmaps ));
@@ -1002,8 +1000,8 @@ THE SOFTWARE.
if ( FT_READ_ULONG_LE( format ) )
goto Bail;
- FT_TRACE4(( "pcf_get_encodings:\n"
- " format: 0x%lX (%s)\n",
+ FT_TRACE4(( "pcf_get_encodings:\n" ));
+ FT_TRACE4(( " format: 0x%lX (%s)\n",
format,
PCF_BYTE_ORDER( format ) == MSBFirst ? "MSB" : "LSB" ));
@@ -1022,11 +1020,11 @@ THE SOFTWARE.
goto Bail;
}
- FT_TRACE4(( " firstCol 0x%X, lastCol 0x%X\n"
- " firstRow 0x%X, lastRow 0x%X\n"
- " defaultChar 0x%X\n",
- enc->firstCol, enc->lastCol,
- enc->firstRow, enc->lastRow,
+ FT_TRACE4(( " firstCol 0x%X, lastCol 0x%X\n",
+ enc->firstCol, enc->lastCol ));
+ FT_TRACE4(( " firstRow 0x%X, lastRow 0x%X\n",
+ enc->firstRow, enc->lastRow ));
+ FT_TRACE4(( " defaultChar 0x%X\n",
enc->defaultChar ));
/* sanity checks; we limit numbers of rows and columns to 256 */
@@ -1036,16 +1034,6 @@ THE SOFTWARE.
enc->lastRow > 0xFF )
return FT_THROW( Invalid_Table );
- nencoding = (FT_ULong)( enc->lastCol - enc->firstCol + 1 ) *
- (FT_ULong)( enc->lastRow - enc->firstRow + 1 );
-
- if ( FT_NEW_ARRAY( enc->offset, nencoding ) )
- goto Bail;
-
- error = FT_Stream_EnterFrame( stream, 2 * nencoding );
- if ( error )
- goto Exit;
-
FT_TRACE5(( "\n" ));
defaultCharRow = enc->defaultChar >> 8;
@@ -1066,6 +1054,13 @@ THE SOFTWARE.
defaultCharCol = enc->firstCol;
}
+ nencoding = (FT_ULong)( enc->lastCol - enc->firstCol + 1 ) *
+ (FT_ULong)( enc->lastRow - enc->firstRow + 1 );
+
+ error = FT_Stream_EnterFrame( stream, 2 * nencoding );
+ if ( error )
+ goto Bail;
+
/*
* FreeType mandates that glyph index 0 is the `undefined glyph', which
* PCF calls the `default character'. However, FreeType needs glyph
@@ -1089,8 +1084,8 @@ THE SOFTWARE.
if ( defaultCharEncodingOffset == 0xFFFF )
{
FT_TRACE0(( "pcf_get_encodings:"
- " No glyph for default character,\n"
- " "
+ " No glyph for default character,\n" ));
+ FT_TRACE0(( " "
" setting it to the first glyph of the font\n" ));
defaultCharEncodingOffset = 1;
}
@@ -1101,8 +1096,8 @@ THE SOFTWARE.
if ( defaultCharEncodingOffset >= face->nmetrics )
{
FT_TRACE0(( "pcf_get_encodings:"
- " Invalid glyph index for default character,\n"
- " "
+ " Invalid glyph index for default character,\n" ));
+ FT_TRACE0(( " "
" setting it to the first glyph of the font\n" ));
defaultCharEncodingOffset = 1;
}
@@ -1111,6 +1106,9 @@ THE SOFTWARE.
/* copy metrics of default character to index 0 */
face->metrics[0] = face->metrics[defaultCharEncodingOffset];
+ if ( FT_QNEW_ARRAY( enc->offset, nencoding ) )
+ goto Bail;
+
/* now loop over all values */
offset = enc->offset;
for ( i = enc->firstRow; i <= enc->lastRow; i++ )
@@ -1133,11 +1131,6 @@ THE SOFTWARE.
}
FT_Stream_ExitFrame( stream );
- return error;
-
- Exit:
- FT_FREE( enc->offset );
-
Bail:
return error;
}
@@ -1209,10 +1202,10 @@ THE SOFTWARE.
if ( FT_READ_ULONG_LE( format ) )
goto Bail;
- FT_TRACE4(( "pcf_get_accel%s:\n"
- " format: 0x%lX (%s, %s)\n",
+ FT_TRACE4(( "pcf_get_accel%s:\n",
type == PCF_BDF_ACCELERATORS ? " (getting BDF accelerators)"
- : "",
+ : "" ));
+ FT_TRACE4(( " format: 0x%lX (%s, %s)\n",
format,
PCF_BYTE_ORDER( format ) == MSBFirst ? "MSB" : "LSB",
PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) ?
@@ -1234,16 +1227,16 @@ THE SOFTWARE.
}
FT_TRACE5(( " noOverlap=%s, constantMetrics=%s,"
- " terminalFont=%s, constantWidth=%s\n"
- " inkInside=%s, inkMetrics=%s, drawDirection=%s\n"
- " fontAscent=%ld, fontDescent=%ld, maxOverlap=%ld\n",
+ " terminalFont=%s, constantWidth=%s\n",
accel->noOverlap ? "yes" : "no",
accel->constantMetrics ? "yes" : "no",
accel->terminalFont ? "yes" : "no",
- accel->constantWidth ? "yes" : "no",
+ accel->constantWidth ? "yes" : "no" ));
+ FT_TRACE5(( " inkInside=%s, inkMetrics=%s, drawDirection=%s\n",
accel->inkInside ? "yes" : "no",
accel->inkMetrics ? "yes" : "no",
- accel->drawDirection ? "RTL" : "LTR",
+ accel->drawDirection ? "RTL" : "LTR" ));
+ FT_TRACE5(( " fontAscent=%ld, fontDescent=%ld, maxOverlap=%ld\n",
accel->fontAscent,
accel->fontDescent,
accel->maxOverlap ));
@@ -1252,13 +1245,13 @@ THE SOFTWARE.
if ( FT_ABS( accel->fontAscent ) > 0x7FFF )
{
accel->fontAscent = accel->fontAscent < 0 ? -0x7FFF : 0x7FFF;
- FT_TRACE0(( "pfc_get_accel: clamping font ascent to value %d\n",
+ FT_TRACE0(( "pfc_get_accel: clamping font ascent to value %ld\n",
accel->fontAscent ));
}
if ( FT_ABS( accel->fontDescent ) > 0x7FFF )
{
accel->fontDescent = accel->fontDescent < 0 ? -0x7FFF : 0x7FFF;
- FT_TRACE0(( "pfc_get_accel: clamping font descent to value %d\n",
+ FT_TRACE0(( "pfc_get_accel: clamping font descent to value %ld\n",
accel->fontDescent ));
}
@@ -1370,7 +1363,7 @@ THE SOFTWARE.
char* s;
- if ( FT_ALLOC( face->style_name, len ) )
+ if ( FT_QALLOC( face->style_name, len ) )
return error;
s = face->style_name;
@@ -1534,7 +1527,7 @@ THE SOFTWARE.
{
l += ft_strlen( foundry_prop->value.atom ) + 1;
- if ( FT_NEW_ARRAY( root->family_name, l ) )
+ if ( FT_QALLOC( root->family_name, l ) )
goto Exit;
ft_strcpy( root->family_name, foundry_prop->value.atom );
@@ -1543,7 +1536,7 @@ THE SOFTWARE.
}
else
{
- if ( FT_NEW_ARRAY( root->family_name, l ) )
+ if ( FT_QALLOC( root->family_name, l ) )
goto Exit;
ft_strcpy( root->family_name, prop->value.atom );
@@ -1567,7 +1560,7 @@ THE SOFTWARE.
root->num_glyphs = (FT_Long)face->nmetrics;
root->num_fixed_sizes = 1;
- if ( FT_NEW_ARRAY( root->available_sizes, 1 ) )
+ if ( FT_NEW( root->available_sizes ) )
goto Exit;
{
@@ -1575,8 +1568,6 @@ THE SOFTWARE.
FT_Short resolution_x = 0, resolution_y = 0;
- FT_ZERO( bsize );
-
/* for simplicity, we take absolute values of integer properties */
#if 0
@@ -1617,7 +1608,7 @@ THE SOFTWARE.
else
{
/* this is a heuristical value */
- bsize->width = (FT_Short)FT_MulDiv( bsize->height, 2, 3 );
+ bsize->width = ( bsize->height * 2 + 1 ) / 3;
}
prop = pcf_find_property( face, "POINT_SIZE" );
@@ -1631,7 +1622,7 @@ THE SOFTWARE.
if ( FT_ABS( prop->value.l ) > 0x504C2L ) /* 0x7FFF * 72270/7200 */
{
bsize->size = 0x7FFF;
- FT_TRACE0(( "pcf_load_font: clamping point size to value %d\n",
+ FT_TRACE0(( "pcf_load_font: clamping point size to value %ld\n",
bsize->size ));
}
else
@@ -1650,7 +1641,7 @@ THE SOFTWARE.
if ( FT_ABS( prop->value.l ) > 0x7FFF )
{
bsize->y_ppem = 0x7FFF << 6;
- FT_TRACE0(( "pcf_load_font: clamping pixel size to value %d\n",
+ FT_TRACE0(( "pcf_load_font: clamping pixel size to value %ld\n",
bsize->y_ppem ));
}
else