using HBBlob = std::unique_ptr<hb_blob_t, SkFunctionObject<hb_blob_destroy>>; using HBFace = std::unique_ptr<hb_face_t, SkFunctionObject<hb_face_destroy>>; using HBSubsetInput = std::unique_ptr<hb_subset_input_t, SkFunctionObject<hb_subset_input_destroy>>; using HBSet = std::unique_ptr<hb_set_t, SkFunctionObject<hb_set_destroy>>;
HBFace make_subset(hb_subset_input_t* input, hb_face_t* face, bool retainZeroGlyph) { // TODO: When possible, check if a font is 'tricky' with FT_IS_TRICKY. // If it isn't known if a font is 'tricky', retain the hints. unsignedint flags = HB_SUBSET_FLAGS_RETAIN_GIDS; if (retainZeroGlyph) {
flags |= HB_SUBSET_FLAGS_NOTDEF_OUTLINE;
}
hb_subset_input_set_flags(input, flags); return HBFace(hb_subset_or_fail(face, input));
}
sk_sp<SkData> subset_harfbuzz(const SkTypeface& typeface, const SkPDFGlyphUse& glyphUsage) { int index = 0;
std::unique_ptr<SkStreamAsset> typefaceAsset = typeface.openStream(&index);
HBFace face;
HBBlob blob(stream_to_blob(std::move(typefaceAsset))); // hb_face_create always succeeds. Check that the format is minimally recognized first. // See https://github.com/harfbuzz/harfbuzz/issues/248 unsignedint num_hb_faces = hb_face_count(blob.get()); if (0 < num_hb_faces && (unsigned)index < num_hb_faces) {
face.reset(hb_face_create(blob.get(), (unsigned)index)); // Check the number of glyphs as a basic sanitization step. if (face && hb_face_get_glyph_count(face.get()) == 0) {
face.reset();
}
}
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 und die Messung sind noch experimentell.