diff options
Diffstat (limited to 'dviware/dvisvgm/libs/woff2')
-rw-r--r-- | dviware/dvisvgm/libs/woff2/Makefile.in | 22 | ||||
-rw-r--r-- | dviware/dvisvgm/libs/woff2/include/woff2/encode.h | 4 | ||||
-rw-r--r-- | dviware/dvisvgm/libs/woff2/include/woff2/output.h | 4 | ||||
-rw-r--r-- | dviware/dvisvgm/libs/woff2/src/glyph.cc | 17 | ||||
-rw-r--r-- | dviware/dvisvgm/libs/woff2/src/glyph.h | 12 | ||||
-rw-r--r-- | dviware/dvisvgm/libs/woff2/src/normalize.cc | 2 | ||||
-rw-r--r-- | dviware/dvisvgm/libs/woff2/src/transform.cc | 20 | ||||
-rw-r--r-- | dviware/dvisvgm/libs/woff2/src/woff2_enc.cc | 8 | ||||
-rw-r--r-- | dviware/dvisvgm/libs/woff2/src/woff2_out.cc | 8 |
9 files changed, 60 insertions, 37 deletions
diff --git a/dviware/dvisvgm/libs/woff2/Makefile.in b/dviware/dvisvgm/libs/woff2/Makefile.in index 673488dce6..5ee0873fd0 100644 --- a/dviware/dvisvgm/libs/woff2/Makefile.in +++ b/dviware/dvisvgm/libs/woff2/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.5 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -91,12 +91,7 @@ host_triplet = @host@ target_triplet = @target@ subdir = libs/woff2 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \ - $(top_srcdir)/m4/ax_code_coverage.m4 \ - $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) @@ -216,8 +211,6 @@ am__define_uniq_tagged_files = \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ @@ -244,6 +237,8 @@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ CODE_COVERAGE_LIBS = @CODE_COVERAGE_LIBS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CSCOPE = @CSCOPE@ +CTAGS = @CTAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ @@ -259,8 +254,10 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ +ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +FILECMD = @FILECMD@ FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ FREETYPE_LIBS = @FREETYPE_LIBS@ GCOV = @GCOV@ @@ -422,9 +419,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libs/woff2/Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libs/woff2/Makefile'; \ $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign libs/woff2/Makefile + $(AUTOMAKE) --gnu libs/woff2/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -577,7 +574,6 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am diff --git a/dviware/dvisvgm/libs/woff2/include/woff2/encode.h b/dviware/dvisvgm/libs/woff2/include/woff2/encode.h index 34b7722974..2ac563032d 100644 --- a/dviware/dvisvgm/libs/woff2/include/woff2/encode.h +++ b/dviware/dvisvgm/libs/woff2/include/woff2/encode.h @@ -26,8 +26,8 @@ struct WOFF2Params { // Returns an upper bound on the size of the compressed file. size_t MaxWOFF2CompressedSize(const uint8_t* data, size_t length); -size_t MaxWOFF2CompressedSize(const uint8_t* data, size_t length, - const std::string& extended_metadata); +size_t MaxWOFF2CompressedSize(const uint8_t *data, size_t length, + const std::string &extended_metadata); // Compresses the font into the target buffer. *result_length should be at least // the value returned by MaxWOFF2CompressedSize(), upon return, it is set to the diff --git a/dviware/dvisvgm/libs/woff2/include/woff2/output.h b/dviware/dvisvgm/libs/woff2/include/woff2/output.h index c325f67be7..dc78ccf826 100644 --- a/dviware/dvisvgm/libs/woff2/include/woff2/output.h +++ b/dviware/dvisvgm/libs/woff2/include/woff2/output.h @@ -51,7 +51,7 @@ class WOFF2StringOut : public WOFF2Out { // Create a writer that writes its data to buf. // buf->size() will grow to at most max_size // buf may be sized (e.g. using EstimateWOFF2FinalSize) or empty. - explicit WOFF2StringOut(std::string* buf); + explicit WOFF2StringOut(std::string *buf); bool Write(const void *buf, size_t n) override; bool Write(const void *buf, size_t offset, size_t n) override; @@ -59,7 +59,7 @@ class WOFF2StringOut : public WOFF2Out { size_t MaxSize() { return max_size_; } void SetMaxSize(size_t max_size); private: - std::string* buf_; + std::string *buf_; size_t max_size_; size_t offset_; }; diff --git a/dviware/dvisvgm/libs/woff2/src/glyph.cc b/dviware/dvisvgm/libs/woff2/src/glyph.cc index 1b4408b924..5b4948679c 100644 --- a/dviware/dvisvgm/libs/woff2/src/glyph.cc +++ b/dviware/dvisvgm/libs/woff2/src/glyph.cc @@ -21,6 +21,7 @@ static const int32_t kFLAG_YSHORT = 1 << 2; static const int32_t kFLAG_REPEAT = 1 << 3; static const int32_t kFLAG_XREPEATSIGN = 1 << 4; static const int32_t kFLAG_YREPEATSIGN = 1 << 5; +static const int32_t kFLAG_OVERLAP_SIMPLE = 1 << 6; static const int32_t kFLAG_ARG_1_AND_2_ARE_WORDS = 1 << 0; static const int32_t kFLAG_WE_HAVE_A_SCALE = 1 << 3; static const int32_t kFLAG_MORE_COMPONENTS = 1 << 5; @@ -134,6 +135,10 @@ bool ReadGlyph(const uint8_t* data, size_t len, Glyph* glyph) { } } + if (!flags.empty() && !flags[0].empty()) { + glyph->overlap_simple_flag_set = (flags[0][0] & kFLAG_OVERLAP_SIMPLE); + } + // Read the x coordinates. int prev_x = 0; for (int i = 0; i < num_contours; ++i) { @@ -239,7 +244,7 @@ bool StoreEndPtsOfContours(const Glyph& glyph, size_t* offset, uint8_t* dst) { bool StorePoints(const Glyph& glyph, size_t* offset, uint8_t* dst, size_t dst_size) { - int last_flag = -1; + int previous_flag = -1; int repeat_count = 0; int last_x = 0; int last_y = 0; @@ -250,6 +255,10 @@ bool StorePoints(const Glyph& glyph, size_t* offset, for (const auto& contour : glyph.contours) { for (const auto& point : contour) { int flag = point.on_curve ? kFLAG_ONCURVE : 0; + if (previous_flag == -1 && glyph.overlap_simple_flag_set) { + // First flag needs to have overlap simple bit set. + flag = flag | kFLAG_OVERLAP_SIMPLE; + } int dx = point.x - last_x; int dy = point.y - last_y; if (dx == 0) { @@ -268,7 +277,7 @@ bool StorePoints(const Glyph& glyph, size_t* offset, } else { y_bytes += 2; } - if (flag == last_flag && repeat_count != 255) { + if (flag == previous_flag && repeat_count != 255) { dst[*offset - 1] |= kFLAG_REPEAT; repeat_count++; } else { @@ -286,7 +295,7 @@ bool StorePoints(const Glyph& glyph, size_t* offset, } last_x = point.x; last_y = point.y; - last_flag = flag; + previous_flag = flag; } } if (repeat_count != 0) { @@ -350,7 +359,7 @@ bool StoreGlyph(const Glyph& glyph, uint8_t* dst, size_t* dst_size) { } } else if (glyph.contours.size() > 0) { // Simple glyph. - if (glyph.contours.size() > size_t(std::numeric_limits<int16_t>::max())) { + if (glyph.contours.size() > std::numeric_limits<int16_t>::max()) { return FONT_COMPRESSION_FAILURE(); } if (*dst_size < ((12ULL + 2 * glyph.contours.size()) + diff --git a/dviware/dvisvgm/libs/woff2/src/glyph.h b/dviware/dvisvgm/libs/woff2/src/glyph.h index f24056f4c8..c38eb5f2bc 100644 --- a/dviware/dvisvgm/libs/woff2/src/glyph.h +++ b/dviware/dvisvgm/libs/woff2/src/glyph.h @@ -10,8 +10,10 @@ #ifndef WOFF2_GLYPH_H_ #define WOFF2_GLYPH_H_ -#include <stddef.h> #include <inttypes.h> +#include <stddef.h> + +#include <cstdint> #include <vector> namespace woff2 { @@ -22,7 +24,10 @@ namespace woff2 { // is around. class Glyph { public: - Glyph() : instructions_size(0), composite_data_size(0) {} + Glyph() + : instructions_size(0), + overlap_simple_flag_set(false), + composite_data_size(0) {} // Bounding box. int16_t x_min; @@ -34,6 +39,9 @@ class Glyph { uint16_t instructions_size; const uint8_t* instructions_data; + // Flags. + bool overlap_simple_flag_set; + // Data model for simple glyphs. struct Point { int x; diff --git a/dviware/dvisvgm/libs/woff2/src/normalize.cc b/dviware/dvisvgm/libs/woff2/src/normalize.cc index dc4bfe6c5c..f7538a1ef3 100644 --- a/dviware/dvisvgm/libs/woff2/src/normalize.cc +++ b/dviware/dvisvgm/libs/woff2/src/normalize.cc @@ -93,7 +93,7 @@ bool MakeEditableBuffer(Font* font, int tableTag) { if (table->IsReused()) { return true; } - uint32_t sz = Round4(table->length); + unsigned sz = Round4(table->length); table->buffer.resize(sz); uint8_t* buf = &table->buffer[0]; memcpy(buf, table->data, table->length); diff --git a/dviware/dvisvgm/libs/woff2/src/transform.cc b/dviware/dvisvgm/libs/woff2/src/transform.cc index 999bef3745..1016efcd2b 100644 --- a/dviware/dvisvgm/libs/woff2/src/transform.cc +++ b/dviware/dvisvgm/libs/woff2/src/transform.cc @@ -22,6 +22,7 @@ namespace { const int FLAG_ARG_1_AND_2_ARE_WORDS = 1 << 0; const int FLAG_WE_HAVE_INSTRUCTIONS = 1 << 8; +const int FLAG_OVERLAP_SIMPLE_BITMAP = 1 << 0; void WriteBytes(std::vector<uint8_t>* out, const uint8_t* data, size_t len) { if (len == 0) return; @@ -69,7 +70,10 @@ class GlyfEncoder { } void GetTransformedGlyfBytes(std::vector<uint8_t>* result) { - WriteLong(result, 0); // version + WriteUShort(result, 0); // Version + WriteUShort(result, overlap_bitmap_.empty() + ? 0x00 + : FLAG_OVERLAP_SIMPLE_BITMAP); // Flags WriteUShort(result, n_glyphs_); WriteUShort(result, 0); // index_format, will be set later WriteLong(result, n_contour_stream_.size()); @@ -87,6 +91,9 @@ class GlyfEncoder { WriteBytes(result, bbox_bitmap_); WriteBytes(result, bbox_stream_); WriteBytes(result, instruction_stream_); + if (!overlap_bitmap_.empty()) { + WriteBytes(result, overlap_bitmap_); + } } private: @@ -127,6 +134,10 @@ class GlyfEncoder { } void WriteSimpleGlyph(int glyph_id, const Glyph& glyph) { + if (glyph.overlap_simple_flag_set) { + EnsureOverlapBitmap(); + overlap_bitmap_[glyph_id >> 3] |= 0x80 >> (glyph_id & 7); + } int num_contours = glyph.contours.size(); WriteUShort(&n_contour_stream_, num_contours); if (ShouldWriteSimpleGlyphBbox(glyph)) { @@ -214,6 +225,12 @@ class GlyfEncoder { } } + void EnsureOverlapBitmap() { + if (overlap_bitmap_.empty()) { + overlap_bitmap_.resize((n_glyphs_ + 7) >> 3); + } + } + std::vector<uint8_t> n_contour_stream_; std::vector<uint8_t> n_points_stream_; std::vector<uint8_t> flag_byte_stream_; @@ -222,6 +239,7 @@ class GlyfEncoder { std::vector<uint8_t> bbox_stream_; std::vector<uint8_t> glyph_stream_; std::vector<uint8_t> instruction_stream_; + std::vector<uint8_t> overlap_bitmap_; int n_glyphs_; }; diff --git a/dviware/dvisvgm/libs/woff2/src/woff2_enc.cc b/dviware/dvisvgm/libs/woff2/src/woff2_enc.cc index 9f32df90ee..43c8bdc9d8 100644 --- a/dviware/dvisvgm/libs/woff2/src/woff2_enc.cc +++ b/dviware/dvisvgm/libs/woff2/src/woff2_enc.cc @@ -28,12 +28,8 @@ namespace woff2 { -namespace { - - -using std::string; -using std::vector; +namespace { const size_t kWoff2HeaderSize = 48; const size_t kWoff2EntrySize = 20; @@ -183,7 +179,7 @@ size_t MaxWOFF2CompressedSize(const uint8_t* data, size_t length) { } size_t MaxWOFF2CompressedSize(const uint8_t* data, size_t length, - const string& extended_metadata) { + const std::string& extended_metadata) { // Except for the header size, which is 32 bytes larger in woff2 format, // all other parts should be smaller (table header in short format, // transformations and compression). Just to be sure, we will give some diff --git a/dviware/dvisvgm/libs/woff2/src/woff2_out.cc b/dviware/dvisvgm/libs/woff2/src/woff2_out.cc index 8ab32681f1..a22d3bf8be 100644 --- a/dviware/dvisvgm/libs/woff2/src/woff2_out.cc +++ b/dviware/dvisvgm/libs/woff2/src/woff2_out.cc @@ -8,14 +8,10 @@ #include <woff2/output.h> -using std::string; - namespace woff2 { -WOFF2StringOut::WOFF2StringOut(string* buf) - : buf_(buf), - max_size_(kDefaultMaxSize), - offset_(0) {} +WOFF2StringOut::WOFF2StringOut(std::string *buf) + : buf_(buf), max_size_(kDefaultMaxSize), offset_(0) {} bool WOFF2StringOut::Write(const void *buf, size_t n) { return Write(buf, offset_, n); |