Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update skiko to 0.8.11 #1486

Merged
merged 4 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import org.jetbrains.skia.Data
import org.jetbrains.skia.FontMgr
import org.jetbrains.skia.FontSlant
import org.jetbrains.skia.FontWidth
import org.jetbrains.skia.makeFromFile

actual sealed class PlatformFont : Font {
actual abstract val identity: String
Expand Down Expand Up @@ -168,10 +167,11 @@ internal actual fun loadTypeface(font: Font): SkTypeface {
return when (font) {
is ResourceFont -> typefaceResource(font.name)
// TODO: replace with FontMgr.makeFromFile(font.file.toString())
is FileFont -> SkTypeface.makeFromFile(font.file.toString())
is FileFont -> FontMgr.default.makeFromFile(font.file.toString())
is LoadedFont -> FontMgr.default.makeFromData(Data.makeFromBytes(font.getData()))
is SystemFont -> FontMgr.default.matchFamilyStyle(font.identity, font.skFontStyle)
} ?: SkTypeface.makeFromName(SkTypeface.makeDefault().familyName, font.skFontStyle)
} ?: (FontMgr.default.legacyMakeTypeface(font.identity, font.skFontStyle)
?: error("loadTypeface legacyMakeTypeface failed"))
}

private fun typefaceResource(resourceName: String): SkTypeface {
Expand All @@ -181,7 +181,7 @@ private fun typefaceResource(resourceName: String): SkTypeface {
?: error("Can't load font from $resourceName")

val bytes = resource.use { it.readAllBytes() }
return SkTypeface.makeFromData(Data.makeFromBytes(bytes))
return FontMgr.default.makeFromData(Data.makeFromBytes(bytes))!!
}

private val Font.skFontStyle: SkFontStyle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import androidx.compose.ui.text.font.FontWeight
import java.io.File
import kotlin.io.path.Path
import kotlin.io.path.absolutePathString
import org.jetbrains.skia.FontMgr
import org.jetbrains.skia.FontSlant
import org.jetbrains.skia.makeFromFile

internal object JetBrainsRuntimeFontFamilies {

Expand Down Expand Up @@ -97,7 +97,8 @@ internal object JetBrainsRuntimeFontFamilies {
val absolutePath = path.absolutePathString()

// We need to parse the typeface to extract its weight and style
val typeface = org.jetbrains.skia.Typeface.makeFromFile(absolutePath)
val typeface = FontMgr.default.makeFromFile(absolutePath)
?: error("makeFromFile $absolutePath failed")
val weight = FontWeight(typeface.fontStyle.weight)
val style = when (typeface.fontStyle.slant) {
FontSlant.UPRIGHT -> FontStyle.Normal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import androidx.compose.ui.text.platform.Typeface
import androidx.compose.ui.text.platform.aliases
import com.google.common.truth.Truth
import org.jetbrains.skia.Data
import org.jetbrains.skia.Typeface
import org.jetbrains.skia.FontMgr
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand Down Expand Up @@ -56,7 +56,8 @@ class DesktopFontTest {
.contextClassLoader
.getResourceAsStream("font/sample_font.ttf")!!
.readAllBytes()
Typeface.makeFromData(Data.makeFromBytes(bytes))
FontMgr.default.makeFromData(Data.makeFromBytes(bytes))
?: error("loadedTypeface failed: FontMgr.default.makeFromData returned null")
}

private val loadedFontFamily by lazy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.jetbrains.skia.FontStyle as SkFontStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontStyle
import org.jetbrains.skia.Data
import org.jetbrains.skia.FontMgr
import org.jetbrains.skia.FontSlant
import org.jetbrains.skia.FontWidth

Expand All @@ -30,8 +31,10 @@ internal actual fun loadTypeface(font: Font): SkTypeface {
}
@Suppress("REDUNDANT_ELSE_IN_WHEN")
return when (font) {
is LoadedFont -> SkTypeface.makeFromData(Data.makeFromBytes(font.getData()))
is SystemFont -> SkTypeface.makeFromName(font.identity, font.skFontStyle)
is LoadedFont -> FontMgr.default.makeFromData(Data.makeFromBytes(font.getData()))
?: error("loadTypeface makeFromData failed")
is SystemFont -> FontMgr.default.legacyMakeTypeface(font.identity, font.skFontStyle)
?: error("loadTypeface legacyMakeTypeface failed")
// TODO: compilation fails without `else` see https://youtrack.jetbrains.com/issue/KT-43875
else -> throw IllegalArgumentException("Unsupported font type: $font")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import org.jetbrains.skia.FontStyle as SkFontStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontStyle
import org.jetbrains.skia.Data
import org.jetbrains.skia.FontMgr
import org.jetbrains.skia.FontSlant
import org.jetbrains.skia.FontWidth
import org.jetbrains.skiko.OS
Expand All @@ -30,8 +31,10 @@ internal actual fun loadTypeface(font: Font): SkTypeface {
throw IllegalArgumentException("Unsupported font type: $font")
}
return when (font) {
is LoadedFont -> SkTypeface.makeFromData(Data.makeFromBytes(font.getData()))
is SystemFont -> SkTypeface.makeFromName(font.identity, font.skFontStyle)
is LoadedFont -> FontMgr.default.makeFromData(Data.makeFromBytes(font.getData()))
?: error("loadTypeface makeFromData failed")
is SystemFont -> FontMgr.default.legacyMakeTypeface(font.identity, font.skFontStyle)
?: error("loadTypeface legacyMakeTypeface failed")
}
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ moshi = "1.13.0"
protobuf = "3.21.8"
paparazzi = "1.0.0"
paparazziNative = "2022.1.1-canary-f5f9f71"
skiko = "0.8.9"
skiko = "0.8.11"
sqldelight = "1.3.0"
retrofit = "2.7.2"
wire = "4.5.1"
Expand Down