diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-07-07 09:56:43 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-07-07 09:56:43 +0000 |
commit | 750d5e56c495ac771c2180183e9fccc00f0fe6bf (patch) | |
tree | e2b12ae3c07d546028e969437ab8ca0eb6047540 /Build/source/libs/freetype2/freetype-src/src/tools | |
parent | 04ab6a8796404e13e659f596d4ae1d912a82ea0f (diff) |
freetype 2.6.4
git-svn-id: svn://tug.org/texlive/trunk@41649 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/freetype2/freetype-src/src/tools')
4 files changed, 133 insertions, 4 deletions
diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/tohtml.py b/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/tohtml.py index 8da10b8a52c..9b28780e960 100644 --- a/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/tohtml.py +++ b/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/tohtml.py @@ -390,7 +390,7 @@ class HtmlFormatter( Formatter ): """Convert a code sequence to HTML.""" line = code_header + '\n' for l in lines: - line = line + html_quote( l ) + '\n' + line = line + html_quote( l ).rstrip() + '\n' return line + code_footer diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/ftfuzzer.cc b/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/ftfuzzer.cc index 7df7abcddc2..39f2b393240 100644 --- a/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/ftfuzzer.cc +++ b/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/ftfuzzer.cc @@ -161,7 +161,7 @@ variations->axis[i].def ) / 2; if ( FT_Set_Var_Design_Coordinates( face, - coords.size(), + FT_UInt( coords.size() ), coords.data() ) ) return; } @@ -248,7 +248,7 @@ // loop over all bitmap stroke sizes // and an arbitrary size for outlines - for ( long fixed_sizes_index = 0; + for ( int fixed_sizes_index = 0; fixed_sizes_index < face->num_fixed_sizes + 1; fixed_sizes_index++ ) { diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/rasterfuzzer.cc b/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/rasterfuzzer.cc new file mode 100644 index 00000000000..05187b0be80 --- /dev/null +++ b/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/rasterfuzzer.cc @@ -0,0 +1,129 @@ +// rasterfuzzer.cc +// +// A fuzzing function to test FreeType's rasterizers with libFuzzer. +// +// Copyright 2016 by +// David Turner, Robert Wilhelm, and Werner Lemberg. +// +// This file is part of the FreeType project, and may only be used, +// modified, and distributed under the terms of the FreeType project +// license, LICENSE.TXT. By continuing to use, modify, or distribute +// this file you indicate that you have read the license and +// understand and accept it fully. + + +#include <stdint.h> + +#include <vector> + + + using namespace std; + + +#include <ft2build.h> + +#include FT_FREETYPE_H +#include FT_IMAGE_H +#include FT_OUTLINE_H + + + static FT_Library library; + static int InitResult; + + + struct FT_Global { + FT_Global() { + InitResult = FT_Init_FreeType( &library ); + } + ~FT_Global() { + FT_Done_FreeType( library ); + } + }; + + FT_Global global_ft; + + + extern "C" int + LLVMFuzzerTestOneInput( const uint8_t* data, + size_t size_ ) + { + unsigned char pixels[4]; + + FT_Bitmap bitmap_mono = { + 1, // rows + 1, // width + 4, // pitch + pixels, // buffer + 2, // num_grays + FT_PIXEL_MODE_MONO, // pixel_mode + 0, // palette_mode + NULL // palette + }; + + FT_Bitmap bitmap_gray = { + 1, // rows + 1, // width + 4, // pitch + pixels, // buffer + 256, // num_grays + FT_PIXEL_MODE_GRAY, // pixel_mode + 0, // palette_mode + NULL // palette + }; + + const size_t vsize = sizeof ( FT_Vector ); + const size_t tsize = sizeof ( char ); + + // we use the input data for both points and tags + short n_points = short( size_ / ( vsize + tsize ) ); + if ( n_points <= 2 ) + return 0; + + FT_Vector* points = reinterpret_cast<FT_Vector*>( + const_cast<uint8_t*>( + data ) ); + char* tags = reinterpret_cast<char*>( + const_cast<uint8_t*>( + data + size_t( n_points ) * vsize ) ); + + // to reduce the number of invalid outlines that are immediately + // rejected in `FT_Outline_Render', limit values to 2^18 pixels + // (i.e., 2^24 bits) + for ( short i = 0; i < n_points; i++ ) + { + if ( points[i].x == LONG_MIN ) + points[i].x = 0; + else if ( points[i].x < 0 ) + points[i].x = -( -points[i].x & 0xFFFFFF ) - 1; + else + points[i].x = ( points[i].x & 0xFFFFFF ) + 1; + + if ( points[i].y == LONG_MIN ) + points[i].y = 0; + else if ( points[i].y < 0 ) + points[i].y = -( -points[i].y & 0xFFFFFF ) - 1; + else + points[i].y = ( points[i].y & 0xFFFFFF ) + 1; + } + + short contours[1]; + contours[0] = n_points - 1; + + FT_Outline outline = + { + 1, // n_contours + n_points, // n_points + points, // points + tags, // tags + contours, // contours + FT_OUTLINE_NONE // flags + }; + + FT_Outline_Get_Bitmap( library, &outline, &bitmap_mono ); + FT_Outline_Get_Bitmap( library, &outline, &bitmap_gray ); + + return 0; + } + + +// END diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/runinput.cc b/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/runinput.cc index 8fa75ad6a96..d5f9f1587db 100644 --- a/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/runinput.cc +++ b/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/runinput.cc @@ -1,6 +1,6 @@ // runinput.cc // -// A `main' function for `ftfuzzer.cc'. +// A `main' function for fuzzers like `ftfuzzer.cc'. // // Copyright 2015-2016 by // David Turner, Robert Wilhelm, and Werner Lemberg. |