mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-29 09:34:05 +01:00
Merge pull request #6326 from harfbuzz/fix/cff2-fdselect-varc
[subset] Bound CFF2 FDSelect lookups by the CharStrings count
This commit is contained in:
1 parent
dcb6e077fb
commit
a52249ff62
5 files changed
+27
-7
No files matched your search
@@ -49,6 +49,7 @@ bool
|
||||
hb_plan_subset_cff_fdselect (const hb_subset_plan_t *plan,
|
||||
unsigned int fdCount,
|
||||
const FDSelect &src, /* IN */
|
||||
unsigned int src_num_glyphs,
|
||||
unsigned int &subset_fd_count /* OUT */,
|
||||
unsigned int &subset_fdselect_size /* OUT */,
|
||||
unsigned int &subset_fdselect_format /* OUT */,
|
||||
@@ -83,7 +84,13 @@ hb_plan_subset_cff_fdselect (const hb_subset_plan_t *plan,
|
||||
/* fonttools retains FDSelect & font dicts for missing glyphs. do the same */
|
||||
old_glyph = gid;
|
||||
}
|
||||
auto fd_range = src.get_fd_range (old_glyph);
|
||||
/* FDSelect may only cover the CharStrings glyphs; see subset_get_fd (). */
|
||||
hb_pair_t<unsigned, hb_codepoint_t> fd_range =
|
||||
likely (old_glyph < src_num_glyphs) ?
|
||||
src.get_fd_range (old_glyph) :
|
||||
hb_pair_t<unsigned, hb_codepoint_t> {0, HB_CODEPOINT_INVALID};
|
||||
if (old_glyph < src_num_glyphs)
|
||||
fd_range.second = hb_min (fd_range.second, src_num_glyphs);
|
||||
unsigned fd = fd_range.first;
|
||||
|
||||
if (fd != prev_fd)
|
||||
|
||||
@@ -34,6 +34,16 @@
|
||||
|
||||
namespace CFF {
|
||||
|
||||
/* CFF2 CharStrings may omit a tail of glyphs provided by VARC, in which
|
||||
* case FDSelect only covers the CharStrings glyphs. Use FD 0 for glyphs
|
||||
* beyond that. */
|
||||
template <typename ACC>
|
||||
static inline unsigned
|
||||
subset_get_fd (const ACC &acc, hb_codepoint_t glyph)
|
||||
{
|
||||
return likely (glyph < acc.num_glyphs) ? acc.fdSelect->get_fd (glyph) : 0;
|
||||
}
|
||||
|
||||
/* Used for writing a temporary charstring */
|
||||
struct str_encoder_t
|
||||
{
|
||||
@@ -378,7 +388,7 @@ struct subr_flattener_t
|
||||
continue;
|
||||
}
|
||||
const hb_ubytes_t str = (*acc.charStrings)[glyph];
|
||||
unsigned int fd = acc.fdSelect->get_fd (glyph);
|
||||
unsigned int fd = subset_get_fd (acc, glyph);
|
||||
if (unlikely (fd >= acc.fdCount))
|
||||
return false;
|
||||
|
||||
@@ -869,7 +879,7 @@ struct subr_subsetter_t
|
||||
hb_codepoint_t old_glyph = _.second;
|
||||
|
||||
const hb_ubytes_t str = (*acc.charStrings)[old_glyph];
|
||||
unsigned int fd = acc.fdSelect->get_fd (old_glyph);
|
||||
unsigned int fd = subset_get_fd (acc, old_glyph);
|
||||
if (unlikely (fd >= acc.fdCount))
|
||||
return false;
|
||||
|
||||
@@ -972,7 +982,7 @@ struct subr_subsetter_t
|
||||
}
|
||||
|
||||
last++; // Skip over gid
|
||||
unsigned int fd = acc.fdSelect->get_fd (old_glyph);
|
||||
unsigned int fd = subset_get_fd (acc, old_glyph);
|
||||
if (unlikely (fd >= acc.fdCount))
|
||||
return false;
|
||||
if (unlikely (!encode_str (get_parsed_charstring (gid), fd, buffArray.arrayZ[gid], encode_prefix)))
|
||||
@@ -1156,7 +1166,7 @@ struct subr_subsetter_t
|
||||
{
|
||||
hb_codepoint_t new_glyph = _.first;
|
||||
hb_codepoint_t old_glyph = _.second;
|
||||
unsigned int fd = acc.fdSelect->get_fd (old_glyph);
|
||||
unsigned int fd = subset_get_fd (acc, old_glyph);
|
||||
if (unlikely (fd >= acc.fdCount))
|
||||
return false;
|
||||
|
||||
@@ -1315,6 +1325,7 @@ HB_INTERNAL bool
|
||||
hb_plan_subset_cff_fdselect (const hb_subset_plan_t *plan,
|
||||
unsigned int fdCount,
|
||||
const CFF::FDSelect &src, /* IN */
|
||||
unsigned int src_num_glyphs,
|
||||
unsigned int &subset_fd_count /* OUT */,
|
||||
unsigned int &subset_fdselect_size /* OUT */,
|
||||
unsigned int &subset_fdselect_format /* OUT */,
|
||||
|
||||
@@ -677,6 +677,7 @@ struct cff1_subset_plan
|
||||
if (unlikely (!hb_plan_subset_cff_fdselect (plan,
|
||||
orig_fdcount,
|
||||
*acc.fdSelect,
|
||||
acc.num_glyphs,
|
||||
subset_fdcount,
|
||||
info.fd_select.size,
|
||||
subset_fdselect_format,
|
||||
|
||||
@@ -1141,7 +1141,7 @@ struct cff2_subset_plan
|
||||
if (!plan->old_gid_for_new_gid (i, &glyph))
|
||||
continue;
|
||||
const hb_ubytes_t str = (*acc.charStrings)[glyph];
|
||||
unsigned int fd = acc.fdSelect->get_fd (glyph);
|
||||
unsigned int fd = CFF::subset_get_fd (acc, glyph);
|
||||
if (unlikely (fd >= acc.fdCount))
|
||||
return false;
|
||||
used_fds.add (fd);
|
||||
@@ -1183,7 +1183,7 @@ struct cff2_subset_plan
|
||||
if (!plan->old_gid_for_new_gid (i, &glyph))
|
||||
continue;
|
||||
const hb_ubytes_t str = (*acc.charStrings)[glyph];
|
||||
unsigned int fd = acc.fdSelect->get_fd (glyph);
|
||||
unsigned int fd = CFF::subset_get_fd (acc, glyph);
|
||||
if (unlikely (fd >= acc.fdCount))
|
||||
return false;
|
||||
|
||||
@@ -1253,6 +1253,7 @@ struct cff2_subset_plan
|
||||
if (unlikely (!hb_plan_subset_cff_fdselect (plan,
|
||||
orig_fdcount,
|
||||
*(const FDSelect *)acc.fdSelect,
|
||||
acc.num_glyphs,
|
||||
subset_fdcount,
|
||||
subset_fdselect_size,
|
||||
subset_fdselect_format,
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user