mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-10 01:08:21 +00:00
bug 803347 - update graphite2 lib to upstream commit 4ddfa0f51098. r=jdaggett
This commit is contained in:
parent
4f9f468db4
commit
cd35ecb8fa
@ -169,17 +169,16 @@ Machine::Code::Code(bool is_constraint, const byte * bytecode_begin, const byte
|
||||
bytecode_end,
|
||||
pre_context,
|
||||
rule_length,
|
||||
static_cast<uint16>(silf.numClasses()),
|
||||
static_cast<uint16>(face.glyphs().numAttrs()),
|
||||
static_cast<byte>(face.numFeatures()),
|
||||
silf.numClasses(),
|
||||
face.glyphs().numAttrs(),
|
||||
face.numFeatures(),
|
||||
{1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,255,
|
||||
1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,0,0,
|
||||
0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,
|
||||
static_cast<byte>(silf.numUser())}
|
||||
0,0,0,0,0,0,0, silf.numUser()}
|
||||
};
|
||||
|
||||
decoder dec(lims, *this);
|
||||
|
@ -25,7 +25,6 @@ License, as published by the Free Software Foundation, either version 2
|
||||
of the License or (at your option) any later version.
|
||||
*/
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include "graphite2/Segment.h"
|
||||
#include "inc/CmapCache.h"
|
||||
#include "inc/debug.h"
|
||||
@ -54,7 +53,7 @@ Face::Face(const void* appFaceHandle/*non-NULL*/, const gr_face_ops & ops)
|
||||
m_descent(0)
|
||||
{
|
||||
memset(&m_ops, 0, sizeof m_ops);
|
||||
memcpy(&m_ops, &ops, std::min(sizeof m_ops, ops.size));
|
||||
memcpy(&m_ops, &ops, min(sizeof m_ops, ops.size));
|
||||
}
|
||||
|
||||
|
||||
@ -92,7 +91,7 @@ bool Face::readGlyphs(uint32 faceOptions)
|
||||
return false;
|
||||
|
||||
if (faceOptions & gr_face_preloadGlyphs)
|
||||
nameTable(); // preload the name table along with the glyphs, heh.
|
||||
nameTable(); // preload the name table along with the glyphs.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -185,23 +185,23 @@ bool SillMap::readFace(const Face & face)
|
||||
bool SillMap::readSill(const Face & face)
|
||||
{
|
||||
const Face::Table sill(face, TtfUtil::Tag::Sill);
|
||||
const byte *pSill = sill;
|
||||
const byte *p = sill;
|
||||
|
||||
if (!pSill) return true;
|
||||
if (!p) return true;
|
||||
if (sill.size() < 12) return false;
|
||||
if (be::read<uint32>(pSill) != 0x00010000UL) return false;
|
||||
m_numLanguages = be::read<uint16>(pSill);
|
||||
if (be::read<uint32>(p) != 0x00010000UL) return false;
|
||||
m_numLanguages = be::read<uint16>(p);
|
||||
m_langFeats = new LangFeaturePair[m_numLanguages];
|
||||
if (!m_langFeats || !m_FeatureMap.m_numFeats) { m_numLanguages = 0; return true; } //defensive
|
||||
|
||||
pSill += 6; // skip the fast search
|
||||
p += 6; // skip the fast search
|
||||
if (sill.size() < m_numLanguages * 8U + 12) return false;
|
||||
|
||||
for (int i = 0; i < m_numLanguages; i++)
|
||||
{
|
||||
uint32 langid = be::read<uint32>(pSill);
|
||||
uint16 numSettings = be::read<uint16>(pSill);
|
||||
uint16 offset = be::read<uint16>(pSill);
|
||||
uint32 langid = be::read<uint32>(p);
|
||||
uint16 numSettings = be::read<uint16>(p);
|
||||
uint16 offset = be::read<uint16>(p);
|
||||
if (offset + 8U * numSettings > sill.size() && numSettings > 0) return false;
|
||||
Features* feats = new Features(*m_FeatureMap.m_defaultFeatures);
|
||||
const byte *pLSet = sill + offset;
|
||||
|
@ -25,14 +25,7 @@ License, as published by the Free Software Foundation, either version 2
|
||||
of the License or (at your option) any later version.
|
||||
*/
|
||||
#include <cstring>
|
||||
//#include "graphite2/Segment.h"
|
||||
//#include "inc/CmapCache.h"
|
||||
//#include "inc/Endian.h"
|
||||
#include "inc/FileFace.h"
|
||||
//#include "inc/GlyphFace.h"
|
||||
//#include "inc/SegCacheStore.h"
|
||||
//#include "inc/Segment.h"
|
||||
//#include "inc/NameTable.h"
|
||||
|
||||
|
||||
#ifndef GRAPHITE2_NFILEFACE
|
||||
|
@ -24,7 +24,6 @@ Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public
|
||||
License, as published by the Free Software Foundation, either version 2
|
||||
of the License or (at your option) any later version.
|
||||
*/
|
||||
#include <algorithm>
|
||||
#include "inc/Face.h"
|
||||
#include "inc/Font.h"
|
||||
#include "inc/GlyphCache.h"
|
||||
@ -39,7 +38,7 @@ Font::Font(float ppm, const Face & f, const void * appFontHandle, const gr_font_
|
||||
{
|
||||
memset(&m_ops, 0, sizeof m_ops);
|
||||
if (m_hinted)
|
||||
memcpy(&m_ops, ops, std::min(sizeof m_ops, ops->size));
|
||||
memcpy(&m_ops, ops, min(sizeof m_ops, ops->size));
|
||||
else
|
||||
m_ops.glyph_advance_x = &Face::default_glyph_advance;
|
||||
|
||||
|
@ -24,8 +24,6 @@ Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public
|
||||
License, as published by the Free Software Foundation, either version 2
|
||||
of the License or (at your option) any later version.
|
||||
*/
|
||||
#include <algorithm>
|
||||
|
||||
#include "graphite2/Font.h"
|
||||
|
||||
#include "inc/Main.h"
|
||||
@ -175,6 +173,11 @@ const GlyphFace *GlyphCache::glyph(unsigned short glyphid) const //result m
|
||||
{
|
||||
GlyphFace * g = new GlyphFace();
|
||||
if (g) p = _glyph_loader->read_glyph(glyphid, *g);
|
||||
if (!p)
|
||||
{
|
||||
delete g;
|
||||
return *_glyphs;
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
@ -183,7 +186,7 @@ uint16 GlyphCache::glyphAttr(uint16 gid, uint16 gattr) const
|
||||
{
|
||||
const GlyphFace * p = glyphSafe(gid);
|
||||
|
||||
return p && gattr < _num_attrs ? p->attrs()[gattr] : 0;
|
||||
return p && gattr < p->attrs().size() ? p->attrs()[gattr] : 0;
|
||||
}
|
||||
|
||||
|
||||
@ -236,7 +239,7 @@ GlyphCache::Loader::Loader(const Face & face, const bool dumb_font)
|
||||
/ (_long_fmt ? sizeof(uint32) : sizeof(uint16)) - 1;
|
||||
|
||||
if (version != 0x00010000
|
||||
|| _num_attrs == 0 || _num_attrs > 0x1000 // is this hard limit appropriate?
|
||||
|| _num_attrs == 0 || _num_attrs > 0x3000 // is this hard limit appropriate?
|
||||
|| _num_glyphs_graphics > _num_glyphs_attributes)
|
||||
{
|
||||
_head = Face::Table();
|
||||
@ -260,7 +263,7 @@ unsigned short int GlyphCache::Loader::units_per_em() const throw()
|
||||
inline
|
||||
unsigned short int GlyphCache::Loader::num_glyphs() const throw()
|
||||
{
|
||||
return std::max(_num_glyphs_graphics, _num_glyphs_attributes);
|
||||
return max(_num_glyphs_graphics, _num_glyphs_attributes);
|
||||
}
|
||||
|
||||
inline
|
||||
@ -333,11 +336,8 @@ const GlyphFace * GlyphCache::Loader::read_glyph(unsigned short glyphid, GlyphFa
|
||||
new (&glyph) GlyphFace(bbox, advance, glat2_iterator(m_pGlat + glocs), glat2_iterator(m_pGlat + gloce));
|
||||
}
|
||||
|
||||
if (glyph.attrs().size() > _num_attrs)
|
||||
{
|
||||
glyph.~GlyphFace();
|
||||
if (glyph.attrs().capacity() > _num_attrs)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return &glyph;
|
||||
|
@ -275,16 +275,19 @@ bool Pass::readRanges(const byte * ranges, size_t num_ranges)
|
||||
memset(m_cols, 0xFF, m_numGlyphs * sizeof(uint16));
|
||||
for (size_t n = num_ranges; n; --n)
|
||||
{
|
||||
const uint16 first = be::read<uint16>(ranges),
|
||||
last = be::read<uint16>(ranges),
|
||||
col = be::read<uint16>(ranges);
|
||||
uint16 *p;
|
||||
uint16 * ci = m_cols + be::read<uint16>(ranges),
|
||||
* ci_end = m_cols + be::read<uint16>(ranges) + 1,
|
||||
col = be::read<uint16>(ranges);
|
||||
|
||||
if (first > last || last >= m_numGlyphs || col >= m_sColumns)
|
||||
if (ci >= ci_end || ci_end > m_cols+m_numGlyphs || col >= m_sColumns)
|
||||
return false;
|
||||
|
||||
for (p = m_cols + first; p <= m_cols + last; )
|
||||
*p++ = col;
|
||||
// A glyph must only belong to one column at a time
|
||||
while (ci != ci_end && *ci == 0xffff)
|
||||
*ci++ = col;
|
||||
|
||||
if (ci != ci_end)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ sparse::mapped_type sparse::operator [] (const key_type k) const throw()
|
||||
}
|
||||
|
||||
|
||||
size_t sparse::size() const throw()
|
||||
size_t sparse::capacity() const throw()
|
||||
{
|
||||
size_t n = m_nchunks,
|
||||
s = 0;
|
||||
|
@ -25,9 +25,6 @@ License, as published by the Free Software Foundation, either version 2
|
||||
of the License or (at your option) any later version.
|
||||
*/
|
||||
#pragma once
|
||||
// #include <cstring>
|
||||
// #include "graphite2/Types.h"
|
||||
//#include "graphite2/Font.h"
|
||||
#include "inc/Main.h"
|
||||
#include "inc/FeatureVal.h"
|
||||
|
||||
|
@ -48,9 +48,9 @@ public:
|
||||
GlyphCache(const Face & face, const uint32 face_options);
|
||||
~GlyphCache();
|
||||
|
||||
size_t numGlyphs() const throw();
|
||||
size_t numAttrs() const throw();
|
||||
size_t unitsPerEm() const throw();
|
||||
unsigned short numGlyphs() const throw();
|
||||
unsigned short numAttrs() const throw();
|
||||
unsigned short unitsPerEm() const throw();
|
||||
|
||||
const GlyphFace *glyph(unsigned short glyphid) const; //result may be changed by subsequent call with a different glyphid
|
||||
const GlyphFace *glyphSafe(unsigned short glyphid) const;
|
||||
@ -67,19 +67,19 @@ private:
|
||||
};
|
||||
|
||||
inline
|
||||
size_t GlyphCache::numGlyphs() const throw()
|
||||
unsigned short GlyphCache::numGlyphs() const throw()
|
||||
{
|
||||
return _num_glyphs;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t GlyphCache::numAttrs() const throw()
|
||||
unsigned short GlyphCache::numAttrs() const throw()
|
||||
{
|
||||
return _num_attrs;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t GlyphCache::unitsPerEm() const throw()
|
||||
unsigned short GlyphCache::unitsPerEm() const throw()
|
||||
{
|
||||
return _upem;
|
||||
}
|
||||
|
@ -56,6 +56,18 @@ template <typename T> T * grzeroalloc(size_t n)
|
||||
return reinterpret_cast<T*>(calloc(n, sizeof(T)));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T min(const T a, const T b)
|
||||
{
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T max(const T a, const T b)
|
||||
{
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
} // namespace graphite2
|
||||
|
||||
#define CLASS_NEW_DELETE \
|
||||
|
@ -150,8 +150,8 @@ public: //only used by: GrSegment* makeAndInitialize(const GrFont *font, c
|
||||
private:
|
||||
Rect m_bbox; // ink box of the segment
|
||||
Position m_advance; // whole segment advance
|
||||
SlotRope m_slots; // std::vector of slot buffers
|
||||
AttributeRope m_userAttrs; // std::vector of userAttrs buffers
|
||||
SlotRope m_slots; // Vector of slot buffers
|
||||
AttributeRope m_userAttrs; // Vector of userAttrs buffers
|
||||
JustifyRope m_justifies; // Slot justification info buffers
|
||||
FeatureList m_feats; // feature settings referenced by charinfos in this segment
|
||||
Slot * m_freeSlots; // linked list of free slots
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
uint16 findClassIndex(uint16 cid, uint16 gid) const;
|
||||
uint16 getClassGlyph(uint16 cid, unsigned int index) const;
|
||||
uint16 findPseudo(uint32 uid) const;
|
||||
size_t numUser() const { return m_aUser; }
|
||||
uint8 numUser() const { return m_aUser; }
|
||||
uint8 aPseudo() const { return m_aPseudo; }
|
||||
uint8 aBreak() const { return m_aBreak; }
|
||||
uint8 aMirror() const {return m_aMirror; }
|
||||
@ -86,11 +86,11 @@ public:
|
||||
uint8 positionPass() const { return m_pPass; }
|
||||
uint8 justificationPass() const { return m_jPass; }
|
||||
uint8 bidiPass() const { return m_bPass; }
|
||||
size_t numPasses() const { return m_numPasses; }
|
||||
size_t maxCompPerLig() const { return m_iMaxComp; }
|
||||
size_t numClasses() const { return m_nClass; }
|
||||
uint8 flags() const { return m_flags; }
|
||||
size_t numJustLevels() const { return m_numJusts; }
|
||||
uint8 numPasses() const { return m_numPasses; }
|
||||
uint8 maxCompPerLig() const { return m_iMaxComp; }
|
||||
uint16 numClasses() const { return m_nClass; }
|
||||
byte flags() const { return m_flags; }
|
||||
uint8 numJustLevels() const { return m_numJusts; }
|
||||
Justinfo *justAttrs() const { return m_justs; }
|
||||
uint16 endLineGlyphid() const { return m_gEndLine; }
|
||||
const gr_faceinfo *silfInfo() const { return &m_silfinfo; }
|
||||
|
@ -33,7 +33,11 @@ of the License or (at your option) any later version.
|
||||
namespace graphite2 {
|
||||
|
||||
|
||||
|
||||
// A read-only packed fast sparse array of uint16 with uint16 keys.
|
||||
// Like most container classes this has capacity and size properties and these
|
||||
// refer to the number of stored entries and the number of addressable entries
|
||||
// as normal. However due the sparse nature the capacity is always <= than the
|
||||
// size.
|
||||
class sparse
|
||||
{
|
||||
public:
|
||||
@ -64,6 +68,7 @@ public:
|
||||
operator bool () const throw();
|
||||
mapped_type operator [] (const key_type k) const throw();
|
||||
|
||||
size_t capacity() const throw();
|
||||
size_t size() const throw();
|
||||
|
||||
size_t _sizeof() const throw();
|
||||
@ -137,11 +142,16 @@ sparse::operator bool () const throw()
|
||||
return m_array.map != 0;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t sparse::size() const throw()
|
||||
{
|
||||
return m_nchunks*SIZEOF_CHUNK;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t sparse::_sizeof() const throw()
|
||||
{
|
||||
return sizeof(sparse) + size()*sizeof(mapped_type) + m_nchunks*sizeof(chunk);
|
||||
return sizeof(sparse) + capacity()*sizeof(mapped_type) + m_nchunks*sizeof(chunk);
|
||||
}
|
||||
|
||||
} // namespace graphite2
|
||||
|
@ -26,6 +26,9 @@ of the License or (at your option) any later version.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace graphite2
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
inline unsigned int bit_set_count(T v)
|
||||
{
|
||||
@ -72,16 +75,16 @@ inline unsigned int log_binary(T v)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T haszero(const T x)
|
||||
inline T has_zero(const T x)
|
||||
{
|
||||
return (x - T(~T(0)/255)) & ~x & T(~T(0)/255*128);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T zerobytes(const T x, unsigned char n)
|
||||
inline T zero_bytes(const T x, unsigned char n)
|
||||
{
|
||||
const T t = T(~T(0)/255*n);
|
||||
return T((haszero(x^t) >> 7)*n);
|
||||
return T((has_zero(x^t) >> 7)*n);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -55,8 +55,8 @@ static const opcode_t opcode_table[] =
|
||||
{{do2(sub)}, 0, "SUB"},
|
||||
{{do2(mul)}, 0, "MUL"},
|
||||
{{do2(div_)}, 0, "DIV"},
|
||||
{{do2(min)}, 0, "MIN"},
|
||||
{{do2(max)}, 0, "MAX"},
|
||||
{{do2(min_)}, 0, "MIN"},
|
||||
{{do2(max_)}, 0, "MAX"},
|
||||
{{do2(neg)}, 0, "NEG"},
|
||||
{{do2(trunc8)}, 0, "TRUNC8"},
|
||||
{{do2(trunc16)}, 0, "TRUNC16"},
|
||||
@ -114,7 +114,7 @@ static const opcode_t opcode_table[] =
|
||||
{{do_(put_glyph), NILOP}, 2, "PUT_GLYPH"}, // output_class output_class
|
||||
{{do2(push_glyph_attr)}, 3, "PUSH_GLYPH_ATTR"}, // gattrnum gattrnum slot
|
||||
{{do2(push_att_to_glyph_attr)}, 3, "PUSH_ATT_TO_GLYPH_ATTR"}, // gattrnum gattrnum slot
|
||||
// private internal private opcodes for internal use only, comes after all other on disk opcodes.
|
||||
// private opcodes for internal use only, comes after all other on disk opcodes.
|
||||
{{do_(temp_copy), NILOP}, 0, "TEMP_COPY"}
|
||||
};
|
||||
|
||||
|
@ -132,12 +132,12 @@ STARTOP(div_)
|
||||
binop(/);
|
||||
ENDOP
|
||||
|
||||
STARTOP(min)
|
||||
STARTOP(min_)
|
||||
const int32 a = pop(), b = *sp;
|
||||
if (a < b) *sp = a;
|
||||
ENDOP
|
||||
|
||||
STARTOP(max)
|
||||
STARTOP(max_)
|
||||
const int32 a = pop(), b = *sp;
|
||||
if (a > b) *sp = a;
|
||||
ENDOP
|
||||
|
Loading…
x
Reference in New Issue
Block a user