Skip to content

Check script of combining marks during font fallback #6857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,18 @@ static public short GetUnicodeClass(int unicodeScalar)
}


/// <summary>
/// Lookup script ID for a Unicode scalar value
/// </summary>
static public ScriptID GetScript(int unicodeScalar)
{
unsafe
{
return (ScriptID)Classification.CharAttributeTable[GetUnicodeClass(unicodeScalar)].Script;
}
}


/// <summary>
/// Compute Unicode scalar value from unicode codepoint stream
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ ref int nextValid
// If the run starts with combining marks, we will not be able to find base characters for them
// within the run. These combining marks will be mapped to their best fonts as normal characters.
//
bool hasBaseChar = false;
const int NOBASE = -1; // null char is a valid base
int baseChar = NOBASE;

// Determine how many characters we can advance, i.e., find the first invalid character.
for (; advance < unicodeString.Length; advance += sizeofChar)
Expand All @@ -307,12 +308,16 @@ out sizeofChar

if (!Classification.IsCombining(originalChar))
{
hasBaseChar = true;
baseChar = originalChar;
}
else if (hasBaseChar)
else if (baseChar != NOBASE)
{
// continue to advance for combining mark with base char
continue;
// continue to advance for combining mark with base char (can be precomposed by shaping engine)
// except if it is a different script (#6801)
if (Classification.GetScript(baseChar) == Classification.GetScript(originalChar))
{
continue;
}
}

int ch = digitMap[originalChar];
Expand Down Expand Up @@ -365,7 +370,7 @@ out sizeofChar
// The same goes for joiner. Note that "hasBaseChar" here indicates if there is an invalid base
// char in front.
if (Classification.IsJoiner(ch)
|| (hasBaseChar && Classification.IsCombining(ch))
|| (baseChar != NOBASE && Classification.IsCombining(ch) && Classification.GetScript(ch) == Classification.GetScript(baseChar))
)
continue;

Expand Down