Commit Graph

56 Commits

Author SHA1 Message Date
Werner Lemberg 2c048a8a62 Fix compiler warning (#52640).
* src/base/ftbitmap.c (ft_bitmap_assure_buffer): Remove unused
variable.
2017-12-11 19:24:30 +01:00
Werner Lemberg e1090c608b Fix access to uninitalized memory (#52613).
Also reported as

  https://bugs.chromium.org/p/chromium/issues/detail?id=791317

* src/base/ftbitmap.c (ft_bitmap_assure_buffer): If increasing the
bitmap size needs a larger bitmap buffer, assure that the new memory
areas are initialized also.
2017-12-08 09:54:36 +01:00
Werner Lemberg 87ddad2007 Update or fix links to use the https protocol instead of http. 2017-12-04 20:43:30 +01:00
Werner Lemberg a3dd6d99a4 Fix multiple calls of `FT_Bitmap_Convert'.
The documentation of `FT_Bitmap_Convert' says that multiple calls do
proper reallocation of the target FT_Bitmap object.  However, this
failed for the sequence

  non-empty bitmap
  empty bitmap
  non-empty bitmap

Reason was that `FT_Bitmap_Convert' only reallocated the bitmap
buffer if it became too small; it didn't make the buffer smaller.
For an empty bitmap following a non-empty one, only the buffer
dimension got set to zero, without deallocation.  If the next call
was a non-empty buffer again, an assertion in `ft_mem_qrealloc' was
triggered.

* src/base/ftbitmap.c (FT_Bitmap_Convert): Always reallocate target
buffer to the correct size.

* docs/CHANGES: Document it.
2017-09-05 23:02:04 +02:00
Alexei Podtelezhnikov f0898b9259 Swap `ALLOC_MULT' arguments (#51833).
* src/base/ftbitmap.c (ft_bitmap_assure_buffer): Updated.
* src/winfonts/winfnt.c (FNT_Load_Glyph): Updated.
* src/raster/ftrend1.c (ft_raster1_render): Updated.
2017-08-25 21:40:01 -04:00
Werner Lemberg 563ae78022 Update copyright year. 2017-01-04 20:16:34 +01:00
Werner Lemberg 4441f7b246 Replace `foo == NULL' and `foo != NULL' with `!foo' and `foo', resp.
Other minor formatting.
2016-12-26 17:08:17 +01:00
Werner Lemberg 3295039107 Whitespace. 2016-02-15 12:54:40 +01:00
Werner Lemberg 9adeab6452 Update copyright year. 2016-01-13 11:54:10 +01:00
Werner Lemberg eee7d8baa1 [base] Rename `FT_Bitmap_New' to `FT_Bitmap_Init'.
* include/ftbitmap.h, src/base/ftbitmap.c: Implement it.
Update all callers.

* docs/CHANGES: Updated.
2015-03-10 11:15:15 +01:00
Werner Lemberg 2e814fc045 More minor signedness warning fixes.
* src/base/ftbbox.c, src/base/ftbitmap.c, src/base/fttrigon.c,
src/base/ftutil.c: Apply.
2015-02-16 20:05:08 +01:00
Werner Lemberg f57fc59e01 Run `src/tools/update-copyright'. 2015-01-17 20:41:43 +01:00
Werner Lemberg 0098d5502d Uppercase all hex digits for orthogonality. 2014-12-07 11:03:57 +01:00
Werner Lemberg 644d6fab7e * src/base/ftbitmap.c (FT_Bitmap_Convert): Improve.
This commit completes argument checks and adds support for different
flow directions.
2014-11-21 07:28:50 +01:00
Werner Lemberg 6de761744c * src/base/ftbitmap.c (FT_Bitmap_Copy): Improve.
This commit adds argument checks and support for different flow
directions.
2014-11-21 06:38:46 +01:00
Werner Lemberg 1e6e1b8390 * src/base/ftbitmap.c (FT_Bitmap_New): Check argument. 2014-11-21 06:38:46 +01:00
Werner Lemberg b3500af717 Change some fields in `FT_Bitmap' to unsigned type.
This doesn't break ABI.

* include/ftimage.h (FT_Bitmap): Make `rows', `width', `num_grays',
`pixel_mode', and `palette_mode' unsigned types.

* src/base/ftbitmap.c: Updated.
(FT_Bitmap_Copy): Fix casts.

* src/cache/ftcsbits.c, src/raster/ftraster.c, src/sfnt/pngshim.c:
Updated.
2014-11-21 06:38:46 +01:00
Werner Lemberg df485774fb Make `FT_Bitmap_Convert' correctly handle negative `pitch' values.
* src/base/ftbitmap.c (FT_Bitmap_Convert): Always use positive value
for the pitch while copying data.
Correctly set pitch sign in target bitmap.
2014-11-21 06:38:46 +01:00
Werner Lemberg d6061212c3 Minor code improvement in `FT_Bitmap_Embolden'.
* src/base/ftbitmap.c (FT_Bitmap_Embolden) <FT_PIXEL_MODE_GRAY[24]>:
Fix thinko.
2014-11-21 06:38:01 +01:00
Werner Lemberg 8d05486eab Minor documentation improvements and whitespace. 2014-11-21 06:10:25 +01:00
Alexei Podtelezhnikov 237c0abfdc Trailing space. 2014-11-19 22:10:29 -05:00
Alexei Podtelezhnikov 90be4b6377 * src/base/ftbitmap.c (ft_gray_for_premultiplied_srgb_bgra): Refactor. 2014-08-08 22:27:10 -04:00
Werner Lemberg 3939c200f3 Minor. 2014-07-17 17:24:22 +09:00
Alexei Podtelezhnikov 1183cd4e17 [base] Further clean up color bitmap conversion.
* src/base/ftbitmap.c (ft_gray_for_premultiplied_srgb_bgra): Stop
using FT_MulFix and FT_DivFix since all calculations fit into 32 bits.
2014-07-14 22:30:55 -04:00
Alexei Podtelezhnikov 35576bf067 [base] Clean up bitmap conversion.
* src/base/ftbitmap.c (ft_gray_for_premultiplied_srgb_bgra): Use
appropriate FT_DivFix and remove superfluous upscaling.
2014-07-11 22:40:34 -04:00
Sean McBride 7be2a94a50 Fix clang static analyzer and compiler warnings.
* src/autofit/afhints.c (af_glyph_hints_align_weak_points),
src/autofit/afloader (af_loader_load_g) <FT_GLYPH_FORMAT_COMPOSITE>,
src/base/ftcalc.c (FT_MSB), src/base/ftoutln.c
(FT_Outline_Decompose), src/bdf/bdfdrivr.c (bdf_interpret_style),
src/cff/cffparse.c (cff_parse_integer), src/cid/cidparse.c
(cid_parser_new), src/pfr/pfrload.c (pfr_phy_font_load),
src/raster/ftraster.c (Decompose_Curve), src/sfnt/sfdriver.c
(sfnt_get_ps_name), src/sfnt/ttcmap.c (tt_cmap12_next,
tt_cmap13_next), src/smooth/ftgrays.c (gray_hline): Remove dead
code.

* src/autofit/afmodule.c (af_property_get_face_globals,
af_property_set, af_property_get), src/base/ftbitmap.c
(ft_gray_for_premultiplied_srgb_bgra): Make functions static.

* src/base/ftobjs.c (ft_remove_renderer): Protect against
library == NULL.
(ft_property_do): Make function static.

* src/base/ftrfork.c: Include `ftbase.h'.

* src/sfnt/ttsbit.c (tt_face_load_sbix_image)
[!FT_CONFIG_OPTION_USE_PNG], src/type1/t1gload.c
(T1_Compute_Max_Advance): Avoid compiler warning.

* src/truetype/ttinterp.c (TT_New_Context): Reduce scope of
variable.
2014-02-08 13:55:38 +01:00
Werner Lemberg cc34efca99 Minor. 2013-07-31 22:55:50 +02:00
suzuki toshiya f2e7f1e1dd 2013-07-30 Behdad Esfahbod <behdad@google.com>
Prevent division by zero by a transparent color.

	* src/base/ftbitmap.c (ft_gray_for_premultiplied_srgb_bgra):
	Return 0 immediately, when alpha channel is zero.
2013-07-30 13:32:57 +09:00
Werner Lemberg 45392b77a8 Fix compiler warnings.
* include/freetype/internal/ftmemory.h: Decorate memory allocation
macros with `FT_Long' where appropriate.
Remove duplicate of FT_MEM_QRENEW_ARRAY definition.

* src/base/ftbitmap.c (ft_gray_for_premultiplied_srgb_bgra): Use
cast.

* src/base/ftobjs.c: Add warning disabling pragma for MSVC while
including `md5.c'.

* src/cff/cf2intrp.c (cf2_interpT2CharString) <cf2_cmdESC>: Add
cast.

* src/sfnt/ttsbit.c (tt_sbit_decoder_load_compound): Fix casts.
(tt_sbit_decoder_load_bitmap): Beautification.

* src/smooth/ftsmooth.c (ft_smooth_render_generic): Initialize
variables (earlier).

* src/truetype/ttgload.c (TT_Process_Simple_Glyph): Pacify compiler.

* src/truetype/ttgxvar.c (TT_Get_MM_Var): Use unsigned constants
where appropriate.

* src/type1/t1load.c (T1_Get_MM_Var): Ditto.
2013-06-05 13:43:20 +02:00
Behdad Esfahbod 760d342d37 Add support for color embedded bitmaps (eg. color emoji).
A new load flag, FT_LOAD_COLOR, makes FreeType load color
embedded-bitmaps, following this draft specification

  https://color-emoji.googlecode.com/git/specification/v1.html

which defines two new SFNT tables, `CBDT' and `CBLC' (named and
modeled after `EBDT' and `EBLC', respectively).  The color bitmaps
are stored in the new FT_PIXEL_MODE_BGRA format to represent BGRA
pre-multiplied sRGB images.  If PNG support is available, PNG color
images as defined in the same proposed specification are supported
also.

Note that color bitmaps are converted to grayscale if client didn't
ask for color.

* builds/unix/configure.raw: Search for libpng.
Add `--without-png' option.

* devel/ftoption.h, include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_PNG): New macro.

* include/freetype/freetype.h (FT_LOAD_COLOR): New load flag.

* include/freetype/ftimage.h (FT_Pixel_Mode): Add
`FT_PIXEL_MODE_BGRA'.

* include/freetype/tttags.h (TTAG_CBDT, TTAG_CBLC): New tags.

* src/base/ftbitmap.c (FT_Bitmap_Embolden): Updated.
(ft_gray_for_premultiplied_srgb_bgra): New function.
(FT_Bitmap_Convert): Handle FT_PIXEL_MODE_BGRA.

* src/sfnt/pngshim.c, src/sfnt/pngshim.h: New files.

* src/sfnt/sfnt.c: Include `pngshim.c'.

* src/sfnt/ttsbit.c: Include FT_BITMAP_H and `pngshim.h'
(tt_face_load_eblc): Load `CBLC'.
(tt_sbit_decoder_init): Load `CBDT'.
(tt_sbit_decoder_alloc_bitmap): Pass load flags to select between
color and grayscale bitmaps.
Set `num_grays'.  This is used by `ftview' to choose the blending
algorithm.
(tt_sbit_decoder_load_byte_aligned,
tt_sbit_decoder_load_bit_aligned, tt_sbit_decoder_load_compound,
tt_sbit_decoder_load_image): Pass load flag.
s/write/pwrite/.
Don't call `tt_sbit_decoder_alloc_bitmap'.
Updated.
(tt_sbit_decoder_load_png) [FT_CONFIG_OPTION_USE_PNG]: New function.
(tt_sbit_decoder_load_bitmap): Pass load flag.
Handle new glyph formats 17, 18, and 19.
Call `tt_sbit_decoder_alloc_bitmap'.
Flatten color bitmaps if necessary.
(tt_face_load_sbit_image): Updated.

* src/sfnt/rules.mk (SFNT_DRV_SRC): Add `pngshim.c'.

* docs/CHANGES: Updated.
2013-05-29 11:36:18 +02:00
Werner Lemberg 059bc335ce */*: Use `FT_THROW'.
This is essentially a mechanical conversion, adding inclusion of
`FT_INTERNAL_DEBUG_H' where necessary, and providing the macros for
stand-alone compiling modes of the rasterizer modules.

To convert the remaining occurrences of FT_Err_XXX and friends it is
necessary to rewrite the code.  Note, however, that it doesn't harm
if some cases are not handled since FT_THROW is a no-op.
2013-03-14 10:27:35 +01:00
suzuki toshiya 1749d8bc6a Remove trailing spaces. 2012-01-17 02:00:24 +09:00
Werner Lemberg dfb475ab7a Fix compiler warning. 2011-11-14 20:29:13 +01:00
Werner Lemberg 9c98fbf634 Handle some border cases.
* include/freetype/config/ftstdlib.h (FT_USHORT_MAX): New macro.

* src/base/ftbitmap.c (FT_Bitmap_Convert): Protect against invalid
value of `target->rows'.

* src/psaux/t1decode.c (t1_decoder_parse_charstrings): Add check for
flex start.

* src/raster/ftrend1.c (ft_raster1_render): Check `width' and
`height'.

* src/truetype/ttgxvar.c (TT_Vary_Get_Glyph_Deltas): Protect against
invalid values in `localpoints' array.
2011-10-01 09:25:55 +02:00
suzuki toshiya 65a449887d [base] Fix g++4.6 compiler warnings in src/base/*.c.
Passing uninitialized pointer to the buffer allocator is
not problematic theoretically (as far as the returned
pointer is checked before writing), but g++4.6 dislikes
it and warns by -Wuninitialized.  Initialize them by NULL.

* src/base/ftobjs.c (FT_Stream_New): Init `stream'.
(new_memory_stream): Ditto.
(FT_New_GlyphSlot): Init `slot'.
(FT_CMap_New): Init `cmap'.
(open_face_PS_from_sfnt_stream): Init `sfnt_ps'.
(Mac_Read_POST_Resource): Init `pfb_data'.
(Mac_Read_sfnt_Resource): Init `sfnt_data'.
* src/base/ftrfork.c (FT_Raccess_Get_DataOffsets):
Init `offsets_internal' and `ref'.
(raccess_guess_darwin_hfsplus): Init `newpath'.
(raccess_guess_darwin_newvfs): Ditto.
* src/base/ftbitmap.c (ft_bitmap_assure_buffer):
Init `buffer'.
* src/base/ftstroke.c (FT_Stroker_New): Init `stroker'.
2011-06-15 01:44:24 +09:00
suzuki toshiya e866cf3f55 Improve bitmap size or pixel variables for 16-bit systems. 2009-08-01 00:32:06 +09:00
Werner Lemberg a86f1b96b5 FT_Bitmap_Convert: Support missing pixel modes.
* src/base/ftbitmap.c (FT_Bitmap_Convert): Handle FT_PIXEL_MODE_LCD
and FT_PIXEL_MODE_LCD_V.  Problem reported by Chi Nguyen
<chint@necsv.com>.
2009-01-06 09:07:22 +00:00
Werner Lemberg c8c4cc837c * include/freetype/ftsynth.h, src/basae/ftsynth.c: Move
FT_GlyphSlot_Own_Bitmap to...
* include/freetype/ftbitmap.h, src/base/ftbitmap.c: These files.

* docs/CHANGES: Document it.
2008-12-17 10:50:31 +00:00
David Turner 1dcb4448c1 fixed a memory buffer overwrite bug. Damn !! 2007-04-06 08:19:04 +00:00
Werner Lemberg 24fd93d6ec formatting 2007-03-29 11:56:21 +00:00
David Turner 3f539694f1 fixing bug in the padding zero-ing of the bitmap emboldener 2007-03-28 14:53:40 +00:00
Werner Lemberg 27cf9de104 formatting, copyright years 2007-01-13 07:34:23 +00:00
David Turner e3654532ea * src/base/ftbitmap.c: fixing memory stomping bug in the
bitmap embolderner when the pitch of the source bitmap is
        *much* larger than its width

        * src/truetype/ttinterp.c: fixing aliasing-related compilation
        warning
2007-01-13 00:19:18 +00:00
David Turner 9ca782569c * include/freetype/internal/ftmemory.h, src/base/ftbitmap.c,
src/base/ftmac.c, src/base/ftrfork.c, src/lzw/ftzopen.c,
    src/raster/ftrend1.c, src/sfnt/ttpost.c, src/truetype/ttgxvar.c,
    src/type42/t42parse.c, src/winfonts/winfnt.c: hardening the code
    against out-of-bounds conditions when allocating arrays. This is
    for the cases where FT_NEW_ARRAY and FT_RENEW_ARRAY are not used
    already. Introducing the new FT_ALLOC_MULT and FT_REALLOC_MULT
    macros.
2006-05-02 09:00:29 +00:00
Werner Lemberg be3c9814a4 Formatting, copyright years. 2006-01-27 14:16:16 +00:00
David Turner 6a681fa84a * src/autofit/afwarp.c: simple #ifdef to prevent compilation when
the warp hinter isn't active (it shouldn't, still experimental)

    * Jamfile, include/freetype/config/ftmodule.h: removed "gxvalid"
    and "otvalid" from the list of modules that are linked statically
    to a given FreeType library. Functionality has been moved to the
    "ftvalid" CVS module.

    note also that current Make-based build system still compiles the
    modules though...

    * include/freetype/config/ftoption.h: added FT_STRICT_ALIASING,
    which controls the definitions of the memory management functions
    to avoid warnings with recent versions of GCC. this macro is
    only here to be disabled, in case we detect problems with the
    new scheme.

    NOTE: disable macro to use the memory debugger. this will be fixed
          later !!
2006-01-27 12:11:22 +00:00
David Turner c562162834 * src/sfnt/ftbitmap.c, src/truetype/ttgload.c, src/sfnt/ttcmap.c:
removing compiler warnings (Visual C++ /W4)

        * Jamfile, src/otvalid/{otvcommn.h,otvgdef.c,otvgpos.c,otvgsub.c,
        otvjstf.c}: modified the code to use a different pre-processor trick
        to implement the OTV_NEST1, OTV_NEST2 and OTV_NEST3 macros. The code
        now compiles neatly with Visual C++. The 'otvalid' module has been
        put in the Jamfile build again.
2005-06-30 11:46:46 +00:00
Werner Lemberg 38e82be157 * include/freetype/ftbitmap.h (FT_Bitmap_Embolden): Minor
documentation improvements.

* include/freetype/ftoutln.h (FT_Outline_Embolden): Fix typos.

* src/base/ftbitmap.c (FT_Bitmap_Embolden): Add support for bitmap
of pixel_mode FT_PIXEL_MODE_GRAY2 or FT_PIXEL_MODE_GRAY4.
If xstr is larger than 8 and bitmap is of pixel_mode
FT_PIXEL_MODE_MONO, set xstr to 8 instead of returning error.
2005-05-30 19:22:44 +00:00
Werner Lemberg 71d7628175 * src/base/ftbitmap.c (FT_Bitmap_Embolden): Fix emboldening bitmap
of mode FT_PIXEL_MODE_GRAY.  Also add support for mode
FT_PIXEL_MODE_LCD and FT_PIXEL_MODE_LCD_V.
(ft_bitmap_assure_buffer): FT_PIXEL_MODE_LCD and FT_PIXEL_MODE_LCD_V
should have ppb (pixel per byte) 1.
Zero the padding when there's no need to allocate memory.

* src/base/ftsynth.c (FT_GlyphSlot_Embolden): Handle slot->advance
too.
More suited emboldening strength.
2005-05-30 07:54:20 +00:00
Werner Lemberg c162eac55c * src/base/ftbitmap.c (FT_Bitmap_Embolden): Handle negative pitch.
Handle FT_PIXEL_MODE_GRAY with num_gray != 256.
Improve speed for FT_PIXEL_MODE_GRAY.
(ft_bitmap_assure_buffer): Accept FT_PIXEL_MODE_LCD and
FT_PIXEL_MODE_LCD_V.
2005-05-28 21:52:37 +00:00