Skip to content

Commit

Permalink
Merge pull request #600 from tuanchauict/auto-merge-alpha-release
Browse files Browse the repository at this point in the history
[Auto merge][main -> release/alpha/1.3] Update alpha release
  • Loading branch information
tuanchauict authored Mar 22, 2024
2 parents 7c68711 + 97ffec9 commit 6b21ec3
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,16 @@ internal object CrossingResources {

val innerMask = maskUpper or maskLower
val outerMask = maskLeft or maskRight or maskTop or maskBottom
val mask = innerMask and outerMask

val outerDirectionCount = countMask(outerMask) / 3 // 3 is the number of format.
val mask = if (countMask(maskUpper) > outerDirectionCount) {
// If the upper char has more directions than the outer directions, use the inner mask
// only. This happens when the upper char is a sole char with no or not enough adjacent
// chars. For example, use ├ for the line anchor.
innerMask
} else {
innerMask and outerMask
}

if (Build.DEBUG) {
console.log(
Expand Down Expand Up @@ -577,4 +586,17 @@ internal object CrossingResources {
((mask shl 8) or (mask shl 4) or mask or (mask shr 4) or (mask shr 8)) and MASK_CROSS
return MASK_CROSS xor allDirectionsMask
}

/**
* Counts the number of bits that are set to 1 in the given mask.
*/
private fun countMask(mask: Int): Int {
var count = 0
var m = mask
while (m != 0) {
count += m and 1
m = m shr 1
}
return count
}
}

0 comments on commit 6b21ec3

Please sign in to comment.