int16_t x_min = glyph.contours[0][0].x;
int16_t y_min = glyph.contours[0][0].y;
int16_t x_max = x_min;
int16_t y_max = y_min; for (constauto& contour : glyph.contours) { for (constauto& point : contour) { if (point.x < x_min) x_min = point.x; if (point.x > x_max) x_max = point.x; if (point.y < y_min) y_min = point.y; if (point.y > y_max) y_max = point.y;
}
}
if (glyph.x_min != x_min) returntrue; if (glyph.y_min != y_min) returntrue; if (glyph.x_max != x_max) returntrue; if (glyph.y_max != y_max) returntrue;
returnfalse;
}
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)) {
WriteBbox(glyph_id, glyph);
} for (int i = 0; i < num_contours; i++) {
Write255UShort(&n_points_stream_, glyph.contours[i].size());
} int lastX = 0; int lastY = 0; for (int i = 0; i < num_contours; i++) { int num_points = glyph.contours[i].size(); for (int j = 0; j < num_points; j++) { int x = glyph.contours[i][j].x; int y = glyph.contours[i][j].y; int dx = x - lastX; int dy = y - lastY;
WriteTriplet(glyph.contours[i][j].on_curve, dx, dy);
lastX = x;
lastY = y;
}
} if (num_contours > 0) {
WriteInstructions(glyph);
}
}
bool TransformGlyfAndLocaTables(Font* font) { // no transform for CFF const Font::Table* glyf_table = font->FindTable(kGlyfTableTag); const Font::Table* loca_table = font->FindTable(kLocaTableTag);
// If you don't have glyf/loca this transform isn't very interesting if (loca_table == NULL && glyf_table == NULL) { returntrue;
} // It would be best if you didn't have just one of glyf/loca if ((glyf_table == NULL) != (loca_table == NULL)) { return FONT_COMPRESSION_FAILURE();
} // Must share neither or both loca & glyf if (loca_table->IsReused() != glyf_table->IsReused()) { return FONT_COMPRESSION_FAILURE();
} if (loca_table->IsReused()) { returntrue;
}
// If you don't have hmtx or a glyf not much is going to happen here if (hmtx_table == NULL || glyf_table == NULL) { returntrue;
}
// hmtx without hhea doesn't make sense if (hhea_table == NULL) { return FONT_COMPRESSION_FAILURE();
}
// Skip 34 to reach 'hhea' numberOfHMetrics
Buffer hhea_buf(hhea_table->data, hhea_table->length);
uint16_t num_hmetrics; if (!hhea_buf.Skip(34) || !hhea_buf.ReadU16(&num_hmetrics)) { return FONT_COMPRESSION_FAILURE();
}
// Must have at least one hMetric if (num_hmetrics < 1) { return FONT_COMPRESSION_FAILURE();
}
int num_glyphs = NumGlyphs(*font);
// Most fonts can be transformed; assume it's a go until proven otherwise
std::vector<uint16_t> advance_widths;
std::vector<int16_t> proportional_lsbs;
std::vector<int16_t> monospace_lsbs;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.