Wear CWF Clean loaded font before loading
This commit is contained in:
parent
a9b6fdef27
commit
e33358d46c
|
@ -104,7 +104,7 @@ data class ResData(val value: ByteArray, val format: ResFormat) {
|
||||||
return when (format) {
|
return when (format) {
|
||||||
ResFormat.TTF -> {
|
ResFormat.TTF -> {
|
||||||
// Workaround with temporary File, Typeface.createFromFileDescriptor(null, value, 0, value.size) more simple not available
|
// Workaround with temporary File, Typeface.createFromFileDescriptor(null, value, 0, value.size) more simple not available
|
||||||
File.createTempFile("temp", ".ttf").let { tempFile ->
|
File.createTempFile("temp", format.extension).let { tempFile ->
|
||||||
FileOutputStream(tempFile).let { fileOutputStream ->
|
FileOutputStream(tempFile).let { fileOutputStream ->
|
||||||
fileOutputStream.write(value)
|
fileOutputStream.write(value)
|
||||||
fileOutputStream.close()
|
fileOutputStream.close()
|
||||||
|
|
|
@ -547,6 +547,7 @@ private enum class FontMap(val key: String, var font: Typeface, @FontRes val fon
|
||||||
|
|
||||||
private val customFonts = mutableMapOf<String, Typeface>()
|
private val customFonts = mutableMapOf<String, Typeface>()
|
||||||
fun init(context: Context, resDataMap: CwfResDataMap) {
|
fun init(context: Context, resDataMap: CwfResDataMap) {
|
||||||
|
customFonts.clear()
|
||||||
values().forEach { fontMap ->
|
values().forEach { fontMap ->
|
||||||
customFonts[fontMap.key.lowercase()] = fontMap.fontRessources?.let { fontResource ->
|
customFonts[fontMap.key.lowercase()] = fontMap.fontRessources?.let { fontResource ->
|
||||||
ResourcesCompat.getFont(context, fontResource)
|
ResourcesCompat.getFont(context, fontResource)
|
||||||
|
|
Loading…
Reference in a new issue