mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-20 22:41:10 +01:00
Merge pull request #5784 from harfbuzz/downgrade-cff-hintmask
[subset] Fix CFF2->CFF1 specializer hintmask encoding
This commit is contained in:
1 parent
1cd38d1c56
commit
19f54f2cfd
8 files changed
+40
No files matched your search
@@ -254,6 +254,13 @@ encode_commands (const hb_vector_t<cs_command_t> &commands,
|
||||
if (cmd.op != OpCode_Invalid)
|
||||
encoder.encode_op (cmd.op);
|
||||
|
||||
/* hintmask/cntrmask are followed by raw mask bytes. */
|
||||
if (cmd.op == OpCode_hintmask || cmd.op == OpCode_cntrmask)
|
||||
{
|
||||
for (const auto &byte : cmd.mask_bytes)
|
||||
encoder.encode_byte (byte);
|
||||
}
|
||||
|
||||
if (encoder.in_error ())
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -325,6 +325,7 @@ struct cff_font_dict_op_serializer_t : op_serializer_t
|
||||
struct cs_command_t
|
||||
{
|
||||
hb_vector_t<number_t> args;
|
||||
hb_vector_t<unsigned char> mask_bytes; /* For hintmask/cntrmask payload bytes. */
|
||||
op_code_t op;
|
||||
|
||||
cs_command_t () : op (OpCode_Invalid) {}
|
||||
|
||||
@@ -218,6 +218,22 @@ struct cff2_cs_opset_flatten_t : cff2_cs_opset_t<cff2_cs_opset_flatten_t, flatte
|
||||
static void flush_hintmask (op_code_t op, cff2_cs_interp_env_t<blend_arg_t> &env, flatten_param_t& param)
|
||||
{
|
||||
SUPER::flush_hintmask (op, env, param);
|
||||
/* Preserve hintmask payload in captured commands for specializer re-encoding. */
|
||||
if (param.commands && !param.drop_hints && param.commands->length > 0)
|
||||
{
|
||||
auto &cmd = param.commands->tail ();
|
||||
if (cmd.op == op)
|
||||
{
|
||||
cmd.mask_bytes.resize (env.hintmask_size);
|
||||
if (unlikely (cmd.mask_bytes.in_error ()))
|
||||
{
|
||||
env.set_error ();
|
||||
return;
|
||||
}
|
||||
for (unsigned int i = 0; i < env.hintmask_size; i++)
|
||||
cmd.mask_bytes[i] = env.str_ref[i];
|
||||
}
|
||||
}
|
||||
if (!param.drop_hints)
|
||||
{
|
||||
str_encoder_t encoder (param.flatStr);
|
||||
|
||||
BIN
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
--downgrade-cff2
|
||||
@@ -0,0 +1,14 @@
|
||||
FONTS:
|
||||
SourceSerif4Variable-Roman-HelloWorld.otf
|
||||
|
||||
PROFILES:
|
||||
downgrade-cff2.txt
|
||||
|
||||
SUBSETS:
|
||||
Hello World
|
||||
|
||||
INSTANCES:
|
||||
wght=400,opsz=20
|
||||
|
||||
OPTIONS:
|
||||
no_fonttools
|
||||
@@ -62,6 +62,7 @@ tests = [
|
||||
'instantiate_colrv1',
|
||||
'instantiate_glyf',
|
||||
'instantiate_cff2',
|
||||
'downgrade_cff2',
|
||||
'instantiate_cff2_tsb',
|
||||
'full_instance',
|
||||
'instance_feature_variations',
|
||||
|
||||
Reference in new issue
Block a user