Commit Graph

783 Commits

Author SHA1 Message Date
Moazin Khatti b84ae3420a Minor doc and styling improvements. 2019-08-26 01:17:15 +05:00
Moazin Khatti 4d24f52ead [sfnt,svg] Fix includes to allow a `multi' build. 2019-08-26 01:17:15 +05:00
Moazin Khatti 3f6f939378 Adds transform support for OT-SVG glyphs. 2019-08-26 01:17:14 +05:00
Moazin Khatti 22d7c8578f Minor name change.
`svgrender.h' -> `otsvg.h'
`FT_SVG_RENDER_H' -> `FT_OTSVG_H'
Since `svgrender.h' contains just the hooks and the SVG document
structure it's probably just better to name it something general
like `otsvg.h'.
2019-08-26 01:17:14 +05:00
Moazin Khatti 5f5a56a0cc Minor. Fixes a silly mistake. 2019-08-26 01:17:14 +05:00
Moazin Khatti b122db0953 Fix TODOs. 2019-08-26 01:17:14 +05:00
Moazin Khatti 168a8f8fe0 Makes some helper functions `static'. 2019-08-26 01:17:14 +05:00
Moazin Khatti 74f80fba49 No need to call `FT_Load_Glyph' with `XX_NO_SCALE'.
We no longer need TTF/CFF outlines for SVG rendering.
2019-08-26 01:17:14 +05:00
Moazin Khatti 398801e2c0 Revert "Performs basic checks to see if SVG data is valid or not."
This reverts commit e5dc1b65cdc7ea357118fddbdb4b00afc403f81c.
These aren't necessary.
2019-08-26 01:17:14 +05:00
Moazin Khatti 0e8e132bd7 Performs basic checks to see if SVG data is valid or not. 2019-08-26 01:17:14 +05:00
Moazin Khatti d7f6f8b16d Tracing implemented for OT-SVG code. 2019-08-26 01:17:14 +05:00
Moazin Khatti 2cef19641a Remove the TODO since I have implemented binary search. 2019-08-26 01:17:14 +05:00
Moazin Khatti faa495befc Remove the unused variable. 2019-08-26 01:17:14 +05:00
Moazin Khatti ba9e6f9d41 Implement binary search for SVG Document Lookup. 2019-08-26 01:17:14 +05:00
Moazin Khatti 6962986cf3 Created `Svg_doc' private struct.
Inside the SVG Document List, four fields exist. It's
better to create a struct to hold at one place instead
of 4 variables. Also created `compare_svg_doc' which
will be helpful in writing binary search later.
2019-08-26 01:17:14 +05:00
Moazin Khatti 3b62e9dc9d Added `FT_CONFIG_OPTION_SVG'. 2019-08-26 01:17:07 +05:00
Moazin Khatti c6a6859ad9 Better naming used. 2019-08-17 20:36:05 +05:00
Moazin Khatti e028be97b8 Minor fixes. 2019-08-17 20:36:05 +05:00
Moazin Khatti d8202166c0 Add `start_glyph_id' and `end_glyph_id'.
These two fields are added to `FT_SvgGlyphRec' and
`FT_SVG_DocumentRec'. This is to allow the rendering port to create
a caching mechanism.
2019-08-17 20:36:05 +05:00
Moazin Khatti e48cf716f8 Add a `units_per_EM' field.
A field `units_per_EM' is added to `FT_SVG_DocumentRec' and
`FT_SvgGlyphRec'. This is needed because the renderer needs this
info to properly scale the SVGs if the viewbox width and height
differ from `face->units_per_EM'. Face object can't be accessed
because of the restrictions put by `FT_Glyph_To_Bitmap' thus this
has to be provided separately just like `metrics'.
2019-08-17 20:36:05 +05:00
Moazin Khatti 7275d6562f Do proper memory freeing to prevent leaks.
* include/freetype/internal/ftobjs.h: Create a new flag named
`FT_GLYPH_OWN_GZIP_SVG' to indicate that `svg_document' in
`slot->other' is GZIP compressed and has to be freed later.

* src/base/ftglyph.c: Minor styling.

* src/base/ftobjs.c: Add code to free memory that was previously
allocated for storing GZIP compressed SVG documents.

* src/sfnt/ttsvg.c: Set the `FT_GLYPH_OWN_GZIP_SVG' flag if the
document is GZIP compressed.
2019-08-17 20:36:05 +05:00
Moazin Khatti 1073e4cf5c * src/sfnt/ttsvg.c (tt_face_load_svg_doc): Minor fix. Don't return
immediately in case of Gzip compressed SVG documents.
2019-08-17 20:36:05 +05:00
Moazin Khatti 6a39dd0b16 Properly free memory of SVG document referenced in `slot->other'.
* include/freetype/freetype.h: Add `FT_FACE_FLAG_SVG' to indicate
the presence of an SVG table in the face.

* src/base/ftobjs.c (ft_glyphslot_init): Allocate memory for
`FT_SVG_Document' in `slot->other' if an SVG table exists in the
face.
(ft_glyphslot_clear): Clear `slot->other' only if the font doesn't
have an SVG table.
(ft_glyphslot_done): Free the memory at `slot->other' if the face
has an SVG table.

* src/base/ttsvg.c (tt_face_load_svg): Set `FT_FACE_FLAG_SVG'.
(tt_face_load_svg_doc): Don't allocate the memory.
2019-08-17 20:36:05 +05:00
Moazin Khatti d1a0615f00 Minor changes.
* src/base/ftobjs.c (FT_Load_Glyph): Use the recrusive call with
`FT_LOAD_NO_SCALE' so that the loaded data is unscaled.

* src/base/ftobjs.c (FT_Render_Glyph_Internal): Change the format
to bitmap once an SVG glyph is successfully rendered.

* src/sfnt/ttsvg.c (tt_face_load_svg_doc): Make sure metrics are
grabbed. Scale `horiAdvance' and `vertAdvance' properly and
convert them to 26.6 format.
2019-08-17 20:36:05 +05:00
Moazin Khatti 0bf6444911 [ot-svg] Create an SVG Document structure for use in `other' field
of `FT_GlyphSlot'.
2019-08-17 20:36:05 +05:00
Moazin Khatti 877736d057 Removes trailing white spaces. 2019-08-17 20:36:05 +05:00
Moazin Khatti 9a55001454 Minor. Better documentation. Adds TODOs for letter. 2019-08-17 20:36:05 +05:00
Moazin Khatti b9734fd870 Very crude way to handle SVG data with only TTF outlined OT fonts. Gonna revert soon. 2019-08-17 20:36:05 +05:00
Moazin Khatti 9b7c3d1df9 Created Svg type and the load/free funcs inside sfnt interface 2019-08-17 20:36:05 +05:00
Werner Lemberg b110acba9e [sfnt, winfonts] Avoid memory leaks in case of error (#56587).
* src/sfnt/sfwoff.c (woff_open_font): Call `FT_FRAME_EXIT' in case
of error.

* src/winfonts/winfnt.c (fnt_face_get_dll_font): Ditto.
2019-07-12 11:36:12 +02:00
Nikhil Ramakrishnan 7b275a5af1 [sfnt] Separate WOFF sources and headers.
Move WOFF sources and headers to separate files.

* include/freetype/internal/wofftypes.h, src/sfnt/sfwoff.c,
src/sfnt/sfwoff.h: New files.

* include/freetype/internal/fttrace.h: Register `sfwoff.c'.

* include/freetype/internal/internal.h: Define
FT_INTERNAL_WOFF_TYPES_H.

* include/freetype/internal/sfnt.h: Include FT_INTERNAL_WOFF_TYPES_H.

* include/freetype/internal/tttypes.h: Move out WOFF structures.

* src/sfnt/rules.mk: Add `sfwoff.c'.

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

* src/sfnt/sfobjs.c: Include `sfwoff.h', move out WOFF sources.
2019-05-30 23:57:34 +05:30
Werner Lemberg 9159128a92 Silence gcc 7's fall-through warnings in `switch' blocks.
Instead of an intentionally missing `break' statement there must be a
comment line containing `fall through' (and nothing else) right before the
next `case' statement.

See

  https://stackoverflow.com/questions/45129741/gcc-7-wimplicit-fallthrough-warnings-and-portable-way-to-clear-them
2019-05-29 07:51:59 +02:00
Nikhil Ramakrishnan e55f969869 * src/sfnt/sfobjs.h: Minor. 2019-05-25 20:56:54 +05:30
Werner Lemberg 7b84104720 Various clang 8.0 static analyzer fixes.
Reported by Sender Ghost <lightside@gmx.com>.

* src/autofit/afcjk.c (af_cjk_hints_compute_edges): Catch a corner
case where `edge->first' could be NULL.

* src/pfr/pfrobjs.c (pfr_slot_load): Remove unnecessary test of
`size'.

* src/raster/ftraster.c (Draw_Sweep): Catch a corner case where
`draw_right' might be NULL.

* src/sfnt/ttmtx.c (tt_face_get_metrics): Fix limit test for
`aadvance'.
Ensure `abearing' always hold a meaningful result.

* src/truetype/ttgload.c (load_truetype_glyph): Ensure `subglyph' is
not NULL before accessing it.
* src/truetype/ttgxvar.c (TT_Set_Named_Instance): Remove unnecessary
test of `namedstyle'.

* src/type42/t42parse.c (t42_parser_done): Ensure
`parser->root.funcs.done' is not NULL before accessing it.
2019-05-04 08:13:22 +02:00
Werner Lemberg 6abce2c2b0 * src/sfnt/ttcmap.c (tt_cmap12_next): Remove dead code.
Found by clang 8.0's static analyzer and reported by Sender Ghost
<lightside@gmx.com>.
2019-04-23 06:52:07 +02:00
Werner Lemberg 885b4c2475 * src/sfnt/ttcmap.c (tt_get_glyph_name): Pacify compiler (#56061).
This is for Visual Studio 2019 on ARM.
2019-04-06 07:07:37 +02:00
Antony Lee 3ad1c93ac1 Make `glyph_name' parameter to `FT_Get_Name_Index' a `const'.
* include/freetype/freetype.h (FT_Get_Name_Index),
include/freetype/internal/ftobjs.h (FT_Face_GetGlyphNameIndexFunc),
include/freetype/internal/services/svgldict.h
(FT_GlyphDict_NameIndexFunc), src/base/ftobjs.c (FT_Get_Name_Index),
src/cff/cffdrivr.c (cff_get_name_index), src/sfnt/sfdriver.c
(sfnt_get_name_index), src/type1/t1driver.c (t1_get_name_index),
src/type42/t42drivr.c (t42_get_name_index): Add `const' to second
argument.
2019-04-06 06:38:16 +02:00
Werner Lemberg 7585997024 Update all copyright notices. 2019-02-23 10:07:09 +01:00
Nikolaus Waxweiler f72b00746c [sfnt] Use typo metrics if OS/2 fsSelection USE_TYPO_METRICS bit is set.
If the OS/2 table exists and fsSelection bit 7 (USE_TYPO_METRICS) is set,
use the sTypo* set of values to compute the FT_Face's ascender, descender
and height. Otherwise, fall back to old behavior.

* src/sfnt/sfobjs.c (sfnt_load_face): Implement.
2019-02-02 15:45:31 +00:00
Werner Lemberg f686ad46a3 Update copyright years. 2019-01-22 20:31:44 +01:00
John Tytgat f61f49fef7 [sfnt] Handle TT fonts having two PostScript font names (#55471).
* src/sfnt/sfdriver.c (sfnt_get_name_id): Prefer English over any
other language found for PostScript font names.
2019-01-18 13:25:23 +01:00
Alexei Podtelezhnikov 3e8ec291ff [sfnt] Make `head' timestamps unsigned.
It's been more than 2^31 seconds since 1904.

* include/freetype/tttables.h (TT_Header): Change field types.
* src/sfnt/ttload.c (tt_face_load_generic_header): Updated.
2018-10-26 23:23:48 -04:00
Werner Lemberg 912e174c66 A missing Unicode cmap is not a fatal error.
This is a follow-up to the previous commit.

* src/cff/cffobjs.c (cff_face_init), src/sfnt/sfobjs.c
(sfnt_load_face), src/type1/t1objs.c (T1_Face_Init),
src/type42/t42objs.c (T42_Face_Init): Implement it.
2018-10-07 09:28:52 +02:00
Werner Lemberg 885f5b0b4e Fix handling of FT_CONFIG_OPTION_ADOBE_GLYPH_LIST (#54794).
* src/cff/cffcmap.c (cff_cmap_unicode_init), src/psaux/t1cmap.c
(t1_cmap_unicode_init), src/sfnt/ttcmap.c (tt_cmap_unicode_init):
Check `unicodes_init' field.
2018-10-07 09:03:05 +02:00
Werner Lemberg de0aabcd0d [sfnt] Comment fix. 2018-09-15 06:14:18 +02:00
Werner Lemberg 7665914ccd * src/sfnt/sfdriver.c (sfnt_get_var_ps_name): Fix last commit. 2018-09-13 08:58:49 +02:00
Werner Lemberg a5818ed1e1 * src/sfnt/sfdriver.c (sfnt_get_var_ps_name): Check `result'.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10316
2018-09-13 08:46:44 +02:00
John Tytgat 6b53300b01 [sfnt] Better PS name handling (#54629).
* src/sfnt/sfdriver (IS_WIN, IS_APPLE): Omit language ID checks.
(get_win_string, get_apple_string): Return NULL when the PostScript
font name characters is not according to specification.
(get_win_string): Make trace output work if the high byte if
non-zero.
(sfnt_get_var_ps_name, sfnt_get_ps_name): Previously we preferred
Win PS name (when there is also an Apple PS name); change this into
a fallback to Apple PS name in case the Win PS name is invalid.
2018-09-12 08:08:09 +02:00
Werner Lemberg fea435fbf8 [sfnt] Comment improvement. 2018-09-09 09:46:29 +02:00
Werner Lemberg 76a52465c1 */*: s/PSNames/psnames/.
Only tracing messages are affected.
2018-09-03 09:08:47 +02:00