Commit Graph

69 Commits

Author SHA1 Message Date
Werner Lemberg d0cfb4e1b2 Update all copyright notices. 2022-01-11 10:54:10 +01:00
Werner Lemberg 2149b51f25 Handle various VC++ compiler warnings.
Fixes #1039.

* src/base/ftstroke.c (ft_stroker_inside, ft_stroker_outside):
Initialize `sigma`.

* src/sdf/ftsdf.c (sdf_generate_with_overlaps): Exit immediately if
function arguments are invalid.
* src/sdf/ftsdfrend.c (sdf_property_set) <"overlaps">: Fix cast.

* src/sfnt/sfwoff2.c (woff2_decompress)
[!FT_CONFIG_OPTION_USE_BROTLI]: Use `FT_UNUSED`.

* src/truetype/ttgxvar.c (TT_Get_MM_Var): Initialize `fvar_head`.
2021-03-13 19:08:09 +01:00
Alexei Podtelezhnikov 7ae5609dbe * src/base/ftstroke.c (FT_Stroker_EndSubPath): Ignore tiny gaps.
Fixes bug #1020.
2021-01-27 16:08:08 -05:00
Alexei Podtelezhnikov 4c3bd2ab93 [stroker] Minor clean-up.
* src/base/ftstroke.c (FT_Stroker_{ConicTo,CubicTo}): Reset the last
line length.
(FT_Stroker_EndSubPath): Call `ft_stroker_process_corner'.
2021-01-27 15:54:34 -05:00
Werner Lemberg b6e8a71266 Update all copyright notices. 2021-01-17 07:18:48 +01:00
Werner Lemberg 1658685967 Remove redundant inclusion of `ft2build.h'.
* */*: Remove `#include <ft2build.h>' where possible.

* include/freetype/freetype.h: Remove cpp error about missing
inclusion of `ft2build.h'.
2020-06-13 21:15:45 +02:00
David Turner e13391333f Make macros for header file names optional.
We no longer have to take care of the 8.3 file name limit; this
allows us (a) to introduce longer, meaningful file names, and (b) to
avoid macro names in `#include' lines altogether since some
compilers (most notably Visual C++) doesn't support this properly.

*/*: Replace

   #include FOO_H

with

   #include <freetype/foo.h>

or something similar.  Also update the documentation.
2020-06-08 13:31:55 +02:00
Werner Lemberg e5038be704 Update all copyright notices. 2020-01-19 17:05:19 +01:00
Alexei Podtelezhnikov c912690d22 * src/base/ftstroke.c (ft_stroker_inside): Speed up. 2019-09-30 22:45:34 -04:00
Alexei Podtelezhnikov b39576f984 * src/base/ftstroke.c (ft_stroker_cap): Speed up caps. 2019-09-27 19:18:49 -04:00
Alexei Podtelezhnikov 432efa25b3 * src/base/ftstroke.c (ft_stroker_outside): Speed up clipped miter.
* include/freetype/ftstroke.h: Wordsmith miter docs.
2019-09-25 21:50:16 -04:00
Alexei Podtelezhnikov 4881f75b7c * src/base/ftstroke.c (ft_stroke_border_arcto): Speed up calculations. 2019-09-23 22:57:00 -04:00
Alexei Podtelezhnikov 7a81b63abc Optimize Bézier bisections.
* src/raster/ftraster.c (Split_Conic, Split_Cubic): Use shifts and
refactor.
* src/smooth/ftgrays.c (gray_split_conic, gray_split_cubic): Ditto.
* src/base/ftstroke.c (ft_conic_split, ft_cubic_split): Ditto.
* src/base/ftbbox.c (cubic_peak): Use shifts.
2019-04-25 22:06:33 -04:00
Werner Lemberg 7585997024 Update all copyright notices. 2019-02-23 10:07:09 +01:00
Werner Lemberg f686ad46a3 Update copyright years. 2019-01-22 20:31:44 +01:00
Alexei Podtelezhnikov 181033d396 [ftstroke] Fix unpredictable failures (#54986).
* src/base/ftstroke.c (ft_sroke_border_lineto): Fix lineto check.
2018-11-08 21:04:56 -05:00
Alexei Podtelezhnikov 81c31f62cb [ftstroke] Fix unpredictable failures (#54976).
* src/base/ftstroke.c (ft_sroke_border_close): Set the start tags.
2018-11-08 07:54:47 -05:00
Werner Lemberg 9ac9060df0 [GSoC] src/*.*: Convert block comments to `light' style.
This monster commit was created by applying Nikhil's scripts
`docconverter.py' and `markify.py' to all C header and source files,
followed up by minor manual clean-up.

No change in functionality, of course.

I used commit f7419907bc6044b9b7057f9789866426c804ba82 from
https://github.com/nikramakrishnan/freetype-docs.git.
2018-06-03 09:08:41 +02:00
Werner Lemberg 9514959241 Remove FT_CONFIG_OPTION_PIC and related code.
*/* [FT_CONFIG_OPTION_PIC]: Remove all code guarded by this
preprocessor symbol.

*/*: Replace `XXX_GET' macros (which could be either a function in
PIC mode or an array in non-PIC mode) with `xxx' arrays.

* include/freetype/internal/ftpic.h, src/autofit/afpic.c,
src/autofit/afpic.h, src/base/basepic.c, src/base/basepic.h,
src/base/ftpic.c, src/cff/cffpic.c, src/cff/cffpic.h,
src/pshinter/pshpic.c, src/pshinter/pshpic.h, src/psnames/pspic.c,
src/psnames/pspic.h, src/raster/rastpic.c, src/raster/rastpic.h,
src/sfnt/sfntpic.c, src/sfnt/sfntpic.h, src/smooth/ftspic.c,
src/smooth/ftspic.h, src/truetype/ttpic.c, src/truetype/ttpic.h:
Removed.
2018-05-02 20:27:48 +02:00
Werner Lemberg 0a0c22569d Update copyright year. 2018-01-02 09:33:57 +01:00
Werner Lemberg 563ae78022 Update copyright year. 2017-01-04 20:16:34 +01:00
Werner Lemberg 78371bd641 Fix another runtime error found by clang's sanitizer (#47082).
* src/base/ftstroke.c (ft_stroke_border_export): Properly handle
empty input buffer.
2016-02-07 21:06:59 +01:00
Werner Lemberg 9adeab6452 Update copyright year. 2016-01-13 11:54:10 +01:00
pazer f0ed30e6e6 Fix C++ compilation (#45762).
* src/base/ftstroke.c (ft_outline_glyph_class): Use
FT_CALLBACK_TABLE.
2015-08-15 06:53:09 +02:00
Alexei Podtelezhnikov 6b832c872d Fix Savannah bug #44412 (part 1).
* src/base/ftstroke.c (ft_stroker_inside): Handle near U-turns.
2015-03-10 23:25:49 -04:00
Alexei Podtelezhnikov dd7498d283 * src/base/ftstroke.c: Simplify. 2015-03-05 22:51:36 -05:00
Werner Lemberg 76abc75c26 [base] Finish compiler warning fixes for signedness issues.
* src/base/ftglyph.c, src/base/ftlcdfil.c, src/base/ftstroke.c:
Apply.
2015-02-16 22:00:27 +01:00
Werner Lemberg f57fc59e01 Run `src/tools/update-copyright'. 2015-01-17 20:41:43 +01:00
Werner Lemberg 9870d6dacf */*: Decorate hex constants with `U' and `L' where appropriate. 2014-12-07 09:40:47 +01:00
Werner Lemberg f34f192535 * src/*: Add checks for parameters of API functions where missing.
`API functions' are functions tagged with `FT_EXPORT_DEF'.

Besides trivial fixes, the following changes are included, too.

* src/base/ftbdf.c (FT_Get_BDF_Charset_ID, FT_Get_BDF_Property): Set
error code if no service is available.

* src/base/ftinit.c (FT_Done_FreeType): Change return value for
invalid `library' parameter to `Invalid_Library_Handle'.

* src/base/ftobjs.c (FT_New_Size): Change return value for invalid
`asize' parameter to `Invalid_Argument'.

* src/base/ftoutln.c (FT_Outline_Copy): Change return value for
invalid `source' and `target' parameters to `Invalid_Outline'.
(FT_Outline_Done_Internal): Change return value for invalid
`outline' parameter to `Invalid_Outline'.
2014-11-26 21:59:21 +01:00
Werner Lemberg f4f9e68800 */*: s/Invalid_Argument/Invalid_Library_Handle/ where appropriate. 2014-11-25 11:11:55 +01:00
Werner Lemberg 04c2aa18bf */*: s/Invalid_Argument/Invalid_Outline/ where appropriate. 2014-11-25 10:22:12 +01:00
Werner Lemberg b24e8ba28a [Savannah bug #43682] Add/remove `void' casts to some functions.
We use a cast to indicate that we intentionally ignore a function's
return value.  However, this doesn't apply to API functions where
errors can only happen for trivially invalid input.

* src/base/ftstroke.c (FT_Glyph_Stroke, FT_Glyph_StrokeBorder),
src/base/ftsynth.c (FT_GlyphSlot_Embolden), src/cff/cffgload.c
(cff_slot_load), src/pfr/pfrdrivr.c (pfr_get_kerning),
src/type1/t1load.c (parse_encoding), src/type42/t42parse.c
(t42_parse_encoding): Do it.
2014-11-25 08:30:49 +01:00
Werner Lemberg 0e73d218bc * src/base/ftstroke.c (ft_stroker_inside): Fix border intersections.
One more place to check whether `radius' is zero.

Problem reported by Marco Wertz <marco.wertz@gmx.de>.
2014-11-09 01:27:38 +01:00
Werner Lemberg 89f5064765 */*: Use FT_ERR_EQ, FT_ERR_NEQ, and FT_ERR where appropriate.
FT_Err_XXX and friends are no longer directly used in the source
code.
2013-03-14 17:50:49 +01: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
Alexei Podtelezhnikov 72e976d415 [ftstroke] Minor improvement.
* src/base/ftstroke.c: Replace nested FT_DivFix and FT_MulFix with
FT_MulDiv.
2012-11-27 21:18:34 -05:00
Alexei Podtelezhnikov bc5bcecfd2 Revert the last commit 45337b07. 2012-07-13 17:52:43 -04:00
Alexei Podtelezhnikov 45337b07a7 [ftstroke] Fix uninitialized return value.
* src/base/ftstroke.c (FT_Stroker_New): Return FT_Err_Ok instead.
2012-07-11 22:12:13 -04:00
David Bevan 864c426eff Fix Savannah bug #33992.
* src/base/ftstroke.c (FT_Stroker_ParseOutline): Fix border case.
2011-08-15 17:34:01 +02:00
David Bevan aecbfe1ba7 [ftstroke] Major revision.
The main problems
-----------------

  o If FT_STROKER_LINEJOIN_BEVEL was specified, unlimited miter
    joins (not bevel joins) were generated.  Indeed, the meanings of
    `miter' and `bevel' were incorrectly reversed (consistently) in
    both the code and comments.

  o The way bevel joins were constructed (whether specified
    explicitly, or created as a result of exceeding the miter limit)
    did not match what is required for stroked text in PostScript or
    PDF.

The main fixes
--------------

  o The behaviour of FT_STROKER_LINEJOIN_BEVEL has been corrected.

  o A new line join style, FT_STROKER_LINEJOIN_MITER_FIXED, has been
    introduced to support PostScript and PDF miter joins.

  o FT_STROKER_LINEJOIN_MITER_VARIABLE has been introduced as an
    alias for FT_STROKER_LINEJOIN_MITER.

Additionally, a variety of stroking errors have been fixed.  These
would cause various artifacts (including points `at infinity'),
especially when stroking poor quality fonts.

See

  http://lists.gnu.org/archive/html/freetype-devel/2011-07/msg00001.html

for example documents.  The FreeType stroker now produces results
very similar to that produced by GhostScript and Distiller for these
fonts.

Other problems
--------------

The following problems have been resolved:

  o Inside corners could be generated incorrectly.  Intersecting the
    inside corner could cause a missing triangular area and other
    effects.

    The intersection point can only be used if the join is between
    two lines and both lines are long enough.  The `optimization'
    condition in `ft_stroker_inside' has been corrected; this
    requires the line length to be passed into various functions and
    stored in `FT_StrokerRec'.

  o Incorrect cubic curves could be generated.  The angle
    calculations in `FT_Stroker_CubicTo' have been corrected to
    handle the case of the curve crossing the +/-PI direction.

  o If the border radius was greater than the radius of curvature of
    a curve, then the negative sector would end up outside (not
    inside) the border.  This situation is now recognized and the
    negative sector is circumnavigated in the opposite direction.
    (If round line joins are being used, this code is disabled
    because the line join will always cover the negative sector.)

  o When a curve is split, the arcs may not join smoothly (especially
    if the curve turns sharply back on itself).  Changes in
    direction between adjacent arcs were not handled.  A round
    corner is now added if the deviation from one arc to the next is
    greater than a suitable threshold.

  o The current direction wasn't retained if a the outline contained
    a zero length lineto or a curve that was determined to be
    `basically a point'.  This could cause a spurious join to be
    added.

  o Cubics with close control points could be mishandled.  All eight
    cases are now distinguished correctly.

Other improvements
------------------

o Borders for cubic curves could be too `flat'.
  FT_SMALL_CUBIC_THRESHOLD has been reduced a little to prevent
  this.

o The handling and use of movable points has been simplified a
  little.

o Various values are now computed only if the results are actually
  needed.

o The directions of the outer and inner borders have been swapped,
  as recommended by Graham Asher.

* src/base/ftstroke.c: Revised.
* include/freetype/ftstroke.h: Updated.
2011-07-02 12:09:52 +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
Werner Lemberg 437fb8ebf8 * src/base/ftstroke.c (FT_StrokerRec): Remove unused `valid' field.
Suggested by Graham Asher.
2011-03-16 08:54:02 +01:00
Werner Lemberg fc58155afc Apply reports from clang static analyzer.
* src/lzw/ftlzw.c (ft_lzw_file_init), src/base/ftstroke.c
(FT_Stroker_ParseOutline), src/base/ftsynth.c
(FT_GlyphSlot_Embolden): Remove dead code.

* src/base/ftpatent.c (_tt_check_patents_in_table): Initialize
`offset_i'.
2010-01-05 20:00:35 +01:00
Werner Lemberg a5e9dbd528 Fix Savannah bug #27742.
* src/base/ftstroke.c (ft_stroker_outside): Avoid silent division by
zero, using a threshold for `theta'.
2009-11-20 09:33:57 +01:00
Michael Zucchi f33b237c96 Handle FT_STROKER_LINECAP_BUTT.
This fixes Savannah bug #26757.

* src/base/ftstroke.c (ft_stroker_cap): Implement it.
2009-06-08 17:12:40 +02:00
Oran Agra 636c294bef Position Independent Code (PIC) support and infrastructure in base.
* include/freetype/config/ftoption.h add FT_CONFIG_OPTION_PIC
* include/freetype/internal/ftobjs.h Add pic_container member to
FT_LibraryRec.
Add macros to declare and init instances of FT_CMap_ClassRec.
Add macros to init instances of FT_Outline_Funcs and FT_Raster_Funcs.
Add macros to declare, allocate and initialize modules
(FT_Module_Class).
Add macros to declare, allocate and initialize renderers
(FT_Renderer_Class).
Add macro to init instances of FT_Glyph_Class.
Add macros to declare, allocate and initialize drivers
(FT_Driver_ClassRec).
* include/freetype/internal/ftpic.h new file to declare the
FT_PIC_Container struct and the functions to allocate and detroy it.
* include/freetype/internal/ftserv.h add macros to allocate and
destory arrays of FT_ServiceDescRec.
* include/freetype/internal/internal.h define macro to include
ftpic.h.

New Files:
* src/base/ftpic.c implement functions to allocate and destory the
global pic_container.
* src/base/basepic.h declare struct to hold PIC globals for base and
macros to access them.
* src/base/basepic.c implement functions to allocate, destroy and
initialize PIC globals for base.

* src/base/ftinit.c when FT_CONFIG_OPTION_PIC is defined implement
functions that allocate and destroy ft_default_modules according to
FT_CONFIG_MODULES_H in the pic_container instead of the global scope
and use macro from basepic.h to access it.
* src/base/ftobjs.c add calls to the functions that allocate and
destroy the global pic_container when the library is created and
destroyed.

* src/base/jamfile add new files to FT2_MULTI build:
ftpic.c and basepic.c.
* src/base/ftbase.c add new files to build:
ftpic.c and basepic.c.

* src/base/ftglyph.c when FT_CONFIG_OPTION_PIC is defined
ft_bitmap_glyph_class and ft_outline_glyph_class will be allocated
in the pic_container instead of the global scope and use macros from
basepic.h to access them.
* src/base/ftbbox.c allocate bbox_interface stract on the stack
instead of the global scope when FT_CONFIG_OPTION_PIC is defined.
* src/base/ftstroke.c access ft_outline_glyph_class allocated in
ftglyph.c via macros from basepic.h
2009-04-05 17:59:26 +03:00
Oran Agra 3da7e68f75 Minor change in ftstroke.c.
* src/base/ftstroke.c (FT_StrokerRec): Replace `memory' member with
`library' needed for PIC version.
Update all callers.
2009-04-05 17:30:14 +03:00
Werner Lemberg b66efefdcd Fix some FreeType Coverity issues as reported for Ghostscript.
* src/base/ftobjs.c (FT_New_Face, FT_New_Memory_Face): Initialize
`args.stream' (#3874, #3875).
(open_face_PS_from_sfnt_stream): Improve error management (#3786).
* src/base/ftmm.c (ft_face_get_mm_service): Fix check of `aservice'
(#3870).
* src/base/ftstroke.c (ft_stroke_border_get_counts): Remove dead
code (#3790).
* src/base/ftrfork.c (raccess_guess_apple_generic): Check error
value of `FT_Stream_Skip' (#3784).

* src/type1/t1gload.c (T1_Load_Glyph): Check `size' before accessing
it (#3872)

* src/pcf/pcfdrivr.c (PCF_Glyph_Load): Check `face' before accessing
it (#3871).
* src/pcf/pcfread.c (pcf_get_metrics): Handle return value of
`pcf_get_metric' (#3789, #3782).
(pcf_get_properties): Use FT_STREAM_SKIP (#3783).

* src/cache/ftcmanag.c (FTC_Manager_RegisterCache): Fix check of
`acache' (#3797)

* src/cff/cffdrivr.c (cff_ps_get_font_info): Fix check of `cff'
(#3796).
* src/cff/cffgload.c (cff_decoder_prepare): Check `size' (#3795).
* src/cff/cffload.c (cff_index_get_pointers): Add comment (#3794).

* src/bdf/bdflib.c (_bdf_add_property): Check `fp->value.atom'
(#3793).
(_bdf_parse_start): Add comment (#3792).

* src/raster/ftraster.c (Finalize_Profile_Table): Check
`ras.fProfile' (#3791).

* src/sfnt/ttsbit.c (Load_SBit_Image): Use FT_STREAM_SKIP (#3785).

* src/gzip/ftgzip.c (ft_gzip_get_uncompressed_size): Properly ignore
seek error (#3781).
2009-03-12 08:07:49 +00:00
Werner Lemberg 4afcfd3056 beautifying, doc fixes. 2008-09-16 17:32:02 +00:00