summaryrefslogtreecommitdiff
path: root/Build/source/libs/freetype2/freetype-src/src/sdf
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2021-12-03 04:03:12 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2021-12-03 04:03:12 +0000
commit4ee9d04bd5d518e5f1f86875f4f8184fc0552f44 (patch)
tree4f27c2cc7196ba469bf631ffe0460cb3d6bcbc9d /Build/source/libs/freetype2/freetype-src/src/sdf
parent39bd39ea6f91fb51d118264f372905de9accc347 (diff)
freetype 2.11.1
git-svn-id: svn://tug.org/texlive/trunk@61211 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/freetype2/freetype-src/src/sdf')
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/sdf/ftbsdf.c22
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/sdf/ftsdf.c30
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/sdf/ftsdfrend.c30
3 files changed, 49 insertions, 33 deletions
diff --git a/Build/source/libs/freetype2/freetype-src/src/sdf/ftbsdf.c b/Build/source/libs/freetype2/freetype-src/src/sdf/ftbsdf.c
index db4a2dd11aa..8da5c9d9e07 100644
--- a/Build/source/libs/freetype2/freetype-src/src/sdf/ftbsdf.c
+++ b/Build/source/libs/freetype2/freetype-src/src/sdf/ftbsdf.c
@@ -163,7 +163,7 @@
{
FT_Memory memory;
- } BSDF_TRaster;
+ } BSDF_TRaster, *BSDF_PRaster;
/**************************************************************************
@@ -928,7 +928,7 @@
/* Forward pass of rows (left -> right). Leave the first */
/* column, which gets covered in the backward pass. */
- for ( i = 1; i < w; i++ )
+ for ( i = 1; i < w - 1; i++ )
{
index = j * w + i;
current = dm + index;
@@ -997,7 +997,7 @@
/* Forward pass of rows (left -> right). Leave the first */
/* column, which gets covered in the backward pass. */
- for ( i = 1; i < w; i++ )
+ for ( i = 1; i < w - 1; i++ )
{
index = j * w + i;
current = dm + index;
@@ -1173,19 +1173,17 @@
/* called when adding a new module through @FT_Add_Module */
static FT_Error
- bsdf_raster_new( FT_Memory memory,
- FT_Raster* araster )
+ bsdf_raster_new( FT_Memory memory,
+ BSDF_PRaster* araster )
{
- FT_Error error = FT_Err_Ok;
- BSDF_TRaster* raster = NULL;
+ FT_Error error;
+ BSDF_PRaster raster = NULL;
- *araster = 0;
- if ( !FT_ALLOC( raster, sizeof ( BSDF_TRaster ) ) )
- {
+ if ( !FT_NEW( raster ) )
raster->memory = memory;
- *araster = (FT_Raster)raster;
- }
+
+ *araster = raster;
return error;
}
diff --git a/Build/source/libs/freetype2/freetype-src/src/sdf/ftsdf.c b/Build/source/libs/freetype2/freetype-src/src/sdf/ftsdf.c
index d3722b1dc17..f69cf49b471 100644
--- a/Build/source/libs/freetype2/freetype-src/src/sdf/ftsdf.c
+++ b/Build/source/libs/freetype2/freetype-src/src/sdf/ftsdf.c
@@ -204,7 +204,7 @@
{
FT_Memory memory;
- } SDF_TRaster;
+ } SDF_TRaster, *SDF_PRaster;
/**************************************************************************
@@ -841,12 +841,12 @@
*
*/
- /* Return the control box of a edge. The control box is a rectangle */
- /* in which all the control points can fit tightly. */
+ /* Return the control box of an edge. The control box is a rectangle */
+ /* in which all the control points can fit tightly. */
static FT_CBox
get_control_box( SDF_Edge edge )
{
- FT_CBox cbox;
+ FT_CBox cbox = { 0, 0, 0, 0 };
FT_Bool is_set = 0;
@@ -3706,25 +3706,19 @@
*/
static FT_Error
- sdf_raster_new( FT_Memory memory,
- FT_Raster* araster)
+ sdf_raster_new( FT_Memory memory,
+ SDF_PRaster* araster )
{
- FT_Error error = FT_Err_Ok;
- SDF_TRaster* raster = NULL;
- FT_Int line = __LINE__;
+ FT_Error error;
+ SDF_PRaster raster = NULL;
- /* in non-debugging mode this is not used */
- FT_UNUSED( line );
-
- *araster = 0;
- if ( !FT_ALLOC( raster, sizeof ( SDF_TRaster ) ) )
- {
+ if ( !FT_NEW( raster ) )
raster->memory = memory;
- *araster = (FT_Raster)raster;
- }
- return error;
+ *araster = raster;
+
+ return error;
}
diff --git a/Build/source/libs/freetype2/freetype-src/src/sdf/ftsdfrend.c b/Build/source/libs/freetype2/freetype-src/src/sdf/ftsdfrend.c
index 420ad496c74..30f2e62a4fe 100644
--- a/Build/source/libs/freetype2/freetype-src/src/sdf/ftsdfrend.c
+++ b/Build/source/libs/freetype2/freetype-src/src/sdf/ftsdfrend.c
@@ -298,8 +298,15 @@
goto Exit;
}
+ /* the rows and pitch must be valid after presetting the */
+ /* bitmap using outline */
if ( !bitmap->rows || !bitmap->pitch )
+ {
+ FT_ERROR(( "ft_sdf_render: failed to preset bitmap\n" ));
+
+ error = FT_THROW( Cannot_Render_Glyph );
goto Exit;
+ }
/* the padding will simply be equal to the `spread' */
x_pad = sdf_module->spread;
@@ -350,6 +357,10 @@
error = render->raster_render( render->raster,
(const FT_Raster_Params*)&params );
+ /* transform the outline back to the original state */
+ if ( x_shift || y_shift )
+ FT_Outline_Translate( outline, -x_shift, -y_shift );
+
Exit:
if ( !error )
{
@@ -362,9 +373,6 @@
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
- if ( x_shift || y_shift )
- FT_Outline_Translate( outline, -x_shift, -y_shift );
-
return error;
}
@@ -506,8 +514,24 @@
goto Exit;
}
+ /* Do not generate SDF if the bitmap is not owned by the */
+ /* glyph: it might be that the source buffer is already freed. */
+ if ( !( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) )
+ {
+ FT_ERROR(( "ft_bsdf_render: can't generate SDF from"
+ " unowned source bitmap\n" ));
+
+ error = FT_THROW( Invalid_Argument );
+ goto Exit;
+ }
+
if ( !bitmap->rows || !bitmap->pitch )
+ {
+ FT_ERROR(( "ft_bsdf_render: invalid bitmap size\n" ));
+
+ error = FT_THROW( Invalid_Argument );
goto Exit;
+ }
FT_Bitmap_New( &target );