mirror of
https://github.com/ONLYOFFICE/sdkjs.git
synced 2026-02-10 18:15:19 +08:00
@ -11748,6 +11748,14 @@
|
||||
"Meiryo", "MS Gothic", "MS PGothic", "MS UI Gothic", "Yu Gothic",
|
||||
"Dotum", "Gulim", "Malgun Gothic"
|
||||
];
|
||||
|
||||
// Символы, на которых работает <w:rFonts w:hint="eastAsia"/>
|
||||
function isAmbiguousCharacter(codePoint)
|
||||
{
|
||||
return (0x00D7 === codePoint
|
||||
|| (0x0370 <= codePoint && codePoint <= 0x03FF));
|
||||
}
|
||||
|
||||
|
||||
function IsEastAsianFont(sName)
|
||||
{
|
||||
@ -15610,6 +15618,7 @@
|
||||
window["AscCommon"].getAscColorScheme = getAscColorScheme;
|
||||
window["AscCommon"].checkAddColorScheme = checkAddColorScheme;
|
||||
window["AscCommon"].getIndexColorSchemeInArray = getIndexColorSchemeInArray;
|
||||
window["AscCommon"].isAmbiguousCharacter = isAmbiguousCharacter;
|
||||
window["AscCommon"].isEastAsianScript = isEastAsianScript;
|
||||
window["AscCommon"].IsEastAsianFont = IsEastAsianFont;
|
||||
window["AscCommon"].IsComplexScript = IsComplexScript;
|
||||
|
||||
@ -105,16 +105,53 @@ $(function () {
|
||||
"界! "
|
||||
]);
|
||||
|
||||
// check non asian text with the eastAsian hint (71108)
|
||||
setText("你好世界! HΩllo! 你好世界! 你好世界! ");
|
||||
recalculate(charWidth * 8.5);
|
||||
checkLines(assert, para, [
|
||||
"你好世界! ",
|
||||
"HΩllo! 你",
|
||||
"好世界! 你好世",
|
||||
"界! "
|
||||
]);
|
||||
|
||||
setText("你好世界! HeΩlo! 你好世界! 你好世界! ");
|
||||
recalculate(charWidth * 8.5);
|
||||
checkLines(assert, para, [
|
||||
"你好世界! ",
|
||||
"HeΩlo! 你",
|
||||
"好世界! 你好世",
|
||||
"界! "
|
||||
]);
|
||||
|
||||
// Check ambiguous characters with the eastAsian hint (71108)
|
||||
// × Ω (whole greek script)
|
||||
|
||||
run.SetRFontsHint(AscWord.fonthint_EastAsia);
|
||||
setText("你好世界! Hello! 你好世界! 你好世界! ");
|
||||
recalculate(charWidth * 8.5);
|
||||
checkLines(assert, para, [
|
||||
"你好世界! He",
|
||||
"你好世界! ",
|
||||
"Hello! 你",
|
||||
"好世界! 你好世",
|
||||
"界! "
|
||||
]);
|
||||
|
||||
setText("你好世界! HΩllo! 你好世界! 你好世界! ");
|
||||
recalculate(charWidth * 8.5);
|
||||
checkLines(assert, para, [
|
||||
"你好世界! HΩ",
|
||||
"llo! 你好世",
|
||||
"界! 你好世界! "
|
||||
]);
|
||||
|
||||
setText("你好世界! HeΩlo! 你好世界! 你好世界! ");
|
||||
recalculate(charWidth * 8.5);
|
||||
checkLines(assert, para, [
|
||||
"你好世界! He",
|
||||
"Ωlo! 你好世",
|
||||
"界! 你好世界! "
|
||||
]);
|
||||
|
||||
run.SetRFontsHint(undefined);
|
||||
});
|
||||
|
||||
|
||||
@ -473,13 +473,15 @@
|
||||
{
|
||||
return this.IsDigit();
|
||||
};
|
||||
CRunText.prototype.IsSpaceAfter = function()
|
||||
CRunText.prototype.IsSpaceAfter = function(fontHint)
|
||||
{
|
||||
return !!(this.Flags & FLAGS_SPACEAFTER);
|
||||
return ((this.Flags & FLAGS_SPACEAFTER)
|
||||
|| (AscWord.fonthint_EastAsia === fontHint && AscCommon.isAmbiguousCharacter(this.Value)));
|
||||
};
|
||||
CRunText.prototype.IsSpaceBefore = function()
|
||||
CRunText.prototype.IsSpaceBefore = function(fontHint)
|
||||
{
|
||||
return AscCommon.isEastAsianScript(this.Value);
|
||||
return (AscCommon.isEastAsianScript(this.Value)
|
||||
|| (AscWord.fonthint_EastAsia === fontHint && AscCommon.isAmbiguousCharacter(this.Value)));
|
||||
};
|
||||
CRunText.prototype.isHyphenAfter = function()
|
||||
{
|
||||
@ -566,7 +568,7 @@
|
||||
// Дефисы
|
||||
if (0x002D === this.Value || 0x2014 === this.Value)
|
||||
return true;
|
||||
|
||||
|
||||
if (AscCommon.isEastAsianScript(this.Value) && this.CanBeAtEndOfLine())
|
||||
return true;
|
||||
|
||||
|
||||
@ -3816,7 +3816,7 @@ ParaRun.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
|
||||
}
|
||||
}
|
||||
|
||||
let isBreakBefore = Item.IsSpaceBefore();
|
||||
let isBreakBefore = Item.IsSpaceBefore(textPr.RFonts.Hint);
|
||||
if (isBreakBefore
|
||||
&& Word
|
||||
&& PRS.LastItem.CanBeAtEndOfLine()
|
||||
@ -3838,7 +3838,7 @@ ParaRun.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
|
||||
let isLigature = Item.IsLigature();
|
||||
let GraphemeLen = isLigature ? Item.GetLigatureWidth() : LetterLen;
|
||||
|
||||
let isBreakAfter = Item.IsSpaceAfter() || textPr.RFonts.Hint === AscWord.fonthint_EastAsia;
|
||||
let isBreakAfter = Item.IsSpaceAfter(textPr.RFonts.Hint);
|
||||
|
||||
if (FirstItemOnLine
|
||||
&& (X + SpaceLen + WordLen + GraphemeLen > XEnd
|
||||
|
||||
Reference in New Issue
Block a user