From bca8960049706c3402156102cce2cec742cecfc2 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 13 Mar 2021 10:47:26 +0000 Subject: [PATCH] ChemText: Fix handling of UTF8 code points with new parameter symbols '^' and '|' git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7979 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/chemtext/source/chemtext.pas | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/components/chemtext/source/chemtext.pas b/components/chemtext/source/chemtext.pas index 624f0a756..e57d59df2 100644 --- a/components/chemtext/source/chemtext.pas +++ b/components/chemtext/source/chemtext.pas @@ -133,7 +133,7 @@ implementation {$R chemtext.res} uses - Themes, Math; + Themes, Math, LazUtf8; type TArrowDir = (adLeft, adRight, adBoth); @@ -251,7 +251,7 @@ var var x0: Integer; - i, j: integer; + i, j, n: integer; s: string; subNos: boolean; // "subscript numbers" escaping: Boolean; @@ -349,14 +349,16 @@ begin SUPERSCRIPT_CHAR: begin - inc(i); - DrawSup(X, Y, AText[i]); + n := UTF8CodePointSize(@AText[i+1]); + DrawSup(X, Y, copy(AText, i+1, n)); + inc(i, n); end; SUBSCRIPT_CHAR: begin - inc(i); - DrawSub(X, Y, AText[i]); + n := UTF8CodePointSize(@AText[i+1]); + DrawSub(X, Y, copy(AText, i+1, n)); + inc(i, n); end; else