Skip to content

Commit 4bb6028

Browse files
committed
Remove isNonSpacingMark method and simplify glyph position handling because of moving this logic to Skia
1 parent 4312022 commit 4bb6028

4 files changed

Lines changed: 2 additions & 45 deletions

File tree

compose/ui/ui-text/src/desktopMain/kotlin/androidx/compose/ui/text/CharHelpers.jvm.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ internal actual fun CodePoint.isNeutralDirection(): Boolean =
3838
else -> false
3939
}
4040

41-
internal actual fun CodePoint.isNonSpacingMark(): Boolean =
42-
getDirectionality() == CharDirectionality.NONSPACING_MARK
43-
4441
/**
4542
* Get the Unicode directionality of a character.
4643
*/

compose/ui/ui-text/src/nonJvmMain/kotlin/androidx/compose/ui/text/CharHelpers.nonJvm.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,4 @@ internal actual fun CodePoint.isNeutralDirection(): Boolean =
3939
CharDirection.BOUNDARY_NEUTRAL -> true
4040

4141
else -> false
42-
}
43-
44-
internal actual fun CodePoint.isNonSpacingMark(): Boolean =
45-
CharDirection.of(this) == CharDirection.DIR_NON_SPACING_MARK
42+
}

compose/ui/ui-text/src/skikoMain/kotlin/androidx/compose/ui/text/CharHelpers.skiko.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ internal fun CodePoint.isSupplementaryCodePoint(): Boolean =
7474

7575
internal expect fun CodePoint.strongDirectionType(): StrongDirectionType
7676
internal expect fun CodePoint.isNeutralDirection(): Boolean
77-
internal expect fun CodePoint.isNonSpacingMark(): Boolean
7877

7978
/**
8079
* Determine direction based on the first strong directional character.

compose/ui/ui-text/src/skikoMain/kotlin/androidx/compose/ui/text/SkiaParagraph.skiko.kt

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -429,26 +429,7 @@ internal class SkiaParagraph(
429429
}
430430

431431
override fun getOffsetForPosition(position: Offset): Int {
432-
val initialGlyphPosition = paragraph.getGlyphPositionAtCoordinate(position.x, position.y).position
433-
434-
// Check if the position is inside a complex character with non-spacing marks
435-
// If it is, adjust the position to the next possible space
436-
var glyphPosition = initialGlyphPosition
437-
if (glyphPosition in 0 until text.length) {
438-
// Check if the current position has a non-spacing mark
439-
val isNonSpacingMark = text.codePointAt(glyphPosition).isNonSpacingMark()
440-
441-
if (isNonSpacingMark) {
442-
// Find the boundaries of the complex character
443-
val precedingBreak = text.findPrecedingBreak(glyphPosition)
444-
val followingBreak = text.findFollowingBreak(glyphPosition)
445-
446-
// If we're inside a complex character, jump to the end of it
447-
if (precedingBreak != glyphPosition && followingBreak != glyphPosition) {
448-
glyphPosition = followingBreak
449-
}
450-
}
451-
}
432+
val glyphPosition = paragraph.getGlyphPositionAtCoordinate(position.x, position.y).position
452433

453434
// Below we apply a workaround for skiko/skia issue:
454435
//
@@ -495,23 +476,6 @@ internal class SkiaParagraph(
495476
return glyphPosition
496477
}
497478

498-
// Check if the last character of the line is a non-spacing mark
499-
val hasNonSpacingMarkAtEnd = if (isNotEmptyLine && expectedLine.endExcludingWhitespaces > 0) {
500-
val lastCharIndex = expectedLine.endExcludingWhitespaces - 1
501-
if (lastCharIndex >= 0 && lastCharIndex < text.length) {
502-
text.codePointAt(lastCharIndex).isNonSpacingMark()
503-
} else {
504-
false
505-
}
506-
} else {
507-
false
508-
}
509-
510-
// If the line ends with a non-spacing mark, don't apply the workaround
511-
if (hasNonSpacingMarkAtEnd) {
512-
return glyphPosition
513-
}
514-
515479
var correctedGlyphPosition = glyphPosition
516480

517481
if (position.x <= leftX) { // when clicked to the left of a text line

0 commit comments

Comments
 (0)