summaryrefslogtreecommitdiff
path: root/vcl/generic/glyphs/gcach_layout.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/generic/glyphs/gcach_layout.cxx')
-rw-r--r--vcl/generic/glyphs/gcach_layout.cxx61
1 files changed, 37 insertions, 24 deletions
diff --git a/vcl/generic/glyphs/gcach_layout.cxx b/vcl/generic/glyphs/gcach_layout.cxx
index 833cf4f9a383..848f4cbc51e5 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -41,6 +41,10 @@
#include <unicode/uscript.h>
#include <unicode/ubidi.h>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/i18n/CharacterIteratorMode.hpp>
+#include <comphelper/processfactory.hxx>
+
// =======================================================================
// layout implementation for ServerFont
// =======================================================================
@@ -90,23 +94,42 @@ void ServerFontLayout::AdjustLayout( ImplLayoutArgs& rArgs )
}
}
-// =======================================================================
-
-static bool lcl_CharIsJoiner(sal_Unicode cChar)
+void ServerFontLayout::setNeedFallback(ImplLayoutArgs& rArgs, sal_Int32 nCharPos,
+ bool bRightToLeft)
{
- return ((cChar == 0x200C) || (cChar == 0x200D));
-}
+ if (nCharPos < 0)
+ return;
-static bool needPreviousCode(sal_Unicode cChar)
-{
- return lcl_CharIsJoiner(cChar) || U16_IS_LEAD(cChar);
-}
+ using namespace ::com::sun::star;
-static bool needNextCode(sal_Unicode cChar)
-{
- return lcl_CharIsJoiner(cChar) || U16_IS_TRAIL(cChar);
+ if (!mxBreak.is())
+ {
+ uno::Reference< lang::XMultiServiceFactory > xFactory =
+ comphelper::getProcessServiceFactory();
+ mxBreak = uno::Reference< i18n::XBreakIterator >(xFactory->createInstance(
+ "com.sun.star.i18n.BreakIterator"), uno::UNO_QUERY);
+ }
+
+ LanguageTag aLangTag(rArgs.meLanguage);
+ lang::Locale aLocale(aLangTag.getLocale());
+
+ //if position nCharPos is missing in the font, grab the entire grapheme and
+ //mark all glyphs as missing so the whole thing is rendered with the same
+ //font
+ OUString aRun(rArgs.mpStr);
+ sal_Int32 nDone;
+ sal_Int32 nGraphemeStartPos =
+ mxBreak->previousCharacters(aRun, nCharPos+1, aLocale,
+ i18n::CharacterIteratorMode::SKIPCELL, 1, nDone);
+ sal_Int32 nGraphemeEndPos =
+ mxBreak->nextCharacters(aRun, nCharPos, aLocale,
+ i18n::CharacterIteratorMode::SKIPCELL, 1, nDone);
+
+ rArgs.NeedFallback(nGraphemeStartPos, nGraphemeEndPos, bRightToLeft);
}
+// =======================================================================
+
std::ostream &operator <<(std::ostream& s, ServerFont* pFont)
{
#ifndef SAL_LOG_INFO
@@ -427,9 +450,7 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
// if needed request glyph fallback by updating LayoutArgs
if (!nGlyphIndex)
{
- if (nCharPos >= 0)
- rArgs.NeedFallback(nCharPos, bRightToLeft);
-
+ rLayout.setNeedFallback(rArgs, nCharPos, bRightToLeft);
if (SAL_LAYOUT_FOR_FALLBACK & rArgs.mnFlags)
continue;
}
@@ -1032,15 +1053,7 @@ bool IcuLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
// if needed request glyph fallback by updating LayoutArgs
if( !nGlyphIndex )
{
- if( nCharPos >= 0 )
- {
- rArgs.NeedFallback( nCharPos, bRightToLeft );
- if ( (nCharPos > 0) && needPreviousCode(rArgs.mpStr[nCharPos-1]) )
- rArgs.NeedFallback( nCharPos-1, bRightToLeft );
- else if ( (nCharPos + 1 < nEndRunPos) && needNextCode(rArgs.mpStr[nCharPos+1]) )
- rArgs.NeedFallback( nCharPos+1, bRightToLeft );
- }
-
+ rLayout.setNeedFallback(rArgs, nCharPos, bRightToLeft);
if( SAL_LAYOUT_FOR_FALLBACK & rArgs.mnFlags )
continue;
}