Bug 1626550 - Update graphite to version 1.3.14. r=lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D69175

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jonathan Kew 2020-04-01 11:00:36 +00:00
parent 3459a30936
commit 9aa1468712
11 changed files with 74 additions and 26 deletions

View File

@ -1,3 +1,3 @@
This directory contains the Graphite2 library release 1.3.13 from
https://github.com/silnrsi/graphite/releases/download/1.3.13/graphite2-minimal-1.3.13.tgz
This directory contains the Graphite2 library release 1.3.14 from
https://github.com/silnrsi/graphite/releases/download/1.3.14/graphite2-minimal-1.3.14.tgz
See ./gfx/graphite2/moz-gr-update.sh for update procedure.

View File

@ -30,7 +30,7 @@
#define GR2_VERSION_MAJOR 1
#define GR2_VERSION_MINOR 3
#define GR2_VERSION_BUGFIX 13
#define GR2_VERSION_BUGFIX 14
#ifdef __cplusplus
extern "C"

View File

@ -111,7 +111,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
add_definitions(-mfpmath=sse -msse2)
endif()
if (CMAKE_COMPILER_IS_GNUCXX)
add_definitions(-Wdouble-promotion)
add_definitions(-Wno-class-memaccess -Wdouble-promotion)
endif()
message(STATUS "Compiler ID is: ${CMAKE_CXX_COMPILER_ID}")
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
@ -136,9 +136,12 @@ endif()
if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set_target_properties(graphite2 PROPERTIES
COMPILE_FLAGS "-Wall -Wextra -Wno-unknown-pragmas -Wimplicit-fallthrough -Wendif-labels -Wshadow -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -fno-rtti -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden -mfpmath=sse -msse2"
COMPILE_FLAGS "-Wall -Wextra -Wno-unknown-pragmas -Wimplicit-fallthrough -Wendif-labels -Wshadow -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -fno-rtti -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden"
LINK_FLAGS "-nodefaultlibs"
LINKER_LANGUAGE C)
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86|i.86")
add_definitions(-mfpmath=sse -msse2)
endif()
target_link_libraries(graphite2 c)
include(Graphite)
nolib_test(stdc++ $<TARGET_SONAME_FILE:graphite2>)

View File

@ -101,6 +101,7 @@ private:
bool valid_upto(const uint16 limit, const uint16 x) const throw();
bool test_context() const throw();
bool test_ref(int8 index) const throw();
bool test_attr(attrCode attr) const throw();
void failure(const status_t s) const throw() { _code.failure(s); }
Code & _code;
@ -381,6 +382,7 @@ opcode Machine::Code::decoder::fetch_opcode(const byte * bc)
valid_upto(gr_slatMax, bc[0]);
if (attrCode(bc[0]) == gr_slatUserDefn) // use IATTR for user attributes
failure(out_of_range_data);
test_attr(attrCode(bc[0]));
test_context();
break;
case IATTR_SET_SLOT :
@ -388,6 +390,7 @@ opcode Machine::Code::decoder::fetch_opcode(const byte * bc)
failure(underfull_stack);
if (valid_upto(gr_slatMax, bc[0]))
valid_upto(_max.attrid[bc[0]], bc[1]);
test_attr(attrCode(bc[0]));
test_context();
break;
case PUSH_SLOT_ATTR :
@ -396,6 +399,7 @@ opcode Machine::Code::decoder::fetch_opcode(const byte * bc)
test_ref(int8(bc[1]));
if (attrCode(bc[0]) == gr_slatUserDefn) // use IATTR for user attributes
failure(out_of_range_data);
test_attr(attrCode(bc[0]));
break;
case PUSH_GLYPH_ATTR_OBS :
case PUSH_ATT_TO_GATTR_OBS :
@ -422,6 +426,7 @@ opcode Machine::Code::decoder::fetch_opcode(const byte * bc)
test_ref(int8(bc[1]));
valid_upto(_max.attrid[bc[0]], bc[2]);
}
test_attr(attrCode(bc[0]));
break;
case PUSH_IGLYPH_ATTR :// not implemented
++_stack_depth;
@ -441,6 +446,7 @@ opcode Machine::Code::decoder::fetch_opcode(const byte * bc)
failure(underfull_stack);
if (valid_upto(gr_slatMax, bc[0]))
valid_upto(_max.attrid[bc[0]], bc[1]);
test_attr(attrCode(bc[0]));
test_context();
break;
case PUSH_PROC_STATE : // dummy: dp[0] no check necessary
@ -681,7 +687,15 @@ bool Machine::Code::decoder::test_ref(int8 index) const throw()
}
}
else
return valid_upto(_max.rule_length, _slotref + _max.pre_context + index);
{
if (_max.rule_length == 0
|| (_slotref + _max.pre_context + index >= _max.rule_length)
|| (_slotref + _max.pre_context + index < 0))
{
failure(out_of_range_data);
return false;
}
}
return true;
}
@ -695,6 +709,22 @@ bool Machine::Code::decoder::test_context() const throw()
return true;
}
bool Machine::Code::decoder::test_attr(attrCode) const throw()
{
#if 0 // This code is coming but causes backward compatibility problems.
if (_passtype < PASS_TYPE_POSITIONING)
{
if (attr != gr_slatBreak && attr != gr_slatDir && attr != gr_slatUserDefn
&& attr != gr_slatCompRef)
{
failure(out_of_range_data);
return false;
}
}
#endif
return true;
}
inline
void Machine::Code::failure(const status_t s) throw() {
release_buffers();

View File

@ -1081,8 +1081,8 @@ void SlotCollision::initFromSlot(Segment *seg, Slot *slot)
return;
const sparse &p = glyphFace->attrs();
_flags = p[aCol];
_limit = Rect(Position(p[aCol+1], p[aCol+2]),
Position(p[aCol+3], p[aCol+4]));
_limit = Rect(Position(int16(p[aCol+1]), int16(p[aCol+2])),
Position(int16(p[aCol+3]), int16(p[aCol+4])));
_margin = p[aCol+5];
_marginWt = p[aCol+6];

View File

@ -71,7 +71,7 @@ namespace
FeatureRef::FeatureRef(const Face & face,
unsigned short & bits_offset, uint32 max_val,
uint32 name, uint16 uiName, uint16 flags,
uint32 name, uint16 uiName, flags_t flags,
FeatureSetting *settings, uint16 num_set) throw()
: m_face(&face),
m_nameValues(settings),
@ -79,8 +79,8 @@ FeatureRef::FeatureRef(const Face & face,
m_max(max_val),
m_id(name),
m_nameid(uiName),
m_flags(flags),
m_numSet(num_set)
m_numSet(num_set),
m_flags(flags)
{
const uint8 need_bits = bit_set_count(m_mask);
m_index = (bits_offset + need_bits) / SIZEOF_CHUNK;
@ -163,7 +163,8 @@ bool FeatureMap::readFeats(const Face & face)
}
::new (m_feats + i) FeatureRef (face, bits, maxVal,
label, uiName, flags,
label, uiName,
FeatureRef::flags_t(flags),
uiSet, num_settings);
}
new (&m_defaultFeatures) Features(bits/(sizeof(uint32)*8) + 1, *this);

View File

@ -704,7 +704,7 @@ void Pass::adjustSlot(int delta, Slot * & slot_out, SlotMap & smap) const
{
slot_out = smap.segment.last();
++delta;
if (!smap.highwater())
if (!smap.highwater() || smap.highwater() == slot_out)
smap.highpassed(false);
}
else

View File

@ -47,7 +47,6 @@ $(_NS)_SOURCES = \
$($(_NS)_BASE)/src/gr_segment.cpp \
$($(_NS)_BASE)/src/gr_slot.cpp \
$($(_NS)_BASE)/src/json.cpp \
$($(_NS)_BASE)/src/CachedFace.cpp \
$($(_NS)_BASE)/src/CmapCache.cpp \
$($(_NS)_BASE)/src/Code.cpp \
$($(_NS)_BASE)/src/Collider.cpp \
@ -74,7 +73,6 @@ $(_NS)_PRIVATE_HEADERS = \
$($(_NS)_BASE)/src/inc/bits.h \
$($(_NS)_BASE)/src/inc/debug.h \
$($(_NS)_BASE)/src/inc/json.h \
$($(_NS)_BASE)/src/inc/CachedFace.h \
$($(_NS)_BASE)/src/inc/CharInfo.h \
$($(_NS)_BASE)/src/inc/CmapCache.h \
$($(_NS)_BASE)/src/inc/Code.h \

View File

@ -163,14 +163,25 @@ const gr_feature_ref* gr_face_find_fref(const gr_face* pFace, gr_uint32 featId)
unsigned short gr_face_n_fref(const gr_face* pFace)
{
assert(pFace);
return pFace->numFeatures();
int res = 0;
for (int i = 0; i < pFace->numFeatures(); ++i)
if (!(pFace->feature(i)->getFlags() & FeatureRef::HIDDEN))
++res;
return res;
}
const gr_feature_ref* gr_face_fref(const gr_face* pFace, gr_uint16 i) //When finished with the FeatureRef, call destroy_FeatureRef
{
assert(pFace);
const FeatureRef* pRef = pFace->feature(i);
return static_cast<const gr_feature_ref*>(pRef);
int count = 0;
for (int j = 0; j < pFace->numFeatures(); ++j)
{
const FeatureRef* pRef = pFace->feature(j);
if (!(pRef->getFlags() & FeatureRef::HIDDEN))
if (count++ == i)
return static_cast<const gr_feature_ref*>(pRef);
}
return 0;
}
unsigned short gr_face_n_languages(const gr_face* pFace)

View File

@ -95,8 +95,9 @@ float gr_slot_advance_X(const gr_slot* p/*not NULL*/, const gr_face *face, const
if (font)
{
scale = font->scale();
if (face && font->isHinted())
res = (res - face->glyphs().glyph(p->gid())->theAdvance().x) * scale + font->advance(p->gid());
int gid = p->glyph();
if (face && font->isHinted() && gid < face->glyphs().numGlyphs())
res = (res - face->glyphs().glyph(gid)->theAdvance().x) * scale + font->advance(gid);
else
res = res * scale;
}

View File

@ -56,9 +56,12 @@ class FeatureRef
static const uint8 SIZEOF_CHUNK = sizeof(chunk_t)*8;
public:
enum flags_t : uint16 {
HIDDEN = 0x0800
};
FeatureRef() throw();
FeatureRef(const Face & face, unsigned short & bits_offset, uint32 max_val,
uint32 name, uint16 uiName, uint16 flags,
uint32 name, uint16 uiName, flags_t flags,
FeatureSetting *settings, uint16 num_set) throw();
~FeatureRef() throw();
@ -75,6 +78,7 @@ public:
uint16 getNumSettings() const { return m_numSet; }
uint16 getSettingName(uint16 index) const { return m_nameValues[index].label(); }
int16 getSettingValue(uint16 index) const { return m_nameValues[index].value(); }
flags_t getFlags() const { return m_flags; }
uint32 maxVal() const { return m_max; }
const Face & getFace() const { assert(m_face); return *m_face;}
const FeatureMap* getFeatureMap() const;// { return m_pFace;}
@ -88,9 +92,9 @@ private:
chunk_t m_mask, // bit mask to get the value from the vector
m_max; // max value the value can take
uint32 m_id; // feature identifier/name
uint16 m_nameid, // Name table id for feature name
m_flags, // feature flags (unused at the moment but read from the font)
m_numSet; // number of values (number of entries in m_nameValues)
uint16 m_nameid, // Name table id for feature name
m_numSet; // number of values (number of entries in m_nameValues)
flags_t m_flags; // feature flags see FeatureRef::flags_t.
byte m_bits, // how many bits to shift the value into place
m_index; // index into the array to find the ulong to mask
@ -103,8 +107,8 @@ FeatureRef::FeatureRef() throw()
: m_face(0),
m_nameValues(0),
m_mask(0), m_max(0),
m_id(0),
m_nameid(0), m_flags(0), m_numSet(0),
m_id(0), m_nameid(0), m_numSet(0),
m_flags(flags_t(0)),
m_bits(0), m_index(0)
{
}