@momo-kits/native-kits 0.162.43-debug → 0.162.44-debug
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/compose/build.gradle.kts
CHANGED
|
@@ -10,10 +10,6 @@ import androidx.compose.ui.text.font.FontFamily
|
|
|
10
10
|
* - Android: `assets/fonts/<fileName>` (gradle task `syncMomoFonts`)
|
|
11
11
|
* - iOS: file rời ở bundle root (pbxproj fileRef được `post_install.rb` trỏ về font-source)
|
|
12
12
|
*
|
|
13
|
-
* AI-GENERATED START: note SF Pro -> iOS system font (ITMS-91182)
|
|
14
|
-
* Ngoại lệ: SF Pro trên iOS dùng system font (chính là SF Pro) — Apple cấm app nhúng font của Apple.
|
|
15
|
-
* AI-GENERATED END: note SF Pro -> iOS system font (ITMS-91182)
|
|
16
|
-
*
|
|
17
13
|
* Trả về `null` nếu host không có font đó — caller tự fallback [FontFamily.Default].
|
|
18
14
|
*/
|
|
19
15
|
@Composable
|
|
@@ -4,12 +4,6 @@ package vn.momo.kits.const
|
|
|
4
4
|
|
|
5
5
|
import androidx.compose.runtime.Composable
|
|
6
6
|
import androidx.compose.runtime.remember
|
|
7
|
-
// AI-GENERATED START: imports for the SF Pro -> iOS system font mapping (ITMS-91182)
|
|
8
|
-
import androidx.compose.ui.text.ExperimentalTextApi
|
|
9
|
-
import androidx.compose.ui.text.font.FontWeight
|
|
10
|
-
import androidx.compose.ui.text.platform.SystemFont
|
|
11
|
-
import platform.UIKit.UIFont
|
|
12
|
-
// AI-GENERATED END: imports for the SF Pro -> iOS system font mapping (ITMS-91182)
|
|
13
7
|
import androidx.compose.ui.text.font.FontFamily
|
|
14
8
|
import androidx.compose.ui.text.platform.Font
|
|
15
9
|
import kotlinx.cinterop.ExperimentalForeignApi
|
|
@@ -20,40 +14,8 @@ import platform.Foundation.NSData
|
|
|
20
14
|
import platform.Foundation.dataWithContentsOfFile
|
|
21
15
|
import platform.posix.memcpy
|
|
22
16
|
|
|
23
|
-
// AI-GENERATED START: SF Pro -> iOS system font mapping (ITMS-91182)
|
|
24
|
-
/**
|
|
25
|
-
* Apple cấm app nhúng font của Apple (ITMS-91182) và font hệ thống iOS chính là SF Pro, nên file SF Pro
|
|
26
|
-
* được thay bằng system font cùng weight thay vì đọc từ bundle — host không cần (và không được) ship nó.
|
|
27
|
-
*
|
|
28
|
-
* Weight đi theo tên face của Apple (Ultralight nhẹ hơn Thin), khớp thang weight CoreText mà Skia dùng
|
|
29
|
-
* (100 = UltraLight, 200 = Thin), để ra đúng face mà tên file chỉ định.
|
|
30
|
-
* Phải mang weight trong Font vì `Text` bỏ `fontWeight` khỏi style (weight nằm sẵn trong font).
|
|
31
|
-
*/
|
|
32
|
-
private val systemFontWeights: Map<String, FontWeight> = mapOf(
|
|
33
|
-
"SFProText-Ultralight.ttf" to FontWeight.Thin,
|
|
34
|
-
"SFProText-Thin.ttf" to FontWeight.ExtraLight,
|
|
35
|
-
"SFProText-Light.ttf" to FontWeight.Light,
|
|
36
|
-
"SFProText-Regular.ttf" to FontWeight.Normal,
|
|
37
|
-
"SFProText-Medium.ttf" to FontWeight.Medium,
|
|
38
|
-
"SFProText-Semibold.ttf" to FontWeight.SemiBold,
|
|
39
|
-
"SFProText-Bold.ttf" to FontWeight.Bold,
|
|
40
|
-
"SFProText-Heavy.ttf" to FontWeight.ExtraBold,
|
|
41
|
-
"SFProText-Black.ttf" to FontWeight.Black,
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
/** Family của system font (`.AppleSystemUIFont`), lấy qua API chính thức thay vì hard-code tên ẩn. */
|
|
45
|
-
private val systemFontFamilyName: String by lazy { UIFont.systemFontOfSize(14.0).familyName }
|
|
46
|
-
|
|
47
|
-
@OptIn(ExperimentalTextApi::class)
|
|
48
|
-
private fun systemFontFamily(weight: FontWeight): FontFamily =
|
|
49
|
-
FontFamily(SystemFont(identity = systemFontFamilyName, weight = weight))
|
|
50
|
-
// AI-GENERATED END: SF Pro -> iOS system font mapping (ITMS-91182)
|
|
51
|
-
|
|
52
17
|
@Composable
|
|
53
18
|
internal actual fun hostFontFamily(fileName: String): FontFamily? = remember(fileName) {
|
|
54
|
-
// AI-GENERATED START: SF Pro -> iOS system font mapping (ITMS-91182)
|
|
55
|
-
systemFontWeights[fileName]?.let { weight -> return@remember systemFontFamily(weight) }
|
|
56
|
-
// AI-GENERATED END: SF Pro -> iOS system font mapping (ITMS-91182)
|
|
57
19
|
val name = fileName.substringBeforeLast('.')
|
|
58
20
|
val ext = fileName.substringAfterLast('.', "")
|
|
59
21
|
// Font từ font-source nằm rời ở bundle root, không nằm trong compose-resources.
|
package/gradle.properties
CHANGED