6#if defined(SK_PDF_USE_HARFBUZZ_SUBSET)
26using HBBlob = std::unique_ptr<hb_blob_t, SkFunctionObject<hb_blob_destroy>>;
27using HBFace = std::unique_ptr<hb_face_t, SkFunctionObject<hb_face_destroy>>;
28using HBSubsetInput = std::unique_ptr<hb_subset_input_t, SkFunctionObject<hb_subset_input_destroy>>;
29using HBSet = std::unique_ptr<hb_set_t, SkFunctionObject<hb_set_destroy>>;
31HBBlob stream_to_blob(std::unique_ptr<SkStreamAsset> asset) {
32 size_t size = asset->getLength();
34 if (
const void*
base = asset->getMemoryBase()) {
35 blob.reset(hb_blob_create(
const_cast<char*
>(
static_cast<const char*
>(
base)),
SkToUInt(
size),
36 HB_MEMORY_MODE_READONLY, asset.release(),
37 [](
void*
p) { delete (SkStreamAsset*)p; }));
40 asset->read(ptr,
size);
42 HB_MEMORY_MODE_READONLY, ptr,
sk_free));
45 hb_blob_make_immutable(blob.get());
54 const char*
data = hb_blob_get_data(blob.get(), &
length);
59 [](
const void*,
void* ctx) { hb_blob_destroy((hb_blob_t*)ctx); },
63HBFace make_subset(hb_subset_input_t* input, hb_face_t* face,
bool retainZeroGlyph) {
66 unsigned int flags = HB_SUBSET_FLAGS_RETAIN_GIDS;
67 if (retainZeroGlyph) {
68 flags |= HB_SUBSET_FLAGS_NOTDEF_OUTLINE;
70 hb_subset_input_set_flags(input,
flags);
71 return HBFace(hb_subset_or_fail(face, input));
76 std::unique_ptr<SkStreamAsset> typefaceAsset = typeface.
openStream(&index);
78 HBBlob blob(stream_to_blob(std::move(typefaceAsset)));
81 unsigned int num_hb_faces = hb_face_count(blob.get());
82 if (0 < num_hb_faces && (
unsigned)index < num_hb_faces) {
83 face.reset(hb_face_create(blob.get(), (
unsigned)index));
85 if (face && hb_face_get_glyph_count(face.get()) == 0) {
90 HBSubsetInput input(hb_subset_input_create_or_fail());
92 if (!face || !input) {
95 hb_set_t*
glyphs = hb_subset_input_glyph_set(input.get());
98 HBFace subset = make_subset(input.get(), face.get(), glyphUsage.
has(0));
102 HBBlob
result(hb_face_reference_blob(subset.get()));
103 return to_data(std::move(
result));
109 return subset_harfbuzz(typeface, glyphUsage);
SK_API void sk_free(void *)
static void * sk_malloc_throw(size_t size)
sk_sp< SkData > SkPDFSubsetFont(const SkTypeface &, const SkPDFGlyphUse &)
constexpr size_t SkToSizeT(S x)
constexpr unsigned SkToUInt(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
std::unique_ptr< SkStreamAsset > openStream(int *ttcIndex) const
FlutterSemanticsFlag flags
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
std::shared_ptr< const fml::Mapping > data