#include "cff_charstring.h"
#include <climits>
#include <cstdio>
#include <cstring>
#include <stack>
#include <string>
#include <utility>
#define TABLE_NAME …
namespace {
const int32_t kMaxSubrsCount = …;
const size_t kMaxCharStringLength = …;
const size_t kMaxNumberOfStemHints = …;
const size_t kMaxSubrNesting = …;
const int32_t dummy_result = …;
bool ExecuteCharString(ots::OpenTypeCFF& cff,
size_t call_depth,
const ots::CFFIndex& global_subrs_index,
const ots::CFFIndex& local_subrs_index,
ots::Buffer *cff_table,
ots::Buffer *char_string,
std::stack<int32_t> *argument_stack,
ots::CharStringContext& cs_ctx);
bool ArgumentStackOverflows(std::stack<int32_t> *argument_stack, bool cff2) { … }
#ifdef DUMP_T2CHARSTRING
const char *CharStringOperatorToString(ots::CharStringOperator op) {
switch (op) {
case ots::kHStem:
return "hstem";
case ots::kVStem:
return "vstem";
case ots::kVMoveTo:
return "vmoveto";
case ots::kRLineTo:
return "rlineto";
case ots::kHLineTo:
return "hlineto";
case ots::kVLineTo:
return "vlineto";
case ots::kRRCurveTo:
return "rrcurveto";
case ots::kCallSubr:
return "callsubr";
case ots::kReturn:
return "return";
case ots::kEndChar:
return "endchar";
case ots::kVSIndex:
return "vsindex";
case ots::kBlend:
return "blend";
case ots::kHStemHm:
return "hstemhm";
case ots::kHintMask:
return "hintmask";
case ots::kCntrMask:
return "cntrmask";
case ots::kRMoveTo:
return "rmoveto";
case ots::kHMoveTo:
return "hmoveto";
case ots::kVStemHm:
return "vstemhm";
case ots::kRCurveLine:
return "rcurveline";
case ots::kRLineCurve:
return "rlinecurve";
case ots::kVVCurveTo:
return "VVCurveTo";
case ots::kHHCurveTo:
return "hhcurveto";
case ots::kCallGSubr:
return "callgsubr";
case ots::kVHCurveTo:
return "vhcurveto";
case ots::kHVCurveTo:
return "HVCurveTo";
case ots::kDotSection:
return "dotsection";
case ots::kAnd:
return "and";
case ots::kOr:
return "or";
case ots::kNot:
return "not";
case ots::kAbs:
return "abs";
case ots::kAdd:
return "add";
case ots::kSub:
return "sub";
case ots::kDiv:
return "div";
case ots::kNeg:
return "neg";
case ots::kEq:
return "eq";
case ots::kDrop:
return "drop";
case ots::kPut:
return "put";
case ots::kGet:
return "get";
case ots::kIfElse:
return "ifelse";
case ots::kRandom:
return "random";
case ots::kMul:
return "mul";
case ots::kSqrt:
return "sqrt";
case ots::kDup:
return "dup";
case ots::kExch:
return "exch";
case ots::kIndex:
return "index";
case ots::kRoll:
return "roll";
case ots::kHFlex:
return "hflex";
case ots::kFlex:
return "flex";
case ots::kHFlex1:
return "hflex1";
case ots::kFlex1:
return "flex1";
}
return "UNKNOWN";
}
#endif
bool ReadNextNumberFromCharString(ots::Buffer *char_string,
int32_t *out_number,
bool *out_is_operator) { … }
bool ValidCFF2Operator(int32_t op) { … }
bool ExecuteCharStringOperator(ots::OpenTypeCFF& cff,
int32_t op,
size_t call_depth,
const ots::CFFIndex& global_subrs_index,
const ots::CFFIndex& local_subrs_index,
ots::Buffer *cff_table,
ots::Buffer *char_string,
std::stack<int32_t> *argument_stack,
ots::CharStringContext& cs_ctx) { … }
bool ExecuteCharString(ots::OpenTypeCFF& cff,
size_t call_depth,
const ots::CFFIndex& global_subrs_index,
const ots::CFFIndex& local_subrs_index,
ots::Buffer *cff_table,
ots::Buffer *char_string,
std::stack<int32_t> *argument_stack,
ots::CharStringContext& cs_ctx) { … }
bool SelectLocalSubr(const ots::OpenTypeCFF& cff,
uint16_t glyph_index,
const ots::CFFIndex **out_local_subrs_to_use) { … }
}
namespace ots {
bool ValidateCFFCharStrings(
ots::OpenTypeCFF& cff,
const CFFIndex& global_subrs_index,
Buffer* cff_table) { … }
}
#undef TABLE_NAME