summaryrefslogtreecommitdiff
path: root/Build/source/libs/freetype2/freetype-src/src/base/ftobjs.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/freetype2/freetype-src/src/base/ftobjs.c')
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/base/ftobjs.c259
1 files changed, 53 insertions, 206 deletions
diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftobjs.c b/Build/source/libs/freetype2/freetype-src/src/base/ftobjs.c
index 0ded2440fca..c060bbbc879 100644
--- a/Build/source/libs/freetype2/freetype-src/src/base/ftobjs.c
+++ b/Build/source/libs/freetype2/freetype-src/src/base/ftobjs.c
@@ -4,7 +4,7 @@
*
* The FreeType private base classes (body).
*
- * Copyright (C) 1996-2021 by
+ * Copyright (C) 1996-2020 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
@@ -78,9 +78,6 @@
#pragma warning( pop )
#endif
- /* This array must stay in sync with the @FT_Pixel_Mode enumeration */
- /* (in file `ftimage.h`). */
-
static const char* const pixel_modes[] =
{
"none",
@@ -90,8 +87,7 @@
"gray 4-bit bitmap",
"LCD 8-bit bitmap",
"vertical LCD 8-bit bitmap",
- "BGRA 32-bit color image bitmap",
- "SDF 8-bit bitmap"
+ "BGRA 32-bit color image bitmap"
};
#endif /* FT_DEBUG_LEVEL_TRACE */
@@ -197,7 +193,6 @@
FT_Error error;
FT_Memory memory;
FT_Stream stream = NULL;
- FT_UInt mode;
*astream = NULL;
@@ -209,15 +204,15 @@
return FT_THROW( Invalid_Argument );
memory = library->memory;
- mode = args->flags &
- ( FT_OPEN_MEMORY | FT_OPEN_STREAM | FT_OPEN_PATHNAME );
- if ( mode == FT_OPEN_MEMORY )
+ if ( FT_NEW( stream ) )
+ goto Exit;
+
+ stream->memory = memory;
+
+ if ( args->flags & FT_OPEN_MEMORY )
{
/* create a memory-based stream */
- if ( FT_NEW( stream ) )
- goto Exit;
-
FT_Stream_OpenMemory( stream,
(const FT_Byte*)args->memory_base,
(FT_ULong)args->memory_size );
@@ -225,40 +220,33 @@
#ifndef FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT
- else if ( mode == FT_OPEN_PATHNAME )
+ else if ( args->flags & FT_OPEN_PATHNAME )
{
/* create a normal system stream */
- if ( FT_NEW( stream ) )
- goto Exit;
-
error = FT_Stream_Open( stream, args->pathname );
- if ( error )
- FT_FREE( stream );
+ stream->pathname.pointer = args->pathname;
}
- else if ( ( mode == FT_OPEN_STREAM ) && args->stream )
+ else if ( ( args->flags & FT_OPEN_STREAM ) && args->stream )
{
/* use an existing, user-provided stream */
/* in this case, we do not need to allocate a new stream object */
/* since the caller is responsible for closing it himself */
+ FT_FREE( stream );
stream = args->stream;
- error = FT_Err_Ok;
}
#endif
else
- {
error = FT_THROW( Invalid_Argument );
- if ( ( args->flags & FT_OPEN_STREAM ) && args->stream )
- FT_Stream_Close( args->stream );
- }
- if ( !error )
- {
- stream->memory = memory;
- *astream = stream;
- }
+ if ( error )
+ FT_FREE( stream );
+ else
+ stream->memory = memory; /* just to be certain */
+
+ *astream = stream;
Exit:
return error;
@@ -547,8 +535,6 @@
ft_glyphslot_free_bitmap( slot );
/* clear all public fields in the glyph slot */
- slot->glyph_index = 0;
-
FT_ZERO( &slot->metrics );
FT_ZERO( &slot->outline );
@@ -569,8 +555,6 @@
slot->linearHoriAdvance = 0;
slot->linearVertAdvance = 0;
- slot->advance.x = 0;
- slot->advance.y = 0;
slot->lsb_delta = 0;
slot->rsb_delta = 0;
}
@@ -750,29 +734,6 @@
}
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( void )
- FT_Get_Transform( FT_Face face,
- FT_Matrix* matrix,
- FT_Vector* delta )
- {
- FT_Face_Internal internal;
-
-
- if ( !face )
- return;
-
- internal = face->internal;
-
- if ( matrix )
- *matrix = internal->transform_matrix;
-
- if ( delta )
- *delta = internal->transform_delta;
- }
-
-
static FT_Renderer
ft_lookup_glyph_renderer( FT_GlyphSlot slot );
@@ -1095,24 +1056,19 @@
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE5(( "FT_Load_Glyph: index %d, flags 0x%x\n",
glyph_index, load_flags ));
- FT_TRACE5(( " bitmap %dx%d %s, %s (mode %d)\n",
- slot->bitmap.width,
- slot->bitmap.rows,
- slot->outline.points ?
- slot->bitmap.buffer ? "rendered"
- : "preset"
- :
- slot->internal->flags & FT_GLYPH_OWN_BITMAP ? "owned"
- : "unowned",
- pixel_modes[slot->bitmap.pixel_mode],
- slot->bitmap.pixel_mode ));
- FT_TRACE5(( "\n" ));
FT_TRACE5(( " x advance: %f\n", slot->advance.x / 64.0 ));
FT_TRACE5(( " y advance: %f\n", slot->advance.y / 64.0 ));
FT_TRACE5(( " linear x advance: %f\n",
slot->linearHoriAdvance / 65536.0 ));
FT_TRACE5(( " linear y advance: %f\n",
slot->linearVertAdvance / 65536.0 ));
+ FT_TRACE5(( "\n" ));
+ FT_TRACE5(( " bitmap %dx%d, %s (mode %d)\n",
+ slot->bitmap.width,
+ slot->bitmap.rows,
+ pixel_modes[slot->bitmap.pixel_mode],
+ slot->bitmap.pixel_mode ));
+ FT_TRACE5(( "\n" ));
{
FT_Glyph_Metrics* metrics = &slot->metrics;
@@ -1826,7 +1782,7 @@
if ( error )
goto Exit;
- if ( FT_QALLOC( sfnt_ps, (FT_Long)length ) )
+ if ( FT_ALLOC( sfnt_ps, (FT_Long)length ) )
goto Exit;
error = FT_Stream_Read( stream, (FT_Byte *)sfnt_ps, length );
@@ -1936,7 +1892,7 @@
goto Exit;
}
- if ( FT_QALLOC( pfb_data, (FT_Long)pfb_len + 2 ) )
+ if ( FT_ALLOC( pfb_data, (FT_Long)pfb_len + 2 ) )
goto Exit;
pfb_data[0] = 0x80;
@@ -2000,7 +1956,7 @@
{
FT_TRACE3(( " Write POST fragment #%d header (4-byte) to buffer"
" %p + 0x%08lx\n",
- i, (void*)pfb_data, pfb_lenpos ));
+ i, pfb_data, pfb_lenpos ));
if ( pfb_lenpos + 3 > pfb_len + 2 )
goto Exit2;
@@ -2015,7 +1971,7 @@
FT_TRACE3(( " Write POST fragment #%d header (6-byte) to buffer"
" %p + 0x%08lx\n",
- i, (void*)pfb_data, pfb_pos ));
+ i, pfb_data, pfb_pos ));
if ( pfb_pos + 6 > pfb_len + 2 )
goto Exit2;
@@ -2038,7 +1994,7 @@
FT_TRACE3(( " Load POST fragment #%d (%ld byte) to buffer"
" %p + 0x%08lx\n",
- i, rlen, (void*)pfb_data, pfb_pos ));
+ i, rlen, pfb_data, pfb_pos ));
error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen );
if ( error )
@@ -2136,7 +2092,7 @@
if ( error )
goto Exit;
- if ( FT_QALLOC( sfnt_data, rlen ) )
+ if ( FT_ALLOC( sfnt_data, rlen ) )
return error;
error = FT_Stream_Read( stream, (FT_Byte *)sfnt_data, (FT_ULong)rlen );
if ( error ) {
@@ -2725,10 +2681,10 @@
#ifdef FT_DEBUG_LEVEL_TRACE
if ( !error && face_index < 0 )
{
- FT_TRACE3(( "FT_Open_Face: The font has %ld face%s\n",
+ FT_TRACE3(( "FT_Open_Face: The font has %ld face%s\n"
+ " and %ld named instance%s for face %ld\n",
face->num_faces,
- face->num_faces == 1 ? "" : "s" ));
- FT_TRACE3(( " and %ld named instance%s for face %ld\n",
+ face->num_faces == 1 ? "" : "s",
face->style_flags >> 16,
( face->style_flags >> 16 ) == 1 ? "" : "s",
-face_index - 1 ));
@@ -4456,7 +4412,8 @@
render->glyph_format = clazz->glyph_format;
/* allocate raster object if needed */
- if ( clazz->raster_class->raster_new )
+ if ( clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE &&
+ clazz->raster_class->raster_new )
{
error = clazz->raster_class->raster_new( memory, &render->raster );
if ( error )
@@ -4503,7 +4460,8 @@
/* release raster object, if any */
- if ( render->raster )
+ if ( render->clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE &&
+ render->raster )
render->clazz->raster_class->raster_done( render->raster );
/* remove from list */
@@ -4598,6 +4556,9 @@
switch ( slot->format )
{
+ case FT_GLYPH_FORMAT_BITMAP: /* already a bitmap, don't do anything */
+ break;
+
default:
if ( slot->internal->load_flags & FT_LOAD_COLOR )
{
@@ -4773,11 +4734,11 @@
/* we use FT_TRACE7 in this block */
if ( !error &&
- ft_trace_levels[trace_checksum] >= 7 &&
- slot->bitmap.buffer )
+ ft_trace_levels[trace_checksum] >= 7 )
{
if ( slot->bitmap.rows < 128U &&
- slot->bitmap.width < 128U )
+ slot->bitmap.width < 128U &&
+ slot->bitmap.buffer )
{
int rows = (int)slot->bitmap.rows;
int width = (int)slot->bitmap.width;
@@ -5188,16 +5149,16 @@
if ( cur == limit )
{
- FT_TRACE2(( "%s: can't find module `%s'\n",
- func_name, module_name ));
+ FT_ERROR(( "%s: can't find module `%s'\n",
+ func_name, module_name ));
return FT_THROW( Missing_Module );
}
/* check whether we have a service interface */
if ( !cur[0]->clazz->get_interface )
{
- FT_TRACE2(( "%s: module `%s' doesn't support properties\n",
- func_name, module_name ));
+ FT_ERROR(( "%s: module `%s' doesn't support properties\n",
+ func_name, module_name ));
return FT_THROW( Unimplemented_Feature );
}
@@ -5206,8 +5167,8 @@
FT_SERVICE_ID_PROPERTIES );
if ( !interface )
{
- FT_TRACE2(( "%s: module `%s' doesn't support properties\n",
- func_name, module_name ));
+ FT_ERROR(( "%s: module `%s' doesn't support properties\n",
+ func_name, module_name ));
return FT_THROW( Unimplemented_Feature );
}
@@ -5220,8 +5181,8 @@
if ( missing_func )
{
- FT_TRACE2(( "%s: property service of module `%s' is broken\n",
- func_name, module_name ));
+ FT_ERROR(( "%s: property service of module `%s' is broken\n",
+ func_name, module_name ));
return FT_THROW( Unimplemented_Feature );
}
@@ -5331,12 +5292,10 @@
if ( !memory || !alibrary )
return FT_THROW( Invalid_Argument );
-#ifndef FT_DEBUG_LOGGING
#ifdef FT_DEBUG_LEVEL_ERROR
/* init debugging support */
ft_debug_init();
-#endif /* FT_DEBUG_LEVEL_ERROR */
-#endif /* !FT_DEBUG_LOGGING */
+#endif
/* first of all, allocate the library object */
if ( FT_NEW( library ) )
@@ -5608,116 +5567,4 @@
}
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Bool )
- FT_Get_Color_Glyph_Paint( FT_Face face,
- FT_UInt base_glyph,
- FT_Color_Root_Transform root_transform,
- FT_OpaquePaint* paint )
- {
- TT_Face ttface;
- SFNT_Service sfnt;
-
-
- if ( !face || !paint )
- return 0;
-
- if ( !FT_IS_SFNT( face ) )
- return 0;
-
- ttface = (TT_Face)face;
- sfnt = (SFNT_Service)ttface->sfnt;
-
- if ( sfnt->get_colr_layer )
- return sfnt->get_colr_glyph_paint( ttface,
- base_glyph,
- root_transform,
- paint );
- else
- return 0;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Bool )
- FT_Get_Paint_Layers( FT_Face face,
- FT_LayerIterator* layer_iterator,
- FT_OpaquePaint* paint )
- {
- TT_Face ttface;
- SFNT_Service sfnt;
-
-
- if ( !face || !paint || !layer_iterator )
- return 0;
-
- if ( !FT_IS_SFNT( face ) )
- return 0;
-
- ttface = (TT_Face)face;
- sfnt = (SFNT_Service)ttface->sfnt;
-
- if ( sfnt->get_paint_layers )
- return sfnt->get_paint_layers( ttface, layer_iterator, paint );
- else
- return 0;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Bool )
- FT_Get_Paint( FT_Face face,
- FT_OpaquePaint opaque_paint,
- FT_COLR_Paint* paint )
- {
- TT_Face ttface;
- SFNT_Service sfnt;
-
-
- if ( !face || !paint || !paint )
- return 0;
-
- if ( !FT_IS_SFNT( face ) )
- return 0;
-
- ttface = (TT_Face)face;
- sfnt = (SFNT_Service)ttface->sfnt;
-
- if ( sfnt->get_paint )
- return sfnt->get_paint( ttface, opaque_paint, paint );
- else
- return 0;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Bool )
- FT_Get_Colorline_Stops ( FT_Face face,
- FT_ColorStop * color_stop,
- FT_ColorStopIterator *iterator )
- {
- TT_Face ttface;
- SFNT_Service sfnt;
-
-
- if ( !face || !color_stop || !iterator )
- return 0;
-
- if ( !FT_IS_SFNT( face ) )
- return 0;
-
- ttface = (TT_Face)face;
- sfnt = (SFNT_Service)ttface->sfnt;
-
- if ( sfnt->get_colorline_stops )
- return sfnt->get_colorline_stops ( ttface, color_stop, iterator );
- else
- return 0;
- }
-
-
/* END */