summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNikhil Ramakrishnan <ramakrishnan.nikhil@gmail.com>2019-07-18 01:50:16 +0530
committerWerner Lemberg <wl@gnu.org>2019-08-27 09:50:48 +0200
commit1e0207681544327f9e96c6d50231b6fbc1f6ed70 (patch)
tree41942152f96292103ac4939599ec6b7a925fec44 /include
parent4d9b3d1d506c2da2cc078369ed130fb2b6994bb2 (diff)
downloadfreetype2-1e0207681544327f9e96c6d50231b6fbc1f6ed70.tar.gz
[woff2] Avoid too many calls to `FT_REALLOC'.
We do this by using `totalSfntSize' as an initial reference, and extending the buffer when required. This reduces rendering time considerably. * include/freetype/internal/wofftypes.h (WOFF2_HeaderRec): Add `totalSfntSize', rename `total_sfnt_size' to `actual_sfnt_size'. * src/sfnt/sfwoff2.c (write_buf): Add parameter `dst_size' to keep track of and update total size of stream. (WRITE_SFNT_BUF, WRITE_SFNT_BUF_AT): Modify macros accordingly. (pad4, store_loca, reconstruct_glyf, reconstruct_hmtx, reconstruct_font): Update parameters to accept `sfnt_size'. (woff2_open_font): Add variable `sfnt_size'. Use WOFF2 header field `totalSfntSize' as initial reference (if value makes sense) and allocate `totalSfntSize' bytes for the sfnt stream. `write_buf' handles reallocation if and when required. Also resize the stream to `actual_sfnt_size' after reconstruction.
Diffstat (limited to 'include')
-rw-r--r--include/freetype/internal/wofftypes.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/freetype/internal/wofftypes.h b/include/freetype/internal/wofftypes.h
index efadb7743..9c827e32c 100644
--- a/include/freetype/internal/wofftypes.h
+++ b/include/freetype/internal/wofftypes.h
@@ -165,6 +165,7 @@ FT_BEGIN_HEADER
FT_ULong flavor;
FT_ULong length;
FT_UShort num_tables;
+ FT_ULong totalSfntSize;
FT_ULong totalCompressedSize;
FT_ULong metaOffset;
FT_ULong metaLength;
@@ -176,7 +177,7 @@ FT_BEGIN_HEADER
FT_ULong compressed_offset;
FT_ULong header_version;
FT_UShort num_fonts;
- FT_ULong total_sfnt_size;
+ FT_ULong actual_sfnt_size;
WOFF2_TtcFont ttc_fonts;