mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-04 17:37:25 +00:00
Improved font selection
This commit is contained in:
parent
fb650bf5ee
commit
2dc161e080
11 changed files with 323 additions and 16 deletions
13
app/src/main/java/eu/ottop/yamlauncher/utils/FontMap.kt
Normal file
13
app/src/main/java/eu/ottop/yamlauncher/utils/FontMap.kt
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package eu.ottop.yamlauncher.utils
|
||||
|
||||
import eu.ottop.yamlauncher.R
|
||||
|
||||
object FontMap {
|
||||
val fonts: Map<String, Int> = mapOf(
|
||||
"arbutus" to R.font.arbutus,
|
||||
"ubuntu" to R.font.ubuntu,
|
||||
"ubuntu_light" to R.font.ubuntu_light,
|
||||
"ubuntu_condensed_regular" to R.font.ubuntu_condensed_regular,
|
||||
"workbench" to R.font.workbench,
|
||||
)
|
||||
}
|
||||
|
|
@ -19,6 +19,7 @@ import android.widget.Space
|
|||
import android.widget.TextClock
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.core.view.children
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
|
|
@ -104,18 +105,26 @@ class UIUtils(private val context: Context) {
|
|||
typedArray.recycle()
|
||||
}
|
||||
|
||||
val fontId = FontMap.fonts[font]
|
||||
|
||||
val newFont = if (fontId != null) {
|
||||
ResourcesCompat.getFont(context, fontId)
|
||||
} else {
|
||||
Typeface.create(font, Typeface.NORMAL)
|
||||
}
|
||||
|
||||
when (style) {
|
||||
"normal" -> {
|
||||
view.setTypeface(Typeface.create(font, Typeface.NORMAL))
|
||||
view.setTypeface(Typeface.create(newFont, Typeface.NORMAL))
|
||||
}
|
||||
"bold" -> {
|
||||
view.setTypeface(Typeface.create(font, Typeface.BOLD))
|
||||
view.setTypeface(Typeface.create(newFont, Typeface.BOLD))
|
||||
}
|
||||
"italic" -> {
|
||||
view.setTypeface(Typeface.create(font, Typeface.ITALIC))
|
||||
view.setTypeface(Typeface.create(newFont, Typeface.ITALIC))
|
||||
}
|
||||
"bold-italic" -> {
|
||||
view.setTypeface(Typeface.create(font, Typeface.BOLD_ITALIC))
|
||||
view.setTypeface(Typeface.create(newFont, Typeface.BOLD_ITALIC))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
BIN
app/src/main/res/font/arbutus.ttf
Normal file
BIN
app/src/main/res/font/arbutus.ttf
Normal file
Binary file not shown.
BIN
app/src/main/res/font/ubuntu.ttf
Normal file
BIN
app/src/main/res/font/ubuntu.ttf
Normal file
Binary file not shown.
BIN
app/src/main/res/font/ubuntu_condensed_regular.ttf
Normal file
BIN
app/src/main/res/font/ubuntu_condensed_regular.ttf
Normal file
Binary file not shown.
BIN
app/src/main/res/font/ubuntu_light.ttf
Normal file
BIN
app/src/main/res/font/ubuntu_light.ttf
Normal file
Binary file not shown.
BIN
app/src/main/res/font/workbench.ttf
Normal file
BIN
app/src/main/res/font/workbench.ttf
Normal file
Binary file not shown.
|
|
@ -33,38 +33,40 @@
|
|||
|
||||
<string-array name="font_options">
|
||||
<item>System</item>
|
||||
<item>Arbutus</item>
|
||||
<item>Casual</item>
|
||||
<item>Cursive</item>
|
||||
<item>Monospace</item>
|
||||
<item>Sans Serif</item>
|
||||
<item>Sans Serif Black</item>
|
||||
<item>Sans Serif Light</item>
|
||||
<item>Sans Serif Thin</item>
|
||||
<item>Sans Serif Condensed</item>
|
||||
<item>Sans Serif Condensed Light</item>
|
||||
<item>Sans Serif Condensed Medium</item>
|
||||
<item>Sans Serif Light</item>
|
||||
<item>Sans Serif Medium</item>
|
||||
<item>Sans Serif Smallcaps</item>
|
||||
<item>Sans Serif Thin</item>
|
||||
<item>Serif</item>
|
||||
<item>Serif Monospace</item>
|
||||
<item>Ubuntu</item>
|
||||
<item>Ubuntu Light</item>
|
||||
<item>Ubuntu Condensed Regular</item>
|
||||
<item>Workbench</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="font_values">
|
||||
<item>system</item>
|
||||
<item>arbutus</item>
|
||||
<item>casual</item>
|
||||
<item>cursive</item>
|
||||
<item>monospace</item>
|
||||
<item>sans-serif</item>
|
||||
<item>sans-serif-black</item>
|
||||
<item>sans-serif-light</item>
|
||||
<item>sans-serif-thin</item>
|
||||
<item>sans-serif-condensed</item>
|
||||
<item>sans-serif-condensed-light</item>
|
||||
<item>sans-serif-condensed-medium</item>
|
||||
<item>sans-serif-light</item>
|
||||
<item>sans-serif-medium</item>
|
||||
<item>sans-serif-smallcaps</item>
|
||||
<item>sans-serif-thin</item>
|
||||
<item>serif</item>
|
||||
<item>serif-monospace</item>
|
||||
<item>ubuntu</item>
|
||||
<item>ubuntu_light</item>
|
||||
<item>ubuntu_condensed_regular</item>
|
||||
<item>workbench</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="style_options">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue