summaryrefslogtreecommitdiffstats
path: root/modules/woff2/src/glyph.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /modules/woff2/src/glyph.h
parentInitial commit. (diff)
downloadfirefox-upstream/124.0.1.tar.xz
firefox-upstream/124.0.1.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'modules/woff2/src/glyph.h')
-rw-r--r--modules/woff2/src/glyph.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/modules/woff2/src/glyph.h b/modules/woff2/src/glyph.h
new file mode 100644
index 0000000000..c38eb5f2bc
--- /dev/null
+++ b/modules/woff2/src/glyph.h
@@ -0,0 +1,71 @@
+/* Copyright 2013 Google Inc. All Rights Reserved.
+
+ Distributed under MIT license.
+ See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
+*/
+
+/* Data model and I/O for glyph data within sfnt format files for the purpose of
+ performing the preprocessing step of the WOFF 2.0 conversion. */
+
+#ifndef WOFF2_GLYPH_H_
+#define WOFF2_GLYPH_H_
+
+#include <inttypes.h>
+#include <stddef.h>
+
+#include <cstdint>
+#include <vector>
+
+namespace woff2 {
+
+// Represents a parsed simple or composite glyph. The composite glyph data and
+// instructions are un-parsed and we keep only pointers to the raw data,
+// therefore the glyph is valid only so long the data from which it was parsed
+// is around.
+class Glyph {
+ public:
+ Glyph()
+ : instructions_size(0),
+ overlap_simple_flag_set(false),
+ composite_data_size(0) {}
+
+ // Bounding box.
+ int16_t x_min;
+ int16_t x_max;
+ int16_t y_min;
+ int16_t y_max;
+
+ // Instructions.
+ uint16_t instructions_size;
+ const uint8_t* instructions_data;
+
+ // Flags.
+ bool overlap_simple_flag_set;
+
+ // Data model for simple glyphs.
+ struct Point {
+ int x;
+ int y;
+ bool on_curve;
+ };
+ std::vector<std::vector<Point> > contours;
+
+ // Data for composite glyphs.
+ const uint8_t* composite_data;
+ uint32_t composite_data_size;
+ bool have_instructions;
+};
+
+// Parses the glyph from the given data. Returns false on parsing failure or
+// buffer overflow. The glyph is valid only so long the input data pointer is
+// valid.
+bool ReadGlyph(const uint8_t* data, size_t len, Glyph* glyph);
+
+// Stores the glyph into the specified dst buffer. The *dst_size is the buffer
+// size on entry and is set to the actual (unpadded) stored size on exit.
+// Returns false on buffer overflow.
+bool StoreGlyph(const Glyph& glyph, uint8_t* dst, size_t* dst_size);
+
+} // namespace woff2
+
+#endif // WOFF2_GLYPH_H_