Merge pull request #327 from keymanapp/developer-5482-character-identifier-crash

Additional management for text editor selection of partial surrogate pair
This commit is contained in:
Marc Durdin 2017-09-26 11:54:35 +07:00 committed by GitHub
commit dab87fddb5
2 changed files with 9 additions and 2 deletions

View file

@ -925,7 +925,9 @@ begin
if ch = '' then Exit;
if Uni_IsSurrogate2(ch[1]) then
ch := memo.GetTextPart(memo.SelStart-2, memo.SelStart);
ch := memo.GetTextPart(memo.SelStart-2, memo.SelStart)
else if Uni_IsSurrogate1(ch[1]) then
ch := memo.GetTextPart(memo.SelStart-1, memo.SelStart+1);
token := FormatUnicode(ch);
end;

View file

@ -325,7 +325,12 @@ procedure TClearTypeDrawCharacter.SelectFallbackFont(Handle: THandle; const Text
var
uc: DWord;
begin
uc := Char.ConvertToUtf32(Text, 0); // I3310
try
uc := Char.ConvertToUtf32(Text, 0); // I3310
except
on E:EArgumentOutOfRangeException do
uc := $FFFD; // Not a character, invalid Unicode
end;
if uc < $10000 then SelectFont(Handle, ctfCode2000)
else if uc < $20000 then SelectFont(Handle, ctfCode2001)
else if uc < $30000 then SelectFont(Handle, ctfCode2002)