Wear CWF Include otf format compatibility for fonts
This commit is contained in:
parent
e33358d46c
commit
d00c4e223e
|
@ -63,7 +63,8 @@ enum class ResFormat(val extension: String) {
|
||||||
SVG("svg"),
|
SVG("svg"),
|
||||||
JPG("jpg"),
|
JPG("jpg"),
|
||||||
PNG("png"),
|
PNG("png"),
|
||||||
TTF("ttf");
|
TTF("ttf"),
|
||||||
|
OTF("otf");
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
|
@ -102,7 +103,7 @@ data class ResData(val value: ByteArray, val format: ResFormat) {
|
||||||
fun toTypeface(): Typeface? {
|
fun toTypeface(): Typeface? {
|
||||||
try {
|
try {
|
||||||
return when (format) {
|
return when (format) {
|
||||||
ResFormat.TTF -> {
|
ResFormat.TTF, ResFormat.OTF -> {
|
||||||
// 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", format.extension).let { tempFile ->
|
File.createTempFile("temp", format.extension).let { tempFile ->
|
||||||
FileOutputStream(tempFile).let { fileOutputStream ->
|
FileOutputStream(tempFile).let { fileOutputStream ->
|
||||||
|
|
|
@ -554,7 +554,7 @@ private enum class FontMap(val key: String, var font: Typeface, @FontRes val fon
|
||||||
} ?: fontMap.font
|
} ?: fontMap.font
|
||||||
}
|
}
|
||||||
resDataMap.filter { (_, resData) ->
|
resDataMap.filter { (_, resData) ->
|
||||||
resData.format == ResFormat.TTF
|
resData.format == ResFormat.TTF || resData.format == ResFormat.OTF
|
||||||
}.forEach { (key, resData) ->
|
}.forEach { (key, resData) ->
|
||||||
customFonts[key.lowercase()] = resData.toTypeface() ?:Typeface.DEFAULT
|
customFonts[key.lowercase()] = resData.toTypeface() ?:Typeface.DEFAULT
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue