27 #ifndef HB_OT_COLOR_CBDT_TABLE_HH
28 #define HB_OT_COLOR_CBDT_TABLE_HH
40 #define HB_OT_TAG_CBLC HB_TAG('C','B','L','C')
41 #define HB_OT_TAG_CBDT HB_TAG('C','B','D','T')
71 cbdt_prime->
length = new_len;
153 template <
typename OffsetType>
165 unsigned int *
length)
const
182 *
size +=
sizeof (OffsetType);
183 auto *
o =
c->embed (embedded_offset);
203 switch (
u.header.indexFormat)
213 unsigned int cbdt_prime_len,
214 unsigned int num_glyphs,
219 unsigned int local_offset = cbdt_prime_len -
u.header.imageDataOffset;
220 switch (
u.header.indexFormat)
224 if (!
u.format3.add_offset (
c, local_offset,
size))
226 if (!(num_glyphs & 0x01))
239 unsigned int cbdt_prime_len,
240 unsigned int num_missing,
242 unsigned int *num_glyphs )
246 unsigned int local_offset = cbdt_prime_len -
u.header.imageDataOffset;
247 switch (
u.header.indexFormat)
250 for (
unsigned int i = 0;
i < num_missing;
i++)
259 for (
unsigned int i = 0;
i < num_missing;
i++)
276 const char *cbdt,
unsigned int cbdt_length,
279 unsigned int *
size )
const
287 auto *header_prime = subtable_prime->
get_header ();
288 unsigned int new_local_offset = cbdt_prime->
length - (
unsigned int) header_prime->imageDataOffset;
299 switch (
u.header.indexFormat)
312 switch (
u.header.indexFormat)
315 case 1:
case 3:
case 4:
316 default:
return (
false);
324 *
format =
u.header.imageFormat;
325 switch (
u.header.indexFormat)
329 default:
return false;
336 unsigned image_format,
337 unsigned int image_data_offset,
340 u.header.indexFormat = index_format;
341 u.header.imageFormat = image_format;
342 u.header.imageDataOffset = image_data_offset;
343 switch (
u.header.indexFormat)
345 case 1: *
size += IndexSubtableFormat1::min_size;
break;
346 case 3: *
size += IndexSubtableFormat3::min_size;
break;
391 unsigned int *
start )
const
400 auto *old_header = old_subtable->get_header ();
402 subtable->populate_header (old_header->indexFormat,
403 old_header->imageFormat,
405 &bitmap_size_context->
size);
407 unsigned int num_glyphs = 0;
408 bool early_exit =
false;
409 for (
unsigned int i = *
start;
i < lookup->length;
i++)
414 auto *next_header = next_subtable->
get_header ();
415 if (next_header != old_header)
421 unsigned int num_missing =
record->add_glyph_for_subset (new_gid);
422 if (
unlikely (!subtable->fill_missing_glyphs (
c->serializer,
425 &bitmap_size_context->
size,
430 c->plan->old_gid_for_new_gid (new_gid, &old_gid);
434 unsigned int old_idx = (
unsigned int) old_gid - next_record->
firstGlyphIndex;
437 bitmap_size_context->
cbdt,
441 &bitmap_size_context->
size)))
446 *
start = lookup->length;
447 if (
unlikely (!subtable->finish_subtable (
c->serializer,
450 &bitmap_size_context->
size)))
463 auto snap =
c->serializer->snapshot ();
464 unsigned int old_size = bitmap_size_context->
size;
465 unsigned int old_cbdt_prime_length = bitmap_size_context->
cbdt_prime->
length;
471 (*records)[records->
length - 1].firstGlyphIndex = 1;
472 (*records)[records->
length - 1].lastGlyphIndex = 0;
473 bitmap_size_context->
size += IndexSubtableRecord::min_size;
475 c->serializer->push ();
479 c->serializer->pop_discard ();
480 c->serializer->revert (snap);
482 bitmap_size_context->
size = old_size;
502 unsigned int num_missing = (
unsigned int) (gid -
lastGlyphIndex - 1);
514 unsigned int *
format)
const
543 bool start_glyph_is_set =
false;
544 for (
hb_codepoint_t new_gid = 0; new_gid <
c->plan->num_output_glyphs (); new_gid++)
547 if (
unlikely (!
c->plan->old_gid_for_new_gid (new_gid, &old_gid)))
continue;
559 if (!start_glyph_is_set)
562 start_glyph_is_set =
true;
565 bitmap_size_context->
end_glyph = new_gid;
580 if (
unlikely (!
c->serializer->propagate_error (lookup)))
583 bitmap_size_context->
size = 0;
588 if (
unlikely (!lookup[
start].second->add_new_record (
c, bitmap_size_context, &lookup,
this, &
start, &records)))
591 for (
unsigned int i = 0;
i < records.
length;
i++)
592 c->serializer->pop_discard ();
600 for (
unsigned int i = 0;
i < records.
length;
i++)
601 objidxs.
push (
c->serializer->pop_pack ());
602 for (
unsigned int i = 0;
i < records.
length;
i++)
606 c->serializer->add_link (
record->offsetToSubtable, objidxs[records.
length - 1 -
i]);
614 for (
unsigned int i = 0;
i < numTables; ++
i)
651 const char *cbdt,
unsigned int cbdt_length,
655 auto *out_table =
c->serializer->embed (
this);
659 bitmap_size_context.
cbdt = cbdt;
667 if (!out_table->indexSubtableArrayOffset.serialize_subset (
c,
670 &bitmap_size_context))
672 if (!bitmap_size_context.
size ||
677 out_table->indexTablesSize = bitmap_size_context.
size;
678 out_table->numberOfIndexSubtables = bitmap_size_context.
num_tables;
679 out_table->startGlyphIndex = bitmap_size_context.
start_glyph;
680 out_table->endGlyphIndex = bitmap_size_context.
end_glyph;
760 const char *cbdt ,
unsigned int cbdt_length,
766 auto snap =
c->serializer->snapshot ();
767 auto cbdt_prime_len = cbdt_prime->
length;
769 if (!
table.subset (
c,
this, cbdt, cbdt_length, cbdt_prime))
772 c->serializer->revert (snap);
773 cbdt_prime->
shrink (cbdt_prime_len);
789 unsigned int requested_ppem = hb_max (
font->x_ppem,
font->y_ppem);
791 requested_ppem = 1<<30;
792 unsigned int best_i = 0;
795 for (
unsigned int i = 1;
i <
count;
i++)
798 if ((requested_ppem <= ppem && ppem < best_ppem) ||
799 (requested_ppem > best_ppem && ppem > best_ppem))
831 this->cblc.destroy ();
832 this->cbdt.destroy ();
841 if (!subtable_record || !strike.
ppemX || !strike.
ppemY)
847 unsigned int image_offset = 0, image_length = 0, image_format = 0;
848 if (!subtable_record->
get_image_data (glyph,
base, &image_offset, &image_length, &image_format))
851 unsigned int cbdt_len = cbdt.get_length ();
852 if (
unlikely (image_offset > cbdt_len || cbdt_len - image_offset < image_length))
855 switch (image_format)
858 if (
unlikely (image_length < GlyphBitmapDataFormat17::min_size))
860 auto &glyphFormat17 = StructAtOffset<GlyphBitmapDataFormat17> (this->cbdt, image_offset);
861 glyphFormat17.glyphMetrics.get_extents (
font, extents);
865 if (
unlikely (image_length < GlyphBitmapDataFormat18::min_size))
867 auto &glyphFormat18 = StructAtOffset<GlyphBitmapDataFormat18> (this->cbdt, image_offset);
868 glyphFormat18.glyphMetrics.get_extents (
font, extents);
871 default:
return false;
875 float x_scale = upem / (float) strike.
ppemX;
876 float y_scale = upem / (
float) strike.
ppemY;
891 if (!subtable_record || !strike.
ppemX || !strike.
ppemY)
894 unsigned int image_offset = 0, image_length = 0, image_format = 0;
895 if (!subtable_record->
get_image_data (glyph,
base, &image_offset, &image_length, &image_format))
898 unsigned int cbdt_len = cbdt.get_length ();
899 if (
unlikely (image_offset > cbdt_len || cbdt_len - image_offset < image_length))
902 switch (image_format)
906 if (
unlikely (image_length < GlyphBitmapDataFormat17::min_size))
908 auto &glyphFormat17 = StructAtOffset<GlyphBitmapDataFormat17> (this->cbdt, image_offset);
910 image_offset + GlyphBitmapDataFormat17::min_size,
911 glyphFormat17.data.len);
915 if (
unlikely (image_length < GlyphBitmapDataFormat18::min_size))
917 auto &glyphFormat18 = StructAtOffset<GlyphBitmapDataFormat18> (this->cbdt, image_offset);
919 image_offset + GlyphBitmapDataFormat18::min_size,
920 glyphFormat18.data.len);
924 if (
unlikely (image_length < GlyphBitmapDataFormat19::min_size))
926 auto &glyphFormat19 = StructAtOffset<GlyphBitmapDataFormat19> (this->cbdt, image_offset);
928 image_offset + GlyphBitmapDataFormat19::min_size,
929 glyphFormat19.data.len);
935 bool has_data ()
const {
return cbdt.get_length (); }
963 auto *cblc_prime =
c->serializer->start_embed<
CBLC> ();
973 unsigned int cbdt_length;
975 if (
unlikely (cbdt_length < CBDT::min_size))
980 _copy_data_to_cbdt (&cbdt_prime, cbdt, CBDT::min_size);
small capitals from c petite p scientific i
[1]
hb_blob_t * hb_blob_get_empty()
hb_blob_t * hb_blob_create_sub_blob(hb_blob_t *parent, unsigned int offset, unsigned int length)
const char * hb_blob_get_data(hb_blob_t *blob, unsigned int *length)
hb_blob_t * hb_blob_create(const char *data, unsigned int length, hb_memory_mode_t mode, void *user_data, hb_destroy_func_t destroy)
void hb_blob_destroy(hb_blob_t *blob)
#define TRACE_SERIALIZE(this)
#define TRACE_SANITIZE(this)
#define return_trace(RET)
#define TRACE_SUBSET(this)
void const void *obj HB_UNUSED
unsigned int hb_face_get_upem(const hb_face_t *face)
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
[3]
GLenum GLuint GLenum GLsizei length
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLint GLsizei GLsizei GLenum format
GLenum const void GLbitfield GLuint firstGlyphIndex
GLenum GLenum GLsizei void * table
@ HB_MEMORY_MODE_WRITABLE
bool sanitize(hb_sanitize_context_t *c, const void *base) const
HBGlyphID16 endGlyphIndex
const IndexSubtableRecord * find_table(hb_codepoint_t glyph, const void *base, const void **out_base) const
HBGlyphID16 startGlyphIndex
SBitLineMetrics horizontal
bool subset(hb_subset_context_t *c, const void *base, const char *cbdt, unsigned int cbdt_length, hb_vector_t< char > *cbdt_prime) const
HBUINT32 numberOfIndexSubtables
NNOffset32To< IndexSubtableArray > indexSubtableArrayOffset
bool get_extents(hb_font_t *font, hb_codepoint_t glyph, hb_glyph_extents_t *extents) const
hb_blob_t * reference_png(hb_font_t *font, hb_codepoint_t glyph) const
accelerator_t(hb_face_t *face)
CBDT_accelerator_t(hb_face_t *face)
UnsizedArrayOf< HBUINT8 > dataZ
bool sanitize(hb_sanitize_context_t *c) const
static constexpr hb_tag_t tableTag
DEFINE_SIZE_ARRAY(4, dataZ)
bool subset_size_table(hb_subset_context_t *c, const BitmapSizeTable &table, const char *cbdt, unsigned int cbdt_length, CBLC *cblc_prime, hb_vector_t< char > *cbdt_prime) const
static constexpr hb_tag_t tableTag
HB_INTERNAL bool subset(hb_subset_context_t *c) const
DEFINE_SIZE_ARRAY(8, sizeTables)
bool sanitize(hb_sanitize_context_t *c) const
Array32Of< BitmapSizeTable > sizeTables
static bool sink_cbdt(hb_subset_context_t *c, hb_vector_t< char > *cbdt_prime)
const BitmapSizeTable & choose_strike(hb_font_t *font) const
bool sanitize(hb_sanitize_context_t *c, unsigned int count) const
const IndexSubtableRecord * find_table(hb_codepoint_t glyph, unsigned int numTables) const
UnsizedArrayOf< IndexSubtableRecord > indexSubtablesZ
bool subset(hb_subset_context_t *c, cblc_bitmap_size_subset_context_t *bitmap_size_context) const
void build_lookup(hb_subset_context_t *c, cblc_bitmap_size_subset_context_t *bitmap_size_context, hb_vector_t< hb_pair_t< hb_codepoint_t, const IndexSubtableRecord * >> *lookup) const
bool get_extents(hb_glyph_extents_t *extents HB_UNUSED) const
void populate_header(unsigned index_format, unsigned image_format, unsigned int image_data_offset, unsigned int *size)
bool add_offset(hb_serialize_context_t *c, unsigned int local_offset, unsigned int *size)
DEFINE_SIZE_UNION(8, header)
bool get_image_data(unsigned int idx, unsigned int *offset, unsigned int *length, unsigned int *format) const
bool sanitize(hb_sanitize_context_t *c, unsigned int glyph_count) const
bool copy_glyph_at_idx(hb_serialize_context_t *c, unsigned int idx, const char *cbdt, unsigned int cbdt_length, hb_vector_t< char > *cbdt_prime, IndexSubtable *subtable_prime, unsigned int *size) const
union OT::IndexSubtable::@150 u
bool fill_missing_glyphs(hb_serialize_context_t *c, unsigned int cbdt_prime_len, unsigned int num_missing, unsigned int *size, unsigned int *num_glyphs)
bool finish_subtable(hb_serialize_context_t *c, unsigned int cbdt_prime_len, unsigned int num_glyphs, unsigned int *size)
const IndexSubtableHeader * get_header() const
IndexSubtableHeader header
IndexSubtableFormat1 format1
IndexSubtableFormat3 format3
HBGlyphID16 lastGlyphIndex
Offset32To< IndexSubtable > offsetToSubtable
bool get_extents(hb_glyph_extents_t *extents, const void *base) const
bool sanitize(hb_sanitize_context_t *c, const void *base) const
HBGlyphID16 firstGlyphIndex
const IndexSubtable * get_subtable(const void *base) const
IndexSubtableRecord & operator=(const IndexSubtableRecord &o)
bool add_new_subtable(hb_subset_context_t *c, cblc_bitmap_size_subset_context_t *bitmap_size_context, IndexSubtableRecord *record, const hb_vector_t< hb_pair_t< hb_codepoint_t, const IndexSubtableRecord * >> *lookup, const void *base, unsigned int *start) const
unsigned int add_glyph_for_subset(hb_codepoint_t gid)
bool add_new_record(hb_subset_context_t *c, cblc_bitmap_size_subset_context_t *bitmap_size_context, const hb_vector_t< hb_pair_t< hb_codepoint_t, const IndexSubtableRecord * >> *lookup, const void *base, unsigned int *start, hb_vector_t< IndexSubtableRecord > *records) const
bool get_image_data(unsigned int gid, const void *base, unsigned int *offset, unsigned int *length, unsigned int *format) const
HBINT8 caretSlopeDenominator
HBINT8 caretSlopeNumerator
bool sanitize(hb_sanitize_context_t *c) const
bool sanitize(hb_sanitize_context_t *c) const
void get_extents(hb_font_t *font, hb_glyph_extents_t *extents) const
hb_vector_t< char > * cbdt_prime
hb_codepoint_t start_glyph
bool alloc(unsigned int size)