字体粗细 #185

This commit is contained in:
HapeLee committed 2025-11-02 12:23:19 +08:00
1 parent 45b454c4c1
commit b1701ad49f
4 files changed
+13 -3

No files matched your search

@@ -598,7 +598,7 @@ object ReadBookConfig {
var titleSize: Int = 0, var titleSize: Int = 0,
var titleTopSpacing: Int = 0, var titleTopSpacing: Int = 0,
var titleBottomSpacing: Int = 0, var titleBottomSpacing: Int = 0,
var titleBold: Int = 500, var titleBold: Int = 500,//是否粗体字 0:正常, 1:粗体, 2:细体
var titleLineSpacingExtra: Int = 4, var titleLineSpacingExtra: Int = 4,
var titleSegType: Int = 0,//分段模式 var titleSegType: Int = 0,//分段模式
var titleSegScaling: Float = 1.2f,//分段缩放,第二段与第一段的字体大小比例 var titleSegScaling: Float = 1.2f,//分段缩放,第二段与第一段的字体大小比例
@@ -140,7 +140,7 @@ class FontSelectDialog : BaseBottomSheetDialogFragment(R.layout.dialog_font_sele
} }
val weightOptions = context?.resources?.getStringArray(R.array.text_font_weight) val weightOptions = context?.resources?.getStringArray(R.array.text_font_weight)
val weightValues = listOf(2, 1, 0) val weightValues = listOf(0, 1, 2)
val initialIndex = weightValues.indexOf(ReadBookConfig.textBold) val initialIndex = weightValues.indexOf(ReadBookConfig.textBold)
binding.textFontWeightConverter.text = weightOptions?.getOrNull(initialIndex) ?: "自定义" binding.textFontWeightConverter.text = weightOptions?.getOrNull(initialIndex) ?: "自定义"
@@ -53,7 +53,7 @@ class TipConfigDialog : BaseBottomSheetDialogFragment(R.layout.dialog_tip_config
else -> { } else -> { }
} }
val weightOptions = context?.resources?.getStringArray(R.array.text_font_weight) val weightOptions = context?.resources?.getStringArray(R.array.text_font_weight)
val weightValues = listOf(2, 1, 0) val weightValues = listOf(0, 1, 2)
val initialIndex = weightValues.indexOf(ReadBookConfig.titleBold) val initialIndex = weightValues.indexOf(ReadBookConfig.titleBold)
binding.textFontWeightConverter.text = weightOptions?.getOrNull(initialIndex) ?: "自定义" binding.textFontWeightConverter.text = weightOptions?.getOrNull(initialIndex) ?: "自定义"
binding.textFontWeightConverter.setOnClickListener { binding.textFontWeightConverter.setOnClickListener {
@@ -930,6 +930,11 @@ object ChapterProvider {
else else
normal normal
0 -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
Typeface.create(typeface, 300, false)
else
normal
in 100..900 -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) in 100..900 -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
Typeface.create(typeface, ReadBookConfig.titleBold, false) Typeface.create(typeface, ReadBookConfig.titleBold, false)
else else
@@ -949,6 +954,11 @@ object ChapterProvider {
else else
normal normal
0 -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
Typeface.create(typeface, 300, false)
else
normal
in 100..900 -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) in 100..900 -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
Typeface.create(typeface, ReadBookConfig.textBold, false) Typeface.create(typeface, ReadBookConfig.textBold, false)
else else