Add files via upload

This commit is contained in:
OTKUSteyler 2026-09-05 12:25:16 +02:00 • committed by GitHub
parent 7814cd0e82
commit d719e15cf8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 5 deletions

View file

@ -6,6 +6,7 @@ import android.graphics.Typeface.CustomFallbackBuilder
import android.graphics.fonts.Font
import android.graphics.fonts.FontFamily
import android.os.Build
import de.robv.android.xposed.XC_MethodHook.MethodHookParam
import de.robv.android.xposed.XC_MethodReplacement
import de.robv.android.xposed.XposedHelpers
import de.robv.android.xposed.callbacks.XC_LoadPackage
@ -13,6 +14,8 @@ import GoonXposed.xposed.Constants
import GoonXposed.xposed.Module
import GoonXposed.xposed.Utils.Companion.JSON
import GoonXposed.xposed.Utils.Log
import GoonXposed.xposed.asDir
import GoonXposed.xposed.asFile
import io.ktor.client.*
import io.ktor.client.call.*
import io.ktor.client.engine.cio.*
@ -118,6 +121,15 @@ object FontsModule : Module() {
}
}
private fun splitFontName(fontFamilyName: String): Pair<String, String> {
val parts = fontFamilyName.split(":")
return if (parts.size >= 2) parts[0] to parts[1] else "" to fontFamilyName
}
private fun fontFileFor(customName: String, refName: String, fileExtension: String): File =
if (customName.isEmpty()) File(fontsDownloadsDir, "$refName.$fileExtension")
else File(fontsDownloadsDir, "$customName/$refName.$fileExtension")
private fun createAssetTypefaceWithFallbacks(
fontFamilyNames: Array<String>, style: Int, assetManager: AssetManager
): Typeface? {
@ -128,8 +140,8 @@ object FontsModule : Module() {
for (fontFamilyName in fontFamilyNames) {
try {
for (fileExtension in FILE_EXTENSIONS) {
val (customName, refName) = fontFamilyName.split(":")
val file = File(fontsDownloadsDir, "$customName/$refName.$fileExtension").apply { asFile() }
val (customName, refName) = splitFontName(fontFamilyName)
val file = fontFileFor(customName, refName, fileExtension).apply { asFile() }
val font = Font.Builder(file).build()
val family = FontFamily.Builder(font).build()
fontFamilies.add(family)
@ -197,8 +209,8 @@ object FontsModule : Module() {
try {
for (fileExtension in FILE_EXTENSIONS) {
val (customName, refName) = fontFamilyName.split(":")
val file = File(fontsDownloadsDir, "$customName/$refName.$fileExtension").apply { asFile() }
val (customName, refName) = splitFontName(fontFamilyName)
val file = fontFileFor(customName, refName, fileExtension).apply { asFile() }
if (!file.exists()) throw Exception()
return Typeface.createFromFile(file.absolutePath)
}

View file

@ -1,10 +1,10 @@
package GoonXposed.xposed.modules.appearance
import android.R.color
import android.app.AndroidAppHelper
import android.content.Context
import android.os.Build
import androidx.core.content.ContextCompat
import de.robv.android.xposed.AndroidAppHelper
import GoonXposed.xposed.Module
import kotlinx.serialization.json.*
import java.lang.ref.WeakReference

View file

@ -5,8 +5,12 @@ import android.content.res.Resources
import androidx.core.graphics.toColorInt
import de.robv.android.xposed.callbacks.XC_LoadPackage
import GoonXposed.xposed.Constants
import GoonXposed.xposed.MethodHookBuilder
import GoonXposed.xposed.Module
import GoonXposed.xposed.Utils.Companion.JSON
import GoonXposed.xposed.asFile
import GoonXposed.xposed.hook
import GoonXposed.xposed.method
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonObjectBuilder