|
|
@ -1,6 +1,5 @@ |
|
|
|
package io.legado.app.ui.book.read.page.provider |
|
|
|
package io.legado.app.ui.book.read.page.provider |
|
|
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint |
|
|
|
|
|
|
|
import android.graphics.Paint |
|
|
|
import android.graphics.Paint |
|
|
|
import android.graphics.Typeface |
|
|
|
import android.graphics.Typeface |
|
|
|
import android.net.Uri |
|
|
|
import android.net.Uri |
|
|
@ -571,15 +570,15 @@ object ChapterProvider { |
|
|
|
upLayout() |
|
|
|
upLayout() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("Recycle") |
|
|
|
|
|
|
|
private fun getTypeface(fontPath: String): Typeface { |
|
|
|
private fun getTypeface(fontPath: String): Typeface { |
|
|
|
return kotlin.runCatching { |
|
|
|
return kotlin.runCatching { |
|
|
|
when { |
|
|
|
when { |
|
|
|
fontPath.isContentScheme() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O -> { |
|
|
|
fontPath.isContentScheme() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O -> { |
|
|
|
val fd = appCtx.contentResolver |
|
|
|
appCtx.contentResolver |
|
|
|
.openFileDescriptor(Uri.parse(fontPath), "r")!! |
|
|
|
.openFileDescriptor(Uri.parse(fontPath), "r")!! |
|
|
|
.fileDescriptor |
|
|
|
.use { |
|
|
|
Typeface.Builder(fd).build() |
|
|
|
Typeface.Builder(it.fileDescriptor).build() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
fontPath.isContentScheme() -> { |
|
|
|
fontPath.isContentScheme() -> { |
|
|
|
Typeface.createFromFile(RealPathUtil.getPath(appCtx, Uri.parse(fontPath))) |
|
|
|
Typeface.createFromFile(RealPathUtil.getPath(appCtx, Uri.parse(fontPath))) |
|
|
|