Commit Graph

208 Commits

Author SHA1 Message Date
Alexei Podtelezhnikov 22befeef82 Signedness revisions.
This eliminates explicit casting by switching to unsigned fields.
The revisions mostly impact the handling of CID fonts.

* include/freetype/fttypes.h (FT_Data): Change to unsigned `length`.
* include/freetype/t1tables.h (CID_FaceDictRec): Ditto for `sd_bytes`.
(CID_FaceInfoRec): Ditto for `gd_bytes` and `gd_bytes`.
* include/freetype/internal/tttypes.h (TT_LoaderRec): Ditto for
`byte_len`.

* src/cid/cidgload.c (cid_load_glyph): Updated.
* src/cid/cidload.h (cid_get_offset): Update argument.
* src/cid/cidload.c (cid_get_offset, cid_read_subrs, cid_face_open):
Updated.
* src/cff/cffgload.c (cff_get_glyph_data, cff_free_glyph_data):
Updated.
* src/psaux/psft.c (cf2_getT1SeacComponent): Updated.
* src/truetype/ttgload.c (TT_Process_Composite_Glyph,
load_truetype_glyph): Updated.
2021-10-07 22:41:56 -04:00
Werner Lemberg b6e8a71266 Update all copyright notices. 2021-01-17 07:18:48 +01:00
Werner Lemberg 4f13a43ab3 * src/cff/cffgload.c (cff_slot_load): Scale `vertBearingY`.
Towards the end of the the function there is a call to
`FT_Outline_Get_CBox` that retrieves the glyph bbox in scaled units.
That sets `horiBearing{X,Y}` and `vertBearingX` but `vertBearingY`
is left alone, and is not scaled.

Patch from Eric Muller <emuller@amazon.com>.
2020-09-24 09:35:24 +02: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
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
Werner Lemberg a9af691481 Fix handing of `FT_Bool'.
Before this commit we had code like

  (FT_Bool)( globals->glyph_styles[gindex] & 0x8000)

Since `FT_Bool' is defined to be an `unsigned char', the code
evaluated to something like

  (unsigned char)( 0x8532 & 0x8000)

which in turn expanded to

  (unsigned char)( 0x8000)

and finally yielded 0x00 – i.e., false – not as expected.

Problem reported and analyzed by Tony Smith <tony.smith@macro4.com>.

* include/freetype/fttypes.h (FT_BOOL): Add a comparison against
zero so that we always have a Boolean expression.

*/*: Replace castings to `FT_Bool' with calls to `FT_BOOL' where
possible.
2018-09-25 09:10:09 +02:00
Werner Lemberg a0dd16fb3d Don't use `trace_' prefix for FT_COMPONENT arguments.
* include/freetype/internal/ftdebug.h (FT_TRACE_COMP,
FT_TRACE_COMP_): New auxiliary macros to add `trace_' prefix.
(FT_TRACE): Use `FT_TRACE_COMP'.

*/* (FT_COMPONENT): Updated.
2018-08-15 18:13:17 +02:00
Werner Lemberg 14032290bf [cff] Avoid left-shift of negative numbers (#54322).
* src/cff/cffgload.c (cff_slot_load): Use multiplication.
2018-07-20 06:44:13 +02: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 0a0c22569d Update copyright year. 2018-01-02 09:33:57 +01:00
Werner Lemberg 98ba0c4a37 New `ftdriver.h' file, covering all driver modules.
This reduces redundancy and increases synergy; it also reduces the
number of header files.

* include/freetype/config/ftheader.h (FT_DRIVER_H): New macro.
(FT_AUTOHINTER_H, FT_CFF_DRIVER_H, FT_TRUETYPE_DRIVER_H,
FT_PCF_DRIVER_H, FT_TYPE1_DRIVER_H): Make them aliases to
FT_DRIVER_H.

* include/freetype/ftautoh.h, include/freetype/ftcffdrv.h,
include/freetype/ftpcfdrv.h, include/freetype/ftt1drv.h,
include/freetype/ftttdrv.h: Replaced with...
* include/freetype/ftdriver.h: ...this new file.
(FT_CFF_HINTING_ADOBE, FT_T1_HINTING_ADOBE): Renamed to...
(FT_HINTING_ADOBE): ... this new macro.
(FT_CFF_HINTING_FREETYPE, FT_T1_HINTING_FREETYPE): Renamed to...
(FT_HINTING_FREETYPE): ... this new macro.

* src/*/*: Updated accordingly.
2017-12-08 18:41:49 +01:00
Werner Lemberg 9b549fa69a [base,cff,cid] Whitespace, formatting. 2017-10-01 00:41:07 +02:00
Ewald Hew ebb1735aa7 Move `psdecode' into `psobjs'.
As the former only contains a single procedure, move it into
`psobjs' for simplicity.  Also change the parameter order to the
conventional one.

* src/psaux/psdecode.c (ps_decoder_init): Moved to...
* src/psaux/psobjs.c: ...Here.
* src/psaux/psdecode.h, src/psaux/psobjs.h: Ditto.

* include/freetype/internal/psaux.h (PSAux_ServiceRec): Update
`ps_decoder_init' function signature.

* src/cff/cffgload.c, src/cid/cidgload.c, src/type1/t1gload.c:
Update calls.

* src/psaux/psaux.c, src/psaux/psauxmod.c: Update includes.

* src/psaux/Jamfile (_sources), src/psaux/rules.mk (PSAUX_DRV_SRC):
Update file references.
2017-09-25 09:26:59 +02:00
Ewald Hew 645d1b86ad Move and rename `CFF_Driver'.
This is so that we can use the same hinting engine parameters for
Type 1.

* include/freetype/internal/cffotypes.h (CFF_Driver): Rename and
move to...
* include/freetype/internal/psaux.h (PS_Driver): ...here.

* src/cff/cffdrivr.c, src/cff/cffgload.c, src/cff/cffload.c,
src/cff/cffobjs.c, src/cff/cffobjs.h, src/psaux/psft.c,
src/psaux/psobjs.c: Update references.
2017-09-25 09:26:59 +02:00
Ewald Hew 0589e3c012 Use the new objects.
* include/freetype/internal/psaux.h, src/psaux/psauxmod.c: Fix
switching between new and old engines.

* src/cff/cffgload.c, src/cff/cffparse.c: Update calls.

* src/psaux/psblues.c, src/psaux/psfont.c, src/psaux/psfont.h,
src/psaux/psft.c, src/psaux/psft.h, src/psaux/psintrp.c: Update all
to use new objects.
2017-09-25 09:26:59 +02:00
Ewald Hew df11628b76 Move struct declarations to `freetype/internal'.
NOTE: Does not compile!

This is so that the CFF functions moved to `psaux' can access the
same structs that they need.

* src/cff/cfftypes.h: Moved to...
* include/freetype/internal/cfftypes.h: ...Here.

* src/cff/cffobjs.h: Moved the struct declarations to...
* include/freetype/internal/cffotypes.h: ... this new file.

* include/freetype/internal/internal.h (FT_INTERNAL_CFF_TYPES_H,
FT_INTERNAL_CFF_OBJECT_TYPES_H): New macros.

* src/cff/cffcmap.h, src/cff/cffdrivr.c, src/cff/cffgload.c,
src/cff/cffgload.h, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.h, src/psaux/psobjs.h,
include/freetype/internal/psaux.h,
include/freetype/internal/services/svcfftl.h: Update includes.

* src/cff/rules.mk (CFF_DRV_H): Updated.
2017-09-25 09:26:59 +02:00
Ewald Hew 9578e07a83 Add callbacks for inter-module calls.
NOTE: Does not compile!

* include/freetype/internal/psaux.h: Add function pointer
declarations.

* src/psaux/cffdecode.c (cff_decoder_init): Update to take in
callbacks.
* src/psaux/cffdecode.h: Ditto.

* src/cff/cffgload.c (cff_compute_max_advance, cff_slot_load):
Update calls to pass in callbacks.
* src/psaux/cf2ft.c, src/psaux/cffdecode.c: Use them.
2017-09-25 09:26:59 +02:00
Ewald Hew 1487be586e Create new `PSAux' service interface entries.
NOTE: Does not compile!

* include/freetype/internal/psaux.h: Include
FT_INTERNAL_TRUETYPE_TYPES_H.
(CFF_Builder_FuncsRec, CFF_Decocer_FuncsRec): New function tables.
(CFF_Builder): Updated.
Fix for forward declaration.
(PSAux_ServiceRec): New field `cff_decoder_funcs'.

* src/psaux/psauxmod.c (cff_builder_funcs, cff_decoder_funcs): New
function tables.
(PSAux_Interface): Updated.

* include/freetype/internal/tttypes.h (TT_FaceRec): Add `psaux'
service interface.

* src/cff/cffgload.c, src/cff/cffobjs.c, src/cff/cffparse.c: Update
function calls to use psaux service.
2017-09-25 09:26:59 +02:00
Ewald Hew 816c9c1f83 Move CFF builder components into `psaux' module.
NOTE: Does not compile!

* src/cff/cffgload.c
(cff_builder_{init,done,add_point,add_point1,add_contour,start_point,close_contour},
cff_check_points): Move to...
* src/psaux/psobjs.c: Here.

* src/cff/cffgload.h: Move corresponding declarations to
`src/psaux/psobjs.h'.

* src/cff/cffgload.h (CFF_Builder): Move struct declaration to...
* include/freetype/internal/psaux.h: Here.
2017-09-25 09:26:59 +02:00
Ewald Hew 705bbe7c7b Move CFF decoder components into `psaux' module.
NOTE: Does not compile!

* src/cff/cffgload.c (CFF_Operator,
CFF_COUNT_{CHECK_WIDTH,EXACT,CLEAR_STACK}, cff_argument_counts,
cff_operator_seac, cff_compute_bias,
cff_lookup_glyph_by_stdcharcode,
cff_decoder_{parse_charstrings,init,prepare}): Move to...
* src/psaux/cffdecode.c: This new file.

* src/cff/cffgload.h: Move corresponding declarations to...
* src/psaux/cffdecode.h: This new file.

* src/cff/cffgload.h (CFF_MAX_{OPERANDS,SUBRS_CALLS,TRANS_ELEMENTS},
CFF_Decoder_Zone, CFF_Decoder): Move declarations to...
* include/freetype/internal/psaux.h: Here.

* src/psaux/cf2ft.h: Update include.

* src/psaux/psaux.c, src/psaux/rules.mk (PSAUX_DRV_SRC): Update with
the new file.
2017-09-25 09:26:59 +02:00
Ewald Hew 62f095f046 [psaux, cff] Move Adobe's engine components into `psaux' module.
This is the first patch of a sequence to move the Type 2 charstring
processing capability from the `cff' module to the `psaux' module.

NOTE: Does not compile!

* src/cff/cf2*: Move these files to...
* src/psaux/cf2*: Here.

* src/cff/Jamfile (_sources), src/cff/rules.mk (CFF_DRV_SRC,
CFF_DRV_H), src/cff/cff.c, src/cff/cffgload.c: Remove file
references.

* src/psaux/Jamfile (_sources), src/psaux/rules.mk, src/psaux/psaux.c
(PSAUX_DRV_SRC, PSAUX_DRV_H): Add file references.
2017-09-25 09:25:55 +02:00
Werner Lemberg dcd8de272f */*: Remove `OVERFLOW_' prefix.
This increases readability.
2017-06-09 11:21:58 +02:00
Werner Lemberg 9b710cd56e [cff] 32bit integer overflow run-time errors 1/2 (#46149).
This commit handles the old engine.

* src/cff/cffgload.c: Include FT_INTERNAL_CALC_H.
(cff_decoder_parse_charstrings): Use OVERFLOW_ADD_LONG and
OVERFLOW_SUB_LONG where needed.

* src/cff/cffparse.c: Include FT_INTERNAL_CALC_H.
(power_ten_limits): New static array.
(do_fixed): Use it to prevent multiplication overflow.
(cff_parser_run): Use OVERFLOW_ADD_LONG.
2017-05-30 22:35:41 +02:00
Werner Lemberg 5412d8869b Introduce `FT_Size_InternalRec' structure.
We are going to extend this later on.

* include/freetype/internal/ftobjs.h (FT_Size_InternalRec): New
structure with a single field `module_data'.

* src/base/ftobjs.c (FT_New_Size): Allocate `internal' field of
`FT_Size' structure.

* src/cff/cffgload.c (cff_builder_init, cff_decoder_prepare): Use
`size->internal->module_data' instead of `size->internal'.

* src/cff/cffobjs.c (cff_size_done): Deallocate `module_data'.
(cff_size_init, cff_size_select, cff_size_request): Use
`size->internal->module_data' instead of `size->internal'.

* src/cif/cidobjs.c (cid_size_done, cid_size_init,
cid_size_request): Use `size->internal->module_data' instead of
`size->internal'.

* src/psaux/psobjs.c (t1_builder_ini): Use
`size->internal->module_data' instead of `size->internal'.

* src/type1/t1objs.c (T1_Size_Done, T1_Size_Init, T1_Size_Request):
Use `size->internal->module_data' instead of `size->internal'.
2017-04-22 12:48:50 +02:00
Werner Lemberg dd64a6227c * src/cff/cffgload.c (cff_builder_init): Add safety guard (#50578). 2017-03-20 05:34:02 +01:00
Werner Lemberg e706798d43 [cff] Finish support for `random' operator.
* src/cff/cfftypes.h (CFF_SubFontRec): Add `random' field.

* src/cff/cffobjs.c: Updated.
(cff_driver_init): Initialize random seed value.

* src/cff/cffload.c (cff_random): New function.
(cff_subfont_load): Add `face' argument.
Update all callers.
Initialize random number generator with a proper seed value.
(cff_font_load): Add `face' argument.
Update all callers.

* src/cff/cffload.h: Updated.

* src/cff/cf2intrp.c (CF2_FIXME): Removed.
(cf2_interpT2CharString) <cf2_escRANDOM>: Implement opcode.

* src/cff/cffgload.c (cff_decoder_parse_charstrings): Don't
initialize random seed value.
<cff_op_random>: Use new random seed framework.
2017-02-20 09:15:13 +01:00
Werner Lemberg 563ae78022 Update copyright year. 2017-01-04 20:16:34 +01:00
Werner Lemberg 84b0d9927b */*: Use `0.5f' for tracing 16.16 numbers. 2016-12-29 10:38:51 +01:00
Werner Lemberg 37c72f66a5 Minor formatting. 2016-12-25 22:55:25 +01:00
Werner Lemberg 2ecf89b481 */*: s/FT_MEM_ZERO/FT_ZERO/ where appropriate. 2016-09-28 19:06:21 +02:00
Werner Lemberg bffe5fd6e4 [cff] Minor comment. 2016-08-28 13:16:37 +02:00
Werner Lemberg 8ed9eaf1cc [cff] Partially handle `load' and `store' ops in old CFF engine.
Now all glyphs of MM CFFs like `ITCGaramondMM-It.otf' can be
displayed.

* src/cff/cffgload.c (cff_decoder_parse_charstrings) <cff_op_store,
cff_op_load>: Partially implement it.

* src/cff/cffparse.c (cff_parser_init): Add new parameter to pass
the number of Multiple Master axes.
Update all callers.
(cff_parse_multiple_master): Get number of axes.
(cff_parser_run) <opcode 31>: Updated.
* src/cff/cffparse.h: Updated.
(CFF_ParserRec): Add `num_axes' field.

* src/cff/cffload.c: Updated.

* src/cff/cfftypes.h (CFF_FontRecDictRec): Add `num_axes' field.
2016-02-15 20:41:58 +01:00
Werner Lemberg 3295039107 Whitespace. 2016-02-15 12:54:40 +01:00
Werner Lemberg 813aca51d2 [cff] Make old CFF engine show MM CFFs (without variations).
The new code only displays the first master in the font.

* src/cff/cffgload.c (cff_decode_parse_charstrings): Add new
parameter to allow function calls from dictionaries also.
<cff_op_blend>: Partially implement it.
Update all callers.
* src/cff/cffgload.h: Updated.

* src/cff/cffparse.c (cff_parser_init): Add new parameter to pass the
number of Multiple Master designs.
Update all callers.
(cff_parse_multiple_master): New function to rudimentarily parse
operator.
(cff_parser_run): Handle `T2' operator.
* src/cff/cffparse.h: Updated.
(CFF_ParserRec): Add `num_designs' field.

* src/cff/cffload.c: Updated.

* src/cff/cfftoken.h: Handle `MultipleMaster' operator.

* src/cff/cfftypes.h (CFF_FontRecDictRec): Add `num_designs' field.

* src/sfnt/sfobjs.c (sfnt_init_face): Don't handle `fvar' table for
MM CFFs.
2016-02-14 16:03:15 +01:00
Werner Lemberg a1460704d9 [cff] Minor.
* src/cff/cffgload.c (cff_decoder_parse_charstrings) <cff_op_sqrt>:
Remove dead code.
2016-02-07 11:42:37 +01:00
Werner Lemberg 5c8a8cb54c [cff] Fix some Type 2 operators in old CFF engine.
* src/cff/cffgload.c (cff_decoder_parse_charstrings): Fix `eq'
operator, add `not' and (unsupported) `blend' operators.
2016-02-06 08:03:03 +01:00
Werner Lemberg 9adeab6452 Update copyright year. 2016-01-13 11:54:10 +01:00
Alexei Podtelezhnikov 4a46686508 [type1,cff,cid] Streamline font matrix application.
* src/type1/t1gload.c (T1_Load_Glyph): Directly modify advances only
if font matrix is not trivial.
* src/cff/cffgload.c (cff_slot_load): Ditto.
* sff/cid/cidgload.c (cid_slot_load_glyph): Ditto for advances and the
entire outline.
2015-08-12 23:45:40 -04:00
Matthias Clasen b650dfbb0b [cff] Don't use `hmtx' table for LSB (#45520).
* src/cff/cffgload.c (cff_slot_load): Use `htmx' table for advance
width only.  Bug introduced 2015-04-10.
2015-07-26 21:08:34 +02:00
Alexei Podtelezhnikov 792db0b9a9 [cff,cid,pfr,sfnt,winfonts] NULL. 2015-04-15 23:20:23 -04:00
Werner Lemberg 5cd2155113 [cff] Update advance width handling to OpenType 1.7.
Problem reported by Behdad.

* src/cff/cffdrivr.c (cff_get_advances): Handle SFNT case
separately.

* src/cff/cffgload.c (cff_slot_load): Use advance width and side
bearing values from `hmtx' table if present.
2015-04-10 07:01:01 +02:00
Werner Lemberg 8ce3026304 [cff] Trace charstring nesting levels.
* src/cff/cf2intrp.c (cf2_interpT2CharString) <cf2_cmdCALLGSUBR,
cf2_cmdCALLSUBR, cf2_cmdRETURN>: Implement it.

* src/cff/cffgload.c (cff_decoder_parse_charstrings)
<cff_op_callsubr, cff_op_callgsubr, cff_op_return>: Ditto.
2015-03-27 08:33:47 +01:00
Werner Lemberg 633a729d38 [cff] Minor signedness fixes related to last commit.
* src/cff/cf2ft.c, src/cff/cf2intrp.c, src/cff/cffgload.c: Apply.
2015-02-21 07:02:01 +01:00
Werner Lemberg c00b05f202 [cff] Thinkos in bias handling.
Only the final result is always positive.

Bug introduced three commits earlier.

* src/cff/cffgload.c, src/cff/cffgload.h: Apply.
2015-02-20 20:42:55 +01:00
Werner Lemberg 3a8d0537b5 [cff] Signedness fixes for basic infrastructure and old engine.
* include/internal/pshints.h, src/cff/cffdrivr.c,
src/cff/cffgload.c, src/cff/cffgload.h, src/cff/cffload.c,
src/cff/cffobjs.c, src/cff/cffparse.c, src/pshinter/pshrec.c: Apply.
2015-02-20 08:35:32 +01:00
Werner Lemberg f57fc59e01 Run `src/tools/update-copyright'. 2015-01-17 20:41:43 +01:00
Werner Lemberg de43ace7a3 * include/*: Improve structure of documentation.
. Add and update many `<Order>' tags.
. Apply various documentation fixes.
. Remove details to deprecated (or never implemented) data.
2014-12-02 23:06:04 +01:00