Commit Graph

551 Commits

Author SHA1 Message Date
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 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 d7f6f8b16d Tracing implemented for OT-SVG code. 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 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 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 e028be97b8 Minor fixes. 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 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 479c76c867 [ot-svg] Silly mistake fix.
Instead of an `FT_Library' instance, `FT_Module' is supposed
to be passed.
2019-08-17 20:36:05 +05:00
Moazin Khatti 4d59b8535e [ot-svg] Creates hooks mechanism in SVG Renderer.
* include/freetype/config/ftheader.h: New macro `FT_SVG_RENDERER_H'
for `freetype/svgrenderer.h'.

* include/freetype/svgrenderer.h: New file to store SVG specific
function types, SVG interface and `FT_Set_Svg_Hooks'.

* src/base/ftobjs.c: Adds implementation of `FT_Set_Svg_Hooks'.

* src/svg/ftsvg.c: Creates `svg_renderer_interface'.

* src/svg/svgtypes.c: Moves hook function types to
`FT_SVG_RENDERER_H'. Adds a hook for svg rendering. Temporary.
2019-08-17 20:36:05 +05:00
Moazin Khatti f1db18a464 Barebones of an SVG rendering module and making it part of the build system 2019-08-17 20:36:05 +05: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
Werner Lemberg f686ad46a3 Update copyright years. 2019-01-22 20:31:44 +01:00
Alexei Podtelezhnikov 4500c701c2 Typo. 2018-09-26 22:04:50 -04: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
Alexei Podtelezhnikov 793a9ff9f5 * src/base/ftobjs.c (ft_glyphslot_reset_bimap): Another tweak.
This one should be clearer. When the rounded monochrome bbox collapses
we add a pixel that covers most if not all original cbox.
2018-09-22 14:38:00 -04:00
Alexei Podtelezhnikov f26d57753f * src/base/ftobjs.c (ft_glyphslot_reset_bimap): Further tweak. 2018-09-21 20:34:58 -04:00
Ben Wagner 335528e11e Improve auto-hinter handling of bitmap fonts (#54681).
For bitmap fonts, `FT_Load_Glyph' should either return an error or
not set the format to `FT_GLYPH_FORMAT_OUTLINE'.  However, in this
case `FT_Load_Glyph' calls into the auto-hinter which calls back
into `FT_Load_Glyph' with `FT_LOAD_NO_SCALE' in the flags, which
marks the glyph as `FT_GLYPH_FORMAT_OUTLINE' with an empty path
(even though it doesn't have any path).  It appears that the
auto-hinter should not be called when the face doesn't have
outlines.  The current test for using the auto-hinter in
`FT_Load_Glyph' checks if the driver supports scalable outlines, but
not if the face supports scalable outlines.

* src/base/ftobjs.c (FT_Load_Glyph): Directly check whether we have
scalable outlines.
2018-09-21 11:27:50 +02:00
Werner Lemberg 493aa68f5c [base] Some comments. 2018-09-21 08:32:22 +02:00
Alexei Podtelezhnikov 2a9850c4fc * src/base/ftobjs.c (ft_glyphslot_reset_bimap): Tiny rounding tweak.
This adds pixels in case a contour goes through the center
and they need to be turned on in the b/w rasterizer.
2018-09-20 22:40:32 -04:00
Alexei Podtelezhnikov 809d5125af * src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Check glyph format. 2018-08-31 22:49:19 -04:00
Werner Lemberg 83525bdd10 Minor comments. 2018-08-31 07:37:15 +02:00
Alexei Podtelezhnikov 1dacbd893d Consolidate bitmap presetting and size assessment.
* include/freetype/internal/ftobjs.h (ft_glyphslot_preset_bitmap):
Change return type.
* src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Return the bitmap
size assessment.

* src/raster/ftrend1.c (ft_raster1_render): Use it to refuse the
rendering of enourmous or far-fetched outlines.
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Ditto.
2018-08-30 23:28:30 -04:00
Alexei Podtelezhnikov ca980b4cf1 * src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Correct mono. 2018-08-30 21:51:18 -04:00
Werner Lemberg 21c2b3905c Minor. 2018-08-30 09:52:08 +02:00
Alexei Podtelezhnikov 5d93a3fc8d [base] Overflow-resistant bitmap presetting.
* src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Implement it.
2018-08-30 01:12:22 -04:00
Werner Lemberg a3e842f9c6 Minor formatting and documentation fixes. 2018-08-22 10:30:08 +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 1aa73fa83d * src/base/ftobjs.c (FT_Render_Glyph_Internal): Improve tracing. 2018-08-10 05:41:32 +02:00
Werner Lemberg 2e3dec5509 Debugging improvements.
* src/base/ftobjs.c (pixel_modes): Move this array to top level
from ...
(FT_Load_Glyph): ... here.
(FT_Render_Glyph_Internal): Use `width' x `height' in trace message.
Use `pixel_modes'.
2018-08-08 13:51:18 +02:00
Werner Lemberg 8f09eb5ce0 Allow FT_ENCODING_NONE for `FT_Select_Charmap'.
This is a valid encoding tag for BDF, PCF, and Windows FNT, and
there is no reason to disallow it for these formats.

* src/base/ftobjs.c (FT_Select_Charmap): Implement it.
2018-07-17 21:45:24 +02:00
Werner Lemberg 4e3b2473d8 Make `FT_Get_Color_Glyph_Layer' return FT_Bool.
* include/freetype/freetype.h, src/base/ftobjs.c
(FT_Get_Color_Glyph_Layer, FT_Render_Glyph_Internal): Updated.

* include/freetype/internal/sfnt.h (TT_Get_Colr_Layer_Func),
src/sfnt/ttcolr.h, src/sfnt/ttcolr.c (tt_face_get_colr_layer):
Updated.
2018-07-02 11:41:44 +02:00
Werner Lemberg f6ccb524af * src/base/ftobjs.c (FT_Get_Color_Glyph_Layer): Guard SFNT function.
Reported by Behdad.
2018-07-01 12:31:57 +02:00
Alexei Podtelezhnikov 4f11209f5c * src/base/ftobjs.c (FT_Set_Charmap): Robustify. 2018-06-28 21:31:35 -04:00
Werner Lemberg e361cc6a75 s/trace_bitmap/trace_checksum/.
* include/freetype/internal/fttrace.h: s/bitmap/checksum/.

* src/base/ftobjs.c (FT_COMPONENT): s/trace_bitmap/trace_checksum/.
Adjust code.
2018-06-17 09:13:37 +02:00
Werner Lemberg 9b31c44620 Replace `FT_Get_GlyphLayers' with `FT_Get_Color_Glyph_Layer'.
This avoids any additional allocation of COLR related structures in
a glyph slot.

* include/freetype/freetype.h (FT_Glyph_Layer, FT_Glyph_LayerRec,
FT_Get_GlyphLayers): Removed.

* include/freetype/internal/ftobjs.h (FT_Colr_InternalRec): Removed.
(FT_Slot_InternalRec): Remove `color_layers'.

* include/freetype/internal/sfnt.h (TT_Load_Colr_Layer_Func):
Removed.
(SFNT_Interface, FT_DEFINE_SFNT_INTERFACE): Remove
`load_colr_layer'.

* src/base/ftobjs.c (ft_glyph_slot_done): Updated.
(FT_Render_Glyph_Internal): Use `FT_Get_Color_Glyph_Layer'.
(FT_Get_GlyphLayers): Removed.

* src/sfnt/sfdriver.c (sfnt_interface): Updated.

* src/sfnt/ttcolr.c (tt_face_load_colr_layers): Removed.
* src/sfnt/ttcolr.h: Updated.

* src/truetype/ttgload.c (TT_Load_Glyph): Updated.
2018-06-14 21:30:43 +02:00