Snowmtl: Use pt as fontsize (#6954)

* Use pt as fontsize

* Add comment
This commit is contained in:
Chopper 2025-01-03 04:55:55 -03:00 committed by Draff
parent 0a3cc9a886
commit b4314f5f0b
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 6 additions and 4 deletions

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'Snow Machine Translations' extName = 'Snow Machine Translations'
extClass = '.SnowmtlFactory' extClass = '.SnowmtlFactory'
extVersionCode = 5 extVersionCode = 6
isNsfw = true isNsfw = true
} }

View File

@ -102,7 +102,7 @@ class ComposedImageInterceptor(
} }
private fun createTextPaint(font: Typeface?): TextPaint { private fun createTextPaint(font: Typeface?): TextPaint {
val defaultTextSize = 50.sp // arbitrary val defaultTextSize = 24.pt // arbitrary
return TextPaint().apply { return TextPaint().apply {
color = Color.BLACK color = Color.BLACK
textSize = defaultTextSize textSize = defaultTextSize
@ -258,7 +258,8 @@ class ComposedImageInterceptor(
restore() restore()
} }
private val Int.sp: Float get() = this * SCALED_DENSITY // https://pixelsconverter.com/pt-to-px
private val Int.pt: Float get() = this / SCALED_DENSITY
// ============================= Utils ====================================== // ============================= Utils ======================================
@ -283,7 +284,8 @@ class ComposedImageInterceptor(
} }
companion object { companion object {
const val SCALED_DENSITY = 1.5f // arbitrary // w3: Absolute Lengths [...](https://www.w3.org/TR/css3-values/#absolute-lengths)
const val SCALED_DENSITY = 0.75f // 1px = 0.75pt
val mediaType = "image/png".toMediaType() val mediaType = "image/png".toMediaType()
} }
} }