Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for 1.3.0 #22

Open
wants to merge 4 commits into
base: origin-1.3.0-1733939394
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/GTF.txt
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,8 @@ approaches are supported in the ClassMap table structure:

|USHORT |numLinear |Number of linearly stored replacement classes |

|USHORT |oClass[ ] |Array of numClass + 1 offsets to class arrays from
the beginning of the class map |
|ULONG |oClass[ ] |Array of numClass + 1 offsets to class arrays from
the beginning of the class map | 4.0 changed from USHORT

|USHORT |glyphs[ ] |Glyphs for linear classes |

Expand Down
14 changes: 7 additions & 7 deletions src/CmapCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ const void * bmp_subtable(const Face::Table & cmap)
{
const void * stbl;
if (!cmap.size()) return 0;
if (TtfUtil::CheckCmapSubtable4(stbl = TtfUtil::FindCmapSubtable(cmap, 3, 1, cmap.size()))
|| TtfUtil::CheckCmapSubtable4(stbl = TtfUtil::FindCmapSubtable(cmap, 0, 3, cmap.size()))
|| TtfUtil::CheckCmapSubtable4(stbl = TtfUtil::FindCmapSubtable(cmap, 0, 2, cmap.size()))
|| TtfUtil::CheckCmapSubtable4(stbl = TtfUtil::FindCmapSubtable(cmap, 0, 1, cmap.size()))
|| TtfUtil::CheckCmapSubtable4(stbl = TtfUtil::FindCmapSubtable(cmap, 0, 0, cmap.size())))
if (TtfUtil::CheckCmapSubtable4(stbl = TtfUtil::FindCmapSubtable(cmap, 3, 1, cmap.size()), cmap.size())
|| TtfUtil::CheckCmapSubtable4(stbl = TtfUtil::FindCmapSubtable(cmap, 0, 3, cmap.size()), cmap.size())
|| TtfUtil::CheckCmapSubtable4(stbl = TtfUtil::FindCmapSubtable(cmap, 0, 2, cmap.size()), cmap.size())
|| TtfUtil::CheckCmapSubtable4(stbl = TtfUtil::FindCmapSubtable(cmap, 0, 1, cmap.size()), cmap.size())
|| TtfUtil::CheckCmapSubtable4(stbl = TtfUtil::FindCmapSubtable(cmap, 0, 0, cmap.size()), cmap.size()))
return stbl;
return 0;
}
Expand All @@ -51,8 +51,8 @@ const void * smp_subtable(const Face::Table & cmap)
{
const void * stbl;
if (!cmap.size()) return 0;
if (TtfUtil::CheckCmapSubtable12(stbl = TtfUtil::FindCmapSubtable(cmap, 3, 10, cmap.size()))
|| TtfUtil::CheckCmapSubtable12(stbl = TtfUtil::FindCmapSubtable(cmap, 0, 4, cmap.size())))
if (TtfUtil::CheckCmapSubtable12(stbl = TtfUtil::FindCmapSubtable(cmap, 3, 10, cmap.size()), cmap.size())
|| TtfUtil::CheckCmapSubtable12(stbl = TtfUtil::FindCmapSubtable(cmap, 0, 4, cmap.size()), cmap.size()))
return stbl;
return 0;
}
Expand Down
12 changes: 8 additions & 4 deletions src/Code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class Machine::Code::decoder
analysis _analysis;
enum passtype _passtype;
int _stack_depth;
bool _in_ctxt_item;
};


Expand All @@ -139,7 +140,8 @@ inline Machine::Code::decoder::decoder(limits & lims, Code &code, enum passtype
_pre_context(code._constraint ? 0 : lims.pre_context),
_rule_length(code._constraint ? 1 : lims.rule_length),
_instr(code._code), _data(code._data), _max(lims), _passtype(pt),
_stack_depth(0)
_stack_depth(0),
_in_ctxt_item(false)
{ }


Expand Down Expand Up @@ -357,8 +359,8 @@ opcode Machine::Code::decoder::fetch_opcode(const byte * bc)
break;
case CNTXT_ITEM :
valid_upto(_max.rule_length, _max.pre_context + int8(bc[0]));
if (bc + 2 + bc[1] >= _max.bytecode) failure(jump_past_end);
if (_pre_context != 0) failure(nested_context_item);
if (bc + 2 + bc[1] >= _max.bytecode) failure(jump_past_end);
if (_in_ctxt_item) failure(nested_context_item);
break;
case ATTR_SET :
case ATTR_ADD :
Expand Down Expand Up @@ -561,6 +563,7 @@ bool Machine::Code::decoder::emit_opcode(opcode opc, const byte * & bc)
if (opc == CNTXT_ITEM)
{
assert(_pre_context == 0);
_in_ctxt_item = true;
_pre_context = _max.pre_context + int8(_data[-2]);
_rule_length = _max.rule_length;

Expand All @@ -579,6 +582,7 @@ bool Machine::Code::decoder::emit_opcode(opcode opc, const byte * & bc)

_rule_length = 1;
_pre_context = 0;
_in_ctxt_item = false;
}
else
return false;
Expand Down Expand Up @@ -620,7 +624,7 @@ bool Machine::Code::decoder::validate_opcode(const opcode opc, const byte * cons
}
const opcode_t & op = Machine::getOpcodeTable()[opc];
const size_t param_sz = op.param_sz == VARARGS ? bc[0] + 1 : op.param_sz;
if (bc - 1 + param_sz > _max.bytecode)
if (bc - 1 + param_sz >= _max.bytecode)
{
failure(arguments_exhausted);
return false;
Expand Down
Loading