Commit Graph

133 Commits

Author SHA1 Message Date
Priyeshkkumar b528826f69 Merging master branch with priyeshLogLibrary branch 2020-07-28 13:43:28 +05:30
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
Alexei Podtelezhnikov afaf3f1de9 [bdf,pcf] Use `const' for string literals.
* src/bdf/bdf.h (bdf_property_t): Updated `name'.
* src/bdf/bdflib.c (_bdf_list_split,bdf_create_property,
_bdf_add_property,_bdf_ato*): Updated.
* src/bdf/bdfdrivr.c (bdf_interpret_style): Updated.
* src/pcf/pcfread.c (pcf_intrpret_style): Ditto.
2019-06-10 22:27:39 -04:00
Werner Lemberg c149f7397e [pcf] Fix handling of undefined glyph (#56067).
This commit fixes the changes from 2018-07-21, which broke charmap
iteration.  We now add the default character as a new glyph with
index 0, thus increasing the number of glyphs by one (as before).

* src/pcf/pcfread.c (pcf_get_metrics): Adjust to new artificial
glyph with index 0.
Limit number of elements to 65534.
(pcf_get_bitmaps): Ditto.
Unify two loops into one; this avoids allocation of an intermediate
array.
(pcf_get_encodings): Don't flip indices but copy glyph metrics of
default character to index 0.
Also handle invalid default character.

* docs/CHANGES: Updated.
2019-04-19 07:02:37 +02:00
Alexei Podtelezhnikov c1b21f47b4 [pcf] Replace charmap implementation.
PCF comes with charmap lookup table, aka PCF encodings.  Using it
directly makes FT_Get_Char_Index and FT_Get_Next_Char 4-5 times
faster than the original BDF-like binary searches.

* src/pcf/pcf.h (PCF_EncodingRec): Removed.
(PCF_FaceRec): Remove `nencodings' and `encodings'.
* src/pcf/pcfdrivr.c (pcf_cmap_char_{index,next}): Replaced.
* src/pcf/pcfread.c (pcf_get_encodings): Store data differently.
2018-09-20 22:14:46 -04:00
Alexei Podtelezhnikov 7f93c977e7 [pcf] Prepare to replace charmap implementation.
* src/pcf/pcf.h (PCF_Face): Updated to include...
(PCF_EncRec): ... this new structure to store charmap geometry.

* src/pcf/pcfread.c (pcf_get_encodings): Store charmap geometry.
2018-09-19 22:45:45 -04: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
Alexei Podtelezhnikov 6a97c95800 [pcf] Revert massive unsigning. 2018-08-08 22:17:35 -04:00
Alexei Podtelezhnikov c633378a5e [pcf] Massive unsigning (part 2).
Treat all size related properties as unsigned values.

* src/pcf/pcf.h (PCF_ParsePropertyRec): Use unsigned `name' and
`value'.
* src/pcf/pcfread.c (pcf_get_propeerties, pcf_load_font): Updated
parsing code and handling of AVERAGE_WIDTH, POINT_SIZE, PIXEL_SIZE,
RESOLUTION_X and RESOLUTION_Y.
2018-08-08 01:21:54 -04:00
Alexei Podtelezhnikov 3d4ab6bac1 [pcf] Massive unsigning (part 1).
Unofficial specifications hesitate to use unsigned 32-bit integers.
Negative values caused a lot of trouble in the past and it is safer
and easier to treat some properties as unsigned.

* src/pcf/pcf.h (PCF_AccelRec): Use unsigned values for `fontAscent',
`fontDescent', and `maxOverlap'.
* src/pcf/pcfread.c (pcf_load_font, pcf_get_accel): Updated.
* src/pcf/pcfdrivr.c (PCF_Glyph_Load, PCF_Size_Select,
PCF_Size_Request): Updated.
2018-08-08 00:09:16 -04:00
Alexei Podtelezhnikov 705bac50d3 * src/pcf/pcfread.c (pcf_get_bitmaps): Unsign `offsets' and `bitmapSizes'. 2018-08-07 22:49:55 -04:00
Alexei Podtelezhnikov f24dbb2811 [pcf] Use unsigned types.
* src/pcf/pcf.h (PCF_Encoding): Use unsigned `enc'.
* src/pcf/pcfdrivr.c (pcf_cmap_char_{index,next}): Ditto.
* src/pcf/pcfread.c (pcf_get_encodings): Use unsigned types.
2018-08-06 04:58:18 -04:00
Werner Lemberg 799d27b0b6 Fix clang warnings.
* src/base/ftoutln.c (FT_Outline_EmboldenXY): Fix type of
`orientation'.

* src/gxvalid/gxvcommn.c (gx_lookup_value_read): Fix signature.

* src/pcf/pcfread.c (pcf_get_encodings): Fix type of some variables.
Add cast.

* src/type1/t1load.c (parse_weight_vector): Fix cast.
2018-08-04 06:39:11 +02:00
Werner Lemberg 00968d8fd6 * src/pcf/pcfread.c (pcf_get_encodings): Another thinko.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9608
2018-07-29 10:22:59 +02:00
Werner Lemberg ff1c28f6c0 * src/pcf/pcfread.c (pcf_get_encodings): Thinko.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9561
2018-07-24 09:59:23 +02:00
Werner Lemberg b98133a4e9 * src/pcf/pcfread.c (pcf_get_encodings): Check index of defaultChar.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9527
2018-07-22 13:06:20 +02:00
Werner Lemberg 9be385c94d * src/pcf/pcfread.c (pcf_load_font): Fix number of glyphs.
This is an oversight of the module change 2018-07-21.

Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9524
2018-07-22 12:49:25 +02:00
Werner Lemberg cba72a0b0f [pcf] Fix handling of the undefined glyph.
This change makes the driver use the `defaultChar' property of PCF
files.

* src/pcf/pcf.h (PCF_FaceRec): Change type of `defaultChar' to
unsigned.

* src/pcf/pcfread.c (pcf_get_encodings): Read `defaultChar' as
unsigned.
Validate `defaultChar'.
If `defaultChar' doesn't point to glyph index zero, swap glyphs with
index zero and index `defaultChar' and adjust the encodings
accordingly.

* src/pcf/pcfdrivr.c (pcf_cmap_char_index, pcf_cmap_char_next,
PCF_Glyph_Load): Undo change from 2002-06-16 which always enforced
the first character in the font to be the default character.
2018-07-21 23:45:32 +02:00
Werner Lemberg 9e69987aaa * src/pcf/pcfread.c (pcf_get_encodings): Trace `defaultChar'. 2018-07-17 19:54:25 +02:00
Parth Wazurkar 89d2f42918 [bdf, pcf] Removed deprecated FT_FACE_FLAG_FAST_GLYPHS flag.
* src/bdf/bdfdrivr.c (BDF_Face_Init): Removed deprecated FT_FACE_FLAG_FAST_GLYPHS flag.

* src/pcf/pcfread.c  (pcf_load_font): Removed deprecated FT_FACE_FLAG_FAST_GLYPHS flag.
2018-06-06 16:53:54 +05:30
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
Parth Wazurkar fb742477b2 [pcf]Documentation Typo. 2018-05-11 23:27:06 +05:30
Werner Lemberg 71fecc539e Improve tracing messages by using singular and plural forms.
* src/*/*.c: Implement it.
2017-12-05 12:06:29 +01:00
Werner Lemberg f01463297f [pcf] 32bit integer overflow run-time errors (#46149).
* src/pcf/pcfread.c (pcf_get_accel): Add sanity checks for
`fontAscent' and `fontDescent'.
(pcf_load_font): Add sanity checks for global height.
Add sanity checks for AVERAGE_WIDTH, POINT_SIZE, PIXEL_SIZE,
RESOLUTION_X, and RESOLUTION_Y properties.
2017-05-29 21:04:27 +02:00
Werner Lemberg 08fd250e1a [pcf] Make long family names configurable.
The change from 2016-09-29 was too radical (except for people using
the openSuSE GNU/Linux distribution).  To ameliorate the situation,
PCF_CONFIG_OPTION_LONG_FAMILY_NAMES gets introduced which controls
the feature; if set, a new PCF property option
`no-long-family-names' can be used to switch this feature off.

* include/freetype/config/ftoption.h, devel/ftoption.h
(PCF_CONFIG_OPTION_LONG_FAMILY_NAMES): New option.

* include/freetype/ftpcfdrv.h: New header file (only containing
comments currently, used for building the documentation).

* include/freetype/config/ftheader.h (FT_PCF_DRIVER_H): New macro.

* src/pcf/pcf.h (PCF_Driver): Add `no_long_family_names' field.

* src/pcf/pcfdrivr.c: Include FT_SERVICE_PROPERTIES_H and
FT_PCF_DRIVER_H.
(pcf_property_set, pcf_property_get): New functions.
(pcf_service_properties): New service.
(pcf_servives): Updated.
(pcf_driver_init) [PCF_CONFIG_OPTION_LONG_FAMILY_NAMES]: Handle
`no_long_family_names'.

* src/pcf/pcfread.c (pcf_load_font): Handle `no_long_family_names'
and PCF_CONFIG_OPTION_LONG_FAMILY_NAMES.

* docs/CHANGES: Updated.
2017-01-09 11:30:32 +01:00
Werner Lemberg 8b755445bb [pcf] Revise driver.
This commit improves tracing and handling of malformed fonts.  In
particular, the changes to `pcf_get_properties' fix

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=379

* src/pcf/pcfread.c (tableNames): Use long names for better
readability.
(pcf_read_TOC): Allow at most 9 tables.
(pcf_get_properties): Allow at most 256 properties.
Limit strings array length to 256 * (65536 + 1) bytes.
Better tracing.
(pcf_get_metric): Trace metric data.
(pcf_get_metrics): Allow at most 65536 metrics.
Fix comparison of `metrics->ascent' and `metrics->descent' to avoid
potential overflow.
Better tracing.
(pcf_get_bitmaps): Allow at most 65536 bitmaps.
Better tracing.
(pcf_get_encodings, pcf_get_accel): Better tracing.

* src/pcf/pcfdrivr.c (PCF_Glyph_Load): Don't trace `format' details.
These are now shown by `pcf_get_bitmaps'.
2017-01-06 11:47:55 +01:00
Werner Lemberg 346b141762 [pcf] Protect against gzip bombs.
Fix suggested by Kostya; reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=345

* src/pcf/pcfread.c (pcf_read_TOC): Limit number of TOC entries to
1024.
2016-12-29 06:03:40 +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 37c72f66a5 Minor formatting. 2016-12-25 22:55:25 +01:00
Werner Lemberg 5d664b6d51 Use FT_SET_ERROR where useful. Other minor code formatting. 2016-12-17 20:47:42 +01:00
Werner Lemberg 3576487add [pcf] Enrich family name with foundry name and glyph width info.
This is a very old patch from openSuSE (from 2006, submitted to
FreeType in 2011) that I forgot to apply.

  https://build.opensuse.org/package/view_file/openSUSE:Factory/freetype2/freetype2-bitmap-foundry.patch

Prepend the foundry name plus a space to the family name.  There are
many fonts just called `Fixed' which look completely different, and
which have nothing to do with each other.  When selecting `Fixed' in
KDE or Gnome one gets results that appear rather random, the style
changes often if one changes the size and one cannot select some
fonts at all.

We also check whether we have `wide' characters; all put together,
we get family names like `Sony Fixed' or `Misc Fixed Wide'.

* src/pcf/pcfread.c (pcf_load_font): Implement it.

* docs/CHANGES: Document it.
2016-09-30 08:11:52 +02:00
Werner Lemberg 2ecf89b481 */*: s/FT_MEM_ZERO/FT_ZERO/ where appropriate. 2016-09-28 19:06:21 +02:00
Alexei Podtelezhnikov 999bcee2d7 [pcf] Fix handling of very large fonts (#47708).
* src/pcf/pcfread.c (pcf_get_encodings): Make `encodingOffset' an
unsigned short.
Only reject `0xFFFF' as an invalid encoding offset.
2016-06-26 08:27:29 +02:00
Werner Lemberg 3295039107 Whitespace. 2016-02-15 12:54:40 +01:00
Werner Lemberg 58b61b6e05 [pcf] Quickly exit if font index < 0.
Similar to other font formats, this commit makes the parser no
longer check the whole PCF file but only the header and the TOC if
we just want to get the number of available faces (and a proper
recognition of the font format).

* src/pcf/pcfdrivr.c (PCF_Face_Init): Updated.
Exit quickly if face_index < 0.

* src/pcfread.c (pcf_load_font): Add `face_index' argument.
Exit quickly if face_index < 0.

* src/pcf/pcf.h: Updated.
2015-10-13 18:26:18 +02:00
Werner Lemberg d353f6e012 * src/pcf/pcfread.c (pcf_read_TOC): Check stream size (#46162). 2015-10-10 06:54:46 +02:00
Werner Lemberg d98053c997 [pcf] Protect against invalid number of TOC entries (#46159).
* src/pcf/pcfread.c (pcf_read_TOC): Check number of TOC entries
against size of data stream.
2015-10-08 23:17:41 +02:00
Werner Lemberg cb7a5122e1 [pcf] Improve `FT_ABS' fix from 2015-09-17 (#45999).
* src/pcf/pcfread.c (pcf_load_font): Do first the cast to FT_Short,
then take the absolute value.
Also apply FT_ABS to `height'.
2015-09-19 07:58:03 +02:00
Werner Lemberg c838c4f7b5 [pcf] Fix integer overflows (#45985).
* src/pcf/pcfread.c (pcf_load_font): Use FT_MulDiv.
2015-09-17 16:22:40 +02:00
Werner Lemberg 9db9adda0f [pcf] Use FT_ABS for some property values (#45893).
* src/pcf/pcfread.c (pcf_load_font): Take absolute values for
AVERAGE_WIDTH, POINT_SIZE, PIXEL_SIZE, RESOLUTION_X, and
RESOLUTION_Y.  In tracing mode, add warnings.
2015-09-17 13:42:59 +02:00
Werner Lemberg 577daf1c30 * src/pcf/pcfread.c (pcf_load_font): Fix integer overflow (#45964). 2015-09-15 07:10:16 +02:00
Alexei Podtelezhnikov adb08efcf1 [bdf,pcf,truetype] NULL. 2015-04-11 23:54:19 -04:00
Werner Lemberg 03ccfd004f [pcf] Signedness fixes.
* src/pcf/pcf.h, src/pcf/pcfdrivr.c: Apply.
* src/pcf/pcfread.c: Apply.
(pcf_get_encodings): Ignore invalid negative encoding offsets.
2015-02-22 08:25:16 +01:00
Werner Lemberg 06842c7b49 * src/pcf/pcfread.c (pcf_read_TOC): Improve fix from 2014-12-08. 2014-12-13 07:42:51 +01:00
Werner Lemberg 74af85c4b6 [pcf] Fix Savannah bug #43774.
Work around `features' of X11's `pcfWriteFont' and `pcfReadFont'
functions.  Since the PCF format doesn't have an official
specification, we have to exactly follow these functions' behaviour.

The problem was unveiled with a patch from 2014-11-06, fixing issue #43547.

* src/pcf/pcfread.c (pcf_read_TOC): Don't check table size for last
element.  Instead, assign real size.
2014-12-08 16:01:50 +01:00
Werner Lemberg b1fc00d5dc * src/pcf/pcfread.c (pcf_get_metrics): Sanitize invalid metrics. 2014-11-21 12:06:40 +01:00
Werner Lemberg ef1eba7518 Fix Savannah bug #43548.
* src/pcf/pcfread (pcf_get_encodings): Add sanity checks for row and
column values.
2014-11-06 23:25:05 +01:00
Werner Lemberg 0e2f5d518c Fix Savannah bug #43547.
* src/pcf/pcfread.c (pcf_read_TOC): Check `size' and `offset'
values.
2014-11-06 22:32:46 +01:00
Werner Lemberg f49a100a6c * src/pcf/pcfread.c (pcf_read_TOC): Avoid memory leak. 2014-11-06 13:30:28 +01:00