Home | History | Annotate | Download | only in woff2

Lines Matching refs:glyph

15 // Glyph manipulation
17 #include "./glyph.h"
39 bool ReadCompositeGlyphData(Buffer* buffer, Glyph* glyph) {
40 glyph->have_instructions = false;
41 glyph->composite_data = buffer->buffer() + buffer->offset();
48 glyph->have_instructions |= (flags & kFLAG_WE_HAVE_INSTRUCTIONS) != 0;
49 size_t arg_size = 2; // glyph index
69 glyph->composite_data_size = buffer->offset() - start_offset;
73 bool ReadGlyph(const uint8_t* data, size_t len, Glyph* glyph) {
82 // Empty glyph.
87 if (!buffer.ReadS16(&glyph->x_min) ||
88 !buffer.ReadS16(&glyph->y_min) ||
89 !buffer.ReadS16(&glyph->x_max) ||
90 !buffer.ReadS16(&glyph->y_max)) {
95 // Simple glyph.
96 glyph->contours.resize(num_contours);
106 glyph->contours[i].resize(num_points);
111 if (!buffer.ReadU16(&glyph->instructions_size)) {
114 glyph->instructions_data = data + buffer.offset();
115 if (!buffer.Skip(glyph->instructions_size)) {
124 flags[i].resize(glyph->contours[i].size());
125 for (int j = 0; j < glyph->contours[i].size(); ++j) {
139 glyph->contours[i][j].on_curve = flag & kFLAG_ONCURVE;
146 for (int j = 0; j < glyph->contours[i].size(); ++j) {
155 glyph->contours[i][j].x = prev_x + sign * x_delta;
164 glyph->contours[i][j].x = prev_x + x_delta;
166 prev_x = glyph->contours[i][j].x;
173 for (int j = 0; j < glyph->contours[i].size(); ++j) {
182 glyph->contours[i][j].y = prev_y + sign * y_delta;
191 glyph->contours[i][j].y = prev_y + y_delta;
193 prev_y = glyph->contours[i][j].y;
197 // Composite glyph.
198 if (!ReadCompositeGlyphData(&buffer, glyph)) {
202 if (glyph->have_instructions) {
203 if (!buffer.ReadU16(&glyph->instructions_size)) {
206 glyph->instructions_data = data + buffer.offset();
207 if (!buffer.Skip(glyph->instructions_size)) {
211 glyph->instructions_size = 0;
221 void StoreBbox(const Glyph& glyph, size_t* offset, uint8_t* dst) {
222 Store16(glyph.x_min, offset, dst);
223 Store16(glyph.y_min, offset, dst);
224 Store16(glyph.x_max, offset, dst);
225 Store16(glyph.y_max, offset, dst);
228 void StoreInstructions(const Glyph& glyph, size_t* offset, uint8_t* dst) {
229 Store16(glyph.instructions_size, offset, dst);
230 StoreBytes(glyph.instructions_data, glyph.instructions_size, offset, dst);
233 bool StoreEndPtsOfContours(const Glyph& glyph, size_t* offset, uint8_t* dst) {
235 for (const auto& contour : glyph.contours) {
246 bool StorePoints(const Glyph& glyph, size_t* offset,
256 for (const auto& contour : glyph.contours) {
314 for (const auto& contour : glyph.contours) {
342 bool StoreGlyph(const Glyph& glyph, uint8_t* dst, size_t* dst_size) {
344 if (glyph.composite_data_size > 0) {
345 // Composite glyph.
346 if (*dst_size < ((10ULL + glyph.composite_data_size) +
347 ((glyph.have_instructions ? 2ULL : 0) +
348 glyph.instructions_size))) {
352 StoreBbox(glyph, &offset, dst);
353 StoreBytes(glyph.composite_data, glyph.composite_data_size, &offset, dst);
354 if (glyph.have_instructions) {
355 StoreInstructions(glyph, &offset, dst);
357 } else if (glyph.contours.size() > 0) {
358 // Simple glyph.
359 if (glyph.contours.size() > std::numeric_limits<int16_t>::max()) {
362 if (*dst_size < ((12ULL + 2 * glyph.contours.size()) +
363 glyph.instructions_size)) {
366 Store16(glyph.contours.size(), &offset, dst);
367 StoreBbox(glyph, &offset, dst);
368 if (!StoreEndPtsOfContours(glyph, &offset, dst)) {
371 StoreInstructions(glyph, &offset, dst);
372 if (!StorePoints(glyph, &offset, dst, *dst_size)) {