r23710 by jghali - #16099: Add implicit space between a Latin character and a CJK character
scribus-commit
scribus-commit at lists.scribus.net
Wed May 6 11:47:48 UTC 2020
Author: jghali
Date: Wed May 6 11:47:48 2020
New Revision: 23710
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23710
Log:
#16099: Add implicit space between a Latin character and a CJK character
Modified:
trunk/Scribus/scribus/text/specialchars.cpp
trunk/Scribus/scribus/text/specialchars.h
trunk/Scribus/scribus/text/textshaper.cpp
Modified: trunk/Scribus/scribus/text/specialchars.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23710&path=/trunk/Scribus/scribus/text/specialchars.cpp
==============================================================================
--- trunk/Scribus/scribus/text/specialchars.cpp (original)
+++ trunk/Scribus/scribus/text/specialchars.cpp Wed May 6 11:47:48 2020
@@ -52,6 +52,34 @@
bool SpecialChars::isExpandingSpace(QChar c)
{
return c == BLANK || c == NBSPACE;
+}
+
+bool SpecialChars::isImplicitSpace(QChar c1, QChar c2)
+{
+ uint uni1 = c1.unicode();
+ uint uni2 = c2.unicode();
+ return isImplicitSpace(uni1, uni2);
+}
+
+bool SpecialChars::isImplicitSpace(uint c1, uint c2)
+{
+ // CJK characters side-by-side
+ bool isCJK1 = SpecialChars::isCJK(c1);
+ bool isCJK2 = SpecialChars::isCJK(c2);
+ if (!isCJK1 && !isCJK2)
+ return false;
+ if (isCJK1 && isCJK2)
+ return true;
+
+ // Not exactly implicit spaces but latin char before or after
+ // a CJK character behaves similarly to an implicit space
+ bool isLatin1 = SpecialChars::isLetterRequiringSpaceAroundCJK(c1);
+ if (isLatin1 && isCJK2)
+ return true;
+ bool isLatin2 = SpecialChars::isLetterRequiringSpaceAroundCJK(c2);
+ if (isCJK1 && isLatin2)
+ return true;
+ return false;
}
bool SpecialChars::isBreak(QChar c, bool includeColBreak)
Modified: trunk/Scribus/scribus/text/specialchars.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23710&path=/trunk/Scribus/scribus/text/specialchars.h
==============================================================================
--- trunk/Scribus/scribus/text/specialchars.h (original)
+++ trunk/Scribus/scribus/text/specialchars.h Wed May 6 11:47:48 2020
@@ -54,6 +54,8 @@
static bool isBreak(QChar c, bool includeColBreak = true);
static bool isBreakingSpace(QChar c);
static bool isExpandingSpace(QChar c);
+ static bool isImplicitSpace(QChar c1, QChar c2);
+ static bool isImplicitSpace(uint c1, uint c2);
enum {
CJK_FENCE_BEGIN = 0x0001,
Modified: trunk/Scribus/scribus/text/textshaper.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23710&path=/trunk/Scribus/scribus/text/textshaper.cpp
==============================================================================
--- trunk/Scribus/scribus/text/textshaper.cpp (original)
+++ trunk/Scribus/scribus/text/textshaper.cpp Wed May 6 11:47:48 2020
@@ -449,9 +449,7 @@
if (effects & ScStyle_UnderlineWords && !ch.isSpace())
run.setFlag(ScLayout_Underlined);
- if (firstChar != 0 &&
- SpecialChars::isCJK(m_story.text(firstChar).unicode()) &&
- SpecialChars::isCJK(m_story.text(firstChar - 1).unicode()))
+ if (firstChar != 0 && SpecialChars::isImplicitSpace(m_story.text(firstChar - 1).unicode(), m_story.text(firstChar).unicode()))
run.setFlag(ScLayout_ImplicitSpace);
int firstStat = SpecialChars::getCJKAttr(m_story.text(firstChar));
@@ -542,7 +540,6 @@
m_contextNeeded = true;
if (m_context != nullptr)
{
-
double smallcapsScale = m_context->typographicPrefs().valueSmallCaps / 100.0;
run.setScaleH(run.scaleH() * smallcapsScale);
run.setScaleV(run.scaleV() * smallcapsScale);
More information about the scribus-commit
mailing list