Commit Graph

6709 Commits

Author SHA1 Message Date
Moazin Khatti 03f7b5a6b6 [ot-svg] Renames `svgtypes.c' to `svgtypes.h'.
Also adds an `ifndef' check to prevent loading multiple times.
2019-08-26 01:17:15 +05:00
Moazin Khatti 253d2bad97 [ot-svg] Properly indent module description. 2019-08-26 01:17:15 +05:00
Moazin Khatti e54fbbf283 [ot-svg] Bug fix. 2019-08-26 01:17:15 +05:00
Moazin Khatti b6f04b03e4 [ot-svg] Free pixmap buffer if error occurs while rendering. 2019-08-26 01:17:15 +05:00
Moazin Khatti 836c94e8d2 [ot-svg] Don't accept the hooks if value has been passed from an
env variable.
2019-08-26 01:17:14 +05:00
Moazin Khatti c492bf3f0a Handle cascaded transformations correctly.
We use homogeneous coordinates to properly calculate an equivalent
transformation correctly.
2019-08-26 01:17:14 +05:00
Moazin Khatti 3f6f939378 Adds transform support for OT-SVG glyphs. 2019-08-26 01:17:14 +05:00
Moazin Khatti 2727bba550 Formatting improvement. 2019-08-26 01:17:14 +05:00
Moazin Khatti cff4467f25 Minor doc improvement. 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 c21c2b0e70 An old commit deleted a line by mistake. Fix that. 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 705320b72d Check if the size has been properly set.
For TTF outlines this is already handled, however,
for traditional CFF outlines the check happens too
late. We need to check early.
2019-08-26 01:17:14 +05:00
Moazin Khatti fdb7d53ebf Fixes code warnings. 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 a227395912 Remove the dependence on outlines. No longer needed. 2019-08-26 01:17:14 +05:00
Moazin Khatti dbcc809e7c relying on cairo recording surface for extents and preset bitmap at load time, work in progress 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 b85cc5ef0d For now resort to a simpler regular expresion.
We have to remove the system installation of FreeType
from the includes, the proper way is to write a regular
expression that removes the whole path. The last one
is buggy (it can remove other libs along with freetype)
so for now I am temporarily resorting to this one.
2019-08-26 01:17:14 +05:00
Moazin Khatti 3479e03cdb Added a new error `Invalid_SVG_Document'. 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 2d13c5127c Add a comment there. That part can be confusing. 2019-08-26 01:17:14 +05:00
Moazin Khatti bb1b25e560 Make `ft_svg_renderer_class' dumb if OT-SVG
support is disabled.
2019-08-26 01:17:14 +05:00
Moazin Khatti 5e949729e3 Correct the prioritization of options. Clean code.
If `yes' is choosen but SVG library isn't found, exit
with error. If `auto' was choosen but the library wasn't
found, go with `no' NOT `no-default'. `no-default' should
be a separate option.
2019-08-26 01:17:14 +05:00
Moazin Khatti f86fe242d4 Improve `--with-svg' in the build system.
Added a `no-default' option that compiles SVG support
but keeps no default rendering port. Thus, the client
application must inject its own hooks.

* builds/unix/configure.raw: Changes in the build
system to support `no-default'.

* builds/unix/unix-cc.in: Add `COMPILE_SVG_PORT' var
to ultimately let the `rules.mk' in `svg' folder know
whether to build the port files or not.

* include/freetype/config/ftoption.h: Change the flag
`FT_CONFIG_OPTION_SVG_DEFAULT' to `*_DEFAULT_SVG' as
`sed' and `ftoption_set' has a problem with the older
version.

* src/svg/ftsvg.c: Ditto.

* src/svg/rules.mk: Compile the port only if
`COMPILE_SVG_PORT' is set.
2019-08-26 01:17:14 +05:00
Moazin Khatti 4025f1213e Add a `hooks_set' flag.
A flag is to be used to indicate whether hooks
have been set or not. In case the hooks haven't
been set, a `Missing_SVG_Hooks' error will be
thrown.
2019-08-26 01:17:14 +05:00
Moazin Khatti 246ac684e4 Plug in a default library. `librsvg' for now. 2019-08-26 01:17:14 +05:00
Moazin Khatti d86de4e9d4 Instead of individual properties. Just use one that
takes pointer to the hooks structure.
2019-08-26 01:17:14 +05:00
Moazin Khatti 1541091e76 Use `FT_Property_Set' to set the hooks. One less API function. 2019-08-26 01:17:14 +05:00
Moazin Khatti b6f2303338 Public interface should remain same whether
`FT_CONFIG_OPTION_SVG' is set or not.
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 c25304fa34 Documentation formatting improvement. 2019-08-17 20:36:05 +05:00
Moazin Khatti c6a6859ad9 Better naming used. 2019-08-17 20:36:05 +05:00
Moazin Khatti bf1deae970 Forgot an `else', fix that. 2019-08-17 20:36:05 +05:00
Moazin Khatti fbdd9f9ba3 Memory allocation for `state' of renderer should be performed
on the SVG port side not the FT size. Minor doc fixes.
2019-08-17 20:36:05 +05:00
Moazin Khatti cf44c0cbdd Remove unnecessary code from `FT_Render_Glyph_Internal'. 2019-08-17 20:36:05 +05:00
Moazin Khatti 1f74524929 Let FT handle the memory management for rendering port's state
and the image buffer.

State has been moved inside the library structure. A new hook
function has been added to query the size needed for the state
structure and this allocation is performed by FT. Memory alloc.
for the image buffer is also being done by FT so that it can later
free it easily.

* include/freetype/svgrenderer.h: Small doc fixes. Addition of two
new hooks. `SVG_Lib_Get_State_Size' and `SVG_Lib_Get_Buffer_Size'.

* src/base/ftglyph.c (FT_Glyph_To_Bitmap): Small bug fix. Memory
was being initialized before library.

* src/base/ftobjs.c (FT_Set_Svg_Hooks): Adjust the code for new
hook functions.

* src/svg/ftsvg.c: Adjust the code for new hook functions. Perform
all memory allocations needed by the rendering port from FreeType
side.

* src/svg/svgtypes.c: Add the new hooks in the hook structure.
2019-08-17 20:36:05 +05:00
Moazin Khatti de44a3fda8 Store the rendering port's state in library.
Before this commit, the state of a rendering port was being
held globally. Now, it'll be stored in library->svg_renderer_state.
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 22988063b0 Minor. Add documentation. 2019-08-17 20:36:05 +05:00