-
Notifications
You must be signed in to change notification settings - Fork 81
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
Font with lazy get data in skikoMain #906
Conversation
@@ -67,13 +67,19 @@ class SystemFont( | |||
*/ | |||
class LoadedFont internal constructor( | |||
override val identity: String, | |||
val data: ByteArray, | |||
val getData: () -> ByteArray, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need it in public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is better to make it internal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
* | ||
* @see FontFamily | ||
*/ | ||
@Deprecated( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's avoid deprecation, just add new overload
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, done
@@ -108,10 +114,10 @@ class LoadedFont internal constructor( | |||
*/ | |||
fun Font( | |||
identity: String, | |||
data: ByteArray, | |||
getData: () -> ByteArray, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getData: () -> ByteArray, | |
data: () -> ByteArray, |
or
getData: () -> ByteArray, | |
dataReader: () -> ByteArray, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, better to leave getData(). It is simple name for this case.
override val weight: FontWeight, | ||
override val style: FontStyle | ||
) : PlatformFont() { | ||
@ExperimentalTextApi | ||
override val loadingStrategy: FontLoadingStrategy = FontLoadingStrategy.Blocking | ||
|
||
val data: ByteArray get() = getData() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure but maybe better to make it by lazy
to avoid unexpected multirun for the lambda
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for suggestion! Done!
compose/ui/ui-text/src/skikoMain/kotlin/androidx/compose/ui/text/platform/PlatformFont.skiko.kt
Outdated
Show resolved
Hide resolved
This reverts commit ccc9c7f.
We just added new function Font with lazy getData lambda. We don't need changes in Skiko library.
We just added new function Font with lazy getData lambda.
We don't need changes in Skiko library.
@MatkovIvan Where are no good primitives for stream of bytes in Kotlin stdlib (This one declared in ktor.io framework https://api.ktor.io/ktor-io/io.ktor.utils.io/-byte-read-channel/index.html).
Anyway - fonts is not big enought, so be can fully handle it in memory.