office-gobmx/graphite/graphite2-0.9.2.patch
2011-05-31 10:52:20 +02:00

463 lines
18 KiB
Diff

diff -r 5369cdd12120 CMakeLists.txt
--- misc/build/graphite2-0.9.2/CMakeLists.txt Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/CMakeLists.txt Fri Feb 18 16:05:40 2011 +0700
@@ -61,7 +61,7 @@
add_subdirectory(gr2fonttest)
add_subdirectory(tests)
add_subdirectory(doc)
-set(version 0.0.0)
+set(version 2.0.0)
set(libdir ${CMAKE_INSTALL_PREFIX}/lib)
set(includedir ${CMAKE_INSTALL_PREFIX}/include)
diff -r 5369cdd12120 gr2fonttest/gr2FontTest.cpp
--- misc/build/graphite2-0.9.2/gr2fonttest/gr2FontTest.cpp Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/gr2fonttest/gr2FontTest.cpp Fri Feb 18 16:05:40 2011 +0700
@@ -758,13 +758,11 @@
float advanceWidth = gr_seg_advance_X(pSeg);
fprintf(log, "Advance width = %6.1f\n", advanceWidth);
unsigned int numchar = gr_seg_n_cinfo(pSeg);
- gr_uint32 *firsts = (gr_uint32 *)malloc(numchar * sizeof(gr_uint32));
- gr_uint32 *lasts = (gr_uint32 *)malloc(numchar * sizeof(gr_uint32));
- gr_seg_char_slots(pSeg, firsts, lasts, 0, 0);
fprintf(log, "\nChar\tUnicode\tBefore\tAfter\n");
for (unsigned int j = 0; j < numchar; j++)
{
- fprintf(log, "%d\t%04X\t%d\t%d\n", j, gr_cinfo_unicode_char(gr_seg_cinfo(pSeg, j)), firsts[j], lasts[j]);
+ const gr_char_info *c = gr_seg_cinfo(pSeg, j);
+ fprintf(log, "%d\t%04X\t%d\t%d\n", j, gr_cinfo_unicode_char(c), gr_cinfo_before(c), gr_cinfo_after(c));
}
free(map);
gr_seg_destroy(pSeg);
diff -r 5369cdd12120 include/graphite2/Segment.h
--- misc/build/graphite2-0.9.2/include/graphite2/Segment.h Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/include/graphite2/Segment.h Fri Feb 18 16:05:40 2011 +0700
@@ -135,6 +135,20 @@
*/
GR2_API int gr_cinfo_break_weight(const gr_char_info* p/*not NULL*/);
+/** Returns the slot index that after this character is after in the slot stream
+ *
+ * @return after slot index between 0 and gr_seg_n_slots()
+ * @param p Pointer to charinfo to return information on.
+ */
+GR2_API int gr_cinfo_after(const gr_char_info* p/*not NULL*/);
+
+/** Returns the slot index that before this character is before in the slot stream
+ *
+ * @return before slot index between 0 and gr_seg_n_slots()
+ * @param p Pointer to charinfo to return information on.
+ */
+GR2_API int gr_cinfo_before(const gr_char_info* p/*not NULL*/);
+
/** Returns the number of unicode characters in a string.
*
* @return number of characters in the string
@@ -205,22 +219,6 @@
*/
GR2_API const gr_slot* gr_seg_last_slot(gr_segment* pSeg/*not NULL*/); //may give a base slot or a slot which is attached to another
-/** Calculates the underlying character to glyph associations.
- *
- * @param pSeg Pointer to the segment we want information on.
- * @param begins An array of gr_seg_n_cinfo integers giving slot index for each
- * charinfo. The value corresponds to which slot a cursor would be before
- * if an underlying cursor were before the charinfo at this index.
- * @param ends An array of gr_seg_n_cinfo integers giving the slot index for each
- * charinfo. The value at an index corresponds to which slot a cursor would
- * be after if an underlying cursor were after the charinfo at the index.
- * @param sbegins An array of gr_seg_n_cinfo gr_slot * corresponding to the gr_slot at
- * index given by begins. The pointer to the array may be NULL.
- * @param sends An array of gr_seg_n_cinfo gr_slot * corresponding to the gr_slot at the
- * index given by ends. The pointer to the array may be NULL.
- */
-GR2_API void gr_seg_char_slots(const gr_segment *pSeg, gr_uint32 *begins, gr_uint32 *ends, gr_slot **sbegins, gr_slot **sends);
-
/** Returns the next slot along in the segment.
*
* Slots are held in a linked list. This returns the next in the linked list. The slot
@@ -306,6 +304,13 @@
*/
GR2_API int gr_slot_after(const gr_slot* p/*not NULL*/);
+/** Returns the index of this slot in the segment
+ *
+ * Returns the index given to this slot during final positioning. This corresponds to the value returned br gr_cinfo_before()
+ * and gr_cinfo_after()
+ */
+GR2_API unsigned int gr_slot_index(const gr_slot* p/*not NULL*/);
+
/** Return a slot attribute value
*
* Given a slot and an attribute along with a possible subattribute, return the
diff -r 5369cdd12120 src/CMakeLists.txt
--- misc/build/graphite2-0.9.2/src/CMakeLists.txt Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/src/CMakeLists.txt Fri Feb 18 16:05:40 2011 +0700
@@ -25,7 +25,7 @@
INCLUDE(CheckTypeSize)
INCLUDE(CheckCXXSourceCompiles)
-set(GRAPHITE_API_MAJOR 1)
+set(GRAPHITE_API_MAJOR 2)
set(GRAPHITE_API_MINOR 0)
set(GRAPHITE_API_AGE 0)
set(GRAPHITE_SO_VERSION ${GRAPHITE_API_MAJOR}.${GRAPHITE_API_MINOR}.${GRAPHITE_API_AGE})
diff -r 5369cdd12120 src/CharInfo.h
--- misc/build/graphite2-0.9.2/src/CharInfo.h Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/src/CharInfo.h Fri Feb 18 16:05:40 2011 +0700
@@ -29,16 +29,23 @@
{
public:
+ CharInfo() : m_before(-1), m_after(0) {}
void init(int cid) { m_char = cid; }
unsigned int unicodeChar() const { return m_char; }
void feats(int offset) { m_featureid = offset; }
int fid() const { return m_featureid; }
int breakWeight() const { return m_break; }
void breakWeight(int val) { m_break = val; }
+ int after() const { return m_after; }
+ void after(int val) { m_after = val; }
+ int before() const { return m_before; }
+ void before(int val) { m_before = val; }
CLASS_NEW_DELETE
private:
int m_char; // Unicode character from character stream
+ int m_before; // slot index before us, comes before
+ int m_after; // slot index after us, comes after
uint8 m_featureid; // index into features list in the segment
int8 m_break; // breakweight coming from lb table
};
diff -r 5369cdd12120 src/Segment.cpp
--- misc/build/graphite2-0.9.2/src/Segment.cpp Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/src/Segment.cpp Fri Feb 18 16:05:40 2011 +0700
@@ -283,6 +283,7 @@
{
Position currpos;
Slot *s, *ls = NULL;
+ int iSlot = 0;
float cMin = 0.;
float clusterMin = 0.;
Rect bbox;
@@ -292,8 +293,16 @@
if (m_dir & 1)
{
- for (s = iEnd; s && s != iStart->prev(); s = s->prev())
+ for (s = iEnd, iSlot = m_numGlyphs - 1; s && s != iStart->prev(); s = s->prev(), --iSlot)
{
+ for (int j = s->before(); j <= s->after(); j++)
+ {
+ CharInfo *c = charinfo(j);
+ if (c->before() == -1 || iSlot < c->before()) c->before(iSlot);
+ if (c->after() < iSlot) c->after(iSlot);
+ }
+ s->index(iSlot);
+
if (s->isBase())
{
clusterMin = currpos.x;
@@ -306,8 +315,16 @@
}
else
{
- for (s = iStart; s && s != iEnd->next(); s = s->next())
+ for (s = iStart, iSlot = 0; s && s != iEnd->next(); s = s->next(), ++iSlot)
{
+ for (int j = s->before(); j <= s->after(); j++)
+ {
+ CharInfo *c = charinfo(j);
+ if (c->before() == -1 || iSlot < c->before()) c->before(iSlot);
+ if (c->after() < iSlot) c->after(iSlot);
+ }
+ s->index(iSlot);
+
if (s->isBase())
{
clusterMin = currpos.x;
@@ -321,35 +338,6 @@
if (iStart == m_first && iEnd == m_last) m_advance = currpos;
}
-
-void Segment::getCharSlots(uint32 *begins, uint32 *ends, Slot **sbegins, Slot **sends) const
-{
- Slot *s;
- uint32 i;
- if (!begins || !ends) return;
- memset(begins, 0xFF, m_numCharinfo * sizeof(uint32));
- memset(ends, 0, m_numCharinfo * sizeof(uint32));
-
- for (s = m_first, i = 0; s; s = s->next(), i++)
- {
- for (int j = s->before(); j <= s->after(); j++)
- {
- assert(j >= 0);
- assert(j < static_cast<int>(m_numCharinfo));
- if (i < begins[j])
- {
- begins[j] = i;
- if (sbegins) sbegins[j] = s;
- }
- if (i > ends[j])
- {
- ends[j] = i;
- if (sends) sends[j] = s;
- }
- }
- }
-}
-
#ifndef DISABLE_TRACING
void Segment::logSegment(gr_encform enc, const void* pStart, size_t nChars) const
{
diff -r 5369cdd12120 src/Segment.h
--- misc/build/graphite2-0.9.2/src/Segment.h Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/src/Segment.h Fri Feb 18 16:05:40 2011 +0700
@@ -118,7 +118,6 @@
int defaultOriginal() const { return m_defaultOriginal; }
const Face * getFace() const { return m_face; }
const Features & getFeatures(unsigned int /*charIndex*/) { assert(m_feats.size() == 1); return m_feats[0]; }
- void getCharSlots(uint32 *begins, uint32 *ends, Slot **sbegins, Slot **sends) const;
CLASS_NEW_DELETE
diff -r 5369cdd12120 src/Slot.cpp
--- misc/build/graphite2-0.9.2/src/Slot.cpp Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/src/Slot.cpp Fri Feb 18 16:05:40 2011 +0700
@@ -188,15 +188,15 @@
}
}
-int Slot::getAttr(const Segment *seg, attrCode index, uint8 subindex) const
+int Slot::getAttr(const Segment *seg, attrCode ind, uint8 subindex) const
{
if (!this) return 0;
- if (index == gr_slatUserDefnV1)
+ if (ind == gr_slatUserDefnV1)
{
- index = gr_slatUserDefn;
+ ind = gr_slatUserDefn;
subindex = 0;
}
- switch (index)
+ switch (ind)
{
case gr_slatAdvX :
return static_cast<int>(m_advance.x);
@@ -259,15 +259,15 @@
}
}
-void Slot::setAttr(Segment *seg, attrCode index, uint8 subindex, int16 value, const SlotMap & map)
+void Slot::setAttr(Segment *seg, attrCode ind, uint8 subindex, int16 value, const SlotMap & map)
{
if (!this) return;
- if (index == gr_slatUserDefnV1)
+ if (ind == gr_slatUserDefnV1)
{
- index = gr_slatUserDefn;
+ ind = gr_slatUserDefn;
subindex = 0;
}
- switch (index)
+ switch (ind)
{
case gr_slatAdvX :
m_advance = Position(value, m_advance.y);
diff -r 5369cdd12120 src/Slot.h
--- misc/build/graphite2-0.9.2/src/Slot.h Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/src/Slot.h Fri Feb 18 16:05:40 2011 +0700
@@ -47,6 +47,8 @@
Position advancePos() const { return m_advance; }
int before() const { return m_before; }
int after() const { return m_after; }
+ uint32 index() const { return m_index; }
+ void index(uint32 val) { m_index = val; }
Slot();
void set(const Slot & slot, int charOffset, uint8 numUserAttr);
@@ -58,10 +60,10 @@
void setGlyph(Segment *seg, uint16 glyphid, const GlyphFace * theGlyph = NULL);
void setRealGid(uint16 realGid) { m_realglyphid = realGid; }
void origin(const Position &pos) { m_position = pos + m_shift; }
- void originate(int index) { m_original = index; }
+ void originate(int ind) { m_original = ind; }
int original() const { return m_original; }
- void before(int index) { m_before = index; }
- void after(int index) { m_after = index; }
+ void before(int ind) { m_before = ind; }
+ 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, float* cMin, uint8 attrLevel, float *clusterMin);
@@ -75,8 +77,8 @@
uint16 *userAttrs() { return m_userAttr; }
void userAttrs(uint16 *p) { m_userAttr = p; }
void markInsertBefore(bool state) { if (!state) m_flags |= SLOT_INSERT; else m_flags &= ~SLOT_INSERT; }
- void setAttr(Segment* seg, attrCode index, uint8 subindex, int16 val, const SlotMap & map);
- int getAttr(const Segment *seg, attrCode index, uint8 subindex) const;
+ void setAttr(Segment* seg, attrCode ind, uint8 subindex, int16 val, const SlotMap & map);
+ int getAttr(const Segment *seg, attrCode ind, uint8 subindex) const;
void attachTo(Slot *ap) { m_parent = ap; }
Slot *attachedTo() const { return m_parent; }
Slot* firstChild() const { return m_child; }
@@ -96,8 +98,9 @@
unsigned short m_glyphid; // glyph id
uint16 m_realglyphid;
uint32 m_original; // charinfo that originated this slot (e.g. for feature values)
- uint32 m_before; // charinfo index of before association
- uint32 m_after; // charinfo index of after association
+ uint32 m_before; // charinfo index of before association
+ uint32 m_after; // charinfo index of after association
+ uint32 m_index; // slot index given to this slot during finalising
Slot *m_parent; // index to parent we are attached to
Slot *m_child; // index to first child slot that attaches to us
Slot *m_sibling; // index to next child that attaches to our parent
diff -r 5369cdd12120 src/gr_char_info.cpp
--- misc/build/graphite2-0.9.2/src/gr_char_info.cpp Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/src/gr_char_info.cpp Fri Feb 18 16:05:40 2011 +0700
@@ -39,4 +39,16 @@
return p->breakWeight();
}
-} // extern "C"
\ No newline at end of file
+int gr_cinfo_after(const gr_char_info *p/*not NULL*/)
+{
+ assert(p);
+ return p->after();
+}
+
+int gr_cinfo_before(const gr_char_info *p/*not NULL*/)
+{
+ assert(p);
+ return p->before();
+}
+
+} // extern "C"
diff -r 5369cdd12120 src/gr_segment.cpp
--- misc/build/graphite2-0.9.2/src/gr_segment.cpp Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/src/gr_segment.cpp Fri Feb 18 16:05:40 2011 +0700
@@ -162,11 +162,5 @@
return static_cast<const gr_slot*>(pSeg->last());
}
-void gr_seg_char_slots(const gr_segment *pSeg, gr_uint32 *begins, gr_uint32 *ends, gr_slot **sbegins, gr_slot **sends)
-{
- assert(pSeg && begins && ends);
- pSeg->getCharSlots(begins, ends, reinterpret_cast<Slot**>(sbegins), reinterpret_cast<Slot**>(sends));
-}
-
} // extern "C"
diff -r 5369cdd12120 src/gr_slot.cpp
--- misc/build/graphite2-0.9.2/src/gr_slot.cpp Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/src/gr_slot.cpp Fri Feb 18 16:05:40 2011 +0700
@@ -121,6 +121,12 @@
return p->after();
}
+unsigned int gr_slot_index(const gr_slot *p/*not NULL*/)
+{
+ assert(p);
+ return p->index();
+}
+
int gr_slot_attr(const gr_slot* p/*not NULL*/, const gr_segment* pSeg/*not NULL*/, gr_attrCode index, gr_uint8 subindex)
{
assert(p);
diff current src/List.h
--- misc/build/graphite2-0.9.2/src/List.h Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/src/List.h Fri Feb 18 16:05:40 2011 +0700
@@ -51,5 +51,5 @@
template <typename I>
Vector(I first, const I last) : m_first(0), m_last(0), m_end(0) { insert(begin(), first, last); }
- ~Vector() { free(m_first); }
+ ~Vector() { clear(); free(m_first); }
iterator begin() { return m_first; }
--- misc/graphite2-0.9.2/src/Code.cpp 2011-02-12 16:54:16.000000000 +0100
+++ misc/build/graphite2-0.9.2/src/Code.cpp 2011-03-11 11:28:11.700215286 +0100
@@ -168,7 +168,7 @@
face.getGlyphFaceCache()->numAttrs(),
face.numFeatures(),
{1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,-1,
+ 1,1,1,1,1,1,1,(uint8)-1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,0,0,
0,0,0,0,0,0,0,0,
--- misc/graphite2-0.9.2/include/graphite2/Types.h 2011-02-12 16:54:16.000000000 +0100
+++ misc/build/graphite2-0.9.2/include/graphite2/Types.h 2011-03-15 21:38:06.264788098 +0100
@@ -36,19 +36,7 @@
// Definitions for library publicly exported symbols
#if defined _WIN32 || defined __CYGWIN__
- #ifdef GR2_EXPORTING
- #ifdef __GNUC__
- #define GR2_API __attribute__((dllexport))
- #else
- #define GR2_API __declspec(dllexport)
- #endif
- #else
- #ifdef __GNUC__
- #define GR2_API __attribute__((dllimport))
- #else
- #define GR2_API __declspec(dllimport)
- #endif
- #endif
+ #define GR2_API
#define GR2_LOCAL
#else
#if __GNUC__ >= 4
diff -r b3a86877ec68 src/Pass.cpp
--- misc/build/graphite2-0.9.2/src/Pass.cpp Wed May 11 09:34:52 2011 +0700
+++ misc/build/graphite2-0.9.2/src/Pass.cpp Mon May 16 13:54:00 2011 +0700
@@ -513,6 +513,7 @@
bool Pass::testConstraint(const Rule &r, Machine & m) const
{
if (r.sort - r.preContext > (int)m.slotMap().size() - m.slotMap().context()) return false;
+ if (m.slotMap().context() - r.preContext < 0) return false;
if (!*r.constraint) return true;
assert(r.constraint->constraint());
@@ -527,6 +528,7 @@
Machine::status_t status = Machine::finished;
for (int n = r.sort; n && map; --n, ++map)
{
+ if (!*map) continue;
const int32 ret = r.constraint->run(m, map, status);
if (!ret || status != Machine::finished)
{
diff -r b3a86877ec68 src/Rule.h
--- misc/build/graphite2-0.9.2/src/Rule.h Wed May 11 09:34:52 2011 +0700
+++ misc/build/graphite2-0.9.2/src/Rule.h Mon May 16 13:54:00 2011 +0700
@@ -187,8 +187,9 @@
// Merge the new sorted rules list into the current sorted result set.
const RuleEntry * lre = begin(), * rre = state.rules;
RuleEntry * out = m_rules + (m_begin == m_rules)*MAX_RULES;
+ const RuleEntry * lrend = out + MAX_RULES;
m_begin = out;
- while (lre != end())
+ while (lre != end() && out != lrend)
{
if (*lre < *rre) *out++ = *lre++;
else if (*rre < *lre) { *out++ = *rre++; }
@@ -196,12 +197,12 @@
if (rre == state.rules_end)
{
- while (lre != end()) { *out++ = *lre++; }
+ while (lre != end() && out != lrend) { *out++ = *lre++; }
m_end = out;
return;
}
}
- while (rre != state.rules_end) { *out++ = *rre++; }
+ while (rre != state.rules_end && out != lrend) { *out++ = *rre++; }
m_end = out;
}