diff options
author | Kurt Zenker <kz@openoffice.org> | 2010-08-18 14:15:04 +0200 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2010-08-18 14:15:04 +0200 |
commit | 2440f8452e59a1b9a6d138c66e723c82a4176d43 (patch) | |
tree | 6881e26ff14cd36e9324e1fcfd93c65620e2e39d /vcl | |
parent | c699cbdac2533d9abe8e8c6fd750968538295a80 (diff) | |
parent | a65f403bfdd25572330b1a7a6142ae2ce3e30031 (diff) |
CWS-TOOLING: integrate CWS graphite04
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/glyphs/graphite_layout.cxx | 71 | ||||
-rwxr-xr-x | vcl/win/source/gdi/winlayout.cxx | 5 |
2 files changed, 63 insertions, 13 deletions
diff --git a/vcl/source/glyphs/graphite_layout.cxx b/vcl/source/glyphs/graphite_layout.cxx index ae7ec8246e33..0f7d2f5f3005 100644 --- a/vcl/source/glyphs/graphite_layout.cxx +++ b/vcl/source/glyphs/graphite_layout.cxx @@ -594,21 +594,39 @@ bool GraphiteLayout::LayoutText(ImplLayoutArgs & rArgs) { #ifdef GRCACHE GrSegRecord * pSegRecord = NULL; - gr::Segment * pSegment = CreateSegment(rArgs, &pSegRecord); - if (!pSegment) - return false; - + gr::Segment * pSegment = NULL; + // Graphite can in rare cases crash with a zero length + if (rArgs.mnMinCharPos < rArgs.mnEndCharPos) + { + pSegment = CreateSegment(rArgs, &pSegRecord); + if (!pSegment) + return false; + } + else + { + clear(); + return true; + } // layout the glyphs as required by OpenOffice bool success = LayoutGlyphs(rArgs, pSegment, pSegRecord); if (pSegRecord) pSegRecord->unlock(); else delete pSegment; #else - gr::Segment * pSegment = CreateSegment(rArgs); - if (!pSegment) - return false; - bool success = LayoutGlyphs(rArgs, pSegment); - delete pSegment; + gr::Segment * pSegment = NULL; + bool success = true; + if (rArgs.mnMinCharPos < rArgs.mnEndCharPos) + { + pSegment = CreateSegment(rArgs); + if (!pSegment) + return false; + success = LayoutGlyphs(rArgs, pSegment); + if (pSegment) delete pSegment; + } + else + { + clear(); + } #endif return success; } @@ -659,7 +677,7 @@ public: return hash; }; protected: - virtual void UniqueCacheInfo(std::wstring & stuFace, bool & fBold, bool & fItalic) + virtual void UniqueCacheInfo( ext_std::wstring& stuFace, bool& fBold, bool& fItalic ) { #ifdef WIN32 dynamic_cast<GraphiteWinFont&>(mrRealFont).UniqueCacheInfo(stuFace, fBold, fItalic); @@ -722,7 +740,7 @@ gr::Segment * GraphiteLayout::CreateSegment(ImplLayoutArgs& rArgs) (GraphiteCacheHandler::instance).getCache(aFontHash); if (pCache) { - *pSegRecord = pCache->getSegment(rArgs, bRtl, nSegCharLimit); + *pSegRecord = pCache->getSegment(rArgs, bRtl, limit); if (*pSegRecord) { pSegment = (*pSegRecord)->getSegment(); @@ -736,7 +754,34 @@ gr::Segment * GraphiteLayout::CreateSegment(ImplLayoutArgs& rArgs) (*pSegRecord)->clearVectors(); } mpTextSrc->switchLayoutArgs(rArgs); - return pSegment; + if (limit > rArgs.mnMinCharPos && limit == rArgs.mnEndCharPos + && pSegment->stopCharacter() != limit) + { + // check that the last character is not part of a ligature + glyph_set_range_t aGlyphSet = pSegment->charToGlyphs(limit - 1); + if (aGlyphSet.first == aGlyphSet.second) + { + // no glyphs associated with this glyph - occurs mid ligature + pSegment = NULL; + *pSegRecord = NULL; + } + else + { + while (aGlyphSet.first != aGlyphSet.second) + { + int lastChar = static_cast<int>((*aGlyphSet.first).lastChar()); + if (lastChar >= limit) + { + pSegment = NULL; + *pSegRecord = NULL; + break; + } + aGlyphSet.first++; + } + } + } + if (pSegment) + return pSegment; } } #endif @@ -1058,7 +1103,7 @@ void GraphiteLayout::ApplyDXArray(ImplLayoutArgs &args, std::vector<int> & rDelt { nXOffset = args.mpDXArray[nChars - 1] - mvCharDxs[nChars - 1]; } - int nPrevClusterGlyph = (bRtl)? mvGlyphs.size() : -1; + int nPrevClusterGlyph = (bRtl)? (signed)mvGlyphs.size() : -1; int nPrevClusterLastChar = -1; for (size_t i = 0; i < nChars; i++) { diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index 6f0c98279e7b..806d3b420b33 100755 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -2894,6 +2894,11 @@ void GraphiteWinLayout::RestoreDC(gr::Segment & segment) const bool GraphiteWinLayout::LayoutText( ImplLayoutArgs & args) { + if (args.mnMinCharPos >= args.mnEndCharPos) + { + maImpl.clear(); + return true; + } HFONT hUnRotatedFont; if (args.mnOrientation) { |