diff --git a/src/GlyphCache.cpp b/src/GlyphCache.cpp index 282bdc18..14e37748 100644 --- a/src/GlyphCache.cpp +++ b/src/GlyphCache.cpp @@ -32,6 +32,7 @@ of the License or (at your option) any later version. #include "inc/GlyphFace.h" #include "inc/Endian.h" #include "inc/bits.h" +#include using namespace graphite2; @@ -357,8 +358,9 @@ const GlyphFace * GlyphCache::Loader::read_glyph(unsigned short glyphid, GlyphFa if (_glyf) { int xMin, yMin, xMax, yMax; - size_t locidx = TtfUtil::LocaLookup(glyphid, _loca, _loca.size(), _head); - void *pGlyph = TtfUtil::GlyfLookup(_glyf, locidx, _glyf.size()); + int locidx = TtfUtil::LocaLookup(glyphid, _loca, _loca.size(), _head); + assert(locidx >= 0); + void *pGlyph = TtfUtil::GlyfLookup(_glyf, static_cast(locidx), _glyf.size()); if (pGlyph && TtfUtil::GlyfBox(pGlyph, xMin, yMin, xMax, yMax)) { diff --git a/src/Silf.cpp b/src/Silf.cpp index 44d3c961..ca2b9c9a 100644 --- a/src/Silf.cpp +++ b/src/Silf.cpp @@ -309,7 +309,7 @@ uint16 Silf::findPseudo(uint32 uid) const return 0; } -uint16 Silf::findClassIndex(uint16 cid, uint16 gid) const +int Silf::findClassIndex(uint16 cid, uint16 gid) const { if (cid > m_nClass) return -1; diff --git a/src/TtfUtil.cpp b/src/TtfUtil.cpp index 2eb46a11..9c00e732 100644 --- a/src/TtfUtil.cpp +++ b/src/TtfUtil.cpp @@ -1211,7 +1211,7 @@ unsigned int CmapSubtable12NextCodepoint(const void *pCmap310, unsigned int nUni Technically this method should return an unsigned long but it is unlikely the offset will exceed 2^31. ----------------------------------------------------------------------------------------------*/ -size_t LocaLookup(gid16 nGlyphId, +int LocaLookup(gid16 nGlyphId, const void * pLoca, size_t lLocaSize, const void * pHead) // throw (std::out_of_range) { diff --git a/src/inc/Segment.h b/src/inc/Segment.h index 6cf83408..fd45efb3 100644 --- a/src/inc/Segment.h +++ b/src/inc/Segment.h @@ -115,7 +115,7 @@ class Segment void associateChars(int offset, size_t num); void linkClusters(Slot *first, Slot *last); uint16 getClassGlyph(uint16 cid, uint16 offset) const { return m_silf->getClassGlyph(cid, offset); } - uint16 findClassIndex(uint16 cid, uint16 gid) const { return m_silf->findClassIndex(cid, gid); } + int findClassIndex(uint16 cid, uint16 gid) const { return m_silf->findClassIndex(cid, gid); } int addFeatures(const Features& feats) { m_feats.push_back(feats); return int(m_feats.size()) - 1; } uint32 getFeature(int index, uint8 findex) const { const FeatureRef* pFR=m_face->theSill().theFeatureMap().featureRef(findex); if (!pFR) return 0; else return pFR->getFeatureVal(m_feats[index]); } void setFeature(int index, uint8 findex, uint32 val) { diff --git a/src/inc/Silf.h b/src/inc/Silf.h index edc0c3a1..5df6b4ed 100644 --- a/src/inc/Silf.h +++ b/src/inc/Silf.h @@ -76,7 +76,7 @@ class Silf bool readGraphite(const byte * const pSilf, size_t lSilf, Face &face, uint32 version); bool runGraphite(Segment *seg, uint8 firstPass=0, uint8 lastPass=0, int dobidi = 0) const; - uint16 findClassIndex(uint16 cid, uint16 gid) const; + int findClassIndex(uint16 cid, uint16 gid) const; uint16 getClassGlyph(uint16 cid, unsigned int index) const; uint16 findPseudo(uint32 uid) const; uint8 numUser() const { return m_aUser; } diff --git a/src/inc/TtfUtil.h b/src/inc/TtfUtil.h index 3952bc06..4c109c0e 100644 --- a/src/inc/TtfUtil.h +++ b/src/inc/TtfUtil.h @@ -153,7 +153,7 @@ class Tag const void * pHhea, int & nLsb, unsigned int & nAdvWid); ////////////////////////////////// primitives for loca and glyf lookup - size_t LocaLookup(gid16 nGlyphId, const void * pLoca, size_t lLocaSize, + int LocaLookup(gid16 nGlyphId, const void * pLoca, size_t lLocaSize, const void * pHead); // throw (std::out_of_range); void * GlyfLookup(const void * pGlyf, size_t lGlyfOffset, size_t lTableLen); diff --git a/src/inc/bits.h b/src/inc/bits.h index 9365986a..dde2cae4 100644 --- a/src/inc/bits.h +++ b/src/inc/bits.h @@ -79,7 +79,7 @@ inline unsigned int bit_set_count(signed long long v) template inline unsigned int bit_set_count(T v) { - static size_t const ONES = ~0; + static size_t const ONES = static_cast(~0); v = v - ((v >> 1) & T(ONES/3)); // temp v = (v & T(ONES/15*3)) + ((v >> 2) & T(ONES/15*3)); // temp diff --git a/src/inc/opcodes.h b/src/inc/opcodes.h index ff2f1741..3e76ffcb 100644 --- a/src/inc/opcodes.h +++ b/src/inc/opcodes.h @@ -24,6 +24,9 @@ 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 + #pragma once // This file will be pulled into and integrated into a machine implmentation // DO NOT build directly and under no circumstances ever #include headers in @@ -233,12 +236,13 @@ STARTOP(put_subs_8bit_obs) const int slot_ref = int8(param[0]); const unsigned int input_class = uint8(param[1]), output_class = uint8(param[2]); - uint16 index; + int index; slotref slot = slotat(slot_ref); if (slot) { index = seg.findClassIndex(input_class, slot->gid()); - is->setGlyph(&seg, seg.getClassGlyph(output_class, index)); + asset(index >= 0); + is->setGlyph(&seg, seg.getClassGlyph(output_class, static_cast(index))); } ENDOP @@ -601,7 +605,8 @@ STARTOP(put_subs) if (slot) { int index = seg.findClassIndex(input_class, slot->gid()); - is->setGlyph(&seg, seg.getClassGlyph(output_class, index)); + assert(index >=0 ); + is->setGlyph(&seg, seg.getClassGlyph(output_class, static_cast(index))); } ENDOP