From 1d71486a4262d5c3ec37f95a91575114ebe55892 Mon Sep 17 00:00:00 2001 From: Aleksandr Veselov Date: Thu, 10 Mar 2022 19:19:29 +0300 Subject: [PATCH 1/2] Fix cursor position in ligatures --- ...and_rects_for_chars_inside_ligatures.patch | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 patches/Fix_glyph_position_and_rects_for_chars_inside_ligatures.patch diff --git a/patches/Fix_glyph_position_and_rects_for_chars_inside_ligatures.patch b/patches/Fix_glyph_position_and_rects_for_chars_inside_ligatures.patch new file mode 100644 index 0000000..ef0eb74 --- /dev/null +++ b/patches/Fix_glyph_position_and_rects_for_chars_inside_ligatures.patch @@ -0,0 +1,55 @@ +Index: modules/skparagraph/src/TextLine.cpp +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/modules/skparagraph/src/TextLine.cpp b/modules/skparagraph/src/TextLine.cpp +--- a/modules/skparagraph/src/TextLine.cpp (revision f85ab491eb97b54d0bfeac19fed27feb499b8912) ++++ b/modules/skparagraph/src/TextLine.cpp (date 1646928189139) +@@ -615,6 +615,7 @@ + } + return result; + } ++ TextRange origTextRange = textRange; + // Find [start:end] clusters for the text + Cluster* start = nullptr; + Cluster* end = nullptr; +@@ -688,8 +689,8 @@ + // TODO: This is where we get smart about selecting a part of a cluster + // by shaping each grapheme separately and then use the result sizes + // to calculate the proportions +- auto leftCorrection = start->sizeToChar(textRange.start); +- auto rightCorrection = end->sizeFromChar(textRange.end - 1); ++ auto leftCorrection = start->sizeToChar(origTextRange.start); ++ auto rightCorrection = end->sizeFromChar(origTextRange.end - 1); + result.clip.fLeft += leftCorrection; + result.clip.fRight -= rightCorrection; + result.clippingNeeded = leftCorrection != 0 || rightCorrection != 0; +@@ -1248,6 +1249,27 @@ + auto clusterIndex8 = context.run->globalClusterIndex(found); + auto clusterEnd8 = context.run->globalClusterIndex(found + 1); + ++ size_t charsInCluster = 0; ++ for (auto i = clusterIndex8; i < clusterEnd8; i++) { ++ i = run->owner()->findNextGraphemeBoundary(i); ++ if (i < clusterEnd8) charsInCluster++; ++ } ++ ++ // Calculate offset for a character inside a ligature (e.g. ff or ffi) ++ // Considering all characters in the ligature have equal width ++ if (glyphemePosWidth > 0 && charsInCluster > 1) { ++ glyphemePosWidth /= charsInCluster; ++ size_t charIndexInCluster = std::floor((dx - glyphemePosLeft) / glyphemePosWidth); ++ if (!context.run->leftToRight()) { ++ charIndexInCluster = charsInCluster - charIndexInCluster; ++ } ++ glyphemePosLeft += charIndexInCluster * glyphemePosWidth; ++ for (size_t i = 0; i < charIndexInCluster; i++) { ++ clusterIndex8 = run->owner()->findNextGraphemeBoundary(clusterIndex8 + 1); ++ } ++ clusterEnd8 = run->owner()->findNextGraphemeBoundary(clusterIndex8 + 1); ++ } ++ + SkScalar center = glyphemePosLeft + glyphemePosWidth / 2; + if ((dx < center) == context.run->leftToRight()) { + size_t utf16Index = context.run->leftToRight() From b2e08768fa69e146fad4fd1539a72575287916f6 Mon Sep 17 00:00:00 2001 From: Aleksandr Veselov Date: Fri, 11 Mar 2022 11:11:02 +0300 Subject: [PATCH 2/2] Update version --- .github/workflows/build.yml | 2 +- README.md | 4 ++-- script/update_version.sh | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2120ef6..f6cf1f1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ on: default: 'false' env: - version: m99-f85ab491eb + version: m99-f85ab491eb-2 jobs: macos: diff --git a/README.md b/README.md index fd17809..028956f 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Update `version` in [.github/workflows/build.yml](https://github.com/JetBrains/s ## Building locally ```sh -python3 script/checkout.py --version m99-f85ab491eb +python3 script/checkout.py --version m99-f85ab491eb-2 python3 script/build.py python3 script/archive.py ``` @@ -21,7 +21,7 @@ python3 script/archive.py To build a debug build: ```sh -python3 script/checkout.py --version m99-f85ab491eb +python3 script/checkout.py --version m99-f85ab491eb-2 python3 script/build.py --build-type Debug python3 script/archive.py --build-type Debug ``` diff --git a/script/update_version.sh b/script/update_version.sh index c41562e..b13d2b1 100755 --- a/script/update_version.sh +++ b/script/update_version.sh @@ -1,5 +1,5 @@ #!/bin/bash ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/.. -OLDVER=m99-51988d0bc1 -NEWVER=m99-f85ab491eb +OLDVER=m99-f85ab491eb +NEWVER=m99-f85ab491eb-2 find -E $ROOT/script *.md .github -regex '.*\.(py|md|yml)' -exec sed -i '' -e "s/$OLDVER/$NEWVER/g" {} \;