summaryrefslogtreecommitdiff
path: root/Build/source/libs/graphite2/graphite2-src/src/inc
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/graphite2/graphite2-src/src/inc')
-rw-r--r--Build/source/libs/graphite2/graphite2-src/src/inc/Code.h8
-rw-r--r--Build/source/libs/graphite2/graphite2-src/src/inc/Face.h2
-rw-r--r--Build/source/libs/graphite2/graphite2-src/src/inc/GlyphFace.h2
-rw-r--r--Build/source/libs/graphite2/graphite2-src/src/inc/Rule.h9
-rw-r--r--Build/source/libs/graphite2/graphite2-src/src/inc/Segment.h4
-rw-r--r--Build/source/libs/graphite2/graphite2-src/src/inc/Slot.h5
-rw-r--r--Build/source/libs/graphite2/graphite2-src/src/inc/UtfCodec.h43
-rw-r--r--Build/source/libs/graphite2/graphite2-src/src/inc/opcode_table.h2
-rw-r--r--Build/source/libs/graphite2/graphite2-src/src/inc/opcodes.h7
9 files changed, 63 insertions, 19 deletions
diff --git a/Build/source/libs/graphite2/graphite2-src/src/inc/Code.h b/Build/source/libs/graphite2/graphite2-src/src/inc/Code.h
index 5451a34809b..3985ae416e9 100644
--- a/Build/source/libs/graphite2/graphite2-src/src/inc/Code.h
+++ b/Build/source/libs/graphite2/graphite2-src/src/inc/Code.h
@@ -86,7 +86,7 @@ private:
void failure(const status_t) throw();
public:
- static size_t estimateCodeDataOut(size_t num_bytecodes);
+ static size_t estimateCodeDataOut(size_t num_bytecodes, int nRules, int nSlots);
Code() throw();
Code(bool is_constraint, const byte * bytecode_begin, const byte * const bytecode_end,
@@ -112,9 +112,11 @@ public:
};
inline
-size_t Machine::Code::estimateCodeDataOut(size_t n_bc)
+size_t Machine::Code::estimateCodeDataOut(size_t n_bc, int nRules, int nSlots)
{
- return (n_bc + 1) * (sizeof(instr)+sizeof(byte));
+ // max is: all codes are instructions + 1 for each rule + max tempcopies
+ // allocate space for separate maximal code and data then merge them later
+ return (n_bc + nRules + nSlots) * sizeof(instr) + n_bc * sizeof(byte);
}
diff --git a/Build/source/libs/graphite2/graphite2-src/src/inc/Face.h b/Build/source/libs/graphite2/graphite2-src/src/inc/Face.h
index 7682dfaca3e..43ea4319681 100644
--- a/Build/source/libs/graphite2/graphite2-src/src/inc/Face.h
+++ b/Build/source/libs/graphite2/graphite2-src/src/inc/Face.h
@@ -87,7 +87,7 @@ public:
const FeatureRef * feature(uint16 index) const;
// Glyph related
- uint16 getGlyphMetric(uint16 gid, uint8 metric) const;
+ int32 getGlyphMetric(uint16 gid, uint8 metric) const;
uint16 findPseudo(uint32 uid) const;
// Errors
diff --git a/Build/source/libs/graphite2/graphite2-src/src/inc/GlyphFace.h b/Build/source/libs/graphite2/graphite2-src/src/inc/GlyphFace.h
index 89ed5aea91a..41685a55f4f 100644
--- a/Build/source/libs/graphite2/graphite2-src/src/inc/GlyphFace.h
+++ b/Build/source/libs/graphite2/graphite2-src/src/inc/GlyphFace.h
@@ -51,7 +51,7 @@ public:
const Position & theAdvance() const;
const Rect & theBBox() const { return m_bbox; }
const sparse & attrs() const { return m_attrs; }
- uint16 getMetric(uint8 metric) const;
+ int32 getMetric(uint8 metric) const;
CLASS_NEW_DELETE;
private:
diff --git a/Build/source/libs/graphite2/graphite2-src/src/inc/Rule.h b/Build/source/libs/graphite2/graphite2-src/src/inc/Rule.h
index 36c8d89a63d..5ac21a17598 100644
--- a/Build/source/libs/graphite2/graphite2-src/src/inc/Rule.h
+++ b/Build/source/libs/graphite2/graphite2-src/src/inc/Rule.h
@@ -102,7 +102,7 @@ class SlotMap
{
public:
enum {MAX_SLOTS=64};
- SlotMap(Segment & seg, uint8 direction);
+ SlotMap(Segment & seg, uint8 direction, int maxSize);
Slot * * begin();
Slot * * end();
@@ -121,6 +121,7 @@ public:
void highpassed(bool v) { m_highpassed = v; }
uint8 dir() const { return m_dir; }
+ int decMax() { return --m_maxSize; }
Segment & segment;
private:
@@ -128,6 +129,7 @@ private:
unsigned short m_size;
unsigned short m_precontext;
Slot * m_highwater;
+ int m_maxSize;
uint8 m_dir;
bool m_highpassed;
};
@@ -242,8 +244,9 @@ void FiniteStateMachine::Rules::accumulate_rules(const State &state)
}
inline
-SlotMap::SlotMap(Segment & seg, uint8 direction)
-: segment(seg), m_size(0), m_precontext(0), m_highwater(0), m_dir(direction), m_highpassed(false)
+SlotMap::SlotMap(Segment & seg, uint8 direction, int maxSize)
+: segment(seg), m_size(0), m_precontext(0), m_highwater(0),
+ m_maxSize(maxSize), m_dir(direction), m_highpassed(false)
{
m_slot_map[0] = 0;
}
diff --git a/Build/source/libs/graphite2/graphite2-src/src/inc/Segment.h b/Build/source/libs/graphite2/graphite2-src/src/inc/Segment.h
index 7d72f98eda4..bcba1f2a87b 100644
--- a/Build/source/libs/graphite2/graphite2-src/src/inc/Segment.h
+++ b/Build/source/libs/graphite2/graphite2-src/src/inc/Segment.h
@@ -40,7 +40,7 @@ of the License or (at your option) any later version.
#include "inc/List.h"
#include "inc/Collider.h"
-#define MAX_SEG_GROWTH_FACTOR 256
+#define MAX_SEG_GROWTH_FACTOR 64
namespace graphite2 {
@@ -159,7 +159,7 @@ public:
void reverseSlots();
bool isWhitespace(const int cid) const;
- bool hasCollisionInfo() const { return (m_flags & SEG_HASCOLLISIONS); }
+ bool hasCollisionInfo() const { return (m_flags & SEG_HASCOLLISIONS) && m_collisions; }
SlotCollision *collisionInfo(const Slot *s) const { return m_collisions ? m_collisions + s->index() : 0; }
CLASS_NEW_DELETE
diff --git a/Build/source/libs/graphite2/graphite2-src/src/inc/Slot.h b/Build/source/libs/graphite2/graphite2-src/src/inc/Slot.h
index a6e05491c6d..daa11244737 100644
--- a/Build/source/libs/graphite2/graphite2-src/src/inc/Slot.h
+++ b/Build/source/libs/graphite2/graphite2-src/src/inc/Slot.h
@@ -97,7 +97,7 @@ public:
void after(int ind) { m_after = ind; }
bool isBase() const { return (!m_parent); }
void update(int numSlots, int numCharInfo, Position &relpos);
- Position finalise(const Segment* seg, const Font* font, Position & base, Rect & bbox, uint8 attrLevel, float & clusterMin, bool rtl, bool isFinal);
+ Position finalise(const Segment* seg, const Font* font, Position & base, Rect & bbox, uint8 attrLevel, float & clusterMin, bool rtl, bool isFinal, int depth = 0);
bool isDeleted() const { return (m_flags & DELETED) ? true : false; }
void markDeleted(bool state) { if (state) m_flags |= DELETED; else m_flags &= ~DELETED; }
bool isCopied() const { return (m_flags & COPIED) ? true : false; }
@@ -128,10 +128,9 @@ public:
void nextSibling(Slot *ap) { m_sibling = ap; }
bool sibling(Slot *ap);
bool removeChild(Slot *ap);
- bool removeSibling(Slot *ap);
int32 clusterMetric(const Segment* seg, uint8 metric, uint8 attrLevel, bool rtl);
void positionShift(Position a) { m_position += a; }
- void floodShift(Position adj);
+ void floodShift(Position adj, int depth = 0);
float just() const { return m_just; }
void just(float j) { m_just = j; }
Slot *nextInCluster(const Slot *s) const;
diff --git a/Build/source/libs/graphite2/graphite2-src/src/inc/UtfCodec.h b/Build/source/libs/graphite2/graphite2-src/src/inc/UtfCodec.h
index 66384ae182a..3417bac7b15 100644
--- a/Build/source/libs/graphite2/graphite2-src/src/inc/UtfCodec.h
+++ b/Build/source/libs/graphite2/graphite2-src/src/inc/UtfCodec.h
@@ -40,6 +40,7 @@ struct _utf_codec
static void put(codeunit_t * cp, const uchar_t , int8 & len) throw();
static uchar_t get(const codeunit_t * cp, int8 & len) throw();
+ static bool validate(const codeunit_t * s, const codeunit_t * e) throw();
};
@@ -63,6 +64,12 @@ public:
if (cp[0] < limit) { l = 1; return cp[0]; }
else { l = -1; return 0xFFFD; }
}
+
+ inline
+ static bool validate(codeunit_t * s, codeunit_t * e) throw()
+ {
+ return e > s;
+ }
};
@@ -93,12 +100,21 @@ public:
const uint32 uh = cp[0];
l = 1;
- if (0xD800 > uh || uh > 0xDFFF) { return uh; }
+ if (uh < 0xD800|| uh > 0xDFFF) { return uh; }
const uint32 ul = cp[1];
- if (uh > 0xDBFF || 0xDC00 > ul || ul > 0xDFFF) { l = -1; return 0xFFFD; }
+ if (uh > 0xDBFF || ul < 0xDC00 || ul > 0xDFFF) { l = -1; return 0xFFFD; }
++l;
return (uh<<10) + ul + surrogate_offset;
}
+
+ inline
+ static bool validate(codeunit_t * s, codeunit_t * e) throw()
+ {
+ const ptrdiff_t n = e-s;
+ if (n <= 0) return n == 0;
+ const uint32 u = *(s+(n-1)); // Get the last codepoint
+ return (u < 0xD800 || u > 0xDBFF);
+ }
};
@@ -148,6 +164,24 @@ public:
}
return u;
}
+
+ inline
+ static bool validate(codeunit_t * s, codeunit_t * e) throw()
+ {
+ const ptrdiff_t n = e-s;
+ if (n <= 0) return n == 0;
+ s += (n-1);
+ if (*s < 0x80) return true;
+ if (*s >= 0xC0) return false;
+ if (n == 1) return true;
+ if (*--s < 0x80) return true;
+ if (*s >= 0xe0) return false;
+ if (n == 2 || *s >= 0xC0) return true;
+ if (*--s < 0x80) return true;
+ if (*s >= 0xF0) return false;
+ return true;
+ }
+
};
@@ -200,6 +234,11 @@ struct utf
typedef _utf_iterator<C> iterator;
typedef _utf_iterator<const C> const_iterator;
+
+ inline
+ static bool validate(codeunit_t * s, codeunit_t * e) throw() {
+ return _utf_codec<sizeof(C)*8>::validate(s,e);
+ }
};
diff --git a/Build/source/libs/graphite2/graphite2-src/src/inc/opcode_table.h b/Build/source/libs/graphite2/graphite2-src/src/inc/opcode_table.h
index 73a99c82043..50ae1d4d077 100644
--- a/Build/source/libs/graphite2/graphite2-src/src/inc/opcode_table.h
+++ b/Build/source/libs/graphite2/graphite2-src/src/inc/opcode_table.h
@@ -118,7 +118,7 @@ static const opcode_t opcode_table[] =
{{do2(band)}, 0, "BITAND"},
{{do2(bnot)}, 0, "BITNOT"}, // 0x40
{{do2(setbits)}, 4, "BITSET"},
- {{do2(set_feat)}, 2, "SET_FEAT"},
+ {{do_(set_feat), NILOP}, 2, "SET_FEAT"}, // featidx slot
// private opcodes for internal use only, comes after all other on disk opcodes.
{{do_(temp_copy), NILOP}, 0, "TEMP_COPY"}
};
diff --git a/Build/source/libs/graphite2/graphite2-src/src/inc/opcodes.h b/Build/source/libs/graphite2/graphite2-src/src/inc/opcodes.h
index 76da50bf409..23f595fde1f 100644
--- a/Build/source/libs/graphite2/graphite2-src/src/inc/opcodes.h
+++ b/Build/source/libs/graphite2/graphite2-src/src/inc/opcodes.h
@@ -242,7 +242,7 @@ ENDOP
STARTOP(put_copy)
declare_params(1);
const int slot_ref = int8(*param);
- if (is)
+ if (is && !is->isDeleted())
{
slotref ref = slotat(slot_ref);
if (ref && ref != is)
@@ -267,6 +267,7 @@ STARTOP(put_copy)
ENDOP
STARTOP(insert)
+ if (smap.decMax() <= 0) DIE;
Slot *newSlot = seg.newSlot();
if (!newSlot) DIE;
Slot *iss = is;
@@ -555,7 +556,7 @@ STARTOP(iattr_add)
const int val = int(pop());
if ((slat == gr_slatPosX || slat == gr_slatPosY) && (flags & POSITIONED) == 0)
{
- seg.positionSlots(0, *smap.begin(), *(smap.end()-1), dir);
+ seg.positionSlots(0, *smap.begin(), *(smap.end()-1), seg.currdir());
flags |= POSITIONED;
}
int res = is->getAttr(&seg, slat, idx);
@@ -569,7 +570,7 @@ STARTOP(iattr_sub)
const int val = int(pop());
if ((slat == gr_slatPosX || slat == gr_slatPosY) && (flags & POSITIONED) == 0)
{
- seg.positionSlots(0, *smap.begin(), *(smap.end()-1), dir);
+ seg.positionSlots(0, *smap.begin(), *(smap.end()-1), seg.currdir());
flags |= POSITIONED;
}
int res = is->getAttr(&seg, slat, idx);