6#if defined(SK_PDF_USE_HARFBUZZ_SUBSET)
15using HBBlob = std::unique_ptr<hb_blob_t, SkFunctionObject<hb_blob_destroy>>;
16using HBFace = std::unique_ptr<hb_face_t, SkFunctionObject<hb_face_destroy>>;
17using HBSubsetInput = std::unique_ptr<hb_subset_input_t, SkFunctionObject<hb_subset_input_destroy>>;
18using HBSet = std::unique_ptr<hb_set_t, SkFunctionObject<hb_set_destroy>>;
21 using blob_size_t =
SkCallableTraits<
decltype(hb_blob_create)>::argument<1>::type;
22 if (!SkTFitsIn<blob_size_t>(
data->size())) {
25 const char* blobData =
static_cast<const char*
>(
data->data());
26 blob_size_t blobSize = SkTo<blob_size_t>(
data->size());
27 return HBBlob(hb_blob_create(blobData, blobSize,
28 HB_MEMORY_MODE_READONLY,
29 data.release(), [](
void* p){ ((SkData*)p)->unref(); }));
37 const char*
data = hb_blob_get_data(blob.get(), &
length);
42 [](
const void*,
void* ctx) { hb_blob_destroy((hb_blob_t*)ctx); },
46static HBFace make_subset(hb_subset_input_t* input, hb_face_t* face,
bool retainZeroGlyph) {
49 unsigned int flags = HB_SUBSET_FLAGS_RETAIN_GIDS;
50 if (retainZeroGlyph) {
51 flags |= HB_SUBSET_FLAGS_NOTDEF_OUTLINE;
53 hb_subset_input_set_flags(input,
flags);
54 return HBFace(hb_subset_or_fail(face, input));
63 HBFace face(hb_face_create(to_blob(std::move(fontData)).
get(), ttcIndex));
66 HBSubsetInput input(hb_subset_input_create_or_fail());
68 if (!face || !input) {
71 hb_set_t*
glyphs = hb_subset_input_glyph_set(input.get());
74 HBFace subset = make_subset(input.get(), face.get(), glyphUsage.
has(0));
78 HBBlob
result(hb_face_reference_blob(subset.get()));
79 return to_data(std::move(
result));
86 return subset_harfbuzz(std::move(fontData), glyphUsage, ttcIndex);
sk_sp< SkData > SkPDFSubsetFont(sk_sp< SkData >, const SkPDFGlyphUse &, SkPDF::Metadata::Subsetter, int)
constexpr size_t SkToSizeT(S x)
static sk_sp< SkData > MakeWithProc(const void *ptr, size_t length, ReleaseProc proc, void *ctx)
bool has(SkGlyphID gid) const
void getSetValues(FN f) const
FlutterSemanticsFlag flags
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
const myers::Point & get(const myers::Segment &)