Commit 3d2be25b authored by David Turner's avatar David Turner
Browse files

- updated doc for FT_New_Memory_Face

- removed lots of compiler warnings in lint-style
  warning modes (/W4 with Visual C++)
parent b90818ed
......@@ -1458,14 +1458,14 @@ FT_BEGIN_HEADER
/* */
typedef struct FT_Open_Args_
{
FT_Open_Flags flags;
FT_Byte* memory_base;
FT_Long memory_size;
FT_String* pathname;
FT_Stream stream;
FT_Module driver;
FT_Int num_params;
FT_Parameter* params;
FT_Open_Flags flags;
const FT_Byte* memory_base;
FT_Long memory_size;
FT_String* pathname;
FT_Stream stream;
FT_Module driver;
FT_Int num_params;
FT_Parameter* params;
} FT_Open_Args;
......@@ -1536,6 +1536,11 @@ FT_BEGIN_HEADER
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* the font data bytes are used _directly_ by the @FT_Face object. */
/* this means that they're not copied, and that the client is */
/* responsible for releasing/destroying them _after_ the */
/* corresponding call to @FT_Done_Face */
/* */
/* Unlike FreeType 1.x, this function automatically creates a glyph */
/* slot for the face object which can be accessed directly through */
/* `face->glyph'. */
......@@ -1546,11 +1551,11 @@ FT_BEGIN_HEADER
/* `aface'. Its return value should be 0 if the font format is */
/* recognized, or non-zero if not. */
/* */
FT_EXPORT( FT_Error ) FT_New_Memory_Face( FT_Library library,
FT_Byte* file_base,
FT_Long file_size,
FT_Long face_index,
FT_Face *aface );
FT_EXPORT( FT_Error ) FT_New_Memory_Face( FT_Library library,
const FT_Byte* file_base,
FT_Long file_size,
FT_Long face_index,
FT_Face *aface );
/*************************************************************************/
......
......@@ -13,91 +13,128 @@
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/* */
/* This special header file is used to define the FT2 enumeration */
/* constants. It can also be used to generate error message strings */
/* with a small macro trick explained below. */
/* */
/* I - Error Formats: */
/* ------------------ */
/* */
/* Since release 2.1, the error constants have changed. The lower byte */
/* of the error value gives the "generic" error code, while the higher */
/* bytes indicates in which module the error occured. */
/* */
/* You can use the macro FT_ERROR_BASE(x) macro to extract the */
/* generic error code from a FT_Error */
/* */
/* The configuration macro FT_CONFIG_OPTION_USE_MODULE_ERRORS can */
/* be undefined in ftoption.h in order to make the higher byte always */
/* zero, in case you'd need to be compatible with previous versions */
/* of FT2. */
/* */
/* */
/* II - Error Message strings: */
/* --------------------------- */
/* */
/* The error definitions below are made through special macros that */
/* allow client applications to build a table of error message strings */
/* if they need it. The strings are not included in a normal build of */
/* FT2 to save space (most client apps do not use them) */
/* */
/* To do so, you'll need to define the following macros before */
/* including this file: */
/* */
/* FT_ERROR_START_LIST :: */
/* this macro is called before anything else to define the */
/* start of the error list. It is followed by several */
/* FT_ERROR_DEF calls (see below) */
/* */
/* FT_ERROR_DEF( e, v, s ) :: */
/* this macro is called to define one single error. */
/* 'e' is the error code identifier (e.g. FT_Err_Invalid_Argument) */
/* 'v' is the error numerical value */
/* 's' is the corresponding error string */
/* */
/* FT_ERROR_END_LIST :: */
/* this macro is used to end the list. */
/* */
/* Additionally, you'll need to undefine __FTERRORS_H__ before */
/* #including this file. */
/* */
/* Here's a simple example: */
/* */
/* { */
/* #undef __FTERRORS_H__ */
/* #define FT_ERRORDEF( e, v, s ) { e, s }, */
/* #define FT_ERROR_START_LIST { */
/* #define FT_ERROR_END_LIST { 0, 0 } }; */
/* */
/* const struct */
/* { */
/* int err_code; */
/* const char* err_msg */
/* } ft_errors[] = */
/* */
/* #include FT_ERRORS_H */
/* } */
/* */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* This file is used to define the FreeType error enumeration constants. */
/* */
/* The lower byte gives the error code, the higher byte gives the */
/* module. The base module has error offset 0. For example, the error */
/* `FT_Err_Invalid_File_Format' has value 0x003, the error */
/* `TT_Err_Invalid_File_Format' has value 0xB03, the error */
/* `T1_Err_Invalid_File_Format' has value 0xC03, etc. */
/* */
/* Undefine the macro FT_CONFIG_OPTION_USE_MODULE_ERRORS (in ftoption.h) */
/* to make the higher byte always zero. */
/* */
/* It can also be used to create an error message table easily with */
/* something like */
/* */
/* { */
/* #undef __FTERRORS_H__ */
/* #define FT_ERRORDEF( e, v, s ) { e, s }, */
/* #define FT_ERROR_START_LIST { */
/* #define FT_ERROR_END_LIST { 0, 0 } }; */
/* */
/* const struct */
/* { */
/* int err_code; */
/* const char* err_msg */
/* } ft_errors[] = */
/* */
/* #include FT_ERRORS_H */
/* } */
/* */
/* To use such a table, all errors must be ANDed with 0x00FF to remove */
/* the module error offset. */
/* */
/*************************************************************************/
#ifndef __FTERRORS_H__
#define __FTERRORS_H__
#include FT_MODULE_ERRORS_H
#undef FT_NEED_EXTERN_C
/*******************************************************************/
/*******************************************************************/
/***** *****/
/***** SETUP MACROS *****/
/***** *****/
/*******************************************************************/
/*******************************************************************/
/* public interface */
#include FT_MODULE_ERRORS_H
#undef FT_NEED_EXTERN_C
#ifndef FT_ERRORDEF
#define FT_ERRORDEF( e, v, s ) e = v,
# define FT_ERRORDEF( e, v, s ) e = v,
#ifdef __cplusplus
#define FT_NEED_EXTERN_C
extern "C" {
#endif
# ifdef __cplusplus
# define FT_NEED_EXTERN_C
extern "C" {
# endif
#endif /* !FT_ERRORDEF */
#ifndef FT_ERROR_START_LIST
# define FT_ERROR_START_LIST enum {
#endif
#define FT_ERROR_START_LIST enum {
#define FT_ERROR_END_LIST FT_Err_Max };
#endif /* !FT_ERROR_START_LIST */
#ifndef FT_ERROR_END_LIST
# define FT_ERROR_END_LIST FT_Err_Max };
#endif
/* internal interface */
#ifndef FT_ERRORDEF_
#define FT_ERRORDEF_( e, v, s ) \
FT_ERRORDEF( FT_Err_ ## e, v + FT_Mod_Err_Base, s )
FT_ERRORDEF( FT_Err_ ## e, v + FT_Mod_Err_Base, s )
#define FT_NOERRORDEF_( e, v, s ) \
FT_ERRORDEF( FT_Err_ ## e, v, s )
FT_ERRORDEF( FT_Err_ ## e, v, s )
#endif /* !FT_ERRORDEF_ */
/*******************************************************************/
/*******************************************************************/
/***** *****/
/***** LIST ERROR CODES/MESSAGES *****/
/***** *****/
/*******************************************************************/
/*******************************************************************/
#ifdef FT_ERROR_START_LIST
FT_ERROR_START_LIST
#endif
/* generic errors */
......@@ -276,11 +313,17 @@
"argument stack underflow" )
#ifdef FT_ERROR_END_LIST
FT_ERROR_END_LIST
#endif
/*******************************************************************/
/*******************************************************************/
/***** *****/
/***** SIMPLE CLEANUPP *****/
/***** *****/
/*******************************************************************/
/*******************************************************************/
#undef FT_ERROR_START_LIST
#undef FT_ERROR_END_LIST
#undef FT_ERRORDEF
......@@ -292,7 +335,6 @@
}
#endif
#endif /* __FTERRORS_H__ */
#endif /* __FT_ERRORS_H__ */
/* END */
......@@ -512,6 +512,7 @@ FT_BEGIN_HEADER
/* return base error code (without module-specific prefix) */
#define FT_ERROR_BASE( x ) ( (x) & 255 )
#define FT_BOOL(x) ((FT_Bool)(x))
FT_END_HEADER
......
......@@ -221,6 +221,14 @@ FT_BEGIN_HEADER
#define FT_TRACE6( varformat ) FT_TRACE( 6, varformat )
#define FT_TRACE7( varformat ) FT_TRACE( 7, varformat )
#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
/* we disable the warnings "conditional expression is constant" here */
/* in order to compile cleanly with the maximum level of warnings */
#pragma warning( disable : 4127 )
#endif /* _MSC_VER */
FT_END_HEADER
......
......@@ -143,63 +143,77 @@ FT_BEGIN_HEADER
/* integer extraction macros -- the `buffer' parameter must ALWAYS be of */
/* type `char*' or equivalent (1-byte elements). */
/* */
#define FT_GET_SHORT_BE(p) \
((short)( ((signed char)(p)[0] << 8) | \
(p)[1] ))
#define FT_GET_OFF3_BE(p) \
((long) ( ((signed char)(p)[0] << 16) | \
((p)[1] << 8) | \
(p)[2] ))
#define FT_GET_LONG_BE(p) \
((long) ( ((signed char)(p)[0] << 24) | \
((p)[1] << 16) | \
((p)[2] << 8) | \
(p)[3] ))
#define FT_GET_SHORT_LE(p) \
((short)( ((signed char)(p)[1] << 8) | \
(p)[0] ))
#define FT_GET_OFF3_LE(p) \
((long) ( ((signed char)(p)[2] << 16) | \
((p)[1] << 8) | \
(p)[0] ))
#define FT_GET_LONG_LE(p) \
((long) ( ((signed char)(p)[3] << 24) | \
((p)[2] << 16) | \
((p)[1] << 8) | \
(p)[0] ))
#define NEXT_Char( buffer ) \
( (signed char)*buffer++ )
#define NEXT_Byte( buffer ) \
( (unsigned char)*buffer++ )
#define NEXT_Short( buffer ) \
( buffer += 2, \
( (short)( (signed char)buffer[-2] << 8 ) | \
(unsigned char)buffer[-1] ) )
( (short)( buffer += 2, FT_GET_SHORT_BE(buffer-2) ) )
#define NEXT_UShort( buffer ) \
( (unsigned short)NEXT_Short( buffer ) )
#define NEXT_Offset( buffer ) \
( buffer += 3, \
( ( (long)(signed char)buffer[-3] << 16 ) | \
( (long)(unsigned char)buffer[-2] << 8 ) | \
(long)(unsigned char)buffer[-1] ) )
#define NEXT_Offset( buffer ) \
( (long)( buffer += 3, FT_GET_OFF3_BE(buffer-3) ) )
#define NEXT_UOffset( buffer ) \
( (unsigned long)NEXT_Offset( buffer ) )
#define NEXT_Long( buffer ) \
( buffer += 4, \
( ( (long)(signed char)buffer[-4] << 24 ) | \
( (long)(unsigned char)buffer[-3] << 16 ) | \
( (long)(unsigned char)buffer[-2] << 8 ) | \
(long)(unsigned char)buffer[-1] ) )
#define NEXT_Long( buffer ) \
( (long)( buffer += 4, FT_GET_LONG_BE(buffer-4) ) )
#define NEXT_ULong( buffer ) \
( (unsigned long)NEXT_Long( buffer ) )
#define NEXT_ShortLE( buffer ) \
( buffer += 2, \
( (short)( (signed char)buffer[-1] << 8 ) | \
(unsigned char)buffer[-2] ) )
( (short)( buffer += 2, FT_GET_SHORT_LE(buffer-2) ) )
#define NEXT_UShortLE( buffer ) \
( (unsigned short)NEXT_ShortLE( buffer ) )
#define NEXT_OffsetLE( buffer ) \
( buffer += 3, \
( ( (long)(signed char)buffer[-1] << 16 ) | \
( (long)(unsigned char)buffer[-2] << 8 ) | \
(long)(unsigned char)buffer[-3] ) )
( (long)( buffer += 3, FT_GET_OFF3_LE(buffer-3) ) )
#define NEXT_UOffsetLE( buffer ) \
( (unsigned long)NEXT_OffsetLE( buffer ) )
( (unsigned long)NEXT_OffsetLE( buffer ) )
#define NEXT_LongLE( buffer ) \
( buffer += 4, \
( ( (long)(signed char)buffer[-1] << 24 ) | \
( (long)(unsigned char)buffer[-2] << 16 ) | \
( (long)(unsigned char)buffer[-3] << 8 ) | \
(long)(unsigned char)buffer[-4] ) )
( (long)( buffer += 4, FT_GET_LONG_LE(buffer-4) ) )
#define NEXT_ULongLE( buffer ) \
( (unsigned long)NEXT_LongLE( buffer ) )
......
......@@ -20,6 +20,7 @@
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include "ahglobal.h"
#include "ahglyph.h"
......@@ -214,9 +215,9 @@
} while ( next != index );
/* now, set the `round' flag depending on the segment's kind */
round =
round = FT_BOOL(
FT_CURVE_TAG( glyph->outline.tags[prev] ) != FT_Curve_Tag_On ||
FT_CURVE_TAG( glyph->outline.tags[next] ) != FT_Curve_Tag_On ;
FT_CURVE_TAG( glyph->outline.tags[next] ) != FT_Curve_Tag_On );
AH_LOG(( "%c ", round ? 'r' : 'f' ));
}
......@@ -265,7 +266,7 @@
{
FT_Pos ref = *blue_ref;
FT_Pos shoot = *blue_shoot;
FT_Bool over_ref = ( shoot > ref );
FT_Bool over_ref = FT_BOOL( shoot > ref );
if ( AH_IS_TOP_BLUE( blue ) ^ over_ref )
......
......@@ -558,7 +558,7 @@
for ( ; contour < contour_limit; contour++, end++ )
{
contour[0] = points + index;
index = end[0] + 1;
index = (short)(end[0] + 1);
}
}
......@@ -959,9 +959,9 @@
/* check that the segments are correctly oriented and */
/* positioned to form a black distance */
is_dir = ( seg1->dir == outline->horz_major_dir ||
seg1->dir == outline->vert_major_dir );
is_pos = pos1 > pos2;
is_dir = (FT_Bool)( seg1->dir == outline->horz_major_dir ||
seg1->dir == outline->vert_major_dir );
is_pos = (FT_Bool)(pos1 > pos2);
if ( pos1 == pos2 || !(is_dir ^ is_pos) )
continue;
......@@ -1199,7 +1199,7 @@
/* check for links -- if seg->serif is set, then seg->link must */
/* be ignored */
is_serif = seg->serif && seg->serif->edge != edge;
is_serif = (FT_Bool)(seg->serif && seg->serif->edge != edge);
if ( seg->link || is_serif )
{
......@@ -1371,8 +1371,8 @@
/* zone, check for left edges */
/* */
/* of course, that's for TrueType XXX */
FT_Bool is_top_blue = AH_IS_TOP_BLUE( blue );
FT_Bool is_major_dir = edge->dir == outline->horz_major_dir;
FT_Bool is_top_blue = FT_BOOL(AH_IS_TOP_BLUE( blue ));
FT_Bool is_major_dir = FT_BOOL(edge->dir == outline->horz_major_dir);
if ( !blue_active[blue] )
continue;
......@@ -1403,7 +1403,7 @@
/* top zone, or under the reference position of a bottom zone */
if ( edge->flags & ah_edge_round && dist != 0 )
{
FT_Bool is_under_ref = edge->fpos < *blue_pos;
FT_Bool is_under_ref = FT_BOOL( edge->fpos < *blue_pos );
if ( is_top_blue ^ is_under_ref )
......
......@@ -1004,10 +1004,10 @@
FT_Error error;
AH_Outline* outline = hinter->glyph;
AH_Loader* gloader = hinter->loader;
FT_Bool no_horz_hints =
( load_flags & AH_HINT_NO_HORZ_EDGES ) != 0;
FT_Bool no_vert_hints =
( load_flags & AH_HINT_NO_VERT_EDGES ) != 0;
FT_Bool no_horz_hints = FT_BOOL(
( load_flags & AH_HINT_NO_HORZ_EDGES ) != 0 );
FT_Bool no_vert_hints = FT_BOOL(
( load_flags & AH_HINT_NO_VERT_EDGES ) != 0 );
/* load the glyph */
......@@ -1251,7 +1251,7 @@
dummy.points += num_base_points;
dummy.n_points = num_new_points;
dummy.n_points = (short)num_new_points;
FT_Outline_Translate( &dummy, x, y );
}
......
......@@ -187,7 +187,7 @@
{
error = 0;
FT_New_Memory_Stream( library,
args->memory_base,
(FT_Byte*)args->memory_base,
args->memory_size,
stream );
}
......@@ -529,13 +529,13 @@
FT_UInt n;
base->outline.n_points += current->outline.n_points;
base->outline.n_contours += current->outline.n_contours;
base->outline.n_points = (short)( base->outline.n_points + current->outline.n_points );
base->outline.n_contours = (short)( base->outline.n_contours + current->outline.n_contours );
base->num_subglyphs += current->num_subglyphs;
/* adjust contours count in newest outline */
for ( n = 0; n < n_curr_contours; n++ )
current->outline.contours[n] += n_base_points;
current->outline.contours[n] = (short)( current->outline.contours[n] + n_base_points );
/* prepare for another new glyph image */
FT_GlyphLoader_Prepare( loader );
......@@ -570,8 +570,8 @@
MEM_Copy( target->base.extra_points, source->base.extra_points,
num_points * sizeof ( FT_Vector ) );
out->n_points = num_points;
out->n_contours = num_contours;
out->n_points = (short)num_points;
out->n_contours = (short)num_contours;
FT_GlyphLoader_Adjust_Points( target );
}
......@@ -844,10 +844,10 @@
/* do we need to load the glyph through the auto-hinter? */
library = driver->root.library;
hinter = library->auto_hinter;
autohint = hinter &&
autohint = FT_BOOL( hinter &&
!( load_flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) ) &&
FT_DRIVER_IS_SCALABLE(driver) &&
FT_DRIVER_USES_OUTLINES(driver);
FT_DRIVER_USES_OUTLINES(driver) );
if ( autohint )
{
if ( FT_DRIVER_HAS_HINTER( driver ) &&
......@@ -1127,11 +1127,11 @@
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error ) FT_New_Memory_Face( FT_Library library,
FT_Byte* file_base,
FT_Long file_size,
FT_Long face_index,
FT_Face *aface )
FT_EXPORT_DEF( FT_Error ) FT_New_Memory_Face( FT_Library library,
const FT_Byte* file_base,
FT_Long file_size,
FT_Long face_index,
FT_Face *aface )
{
FT_Open_Args args;
......@@ -1172,7 +1172,7 @@
*aface = 0;
external_stream = ( ( args->flags & ft_open_stream ) && args->stream );
external_stream = FT_BOOL(( args->flags & ft_open_stream ) && args->stream);
/* create input stream */
error = ft_new_input_stream( library, args, &stream );
......@@ -1648,8 +1648,8 @@
if ( pixel_height < 1 )
pixel_height = 1;
metrics->x_ppem = pixel_width;
metrics->y_ppem = pixel_height;
metrics->x_ppem = (FT_UShort)pixel_width;
metrics->y_ppem = (FT_UShort)pixel_height;
if ( face->face_flags & FT_FACE_FLAG_SCALABLE )
{
......
......@@ -64,7 +64,7 @@
FT_Int n; /* index of contour in outline */
FT_UInt first; /* index of first point in contour */
char tag; /* current point's state */
FT_Int tag; /* current point's state */
FT_Int shift;
FT_Pos delta;
......
......@@ -31,10 +31,10 @@
#define FT_COMPONENT trace_stream
FT_BASE_DEF( void ) FT_New_Memory_Stream( FT_Library library,
FT_Byte* base,
FT_ULong size,
FT_Stream stream )
FT_BASE_DEF( void ) FT_New_Memory_Stream( FT_Library library,
FT_Byte* base,
FT_ULong size,
FT_Stream stream )
{
stream->memory = library->memory;
stream->base = base;
......
......@@ -50,9 +50,9 @@
data->ref_count = (FT_Short) 0;
node->cset = cset;
node->cset_index = (FT_UShort)index;
node->num_elements = ( index + 1 < cset->num_chunks )
node->num_elements = (unsigned short)(( index + 1 < cset->num_chunks )
? cset->element_count
: cset->element_max - cset->element_count*index;
: cset->element_max - cset->element_count*index );
if ( alloc )