├── .gitattributes
├── composeApp
├── proguard-rules-android.pro
├── proguard-rules-jvm.pro
├── src
│ ├── desktopMain
│ │ ├── resources
│ │ │ ├── linux
│ │ │ │ └── Icon.png
│ │ │ ├── macos
│ │ │ │ └── Icon.icns
│ │ │ └── windows
│ │ │ │ └── Icon.ico
│ │ └── kotlin
│ │ │ ├── theme
│ │ │ ├── MacOSThemeManager.kt
│ │ │ ├── WindowsThemeManager.kt
│ │ │ └── LinuxThemeManager.kt
│ │ │ └── Main.kt
│ ├── androidMain
│ │ ├── res
│ │ │ ├── values-zh-rCN
│ │ │ │ └── strings.xml
│ │ │ ├── values-zh-rTW
│ │ │ │ └── strings.xml
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── themes.xml
│ │ │ │ └── colors.xml
│ │ │ ├── values-night
│ │ │ │ └── themes.xml
│ │ │ └── drawable
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_foreground.xml
│ │ ├── kotlin
│ │ │ └── top
│ │ │ │ └── yukonga
│ │ │ │ └── fontWeightTest
│ │ │ │ └── MainActivity.kt
│ │ └── AndroidManifest.xml
│ ├── macosMain
│ │ ├── resources
│ │ │ └── FontWeightTest.icns
│ │ └── kotlin
│ │ │ └── Main.kt
│ ├── iosMain
│ │ └── kotlin
│ │ │ └── Main.kt
│ └── commonMain
│ │ ├── composeResources
│ │ ├── font
│ │ │ ├── misans_black.ttf
│ │ │ ├── misans_bold.ttf
│ │ │ ├── misans_light.ttf
│ │ │ ├── misans_medium.ttf
│ │ │ ├── misans_normal.ttf
│ │ │ ├── misans_thin.ttf
│ │ │ ├── misans_semibold.ttf
│ │ │ ├── misans_extrabold.ttf
│ │ │ └── misans_extralight.ttf
│ │ ├── drawable
│ │ │ ├── tune.xml
│ │ │ ├── sans_serif.xml
│ │ │ ├── serif.xml
│ │ │ ├── monospace.xml
│ │ │ ├── home.xml
│ │ │ └── icon.xml
│ │ ├── values-zh-rCN
│ │ │ └── strings.xml
│ │ ├── values-zh-rTW
│ │ │ └── strings.xml
│ │ └── values
│ │ │ └── strings.xml
│ │ └── kotlin
│ │ └── top
│ │ └── yukonga
│ │ └── fontWeightTest
│ │ ├── ui
│ │ ├── theme
│ │ │ └── Theme.kt
│ │ ├── components
│ │ │ ├── CardView.kt
│ │ │ ├── WeightedText.kt
│ │ │ └── OtherTestView.kt
│ │ ├── SansSerifView.kt
│ │ ├── SerifView.kt
│ │ ├── MonospaceView.kt
│ │ ├── AboutDialog.kt
│ │ └── HomeView.kt
│ │ ├── utils
│ │ └── AppUtils.kt
│ │ └── App.kt
└── build.gradle.kts
├── Picture
└── Screenshot.jpg
├── iosApp
├── Configuration
│ └── Config.xcconfig
├── iosApp
│ ├── Assets.xcassets
│ │ ├── Contents.json
│ │ └── AppIcon.appiconset
│ │ │ ├── app-icon-1024.png
│ │ │ └── Contents.json
│ ├── iosApp.swift
│ ├── ContentView.swift
│ └── Info.plist
└── iosApp.xcodeproj
│ ├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
│ ├── xcshareddata
│ └── xcschemes
│ │ └── iosApp.xcscheme
│ └── project.pbxproj
├── gradle
├── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
└── libs.versions.toml
├── README.md
├── gradle.properties
├── settings.gradle.kts
├── gradlew.bat
├── .github
└── workflows
│ └── Action CI.yml
├── gradlew
├── .gitignore
└── LICENSE
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/composeApp/proguard-rules-android.pro:
--------------------------------------------------------------------------------
1 | -dontwarn org.slf4j.**
2 | -dontwarn kotlinx.datetime.**
--------------------------------------------------------------------------------
/Picture/Screenshot.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YuKongA/Font-Weight-Test_Compose/HEAD/Picture/Screenshot.jpg
--------------------------------------------------------------------------------
/iosApp/Configuration/Config.xcconfig:
--------------------------------------------------------------------------------
1 | TEAM_ID=
2 | BUNDLE_ID=top.yukonga.fontWeightTest
3 | APP_NAME=FontWeightTest
4 |
--------------------------------------------------------------------------------
/iosApp/iosApp/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YuKongA/Font-Weight-Test_Compose/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/composeApp/proguard-rules-jvm.pro:
--------------------------------------------------------------------------------
1 | -dontwarn org.slf4j.**
2 |
3 | -keep class com.sun.jna.** { *; }
4 | -keep class * implements com.sun.jna.** { *; }
--------------------------------------------------------------------------------
/composeApp/src/desktopMain/resources/linux/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YuKongA/Font-Weight-Test_Compose/HEAD/composeApp/src/desktopMain/resources/linux/Icon.png
--------------------------------------------------------------------------------
/composeApp/src/desktopMain/resources/macos/Icon.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YuKongA/Font-Weight-Test_Compose/HEAD/composeApp/src/desktopMain/resources/macos/Icon.icns
--------------------------------------------------------------------------------
/composeApp/src/androidMain/res/values-zh-rCN/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 字体字重测试
4 |
--------------------------------------------------------------------------------
/composeApp/src/androidMain/res/values-zh-rTW/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 字體字重測試
4 |
--------------------------------------------------------------------------------
/composeApp/src/desktopMain/resources/windows/Icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YuKongA/Font-Weight-Test_Compose/HEAD/composeApp/src/desktopMain/resources/windows/Icon.ico
--------------------------------------------------------------------------------
/composeApp/src/macosMain/resources/FontWeightTest.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YuKongA/Font-Weight-Test_Compose/HEAD/composeApp/src/macosMain/resources/FontWeightTest.icns
--------------------------------------------------------------------------------
/composeApp/src/androidMain/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | FontWeightTest
4 |
5 |
--------------------------------------------------------------------------------
/iosApp/iosApp/iosApp.swift:
--------------------------------------------------------------------------------
1 | import SwiftUI
2 |
3 | @main
4 | struct iosApp: App {
5 | var body: some Scene {
6 | WindowGroup {
7 | ContentView()
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/composeApp/src/iosMain/kotlin/Main.kt:
--------------------------------------------------------------------------------
1 | import androidx.compose.ui.window.ComposeUIViewController
2 | import top.yukonga.fontWeightTest.App
3 |
4 | fun main() = ComposeUIViewController { App() }
--------------------------------------------------------------------------------
/composeApp/src/commonMain/composeResources/font/misans_black.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YuKongA/Font-Weight-Test_Compose/HEAD/composeApp/src/commonMain/composeResources/font/misans_black.ttf
--------------------------------------------------------------------------------
/composeApp/src/commonMain/composeResources/font/misans_bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YuKongA/Font-Weight-Test_Compose/HEAD/composeApp/src/commonMain/composeResources/font/misans_bold.ttf
--------------------------------------------------------------------------------
/composeApp/src/commonMain/composeResources/font/misans_light.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YuKongA/Font-Weight-Test_Compose/HEAD/composeApp/src/commonMain/composeResources/font/misans_light.ttf
--------------------------------------------------------------------------------
/composeApp/src/commonMain/composeResources/font/misans_medium.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YuKongA/Font-Weight-Test_Compose/HEAD/composeApp/src/commonMain/composeResources/font/misans_medium.ttf
--------------------------------------------------------------------------------
/composeApp/src/commonMain/composeResources/font/misans_normal.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YuKongA/Font-Weight-Test_Compose/HEAD/composeApp/src/commonMain/composeResources/font/misans_normal.ttf
--------------------------------------------------------------------------------
/composeApp/src/commonMain/composeResources/font/misans_thin.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YuKongA/Font-Weight-Test_Compose/HEAD/composeApp/src/commonMain/composeResources/font/misans_thin.ttf
--------------------------------------------------------------------------------
/composeApp/src/commonMain/composeResources/font/misans_semibold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YuKongA/Font-Weight-Test_Compose/HEAD/composeApp/src/commonMain/composeResources/font/misans_semibold.ttf
--------------------------------------------------------------------------------
/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/app-icon-1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YuKongA/Font-Weight-Test_Compose/HEAD/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/app-icon-1024.png
--------------------------------------------------------------------------------
/composeApp/src/commonMain/composeResources/font/misans_extrabold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YuKongA/Font-Weight-Test_Compose/HEAD/composeApp/src/commonMain/composeResources/font/misans_extrabold.ttf
--------------------------------------------------------------------------------
/composeApp/src/commonMain/composeResources/font/misans_extralight.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YuKongA/Font-Weight-Test_Compose/HEAD/composeApp/src/commonMain/composeResources/font/misans_extralight.ttf
--------------------------------------------------------------------------------
/composeApp/src/androidMain/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/composeApp/src/androidMain/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/iosApp/iosApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/composeApp/src/androidMain/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFFFFFFF
4 | #FF3482FF
5 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/iosApp/iosApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "filename" : "app-icon-1024.png",
5 | "idiom" : "universal",
6 | "platform" : "ios",
7 | "size" : "1024x1024"
8 | }
9 | ],
10 | "info" : {
11 | "author" : "xcode",
12 | "version" : 1
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/composeApp/src/androidMain/res/drawable/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Font Weight Test
2 |
3 | Font Weight Test is an application that testing font weights, uses [Jetpack Compose](https://developer.android.com/develop/ui/compose) toolkit.
4 |
5 | ### Screenshot:
6 |
7 |
8 |

9 |
10 |
--------------------------------------------------------------------------------
/composeApp/src/commonMain/composeResources/drawable/tune.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/composeApp/src/commonMain/composeResources/drawable/sans_serif.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/composeApp/src/commonMain/composeResources/drawable/serif.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/composeApp/src/commonMain/kotlin/top/yukonga/fontWeightTest/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package top.yukonga.fontWeightTest.ui.theme
2 |
3 | import androidx.compose.runtime.Composable
4 | import top.yukonga.miuix.kmp.theme.MiuixTheme
5 | import top.yukonga.miuix.kmp.theme.darkColorScheme
6 | import top.yukonga.miuix.kmp.theme.lightColorScheme
7 |
8 | @Composable
9 | fun AppTheme(
10 | isDarkTheme: Boolean,
11 | content: @Composable () -> Unit
12 | ) {
13 | MiuixTheme(
14 | colors = if (isDarkTheme) darkColorScheme() else lightColorScheme()
15 | ) {
16 | content()
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/iosApp/iosApp/ContentView.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import SwiftUI
3 | import shared
4 |
5 | struct ComposeView: UIViewControllerRepresentable {
6 | func makeUIViewController(context: Context) -> UIViewController {
7 | MainKt.main()
8 | }
9 |
10 | func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
11 | }
12 |
13 | struct ContentView: View {
14 | var body: some View {
15 | ComposeView()
16 | .ignoresSafeArea(.keyboard) // Compose has own keyboard handler
17 | .edgesIgnoringSafeArea(.all) // edge to edge
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/composeApp/src/commonMain/composeResources/drawable/monospace.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/composeApp/src/commonMain/composeResources/drawable/home.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/composeApp/src/commonMain/composeResources/drawable/icon.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/composeApp/src/androidMain/kotlin/top/yukonga/fontWeightTest/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package top.yukonga.fontWeightTest
2 |
3 | import android.annotation.SuppressLint
4 | import android.os.Build
5 | import android.os.Bundle
6 | import androidx.activity.ComponentActivity
7 | import androidx.activity.compose.setContent
8 | import androidx.activity.enableEdgeToEdge
9 |
10 | class MainActivity : ComponentActivity() {
11 | @SuppressLint("SourceLockedOrientationActivity")
12 | override fun onCreate(savedInstanceState: Bundle?) {
13 | super.onCreate(savedInstanceState)
14 |
15 | enableEdgeToEdge()
16 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
17 | window.isNavigationBarContrastEnforced = false
18 | }
19 | setContent {
20 | App()
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/composeApp/src/commonMain/kotlin/top/yukonga/fontWeightTest/ui/components/CardView.kt:
--------------------------------------------------------------------------------
1 | package top.yukonga.fontWeightTest.ui.components
2 |
3 | import androidx.compose.foundation.layout.Column
4 | import androidx.compose.foundation.layout.fillMaxWidth
5 | import androidx.compose.foundation.layout.padding
6 | import androidx.compose.runtime.Composable
7 | import androidx.compose.ui.Modifier
8 | import androidx.compose.ui.unit.dp
9 | import top.yukonga.miuix.kmp.basic.Card
10 |
11 | @Composable
12 | fun CardView(view: @Composable () -> Unit) {
13 | Card(
14 | modifier = Modifier
15 | .fillMaxWidth()
16 | .padding(horizontal = 12.dp)
17 | ) {
18 | Column(
19 | modifier = Modifier.padding(16.dp)
20 | ) {
21 | view()
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Gradle
2 | org.gradle.jvmargs=-Xmx8g -Dfile.encoding=UTF-8
3 | org.gradle.parallel=true
4 | org.gradle.caching=true
5 | org.gradle.configureondemand=true
6 | # Android
7 | android.useAndroidX=true
8 | android.nonTransitiveRClass=true
9 | # Kotlin
10 | kotlin.code.style=official
11 | # MPP
12 | kotlin.mpp.androidSourceSetLayoutVersion=2
13 | kotlin.mpp.enableCInteropCommonization=true
14 | # Native
15 | kotlin.native.binary.smallBinary=true
16 | kotlin.native.ignoreDisabledTargets=true
17 | # Incremental compilation
18 | kotlin.incremental=true
19 | kotlin.incremental.multiplatform=true
20 | kotlin.incremental.jvm.fir=true
21 | kotlin.incremental.native=true
22 | # Experimental target
23 | org.jetbrains.compose.experimental.macos.enabled=true
24 | # Xcode
25 | kotlin.apple.xcodeCompatibility.nowarn=true
26 | xcodeproj=./iosApp
--------------------------------------------------------------------------------
/composeApp/src/commonMain/composeResources/values-zh-rCN/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 字体字重测试
4 | 查看源码:
5 | 加入群组:
6 | 版权所有 © 2024 YuKongA
7 | 首页
8 | 无衬线
9 | 衬线
10 | 等宽
11 | 字重对比显示
12 | 可变字体测试
13 | 文本
14 | 清除
15 | 设备字体
16 | 倾斜字体
17 | 更多示例
18 | 字重
19 | 字号
20 | 关于
21 |
--------------------------------------------------------------------------------
/composeApp/src/commonMain/composeResources/values-zh-rTW/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 字體字重測試
4 | 查看原始碼:
5 | 加入群組:
6 | 版權所有 © 2024 YuKongA
7 | 首頁
8 | 無襯線
9 | 襯線
10 | 等寬
11 | 字重對比顯示
12 | 可變字體測試
13 | 文本
14 | 清除
15 | 設備字體
16 | 傾斜字體
17 | 更多範例
18 | 字重
19 | 字號
20 | 關於
21 |
--------------------------------------------------------------------------------
/composeApp/src/desktopMain/kotlin/theme/MacOSThemeManager.kt:
--------------------------------------------------------------------------------
1 | package theme
2 |
3 | import kotlinx.coroutines.currentCoroutineContext
4 | import kotlinx.coroutines.isActive
5 |
6 | object MacOSThemeManager {
7 | fun isMacOSDarkTheme(): Boolean {
8 | return try {
9 | val process = ProcessBuilder("defaults", "read", "-g", "AppleInterfaceStyle").start()
10 | val result = process.inputStream.bufferedReader().readText().trim()
11 | process.waitFor()
12 | result.equals("Dark", ignoreCase = true)
13 | } catch (_: Exception) {
14 | false
15 | }
16 | }
17 |
18 | suspend fun listenMacOSThemeChanges(onThemeChanged: (Boolean) -> Unit) {
19 | try {
20 | while (currentCoroutineContext().isActive) {
21 | val currentSystemThemeIsDark = isMacOSDarkTheme()
22 | onThemeChanged(currentSystemThemeIsDark)
23 | }
24 | } catch (_: Exception) {
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/composeApp/src/androidMain/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
15 |
16 |
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | android-gradle-plugin = "8.13.2"
3 | androidx-activity-compose = "1.12.1"
4 | compose-plugin = "1.9.3"
5 | haze = "1.7.1"
6 | jna = "5.18.1"
7 | kotlin = "2.2.21"
8 | miuix = "0.7.1"
9 |
10 | [libraries]
11 | androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "androidx-activity-compose" }
12 | haze = { module = "dev.chrisbanes.haze:haze", version.ref = "haze" }
13 | jna = { module = "net.java.dev.jna:jna", version.ref = "jna" }
14 | jna-platform = { module = "net.java.dev.jna:jna-platform", version.ref = "jna" }
15 | miuix = { module = "top.yukonga.miuix.kmp:miuix", version.ref = "miuix" }
16 |
17 | [plugins]
18 | android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" }
19 | jetbrains-compose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
20 | compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
21 | kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
22 |
--------------------------------------------------------------------------------
/composeApp/src/commonMain/composeResources/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | FontWeightTest
4 | View Source:
5 | Join Group:
6 | Copyright © 2024 YuKongA
7 | Home
8 | Sans Serif
9 | Serif
10 | Monospace
11 | Font weight display
12 | Variable font test
13 | Custom text
14 | Clear
15 | Device font
16 | Italic font
17 | More Examples
18 | Font Weight
19 | Font Size
20 | About
21 |
22 |
--------------------------------------------------------------------------------
/composeApp/src/androidMain/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
13 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | @file:Suppress("UnstableApiUsage")
2 |
3 | pluginManagement {
4 | repositories {
5 | google {
6 | mavenContent {
7 | includeGroupAndSubgroups("androidx")
8 | includeGroupAndSubgroups("com.android")
9 | includeGroupAndSubgroups("com.google")
10 | }
11 | }
12 | mavenCentral()
13 | gradlePluginPortal()
14 | }
15 | }
16 |
17 | dependencyResolutionManagement {
18 | repositories {
19 | google {
20 | mavenContent {
21 | includeGroupAndSubgroups("androidx")
22 | includeGroupAndSubgroups("com.android")
23 | includeGroupAndSubgroups("com.google")
24 | }
25 | }
26 | mavenCentral()
27 | }
28 | }
29 |
30 | plugins {
31 | id("com.android.settings") version ("8.13.2")
32 | id("org.gradle.toolchains.foojay-resolver-convention") version ("1.0.0")
33 | }
34 |
35 | android {
36 | compileSdk = 36
37 | targetSdk = 36
38 | minSdk = 26
39 | buildToolsVersion = "36.1.0"
40 | }
41 |
42 | rootProject.name = "FontWeightTest"
43 | include(":composeApp")
--------------------------------------------------------------------------------
/composeApp/src/macosMain/kotlin/Main.kt:
--------------------------------------------------------------------------------
1 | import androidx.compose.ui.unit.DpSize
2 | import androidx.compose.ui.unit.dp
3 | import androidx.compose.ui.window.Window
4 | import fontweighttest.composeapp.generated.resources.Res
5 | import fontweighttest.composeapp.generated.resources.app_name
6 | import kotlinx.cinterop.ExperimentalForeignApi
7 | import org.jetbrains.compose.resources.stringResource
8 | import platform.AppKit.NSApplication
9 | import platform.AppKit.NSApplicationActivationPolicy
10 | import platform.AppKit.NSApplicationDelegateProtocol
11 | import platform.CoreGraphics.CGSizeMake
12 | import platform.darwin.NSObject
13 | import top.yukonga.fontWeightTest.App
14 |
15 | @OptIn(ExperimentalForeignApi::class)
16 | fun main() {
17 | val nsApplication = NSApplication.sharedApplication()
18 | nsApplication.setActivationPolicy(NSApplicationActivationPolicy.NSApplicationActivationPolicyRegular)
19 | nsApplication.delegate =
20 | object : NSObject(), NSApplicationDelegateProtocol {
21 | override fun applicationShouldTerminateAfterLastWindowClosed(sender: NSApplication): Boolean = true
22 | }
23 | Window(
24 | size = DpSize(420.dp, 840.dp),
25 | ) {
26 | window.title = stringResource(Res.string.app_name)
27 | window.minSize = CGSizeMake(300.0, 600.0)
28 | App()
29 | }
30 | nsApplication.run()
31 | }
--------------------------------------------------------------------------------
/composeApp/src/commonMain/kotlin/top/yukonga/fontWeightTest/ui/components/WeightedText.kt:
--------------------------------------------------------------------------------
1 | package top.yukonga.fontWeightTest.ui.components
2 |
3 | import androidx.compose.runtime.Composable
4 | import androidx.compose.ui.text.font.FontFamily
5 | import androidx.compose.ui.text.font.FontStyle
6 | import androidx.compose.ui.unit.sp
7 | import top.yukonga.fontWeightTest.utils.fontWeightsList
8 | import top.yukonga.miuix.kmp.basic.Text
9 |
10 | @Composable
11 | fun WeightTextView(
12 | fontStyle: FontStyle = FontStyle.Normal,
13 | fontFamily: FontFamily = FontFamily.Default
14 | ) {
15 | val text = "伤仲永 にほんご 한국어 AaBbCc 123"
16 | val labels = fontWeightsList.mapIndexed { index, _ ->
17 | "${(index + 1) * 100} - $text"
18 | }
19 |
20 | fontWeightsList.forEachIndexed { index, fontWeight ->
21 | WeightTextItem(
22 | text = labels[index],
23 | fontWeight = fontWeight,
24 | fontFamily = fontFamily,
25 | fontStyle = fontStyle
26 | )
27 | }
28 | }
29 |
30 | @Composable
31 | private fun WeightTextItem(
32 | text: String,
33 | fontWeight: androidx.compose.ui.text.font.FontWeight,
34 | fontFamily: FontFamily,
35 | fontStyle: FontStyle
36 | ) {
37 | Text(
38 | text = text,
39 | fontWeight = fontWeight,
40 | fontFamily = fontFamily,
41 | fontStyle = fontStyle,
42 | fontSize = 15.4.sp,
43 | maxLines = 1
44 | )
45 | }
46 |
--------------------------------------------------------------------------------
/iosApp/iosApp/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE)
17 | CFBundleShortVersionString
18 | 1.6.3
19 | CFBundleVersion
20 | 155
21 | LSRequiresIPhoneOS
22 |
23 | CADisableMinimumFrameDurationOnPhone
24 |
25 | UIApplicationSceneManifest
26 |
27 | UIApplicationSupportsMultipleScenes
28 |
29 |
30 | UILaunchScreen
31 |
32 | UIRequiredDeviceCapabilities
33 |
34 | arm64
35 |
36 | UISupportedInterfaceOrientations
37 |
38 | UIInterfaceOrientationPortrait
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UISupportedInterfaceOrientations~ipad
43 |
44 | UIInterfaceOrientationPortrait
45 | UIInterfaceOrientationPortraitUpsideDown
46 | UIInterfaceOrientationLandscapeLeft
47 | UIInterfaceOrientationLandscapeRight
48 |
49 |
50 |
--------------------------------------------------------------------------------
/composeApp/src/commonMain/kotlin/top/yukonga/fontWeightTest/ui/components/OtherTestView.kt:
--------------------------------------------------------------------------------
1 | package top.yukonga.fontWeightTest.ui.components
2 |
3 | import androidx.compose.foundation.layout.Column
4 | import androidx.compose.foundation.layout.Spacer
5 | import androidx.compose.foundation.layout.fillMaxWidth
6 | import androidx.compose.foundation.layout.height
7 | import androidx.compose.runtime.Composable
8 | import androidx.compose.ui.Alignment
9 | import androidx.compose.ui.Modifier
10 | import androidx.compose.ui.text.font.FontFamily
11 | import androidx.compose.ui.text.font.FontStyle
12 | import androidx.compose.ui.text.style.TextAlign
13 | import androidx.compose.ui.unit.dp
14 | import androidx.compose.ui.unit.sp
15 | import top.yukonga.fontWeightTest.utils.fontWeightsList
16 | import top.yukonga.miuix.kmp.basic.Text
17 |
18 | @Composable
19 | fun OtherTestView(fontFamily: FontFamily? = null) {
20 | val testText = "不以物喜,不以己悲。——范仲淹《岳阳楼记》\n" +
21 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n" +
22 | "abcdefghijklmnopqrstuvwxyz\n" +
23 | "0123456789,."
24 |
25 | Column(
26 | modifier = Modifier.fillMaxWidth(),
27 | horizontalAlignment = Alignment.CenterHorizontally
28 | ) {
29 | fontWeightsList.forEachIndexed { index, fontWeight ->
30 | OtherTestTextItem(
31 | index = index,
32 | text = testText,
33 | fontWeight = fontWeight,
34 | fontFamily = fontFamily
35 | )
36 | if (index < fontWeightsList.size - 1) {
37 | Spacer(modifier = Modifier.height(8.dp))
38 | }
39 | }
40 | }
41 | }
42 |
43 | @Composable
44 | private fun OtherTestTextItem(
45 | index: Int,
46 | text: String,
47 | fontWeight: androidx.compose.ui.text.font.FontWeight,
48 | fontFamily: FontFamily?
49 | ) {
50 | val label = "- ${(index + 1) * 100} -"
51 |
52 | Column(
53 | modifier = Modifier.fillMaxWidth(),
54 | horizontalAlignment = Alignment.CenterHorizontally
55 | ) {
56 | Text(
57 | text = label,
58 | fontWeight = fontWeight,
59 | fontFamily = fontFamily,
60 | textAlign = TextAlign.Center,
61 | fontSize = 16.sp
62 | )
63 | Text(
64 | text = text,
65 | fontWeight = fontWeight,
66 | fontFamily = fontFamily,
67 | textAlign = TextAlign.Center,
68 | fontSize = 16.sp
69 | )
70 | Text(
71 | text = text,
72 | fontWeight = fontWeight,
73 | fontFamily = fontFamily,
74 | fontStyle = FontStyle.Italic,
75 | textAlign = TextAlign.Center,
76 | fontSize = 16.sp
77 | )
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/composeApp/src/commonMain/kotlin/top/yukonga/fontWeightTest/ui/SansSerifView.kt:
--------------------------------------------------------------------------------
1 | package top.yukonga.fontWeightTest.ui
2 |
3 | import androidx.compose.foundation.layout.PaddingValues
4 | import androidx.compose.foundation.layout.calculateEndPadding
5 | import androidx.compose.foundation.layout.calculateStartPadding
6 | import androidx.compose.foundation.layout.padding
7 | import androidx.compose.foundation.lazy.LazyColumn
8 | import androidx.compose.runtime.Composable
9 | import androidx.compose.ui.Modifier
10 | import androidx.compose.ui.input.nestedscroll.nestedScroll
11 | import androidx.compose.ui.platform.LocalLayoutDirection
12 | import androidx.compose.ui.text.font.FontStyle
13 | import androidx.compose.ui.unit.dp
14 | import fontweighttest.composeapp.generated.resources.Res
15 | import fontweighttest.composeapp.generated.resources.italic_font
16 | import fontweighttest.composeapp.generated.resources.more_examples
17 | import org.jetbrains.compose.resources.stringResource
18 | import top.yukonga.fontWeightTest.ui.components.CardView
19 | import top.yukonga.fontWeightTest.ui.components.OtherTestView
20 | import top.yukonga.fontWeightTest.ui.components.WeightTextView
21 | import top.yukonga.miuix.kmp.basic.ScrollBehavior
22 | import top.yukonga.miuix.kmp.basic.SmallTitle
23 | import top.yukonga.miuix.kmp.utils.overScrollVertical
24 | import top.yukonga.miuix.kmp.utils.scrollEndHaptic
25 |
26 | @Composable
27 | fun SansSerifView(
28 | topAppBarScrollBehavior: ScrollBehavior,
29 | padding: PaddingValues
30 | ) {
31 | val layoutDirection = LocalLayoutDirection.current
32 |
33 | LazyColumn(
34 | modifier = Modifier
35 | .scrollEndHaptic()
36 | .overScrollVertical()
37 | .nestedScroll(topAppBarScrollBehavior.nestedScrollConnection),
38 | contentPadding = PaddingValues(
39 | top = padding.calculateTopPadding() + 12.dp,
40 | start = padding.calculateStartPadding(layoutDirection),
41 | end = padding.calculateEndPadding(layoutDirection),
42 | bottom = padding.calculateBottomPadding() + 12.dp
43 | ),
44 | ) {
45 | item(key = "normal_font") {
46 | CardView {
47 | WeightTextView()
48 | }
49 | }
50 |
51 | item(key = "italic_title") {
52 | SmallTitle(
53 | modifier = Modifier.padding(top = 6.dp),
54 | text = stringResource(Res.string.italic_font),
55 | )
56 | }
57 |
58 | item(key = "italic_font") {
59 | CardView {
60 | WeightTextView(fontStyle = FontStyle.Italic)
61 | }
62 | }
63 |
64 | item(key = "examples_title") {
65 | SmallTitle(
66 | modifier = Modifier.padding(top = 6.dp),
67 | text = stringResource(Res.string.more_examples),
68 | )
69 | }
70 |
71 | item(key = "examples") {
72 | CardView {
73 | OtherTestView()
74 | }
75 | }
76 | }
77 | }
--------------------------------------------------------------------------------
/composeApp/src/commonMain/kotlin/top/yukonga/fontWeightTest/utils/AppUtils.kt:
--------------------------------------------------------------------------------
1 | package top.yukonga.fontWeightTest.utils
2 |
3 | import androidx.compose.runtime.Stable
4 | import androidx.compose.ui.text.font.FontWeight
5 | import fontweighttest.composeapp.generated.resources.Res
6 | import fontweighttest.composeapp.generated.resources.misans_black
7 | import fontweighttest.composeapp.generated.resources.misans_bold
8 | import fontweighttest.composeapp.generated.resources.misans_extrabold
9 | import fontweighttest.composeapp.generated.resources.misans_extralight
10 | import fontweighttest.composeapp.generated.resources.misans_light
11 | import fontweighttest.composeapp.generated.resources.misans_medium
12 | import fontweighttest.composeapp.generated.resources.misans_normal
13 | import fontweighttest.composeapp.generated.resources.misans_semibold
14 | import fontweighttest.composeapp.generated.resources.misans_thin
15 |
16 | @Stable
17 | data class FontDisplayState(
18 | val customText: String = "",
19 | val fontSizeValue: Int = 24,
20 | val fontWeightValue: Int = 400
21 | ) {
22 | val effectiveFontSize = fontSizeValue.coerceIn(6, 96)
23 | val effectiveFontWeight = getOptimizedFontWeight(fontWeightValue.coerceIn(1, 999))
24 | val displayText = customText.ifEmpty { "永 の A 6" }
25 | }
26 |
27 |
28 | @Stable
29 | fun getOptimizedFontWeight(value: Int): FontWeight {
30 | return commonFontWeights[value] ?: FontWeight(value.coerceIn(1, 1000))
31 | }
32 |
33 | @Stable
34 | val fontWeightsList = listOf(
35 | FontWeight.Thin, // W100
36 | FontWeight.ExtraLight, // W200
37 | FontWeight.Light, // W300
38 | FontWeight.Normal, // W400
39 | FontWeight.Medium, // W500
40 | FontWeight.SemiBold, // W600
41 | FontWeight.Bold, // W700
42 | FontWeight.ExtraBold, // W800
43 | FontWeight.Black // W900
44 | )
45 |
46 | @Stable
47 | val commonFontWeights = mapOf(
48 | 100 to FontWeight.Thin,
49 | 200 to FontWeight.ExtraLight,
50 | 300 to FontWeight.Light,
51 | 400 to FontWeight.Normal,
52 | 500 to FontWeight.Medium,
53 | 600 to FontWeight.SemiBold,
54 | 700 to FontWeight.Bold,
55 | 800 to FontWeight.ExtraBold,
56 | 900 to FontWeight.Black
57 | )
58 |
59 | @Stable
60 | val miSansList = listOf(
61 | Res.font.misans_thin, // W100
62 | Res.font.misans_extralight, // W200
63 | Res.font.misans_light, // W300
64 | Res.font.misans_normal, // W400
65 | Res.font.misans_medium, // W500
66 | Res.font.misans_semibold, // W600
67 | Res.font.misans_bold, // W700
68 | Res.font.misans_extrabold, // W800
69 | Res.font.misans_black // W900
70 | )
71 |
72 | @Stable
73 | val fontWeightDescriptions = listOf(
74 | "淡体 Thin (Hairline)", // W100
75 | "特细 ExtraLight (UltraLight)", // W200
76 | "细体 Light", // W300
77 | "标准 Normal (Regular)", // W400
78 | "适中 Medium", // W500
79 | "次粗 SemiBold (DemiBold)", // W600
80 | "粗体 Bold", // W700
81 | "特粗 ExtraBold (UltraBold)", // W800
82 | "浓体 Black (Heavy)" // W900
83 | )
84 |
85 | @Stable
86 | val testCharacters = listOf("永", "の", "A", "6")
87 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 | @rem SPDX-License-Identifier: Apache-2.0
17 | @rem
18 |
19 | @if "%DEBUG%"=="" @echo off
20 | @rem ##########################################################################
21 | @rem
22 | @rem Gradle startup script for Windows
23 | @rem
24 | @rem ##########################################################################
25 |
26 | @rem Set local scope for the variables with windows NT shell
27 | if "%OS%"=="Windows_NT" setlocal
28 |
29 | set DIRNAME=%~dp0
30 | if "%DIRNAME%"=="" set DIRNAME=.
31 | @rem This is normally unused
32 | set APP_BASE_NAME=%~n0
33 | set APP_HOME=%DIRNAME%
34 |
35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37 |
38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40 |
41 | @rem Find java.exe
42 | if defined JAVA_HOME goto findJavaFromJavaHome
43 |
44 | set JAVA_EXE=java.exe
45 | %JAVA_EXE% -version >NUL 2>&1
46 | if %ERRORLEVEL% equ 0 goto execute
47 |
48 | echo. 1>&2
49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50 | echo. 1>&2
51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52 | echo location of your Java installation. 1>&2
53 |
54 | goto fail
55 |
56 | :findJavaFromJavaHome
57 | set JAVA_HOME=%JAVA_HOME:"=%
58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59 |
60 | if exist "%JAVA_EXE%" goto execute
61 |
62 | echo. 1>&2
63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64 | echo. 1>&2
65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66 | echo location of your Java installation. 1>&2
67 |
68 | goto fail
69 |
70 | :execute
71 | @rem Setup the command line
72 |
73 | set CLASSPATH=
74 |
75 |
76 | @rem Execute Gradle
77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
78 |
79 | :end
80 | @rem End local scope for the variables with windows NT shell
81 | if %ERRORLEVEL% equ 0 goto mainEnd
82 |
83 | :fail
84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85 | rem the _cmd.exe /c_ return code!
86 | set EXIT_CODE=%ERRORLEVEL%
87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89 | exit /b %EXIT_CODE%
90 |
91 | :mainEnd
92 | if "%OS%"=="Windows_NT" endlocal
93 |
94 | :omega
95 |
--------------------------------------------------------------------------------
/composeApp/src/commonMain/kotlin/top/yukonga/fontWeightTest/ui/SerifView.kt:
--------------------------------------------------------------------------------
1 | package top.yukonga.fontWeightTest.ui
2 |
3 | import androidx.compose.foundation.layout.PaddingValues
4 | import androidx.compose.foundation.layout.calculateEndPadding
5 | import androidx.compose.foundation.layout.calculateStartPadding
6 | import androidx.compose.foundation.layout.padding
7 | import androidx.compose.foundation.lazy.LazyColumn
8 | import androidx.compose.runtime.Composable
9 | import androidx.compose.ui.Modifier
10 | import androidx.compose.ui.input.nestedscroll.nestedScroll
11 | import androidx.compose.ui.platform.LocalLayoutDirection
12 | import androidx.compose.ui.text.font.FontFamily
13 | import androidx.compose.ui.text.font.FontStyle
14 | import androidx.compose.ui.unit.dp
15 | import fontweighttest.composeapp.generated.resources.Res
16 | import fontweighttest.composeapp.generated.resources.italic_font
17 | import fontweighttest.composeapp.generated.resources.more_examples
18 | import org.jetbrains.compose.resources.stringResource
19 | import top.yukonga.fontWeightTest.ui.components.CardView
20 | import top.yukonga.fontWeightTest.ui.components.OtherTestView
21 | import top.yukonga.fontWeightTest.ui.components.WeightTextView
22 | import top.yukonga.miuix.kmp.basic.ScrollBehavior
23 | import top.yukonga.miuix.kmp.basic.SmallTitle
24 | import top.yukonga.miuix.kmp.utils.overScrollVertical
25 | import top.yukonga.miuix.kmp.utils.scrollEndHaptic
26 |
27 | @Composable
28 | fun SerifView(
29 | topAppBarScrollBehavior: ScrollBehavior,
30 | padding: PaddingValues
31 | ) {
32 | val layoutDirection = LocalLayoutDirection.current
33 |
34 | LazyColumn(
35 | modifier = Modifier
36 | .scrollEndHaptic()
37 | .overScrollVertical()
38 | .nestedScroll(topAppBarScrollBehavior.nestedScrollConnection),
39 | contentPadding = PaddingValues(
40 | top = padding.calculateTopPadding() + 12.dp,
41 | start = padding.calculateStartPadding(layoutDirection),
42 | end = padding.calculateEndPadding(layoutDirection),
43 | bottom = padding.calculateBottomPadding() + 12.dp
44 | ),
45 | ) {
46 | item(key = "normal_font") {
47 | CardView {
48 | WeightTextView(fontFamily = FontFamily.Serif)
49 | }
50 | }
51 |
52 | item(key = "italic_title") {
53 | SmallTitle(
54 | modifier = Modifier.padding(top = 6.dp),
55 | text = stringResource(Res.string.italic_font),
56 | )
57 | }
58 |
59 | item(key = "italic_font") {
60 | CardView {
61 | WeightTextView(
62 | fontStyle = FontStyle.Italic,
63 | fontFamily = FontFamily.Serif
64 | )
65 | }
66 | }
67 |
68 | item(key = "examples_title") {
69 | SmallTitle(
70 | modifier = Modifier.padding(top = 6.dp),
71 | text = stringResource(Res.string.more_examples),
72 | )
73 | }
74 |
75 | item(key = "examples") {
76 | CardView {
77 | OtherTestView(fontFamily = FontFamily.Serif)
78 | }
79 | }
80 | }
81 | }
--------------------------------------------------------------------------------
/composeApp/src/commonMain/kotlin/top/yukonga/fontWeightTest/ui/MonospaceView.kt:
--------------------------------------------------------------------------------
1 | package top.yukonga.fontWeightTest.ui
2 |
3 | import androidx.compose.foundation.layout.PaddingValues
4 | import androidx.compose.foundation.layout.calculateEndPadding
5 | import androidx.compose.foundation.layout.calculateStartPadding
6 | import androidx.compose.foundation.layout.padding
7 | import androidx.compose.foundation.lazy.LazyColumn
8 | import androidx.compose.runtime.Composable
9 | import androidx.compose.ui.Modifier
10 | import androidx.compose.ui.input.nestedscroll.nestedScroll
11 | import androidx.compose.ui.platform.LocalLayoutDirection
12 | import androidx.compose.ui.text.font.FontFamily
13 | import androidx.compose.ui.text.font.FontStyle
14 | import androidx.compose.ui.unit.dp
15 | import fontweighttest.composeapp.generated.resources.Res
16 | import fontweighttest.composeapp.generated.resources.italic_font
17 | import fontweighttest.composeapp.generated.resources.more_examples
18 | import org.jetbrains.compose.resources.stringResource
19 | import top.yukonga.fontWeightTest.ui.components.CardView
20 | import top.yukonga.fontWeightTest.ui.components.OtherTestView
21 | import top.yukonga.fontWeightTest.ui.components.WeightTextView
22 | import top.yukonga.miuix.kmp.basic.ScrollBehavior
23 | import top.yukonga.miuix.kmp.basic.SmallTitle
24 | import top.yukonga.miuix.kmp.utils.overScrollVertical
25 | import top.yukonga.miuix.kmp.utils.scrollEndHaptic
26 |
27 | @Composable
28 | fun MonospaceView(
29 | topAppBarScrollBehavior: ScrollBehavior,
30 | padding: PaddingValues
31 | ) {
32 | val layoutDirection = LocalLayoutDirection.current
33 |
34 | LazyColumn(
35 | modifier = Modifier
36 | .scrollEndHaptic()
37 | .overScrollVertical()
38 | .nestedScroll(topAppBarScrollBehavior.nestedScrollConnection),
39 | contentPadding = PaddingValues(
40 | top = padding.calculateTopPadding() + 12.dp,
41 | start = padding.calculateStartPadding(layoutDirection),
42 | end = padding.calculateEndPadding(layoutDirection),
43 | bottom = padding.calculateBottomPadding() + 12.dp
44 | ),
45 | ) {
46 | item(key = "normal_font") {
47 | CardView {
48 | WeightTextView(fontFamily = FontFamily.Monospace)
49 | }
50 | }
51 |
52 | item(key = "italic_title") {
53 | SmallTitle(
54 | modifier = Modifier.padding(top = 6.dp),
55 | text = stringResource(Res.string.italic_font),
56 | )
57 | }
58 |
59 | item(key = "italic_font") {
60 | CardView {
61 | WeightTextView(
62 | fontStyle = FontStyle.Italic,
63 | fontFamily = FontFamily.Monospace
64 | )
65 | }
66 | }
67 |
68 | item(key = "examples_title") {
69 | SmallTitle(
70 | modifier = Modifier.padding(top = 6.dp),
71 | text = stringResource(Res.string.more_examples),
72 | )
73 | }
74 |
75 | item(key = "examples") {
76 | CardView {
77 | OtherTestView(fontFamily = FontFamily.Monospace)
78 | }
79 | }
80 | }
81 | }
--------------------------------------------------------------------------------
/composeApp/src/desktopMain/kotlin/theme/WindowsThemeManager.kt:
--------------------------------------------------------------------------------
1 | package theme
2 |
3 | import com.sun.jna.Native
4 | import com.sun.jna.Pointer
5 | import com.sun.jna.platform.win32.Advapi32
6 | import com.sun.jna.platform.win32.Advapi32Util
7 | import com.sun.jna.platform.win32.WinDef
8 | import com.sun.jna.platform.win32.WinDef.HWND
9 | import com.sun.jna.platform.win32.WinError
10 | import com.sun.jna.platform.win32.WinNT
11 | import com.sun.jna.platform.win32.WinReg
12 | import com.sun.jna.win32.StdCallLibrary
13 | import kotlinx.coroutines.currentCoroutineContext
14 | import kotlinx.coroutines.isActive
15 |
16 | object WindowsThemeManager {
17 | private const val REGISTRY_KEY_PATH = "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"
18 | private const val REGISTRY_VALUE_NAME = "AppsUseLightTheme"
19 |
20 | private interface DwmApi : StdCallLibrary {
21 | fun DwmSetWindowAttribute(
22 | hwnd: HWND,
23 | dwAttribute: Int,
24 | pvAttribute: Pointer,
25 | cbAttribute: Int
26 | ): Int
27 |
28 | companion object {
29 | val INSTANCE: DwmApi by lazy {
30 | Native.load("dwmapi", DwmApi::class.java)
31 | }
32 | const val DWMWA_USE_IMMERSIVE_DARK_MODE = 20
33 | }
34 | }
35 |
36 | fun isWindowsDarkTheme(): Boolean {
37 | return try {
38 | val value = Advapi32Util.registryGetIntValue(
39 | WinReg.HKEY_CURRENT_USER,
40 | REGISTRY_KEY_PATH,
41 | REGISTRY_VALUE_NAME
42 | )
43 | value == 0
44 | } catch (_: Exception) {
45 | false
46 | }
47 | }
48 |
49 | fun setWindowsTitleBarTheme(window: java.awt.Window, isDark: Boolean) {
50 | try {
51 | val hwnd = HWND(Native.getComponentPointer(window))
52 | val darkModeValue = WinDef.BOOLByReference(WinDef.BOOL(isDark))
53 |
54 | DwmApi.INSTANCE.DwmSetWindowAttribute(
55 | hwnd,
56 | DwmApi.DWMWA_USE_IMMERSIVE_DARK_MODE,
57 | darkModeValue.pointer,
58 | 4,
59 | )
60 | } catch (_: Throwable) {
61 | }
62 | }
63 |
64 | suspend fun listenWindowsThemeChanges(onThemeChanged: (isDark: Boolean) -> Unit) {
65 | val advapi32 = Advapi32.INSTANCE
66 | val hKeyByRef = WinReg.HKEYByReference()
67 |
68 | val openResult = advapi32.RegOpenKeyEx(
69 | WinReg.HKEY_CURRENT_USER,
70 | REGISTRY_KEY_PATH,
71 | 0,
72 | WinNT.KEY_NOTIFY,
73 | hKeyByRef,
74 | )
75 |
76 | if (openResult != WinError.ERROR_SUCCESS) return
77 |
78 | val hKey = hKeyByRef.value
79 | try {
80 | while (currentCoroutineContext().isActive) {
81 | val notifyResult = advapi32.RegNotifyChangeKeyValue(
82 | hKey,
83 | false,
84 | WinNT.REG_NOTIFY_CHANGE_LAST_SET,
85 | null,
86 | false
87 | )
88 |
89 | if (!currentCoroutineContext().isActive) break
90 | if (notifyResult == WinError.ERROR_SUCCESS) {
91 | val currentSystemThemeIsDark = isWindowsDarkTheme()
92 | onThemeChanged(currentSystemThemeIsDark)
93 | } else {
94 | break
95 | }
96 | }
97 | } finally {
98 | advapi32.RegCloseKey(hKey)
99 | }
100 | }
101 | }
--------------------------------------------------------------------------------
/iosApp/iosApp.xcodeproj/xcshareddata/xcschemes/iosApp.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
9 |
10 |
16 |
22 |
23 |
24 |
25 |
26 |
32 |
33 |
50 |
52 |
58 |
59 |
60 |
61 |
65 |
66 |
67 |
68 |
74 |
76 |
82 |
83 |
84 |
85 |
87 |
88 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/composeApp/src/desktopMain/kotlin/Main.kt:
--------------------------------------------------------------------------------
1 | import androidx.compose.runtime.LaunchedEffect
2 | import androidx.compose.runtime.getValue
3 | import androidx.compose.runtime.mutableStateOf
4 | import androidx.compose.runtime.remember
5 | import androidx.compose.runtime.setValue
6 | import androidx.compose.ui.Alignment
7 | import androidx.compose.ui.unit.DpSize
8 | import androidx.compose.ui.unit.dp
9 | import androidx.compose.ui.window.Window
10 | import androidx.compose.ui.window.WindowPosition
11 | import androidx.compose.ui.window.application
12 | import androidx.compose.ui.window.rememberWindowState
13 | import com.sun.jna.Platform.isLinux
14 | import com.sun.jna.Platform.isMac
15 | import com.sun.jna.Platform.isWindows
16 | import fontweighttest.composeapp.generated.resources.Res
17 | import fontweighttest.composeapp.generated.resources.app_name
18 | import fontweighttest.composeapp.generated.resources.icon
19 | import kotlinx.coroutines.Dispatchers
20 | import kotlinx.coroutines.withContext
21 | import org.jetbrains.compose.resources.painterResource
22 | import org.jetbrains.compose.resources.stringResource
23 | import theme.LinuxThemeManager
24 | import theme.MacOSThemeManager
25 | import theme.WindowsThemeManager
26 | import top.yukonga.fontWeightTest.App
27 | import java.awt.Dimension
28 | import javax.swing.SwingUtilities
29 |
30 | fun main() = application {
31 | val state = rememberWindowState(
32 | size = DpSize(420.dp, 840.dp),
33 | position = WindowPosition.Aligned(Alignment.Center)
34 | )
35 | Window(
36 | state = state,
37 | onCloseRequest = ::exitApplication,
38 | title = stringResource(Res.string.app_name),
39 | icon = painterResource(Res.drawable.icon),
40 | ) {
41 | window.minimumSize = Dimension(300, 600)
42 | when {
43 | isWindows() -> {
44 | var isDarkTheme by remember { mutableStateOf(WindowsThemeManager.isWindowsDarkTheme()) }
45 | LaunchedEffect(Unit) {
46 | withContext(Dispatchers.IO) {
47 | WindowsThemeManager.listenWindowsThemeChanges { newSystemThemeIsDark ->
48 | if (isDarkTheme != newSystemThemeIsDark) isDarkTheme = newSystemThemeIsDark
49 | }
50 | }
51 | }
52 | LaunchedEffect(isDarkTheme, window) {
53 | SwingUtilities.invokeLater {
54 | WindowsThemeManager.setWindowsTitleBarTheme(window, isDarkTheme)
55 | }
56 | }
57 | App(isDarkTheme)
58 | }
59 |
60 | isMac() -> {
61 | var isDarkTheme by remember { mutableStateOf(MacOSThemeManager.isMacOSDarkTheme()) }
62 | LaunchedEffect(Unit) {
63 | withContext(Dispatchers.IO) {
64 | MacOSThemeManager.listenMacOSThemeChanges { newSystemThemeIsDark ->
65 | if (isDarkTheme != newSystemThemeIsDark) isDarkTheme = newSystemThemeIsDark
66 | }
67 | }
68 | }
69 | App(isDarkTheme)
70 | }
71 |
72 | isLinux() -> {
73 | var isDarkTheme by remember { mutableStateOf(LinuxThemeManager.isLinuxDarkTheme()) }
74 | LaunchedEffect(Unit) {
75 | withContext(Dispatchers.IO) {
76 | LinuxThemeManager.listenLinuxThemeChanges { newSystemThemeIsDark ->
77 | if (isDarkTheme != newSystemThemeIsDark) isDarkTheme = newSystemThemeIsDark
78 | }
79 | }
80 | }
81 | App(isDarkTheme)
82 | }
83 |
84 | else -> {
85 | App()
86 | }
87 | }
88 | }
89 | }
--------------------------------------------------------------------------------
/.github/workflows/Action CI.yml:
--------------------------------------------------------------------------------
1 | name: Action CI
2 |
3 | on:
4 | push:
5 | branches: [ main ]
6 | paths-ignore:
7 | - 'README.md'
8 | - 'LICENSE'
9 |
10 | permissions:
11 | contents: read
12 | actions: write
13 |
14 | jobs:
15 | build:
16 | runs-on: ${{ matrix.os }}
17 | strategy:
18 | matrix:
19 | os: [ ubuntu-latest, windows-latest ]
20 | include:
21 | - os: windows-latest
22 | platform: windows x64
23 | build-command: ./gradlew createReleaseDistributable
24 | artifact-path: composeApp/build/compose/binaries/main-release/app/FontWeightTest
25 | artifact-name: FontWeightTest-windows-x64-exe
26 | jdk-distribution: jetbrains
27 | - os: macos-latest
28 | platform: macos arm64
29 | build-command: ./gradlew packageDmgNativeReleaseMacosArm64
30 | artifact-path: composeApp/build/compose/binaries/main/native-macosArm64-release-dmg
31 | artifact-name: FontWeightTest-darwin-arm64-dmg
32 | jdk-distribution: zulu
33 | - os: ubuntu-latest
34 | platform: linux x64
35 | platformEx: android aarch64
36 | build-command: ./gradlew createReleaseDistributable
37 | build-commandEx: ./gradlew assembleDebug && ./gradlew assembleRelease
38 | artifact-path: composeApp/build/compose/binaries/main-release/app/FontWeightTest
39 | artifact-pathEx: composeApp/build/outputs/apk/release
40 | artifact-name: FontWeightTest-linux-x64-bin
41 | artifact-nameEx: FontWeightTest-android-aarch64-apk
42 | jdk-distribution: zulu
43 |
44 | steps:
45 | - name: Checkout sources
46 | uses: actions/checkout@v4
47 | with:
48 | fetch-depth: 0
49 |
50 | - name: Setup JDK
51 | uses: actions/setup-java@v4
52 | with:
53 | distribution: ${{ matrix.jdk-distribution }}
54 | java-version: '21'
55 |
56 | - name: Setup Gradle
57 | uses: gradle/actions/setup-gradle@v4
58 |
59 | - name: Decode android signing key
60 | if: matrix.platformEx == 'android aarch64'
61 | run: echo ${{ secrets.SIGNING_KEY }} | base64 -d > keystore.jks
62 |
63 | - name: Build ${{ matrix.platform }} platform
64 | run: ${{ matrix.build-command }}
65 |
66 | - name: Build ${{ matrix.platformEx }} platform
67 | if: matrix.platformEx == 'android aarch64'
68 | run: ${{ matrix.build-commandEx }}
69 | env:
70 | KEYSTORE_PATH: "../keystore.jks"
71 | KEYSTORE_PASS: ${{ secrets.KEY_STORE_PASSWORD }}
72 | KEY_ALIAS: ${{ secrets.ALIAS }}
73 | KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
74 |
75 | - name: Upload FontWeightTest ${{ matrix.platform }} artifact
76 | uses: actions/upload-artifact@v4
77 | with:
78 | name: ${{ matrix.artifact-name }}
79 | path: ${{ matrix.artifact-path }}
80 | compression-level: 9
81 |
82 | - name: Upload FontWeightTest ${{ matrix.platformEx }} artifact
83 | if: matrix.platformEx == 'android aarch64'
84 | uses: actions/upload-artifact@v4
85 | with:
86 | name: ${{ matrix.artifact-nameEx }}
87 | path: ${{ matrix.artifact-pathEx }}
88 | compression-level: 9
89 |
90 | - name: Post to Telegram ci channel
91 | if: ${{ success() && matrix.platformEx == 'android aarch64' && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.ref_type != 'tag' }}
92 | env:
93 | CHANNEL_ID: ${{ secrets.CHANNEL_ID }}
94 | BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
95 | COMMIT_MESSAGE: |+
96 | New CI from FontWeightTest
97 |
98 | ```
99 | ${{ github.event.head_commit.message }}
100 | ```
101 | run: |
102 | if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then
103 | export RELEASE=$(find ./composeApp/build/outputs/apk/release -name "*.apk")
104 | export DEBUG=$(find ./composeApp/build/outputs/apk/debug -name "*.apk")
105 | ESCAPED=`python3 -c 'import json,os,urllib.parse; print(urllib.parse.quote(json.dumps(os.environ["COMMIT_MESSAGE"])))'`
106 | curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${CHANNEL_ID}&media=%5B%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2Frelease%22%7D%2C%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2Fdebug%22%2C%22parse_mode%22%3A%22MarkdownV2%22%2C%22caption%22%3A${ESCAPED}%7D%5D" -F release="@$RELEASE" -F debug="@$DEBUG"
107 | fi
--------------------------------------------------------------------------------
/composeApp/src/desktopMain/kotlin/theme/LinuxThemeManager.kt:
--------------------------------------------------------------------------------
1 | package theme
2 |
3 | import kotlinx.coroutines.currentCoroutineContext
4 | import kotlinx.coroutines.delay
5 | import kotlinx.coroutines.isActive
6 | import java.io.BufferedReader
7 | import java.io.InputStreamReader
8 | import java.util.concurrent.ConcurrentHashMap
9 | import java.util.function.Consumer
10 |
11 | object LinuxThemeManager {
12 | private val darkThemeRegex = ".*dark.*".toRegex(RegexOption.IGNORE_CASE)
13 |
14 | private val GET_THEME_COMMANDS = arrayOf(
15 | "gsettings get org.gnome.desktop.interface gtk-theme",
16 | "gsettings get org.gnome.desktop.interface color-scheme"
17 | )
18 |
19 | private const val MONITORING_CMD = "gsettings monitor org.gnome.desktop.interface"
20 |
21 | @Volatile
22 | private var monitoringThread: Thread? = null
23 |
24 | private val listeners: MutableSet> = ConcurrentHashMap.newKeySet()
25 |
26 | fun isLinuxDarkTheme(): Boolean {
27 | return try {
28 | for (cmd in GET_THEME_COMMANDS) {
29 | val cmdParts = cmd.split(" ")
30 | val process = ProcessBuilder(*cmdParts.toTypedArray()).start()
31 | BufferedReader(InputStreamReader(process.inputStream)).use { reader ->
32 | val line = reader.readLine()
33 | if (line != null && isDarkTheme(line)) return true
34 | }
35 | }
36 | false
37 | } catch (_: Exception) {
38 | false
39 | }
40 | }
41 |
42 | suspend fun listenLinuxThemeChanges(onThemeChanged: (Boolean) -> Unit) {
43 | try {
44 | val listener = Consumer { isDark ->
45 | onThemeChanged(isDark)
46 | }
47 | registerListener(listener)
48 |
49 | while (currentCoroutineContext().isActive) {
50 | delay(1000)
51 | }
52 |
53 | removeListener(listener)
54 | } catch (_: Exception) {
55 | var lastValue = isLinuxDarkTheme()
56 | while (currentCoroutineContext().isActive) {
57 | val currentValue = isLinuxDarkTheme()
58 | if (currentValue != lastValue) {
59 | lastValue = currentValue
60 | onThemeChanged(currentValue)
61 | }
62 | delay(2000)
63 | }
64 | }
65 | }
66 |
67 | private fun isDarkTheme(text: String): Boolean {
68 | return darkThemeRegex.containsMatchIn(text)
69 | }
70 |
71 | private fun registerListener(listener: Consumer) {
72 | val wasEmpty = listeners.isEmpty()
73 | listeners.add(listener)
74 | if (wasEmpty) {
75 | startMonitoring()
76 | }
77 | }
78 |
79 | private fun removeListener(listener: Consumer) {
80 | listeners.remove(listener)
81 | if (listeners.isEmpty()) {
82 | monitoringThread?.interrupt()
83 | monitoringThread = null
84 | }
85 | }
86 |
87 | private fun startMonitoring() {
88 | if (monitoringThread?.isAlive == true) return
89 |
90 | monitoringThread = Thread {
91 | var lastValue = isLinuxDarkTheme()
92 |
93 | try {
94 | val cmdParts = MONITORING_CMD.split(" ")
95 | val process = ProcessBuilder(*cmdParts.toTypedArray()).start()
96 | BufferedReader(InputStreamReader(process.inputStream)).use { reader ->
97 | while (!Thread.currentThread().isInterrupted) {
98 | val line = reader.readLine() ?: break
99 |
100 | if (!line.contains("gtk-theme", ignoreCase = true) &&
101 | !line.contains("color-scheme", ignoreCase = true)
102 | ) {
103 | continue
104 | }
105 |
106 | val currentIsDark = isLinuxDarkTheme()
107 | if (currentIsDark != lastValue) {
108 | lastValue = currentIsDark
109 |
110 | listeners.forEach {
111 | try {
112 | it.accept(currentIsDark)
113 | } catch (_: Exception) {
114 | }
115 | }
116 | }
117 | }
118 |
119 | if (process.isAlive) {
120 | process.destroy()
121 | }
122 | }
123 | } catch (_: Exception) {
124 | while (!Thread.currentThread().isInterrupted) {
125 | try {
126 | val currentIsDark = isLinuxDarkTheme()
127 | if (currentIsDark != lastValue) {
128 | lastValue = currentIsDark
129 | listeners.forEach { it.accept(currentIsDark) }
130 | }
131 | Thread.sleep(2000)
132 | } catch (_: InterruptedException) {
133 | break
134 | } catch (_: Exception) {
135 | }
136 | }
137 | }
138 | }.apply {
139 | isDaemon = true
140 | start()
141 | }
142 | }
143 | }
--------------------------------------------------------------------------------
/composeApp/src/commonMain/kotlin/top/yukonga/fontWeightTest/ui/AboutDialog.kt:
--------------------------------------------------------------------------------
1 | package top.yukonga.fontWeightTest.ui
2 |
3 | import androidx.compose.foundation.Image
4 | import androidx.compose.foundation.background
5 | import androidx.compose.foundation.clickable
6 | import androidx.compose.foundation.layout.Arrangement
7 | import androidx.compose.foundation.layout.Box
8 | import androidx.compose.foundation.layout.Column
9 | import androidx.compose.foundation.layout.Row
10 | import androidx.compose.foundation.layout.Spacer
11 | import androidx.compose.foundation.layout.padding
12 | import androidx.compose.foundation.layout.size
13 | import androidx.compose.foundation.shape.RoundedCornerShape
14 | import androidx.compose.runtime.Composable
15 | import androidx.compose.runtime.mutableStateOf
16 | import androidx.compose.runtime.remember
17 | import androidx.compose.ui.Alignment
18 | import androidx.compose.ui.Modifier
19 | import androidx.compose.ui.draw.clip
20 | import androidx.compose.ui.graphics.ColorFilter
21 | import androidx.compose.ui.hapticfeedback.HapticFeedbackType
22 | import androidx.compose.ui.platform.LocalHapticFeedback
23 | import androidx.compose.ui.platform.LocalUriHandler
24 | import androidx.compose.ui.text.AnnotatedString
25 | import androidx.compose.ui.text.SpanStyle
26 | import androidx.compose.ui.text.font.FontWeight
27 | import androidx.compose.ui.text.style.TextDecoration
28 | import androidx.compose.ui.unit.dp
29 | import fontweighttest.composeapp.generated.resources.Res
30 | import fontweighttest.composeapp.generated.resources.about
31 | import fontweighttest.composeapp.generated.resources.app_name
32 | import fontweighttest.composeapp.generated.resources.icon
33 | import fontweighttest.composeapp.generated.resources.join_group
34 | import fontweighttest.composeapp.generated.resources.opensource_info
35 | import fontweighttest.composeapp.generated.resources.view_source
36 | import misc.VersionInfo
37 | import org.jetbrains.compose.resources.painterResource
38 | import org.jetbrains.compose.resources.stringResource
39 | import top.yukonga.miuix.kmp.basic.IconButton
40 | import top.yukonga.miuix.kmp.basic.Text
41 | import top.yukonga.miuix.kmp.extra.SuperDialog
42 | import top.yukonga.miuix.kmp.theme.MiuixTheme
43 |
44 | @Composable
45 | fun AboutDialog() {
46 | val showDialog = remember { mutableStateOf(false) }
47 | val hapticFeedback = LocalHapticFeedback.current
48 |
49 | IconButton(
50 | modifier = Modifier.padding(start = 18.dp),
51 | onClick = {
52 | showDialog.value = true
53 | hapticFeedback.performHapticFeedback(HapticFeedbackType.ContextClick)
54 | },
55 | holdDownState = showDialog.value
56 | ) {
57 | Image(
58 | modifier = Modifier.size(30.dp),
59 | painter = painterResource(Res.drawable.icon),
60 | contentDescription = null,
61 | colorFilter = ColorFilter.tint(MiuixTheme.colorScheme.onSurface)
62 | )
63 | }
64 |
65 | SuperDialog(
66 | show = showDialog,
67 | title = stringResource(Res.string.about),
68 | onDismissRequest = { showDialog.value = false },
69 | content = {
70 | AboutDialogContent(
71 | onLinkClick = {
72 | hapticFeedback.performHapticFeedback(HapticFeedbackType.ContextClick)
73 | }
74 | )
75 | }
76 | )
77 | }
78 |
79 | @Composable
80 | private fun AboutDialogContent(
81 | onLinkClick: (String) -> Unit
82 | ) {
83 | val versionInfo = remember {
84 | "${VersionInfo.VERSION_NAME} (${VersionInfo.VERSION_CODE})"
85 | }
86 |
87 | Column {
88 | AppInfoSection(versionInfo = versionInfo)
89 | LinksSection(onLinkClick = onLinkClick)
90 | OpenSourceSection()
91 | }
92 | }
93 |
94 | @Composable
95 | private fun AppInfoSection(versionInfo: String) {
96 | Row(
97 | horizontalArrangement = Arrangement.spacedBy(16.dp),
98 | verticalAlignment = Alignment.CenterVertically
99 | ) {
100 | AppIcon()
101 | AppDetails(versionInfo = versionInfo)
102 | }
103 | }
104 |
105 | @Composable
106 | private fun AppIcon() {
107 | Box(
108 | contentAlignment = Alignment.Center,
109 | modifier = Modifier
110 | .size(48.dp)
111 | .clip(RoundedCornerShape(12.dp))
112 | .background(MiuixTheme.colorScheme.primary)
113 | ) {
114 | Image(
115 | painter = painterResource(Res.drawable.icon),
116 | colorFilter = ColorFilter.tint(MiuixTheme.colorScheme.onPrimary),
117 | contentDescription = null,
118 | modifier = Modifier.size(30.dp),
119 | )
120 | }
121 | }
122 |
123 | @Composable
124 | private fun AppDetails(versionInfo: String) {
125 | Column {
126 | Text(
127 | text = stringResource(Res.string.app_name),
128 | fontWeight = FontWeight.SemiBold
129 | )
130 | Text(text = versionInfo)
131 | }
132 | }
133 |
134 | @Composable
135 | private fun LinksSection(onLinkClick: (String) -> Unit) {
136 | Column(
137 | modifier = Modifier.padding(top = 12.dp)
138 | ) {
139 | val uriHandler = LocalUriHandler.current
140 |
141 | LinkRow(
142 | prefixText = stringResource(Res.string.view_source),
143 | linkText = "GitHub",
144 | url = "https://github.com/YuKongA/Font-Weight-Test_Compose",
145 | onClick = { url ->
146 | uriHandler.openUri(url)
147 | onLinkClick(url)
148 | }
149 | )
150 |
151 | LinkRow(
152 | prefixText = stringResource(Res.string.join_group),
153 | linkText = "Telegram",
154 | url = "https://t.me/YuKongA13579",
155 | onClick = { url ->
156 | uriHandler.openUri(url)
157 | onLinkClick(url)
158 | }
159 | )
160 | }
161 | }
162 |
163 | @Composable
164 | private fun LinkRow(
165 | prefixText: String,
166 | linkText: String,
167 | url: String,
168 | onClick: (String) -> Unit
169 | ) {
170 | Row(verticalAlignment = Alignment.CenterVertically) {
171 | Text(text = "$prefixText ")
172 |
173 | val primaryColor = MiuixTheme.colorScheme.primary
174 | val annotatedLinkText = remember(linkText, primaryColor) {
175 | AnnotatedString(
176 | text = linkText,
177 | spanStyle = SpanStyle(
178 | textDecoration = TextDecoration.Underline,
179 | color = primaryColor
180 | )
181 | )
182 | }
183 |
184 | Text(
185 | text = annotatedLinkText,
186 | modifier = Modifier.clickable { onClick(url) }
187 | )
188 | }
189 | }
190 |
191 | @Composable
192 | private fun OpenSourceSection() {
193 | Column {
194 | Spacer(modifier = Modifier.padding(top = 12.dp))
195 | Text(text = stringResource(Res.string.opensource_info))
196 | }
197 | }
198 |
--------------------------------------------------------------------------------
/composeApp/src/commonMain/kotlin/top/yukonga/fontWeightTest/App.kt:
--------------------------------------------------------------------------------
1 | package top.yukonga.fontWeightTest
2 |
3 | import androidx.compose.foundation.isSystemInDarkTheme
4 | import androidx.compose.foundation.layout.BoxWithConstraints
5 | import androidx.compose.foundation.layout.PaddingValues
6 | import androidx.compose.foundation.layout.fillMaxSize
7 | import androidx.compose.foundation.pager.HorizontalPager
8 | import androidx.compose.foundation.pager.PagerState
9 | import androidx.compose.foundation.pager.rememberPagerState
10 | import androidx.compose.runtime.Composable
11 | import androidx.compose.runtime.CompositionLocalProvider
12 | import androidx.compose.runtime.compositionLocalOf
13 | import androidx.compose.runtime.derivedStateOf
14 | import androidx.compose.runtime.getValue
15 | import androidx.compose.runtime.key
16 | import androidx.compose.runtime.remember
17 | import androidx.compose.runtime.rememberCoroutineScope
18 | import androidx.compose.ui.Modifier
19 | import androidx.compose.ui.graphics.Color
20 | import androidx.compose.ui.unit.dp
21 | import dev.chrisbanes.haze.HazeState
22 | import dev.chrisbanes.haze.HazeStyle
23 | import dev.chrisbanes.haze.HazeTint
24 | import dev.chrisbanes.haze.hazeEffect
25 | import dev.chrisbanes.haze.hazeSource
26 | import fontweighttest.composeapp.generated.resources.Res
27 | import fontweighttest.composeapp.generated.resources.app_name
28 | import fontweighttest.composeapp.generated.resources.home
29 | import fontweighttest.composeapp.generated.resources.monospace
30 | import fontweighttest.composeapp.generated.resources.sans_serif
31 | import fontweighttest.composeapp.generated.resources.serif
32 | import kotlinx.coroutines.launch
33 | import org.jetbrains.compose.resources.stringResource
34 | import org.jetbrains.compose.resources.vectorResource
35 | import top.yukonga.fontWeightTest.ui.AboutDialog
36 | import top.yukonga.fontWeightTest.ui.HomeView
37 | import top.yukonga.fontWeightTest.ui.MonospaceView
38 | import top.yukonga.fontWeightTest.ui.SansSerifView
39 | import top.yukonga.fontWeightTest.ui.SerifView
40 | import top.yukonga.fontWeightTest.ui.theme.AppTheme
41 | import top.yukonga.miuix.kmp.basic.MiuixScrollBehavior
42 | import top.yukonga.miuix.kmp.basic.NavigationBar
43 | import top.yukonga.miuix.kmp.basic.NavigationItem
44 | import top.yukonga.miuix.kmp.basic.Scaffold
45 | import top.yukonga.miuix.kmp.basic.ScrollBehavior
46 | import top.yukonga.miuix.kmp.basic.SmallTopAppBar
47 | import top.yukonga.miuix.kmp.basic.TopAppBar
48 | import top.yukonga.miuix.kmp.theme.MiuixTheme
49 |
50 | val LocalPagerState = compositionLocalOf { error("No pager state") }
51 | val LocalHandlePageChange = compositionLocalOf<(Int) -> Unit> { error("No handle page change") }
52 |
53 | @Composable
54 | fun App(
55 | isDarkTheme: Boolean = isSystemInDarkTheme()
56 | ) {
57 | AppTheme(
58 | isDarkTheme = isDarkTheme
59 | ) {
60 | val coroutineScope = rememberCoroutineScope()
61 | val topAppBarScrollBehaviorList = List(4) { MiuixScrollBehavior() }
62 |
63 | val pagerState = rememberPagerState(pageCount = { 4 })
64 |
65 | val currentScrollBehavior by remember {
66 | derivedStateOf { topAppBarScrollBehaviorList[pagerState.currentPage] }
67 | }
68 |
69 | val handlePageChange: (Int) -> Unit = remember(pagerState, coroutineScope) {
70 | { page ->
71 | coroutineScope.launch { pagerState.animateScrollToPage(page) }
72 | }
73 | }
74 |
75 | val navigationItems = listOf(
76 | NavigationItem(stringResource(Res.string.home), vectorResource(Res.drawable.home)),
77 | NavigationItem(stringResource(Res.string.sans_serif), vectorResource(Res.drawable.sans_serif)),
78 | NavigationItem(stringResource(Res.string.serif), vectorResource(Res.drawable.serif)),
79 | NavigationItem(stringResource(Res.string.monospace), vectorResource(Res.drawable.monospace)),
80 | )
81 |
82 | val hazeState = remember { HazeState() }
83 | val surface = MiuixTheme.colorScheme.surface
84 | val hazeStyle = remember(surface) {
85 | HazeStyle(
86 | backgroundColor = surface,
87 | tint = HazeTint(surface.copy(0.67f))
88 | )
89 | }
90 |
91 | CompositionLocalProvider(
92 | LocalPagerState provides pagerState,
93 | LocalHandlePageChange provides handlePageChange,
94 | ) {
95 | val page by remember { derivedStateOf { pagerState.targetPage } }
96 |
97 | Scaffold(
98 | modifier = Modifier.fillMaxSize(),
99 | topBar = {
100 | TopAppBarContent(
101 | currentScrollBehavior = currentScrollBehavior,
102 | hazeState = hazeState,
103 | hazeStyle = hazeStyle
104 | )
105 | },
106 | bottomBar = {
107 | NavigationBar(
108 | color = Color.Transparent,
109 | modifier = Modifier.hazeEffect(hazeState) {
110 | style = hazeStyle
111 | blurRadius = 25.dp
112 | noiseFactor = 0f
113 | },
114 | items = navigationItems,
115 | selected = page,
116 | onClick = handlePageChange,
117 | )
118 | }
119 | ) { padding ->
120 | PagerContent(
121 | pagerState = pagerState,
122 | hazeState = hazeState,
123 | topAppBarScrollBehaviorList = topAppBarScrollBehaviorList,
124 | padding = padding
125 | )
126 | }
127 | }
128 | }
129 | }
130 |
131 | @Composable
132 | private fun TopAppBarContent(
133 | currentScrollBehavior: ScrollBehavior,
134 | hazeState: HazeState,
135 | hazeStyle: HazeStyle
136 | ) {
137 | BoxWithConstraints {
138 | val isCompact = maxWidth < 768.dp
139 | val modifier = Modifier.hazeEffect(hazeState) {
140 | style = hazeStyle
141 | blurRadius = 25.dp
142 | noiseFactor = 0f
143 | }
144 |
145 | if (isCompact) {
146 | TopAppBar(
147 | color = Color.Transparent,
148 | modifier = modifier,
149 | title = stringResource(Res.string.app_name),
150 | navigationIcon = { AboutDialog() },
151 | scrollBehavior = currentScrollBehavior
152 | )
153 | } else {
154 | SmallTopAppBar(
155 | color = Color.Transparent,
156 | modifier = modifier,
157 | title = stringResource(Res.string.app_name),
158 | navigationIcon = { AboutDialog() },
159 | scrollBehavior = currentScrollBehavior
160 | )
161 | }
162 | }
163 | }
164 |
165 | @Composable
166 | private fun PagerContent(
167 | pagerState: PagerState,
168 | hazeState: HazeState,
169 | topAppBarScrollBehaviorList: List,
170 | padding: PaddingValues
171 | ) {
172 | HorizontalPager(
173 | modifier = Modifier.hazeSource(state = hazeState),
174 | state = pagerState,
175 | userScrollEnabled = false,
176 | pageContent = { page ->
177 | key(page) {
178 | when (page) {
179 | 0 -> HomeView(topAppBarScrollBehaviorList[0], padding)
180 | 1 -> SansSerifView(topAppBarScrollBehaviorList[1], padding)
181 | 2 -> SerifView(topAppBarScrollBehaviorList[2], padding)
182 | 3 -> MonospaceView(topAppBarScrollBehaviorList[3], padding)
183 | }
184 | }
185 | }
186 | )
187 | }
188 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 | # SPDX-License-Identifier: Apache-2.0
19 | #
20 |
21 | ##############################################################################
22 | #
23 | # Gradle start up script for POSIX generated by Gradle.
24 | #
25 | # Important for running:
26 | #
27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
28 | # noncompliant, but you have some other compliant shell such as ksh or
29 | # bash, then to run this script, type that shell name before the whole
30 | # command line, like:
31 | #
32 | # ksh Gradle
33 | #
34 | # Busybox and similar reduced shells will NOT work, because this script
35 | # requires all of these POSIX shell features:
36 | # * functions;
37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
39 | # * compound commands having a testable exit status, especially «case»;
40 | # * various built-in commands including «command», «set», and «ulimit».
41 | #
42 | # Important for patching:
43 | #
44 | # (2) This script targets any POSIX shell, so it avoids extensions provided
45 | # by Bash, Ksh, etc; in particular arrays are avoided.
46 | #
47 | # The "traditional" practice of packing multiple parameters into a
48 | # space-separated string is a well documented source of bugs and security
49 | # problems, so this is (mostly) avoided, by progressively accumulating
50 | # options in "$@", and eventually passing that to Java.
51 | #
52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
54 | # see the in-line comments for details.
55 | #
56 | # There are tweaks for specific operating systems such as AIX, CygWin,
57 | # Darwin, MinGW, and NonStop.
58 | #
59 | # (3) This script is generated from the Groovy template
60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
61 | # within the Gradle project.
62 | #
63 | # You can find Gradle at https://github.com/gradle/gradle/.
64 | #
65 | ##############################################################################
66 |
67 | # Attempt to set APP_HOME
68 |
69 | # Resolve links: $0 may be a link
70 | app_path=$0
71 |
72 | # Need this for daisy-chained symlinks.
73 | while
74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
75 | [ -h "$app_path" ]
76 | do
77 | ls=$( ls -ld "$app_path" )
78 | link=${ls#*' -> '}
79 | case $link in #(
80 | /*) app_path=$link ;; #(
81 | *) app_path=$APP_HOME$link ;;
82 | esac
83 | done
84 |
85 | # This is normally unused
86 | # shellcheck disable=SC2034
87 | APP_BASE_NAME=${0##*/}
88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH="\\\"\\\""
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | if ! command -v java >/dev/null 2>&1
137 | then
138 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
139 |
140 | Please set the JAVA_HOME variable in your environment to match the
141 | location of your Java installation."
142 | fi
143 | fi
144 |
145 | # Increase the maximum file descriptors if we can.
146 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
147 | case $MAX_FD in #(
148 | max*)
149 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
150 | # shellcheck disable=SC2039,SC3045
151 | MAX_FD=$( ulimit -H -n ) ||
152 | warn "Could not query maximum file descriptor limit"
153 | esac
154 | case $MAX_FD in #(
155 | '' | soft) :;; #(
156 | *)
157 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
158 | # shellcheck disable=SC2039,SC3045
159 | ulimit -n "$MAX_FD" ||
160 | warn "Could not set maximum file descriptor limit to $MAX_FD"
161 | esac
162 | fi
163 |
164 | # Collect all arguments for the java command, stacking in reverse order:
165 | # * args from the command line
166 | # * the main class name
167 | # * -classpath
168 | # * -D...appname settings
169 | # * --module-path (only if needed)
170 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
171 |
172 | # For Cygwin or MSYS, switch paths to Windows format before running java
173 | if "$cygwin" || "$msys" ; then
174 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
175 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
176 |
177 | JAVACMD=$( cygpath --unix "$JAVACMD" )
178 |
179 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
180 | for arg do
181 | if
182 | case $arg in #(
183 | -*) false ;; # don't mess with options #(
184 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
185 | [ -e "$t" ] ;; #(
186 | *) false ;;
187 | esac
188 | then
189 | arg=$( cygpath --path --ignore --mixed "$arg" )
190 | fi
191 | # Roll the args list around exactly as many times as the number of
192 | # args, so each arg winds up back in the position where it started, but
193 | # possibly modified.
194 | #
195 | # NB: a `for` loop captures its iteration list before it begins, so
196 | # changing the positional parameters here affects neither the number of
197 | # iterations, nor the values presented in `arg`.
198 | shift # remove old arg
199 | set -- "$@" "$arg" # push replacement arg
200 | done
201 | fi
202 |
203 |
204 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
205 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
206 |
207 | # Collect all arguments for the java command:
208 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
209 | # and any embedded shellness will be escaped.
210 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
211 | # treated as '${Hostname}' itself on the command line.
212 |
213 | set -- \
214 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
215 | -classpath "$CLASSPATH" \
216 | -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
217 | "$@"
218 |
219 | # Stop when "xargs" is not available.
220 | if ! command -v xargs >/dev/null 2>&1
221 | then
222 | die "xargs is not available"
223 | fi
224 |
225 | # Use "xargs" to parse quoted args.
226 | #
227 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
228 | #
229 | # In Bash we could simply go:
230 | #
231 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
232 | # set -- "${ARGS[@]}" "$@"
233 | #
234 | # but POSIX shell has neither arrays nor command substitution, so instead we
235 | # post-process each arg (as a line of input to sed) to backslash-escape any
236 | # character that might be a shell metacharacter, then use eval to reverse
237 | # that process (while maintaining the separation between arguments), and wrap
238 | # the whole thing up as a single "set" statement.
239 | #
240 | # This will of course break if any of these variables contains a newline or
241 | # an unmatched quote.
242 | #
243 |
244 | eval "set -- $(
245 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
246 | xargs -n1 |
247 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
248 | tr '\n' ' '
249 | )" '"$@"'
250 |
251 | exec "$JAVACMD" "$@"
252 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by https://www.toptal.com/developers/gitignore/api/java,linux,macos,kotlin,android,windows,composer,jetbrains,androidstudio,visualstudiocode,xcode
2 | # Edit at https://www.toptal.com/developers/gitignore?templates=java,linux,macos,kotlin,android,windows,composer,jetbrains,androidstudio,visualstudiocode,xcode
3 |
4 | ### Android ###
5 | # Gradle files
6 | .gradle/
7 | build/
8 |
9 | # Local configuration file (sdk path, etc)
10 | local.properties
11 |
12 | # Log/OS Files
13 | *.log
14 |
15 | # Android Studio generated files and folders
16 | captures/
17 | .externalNativeBuild/
18 | .cxx/
19 | *.apk
20 | output.json
21 |
22 | # IntelliJ
23 | *.iml
24 | .idea/
25 | misc.xml
26 | deploymentTargetDropDown.xml
27 | render.experimental.xml
28 |
29 | # Keystore files
30 | *.jks
31 | *.keystore
32 |
33 | # Google Services (e.g. APIs or Firebase)
34 | google-services.json
35 |
36 | # Android Profiling
37 | *.hprof
38 |
39 | ### Android Patch ###
40 | gen-external-apklibs
41 |
42 | # Replacement of .externalNativeBuild directories introduced
43 | # with Android Studio 3.5.
44 |
45 | ### Composer ###
46 | composer.phar
47 | /vendor/
48 |
49 | # Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
50 | # You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
51 | # composer.lock
52 |
53 | ### Java ###
54 | # Compiled class file
55 | *.class
56 |
57 | # Log file
58 |
59 | # BlueJ files
60 | *.ctxt
61 |
62 | # Mobile Tools for Java (J2ME)
63 | .mtj.tmp/
64 |
65 | # Package Files #
66 | *.jar
67 | *.war
68 | *.nar
69 | *.ear
70 | *.zip
71 | *.tar.gz
72 | *.rar
73 |
74 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
75 | hs_err_pid*
76 | replay_pid*
77 |
78 | ### JetBrains ###
79 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
80 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
81 |
82 | # User-specific stuff
83 | .idea/**/workspace.xml
84 | .idea/**/tasks.xml
85 | .idea/**/usage.statistics.xml
86 | .idea/**/dictionaries
87 | .idea/**/shelf
88 |
89 | # AWS User-specific
90 | .idea/**/aws.xml
91 |
92 | # Generated files
93 | .idea/**/contentModel.xml
94 |
95 | # Sensitive or high-churn files
96 | .idea/**/dataSources/
97 | .idea/**/dataSources.ids
98 | .idea/**/dataSources.local.xml
99 | .idea/**/sqlDataSources.xml
100 | .idea/**/dynamic.xml
101 | .idea/**/uiDesigner.xml
102 | .idea/**/dbnavigator.xml
103 |
104 | # Gradle
105 | .idea/**/gradle.xml
106 | .idea/**/libraries
107 |
108 | # Gradle and Maven with auto-import
109 | # When using Gradle or Maven with auto-import, you should exclude module files,
110 | # since they will be recreated, and may cause churn. Uncomment if using
111 | # auto-import.
112 | # .idea/artifacts
113 | # .idea/compiler.xml
114 | # .idea/jarRepositories.xml
115 | # .idea/modules.xml
116 | # .idea/*.iml
117 | # .idea/modules
118 | # *.iml
119 | # *.ipr
120 |
121 | # CMake
122 | cmake-build-*/
123 |
124 | # Mongo Explorer plugin
125 | .idea/**/mongoSettings.xml
126 |
127 | # File-based project format
128 | *.iws
129 |
130 | # IntelliJ
131 | out/
132 |
133 | # mpeltonen/sbt-idea plugin
134 | .idea_modules/
135 |
136 | # JIRA plugin
137 | atlassian-ide-plugin.xml
138 |
139 | # Cursive Clojure plugin
140 | .idea/replstate.xml
141 |
142 | # SonarLint plugin
143 | .idea/sonarlint/
144 |
145 | # Crashlytics plugin (for Android Studio and IntelliJ)
146 | com_crashlytics_export_strings.xml
147 | crashlytics.properties
148 | crashlytics-build.properties
149 | fabric.properties
150 |
151 | # Editor-based Rest Client
152 | .idea/httpRequests
153 |
154 | # Android studio 3.1+ serialized cache file
155 | .idea/caches/build_file_checksums.ser
156 |
157 | ### JetBrains Patch ###
158 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
159 |
160 | # *.iml
161 | # modules.xml
162 | # .idea/misc.xml
163 | # *.ipr
164 |
165 | # Sonarlint plugin
166 | # https://plugins.jetbrains.com/plugin/7973-sonarlint
167 | .idea/**/sonarlint/
168 |
169 | # SonarQube Plugin
170 | # https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
171 | .idea/**/sonarIssues.xml
172 |
173 | # Markdown Navigator plugin
174 | # https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
175 | .idea/**/markdown-navigator.xml
176 | .idea/**/markdown-navigator-enh.xml
177 | .idea/**/markdown-navigator/
178 |
179 | # Cache file creation bug
180 | # See https://youtrack.jetbrains.com/issue/JBR-2257
181 | .idea/$CACHE_FILE$
182 |
183 | # CodeStream plugin
184 | # https://plugins.jetbrains.com/plugin/12206-codestream
185 | .idea/codestream.xml
186 |
187 | # Azure Toolkit for IntelliJ plugin
188 | # https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
189 | .idea/**/azureSettings.xml
190 |
191 | ### Kotlin ###
192 | /.kotlin
193 | # Compiled class file
194 |
195 | # Log file
196 |
197 | # BlueJ files
198 |
199 | # Mobile Tools for Java (J2ME)
200 |
201 | # Package Files #
202 |
203 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
204 |
205 | ### Linux ###
206 | *~
207 |
208 | # temporary files which can be created if a process still has a handle open of a deleted file
209 | .fuse_hidden*
210 |
211 | # KDE directory preferences
212 | .directory
213 |
214 | # Linux trash folder which might appear on any partition or disk
215 | .Trash-*
216 |
217 | # .nfs files are created when an open file is removed but is still being accessed
218 | .nfs*
219 |
220 | ### macOS ###
221 | # General
222 | .DS_Store
223 | .AppleDouble
224 | .LSOverride
225 |
226 | # Icon must end with two \r
227 | Icon
228 |
229 |
230 | # Thumbnails
231 | ._*
232 |
233 | # Files that might appear in the root of a volume
234 | .DocumentRevisions-V100
235 | .fseventsd
236 | .Spotlight-V100
237 | .TemporaryItems
238 | .Trashes
239 | .VolumeIcon.icns
240 | .com.apple.timemachine.donotpresent
241 |
242 | # Directories potentially created on remote AFP share
243 | .AppleDB
244 | .AppleDesktop
245 | Network Trash Folder
246 | Temporary Items
247 | .apdisk
248 |
249 | ### macOS Patch ###
250 | # iCloud generated files
251 | *.icloud
252 |
253 | ### VisualStudioCode ###
254 | .vscode/*
255 | !.vscode/settings.json
256 | !.vscode/tasks.json
257 | !.vscode/launch.json
258 | !.vscode/extensions.json
259 | !.vscode/*.code-snippets
260 |
261 | # Local History for Visual Studio Code
262 | .history/
263 |
264 | # Built Visual Studio Code Extensions
265 | *.vsix
266 |
267 | ### VisualStudioCode Patch ###
268 | # Ignore all local history of files
269 | .history
270 | .ionide
271 |
272 | ### Windows ###
273 | # Windows thumbnail cache files
274 | Thumbs.db
275 | Thumbs.db:encryptable
276 | ehthumbs.db
277 | ehthumbs_vista.db
278 |
279 | # Dump file
280 | *.stackdump
281 |
282 | # Folder config file
283 | [Dd]esktop.ini
284 |
285 | # Recycle Bin used on file shares
286 | $RECYCLE.BIN/
287 |
288 | # Windows Installer files
289 | *.cab
290 | *.msi
291 | *.msix
292 | *.msm
293 | *.msp
294 |
295 | # Windows shortcuts
296 | *.lnk
297 |
298 | ### Xcode ###
299 | ## User settings
300 | xcuserdata/
301 |
302 | ## Xcode 8 and earlier
303 | *.xcscmblueprint
304 | *.xccheckout
305 |
306 | ### Xcode Patch ###
307 |
308 | # Ignore cocoapods files
309 | iosApp/Podfile.lock
310 | iosApp/Pods/*
311 | iosApp/iosApp.xcworkspace/*
312 | iosApp/iosApp.xcodeproj/*
313 | !iosApp/iosApp.xcodeproj/project.pbxproj
314 | composeApp/composeApp.podspec
315 |
316 | ### AndroidStudio ###
317 | # Covers files to be ignored for android development using Android Studio.
318 |
319 | # Built application files
320 | *.ap_
321 | *.aab
322 |
323 | # Files for the ART/Dalvik VM
324 | *.dex
325 |
326 | # Java class files
327 |
328 | # Generated files
329 | bin/
330 | gen/
331 |
332 | # Gradle files
333 | .gradle
334 |
335 | # Signing files
336 | .signing/
337 |
338 | # Local configuration file (sdk path, etc)
339 |
340 | # Proguard folder generated by Eclipse
341 | proguard/
342 |
343 | # Log Files
344 |
345 | # Android Studio
346 | /*/build/
347 | /*/local.properties
348 | /*/out
349 | /*/*/build
350 | /*/*/production
351 | .navigation/
352 | *.ipr
353 | *.swp
354 |
355 | # Keystore files
356 |
357 | # Google Services (e.g. APIs or Firebase)
358 | # google-services.json
359 |
360 | # Android Patch
361 |
362 | # External native build folder generated in Android Studio 2.2 and later
363 | .externalNativeBuild
364 |
365 | # NDK
366 | obj/
367 |
368 | # IntelliJ IDEA
369 | /out/
370 |
371 | # User-specific configurations
372 | .idea/caches/
373 | .idea/libraries/
374 | .idea/shelf/
375 | .idea/workspace.xml
376 | .idea/tasks.xml
377 | .idea/.name
378 | .idea/compiler.xml
379 | .idea/copyright/profiles_settings.xml
380 | .idea/encodings.xml
381 | .idea/misc.xml
382 | .idea/modules.xml
383 | .idea/scopes/scope_settings.xml
384 | .idea/dictionaries
385 | .idea/vcs.xml
386 | .idea/jsLibraryMappings.xml
387 | .idea/datasources.xml
388 | .idea/dataSources.ids
389 | .idea/sqlDataSources.xml
390 | .idea/dynamic.xml
391 | .idea/uiDesigner.xml
392 | .idea/assetWizardSettings.xml
393 | .idea/gradle.xml
394 | .idea/jarRepositories.xml
395 | .idea/navEditor.xml
396 |
397 | # Legacy Eclipse project files
398 | .classpath
399 | .project
400 | .cproject
401 | .settings/
402 |
403 | # Mobile Tools for Java (J2ME)
404 |
405 | # Package Files #
406 |
407 | # virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml)
408 |
409 | ## Plugin-specific files:
410 |
411 | # mpeltonen/sbt-idea plugin
412 |
413 | # JIRA plugin
414 |
415 | # Mongo Explorer plugin
416 | .idea/mongoSettings.xml
417 |
418 | # Crashlytics plugin (for Android Studio and IntelliJ)
419 |
420 | ### AndroidStudio Patch ###
421 |
422 | !/gradle/wrapper/gradle-wrapper.jar
423 |
424 | # End of https://www.toptal.com/developers/gitignore/api/java,linux,macos,kotlin,android,windows,composer,jetbrains,androidstudio,visualstudiocode,xcode
425 |
--------------------------------------------------------------------------------
/composeApp/build.gradle.kts:
--------------------------------------------------------------------------------
1 | @file:Suppress("UnstableApiUsage")
2 |
3 | import com.android.build.gradle.internal.api.BaseVariantOutputImpl
4 | import com.android.build.gradle.internal.tasks.factory.dependsOn
5 | import org.gradle.kotlin.dsl.support.uppercaseFirstChar
6 | import org.jetbrains.compose.desktop.application.dsl.TargetFormat
7 | import org.jetbrains.compose.desktop.application.tasks.AbstractNativeMacApplicationPackageAppDirTask
8 | import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
9 | import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
10 | import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
11 | import org.jetbrains.kotlin.konan.target.KonanTarget
12 | import java.util.Properties
13 |
14 | plugins {
15 | alias(libs.plugins.android.application)
16 | alias(libs.plugins.jetbrains.compose)
17 | alias(libs.plugins.compose.compiler)
18 | alias(libs.plugins.kotlin.multiplatform)
19 | }
20 |
21 | val appName = "FontWeightTest"
22 | val pkgName = "top.yukonga.fontWeightTest"
23 | val verName = "1.6.3"
24 | val verCode = getVersionCode()
25 | val generatedSrcDir = layout.buildDirectory.dir("generated").get().asFile.resolve("fontWeightTest")
26 | kotlin {
27 | androidTarget()
28 |
29 | jvm("desktop")
30 |
31 | listOf(
32 | iosArm64(),
33 | iosSimulatorArm64(),
34 | ).forEach {
35 | it.compilerOptions {
36 | freeCompilerArgs.add("-Xbinary=preCodegenInlineThreshold=40")
37 | }
38 | it.binaries.framework {
39 | baseName = "shared"
40 | isStatic = true
41 | }
42 | }
43 |
44 | listOf(
45 | macosArm64(),
46 | ).forEach {
47 | it.compilerOptions {
48 | freeCompilerArgs.add("-Xbinary=preCodegenInlineThreshold=40")
49 | }
50 | it.binaries.executable {
51 | entryPoint = "main"
52 | }
53 | }
54 |
55 | sourceSets {
56 | val desktopMain by getting
57 | val commonMain by getting {
58 | kotlin.srcDir(generatedSrcDir.resolve("kotlin").absolutePath)
59 | }
60 | commonMain.dependencies {
61 | implementation(compose.runtime)
62 | implementation(compose.foundation)
63 | implementation(compose.ui)
64 | implementation(compose.components.resources)
65 | implementation(libs.miuix)
66 | implementation(libs.haze)
67 | }
68 | androidMain.dependencies {
69 | implementation(libs.androidx.activity.compose)
70 | }
71 | desktopMain.dependencies {
72 | implementation(compose.desktop.currentOs)
73 | implementation(libs.jna)
74 | implementation(libs.jna.platform)
75 | }
76 | }
77 |
78 |
79 | }
80 |
81 | android {
82 | namespace = pkgName
83 | defaultConfig {
84 | applicationId = pkgName
85 | versionCode = verCode
86 | versionName = verName
87 | }
88 | val properties = Properties()
89 | runCatching { properties.load(project.rootProject.file("local.properties").inputStream()) }
90 | val keystorePath = properties.getProperty("KEYSTORE_PATH") ?: System.getenv("KEYSTORE_PATH")
91 | val keystorePwd = properties.getProperty("KEYSTORE_PASS") ?: System.getenv("KEYSTORE_PASS")
92 | val alias = properties.getProperty("KEY_ALIAS") ?: System.getenv("KEY_ALIAS")
93 | val pwd = properties.getProperty("KEY_PASSWORD") ?: System.getenv("KEY_PASSWORD")
94 | if (keystorePath != null) {
95 | signingConfigs {
96 | create("release") {
97 | storeFile = file(keystorePath)
98 | storePassword = keystorePwd
99 | keyAlias = alias
100 | keyPassword = pwd
101 | enableV2Signing = true
102 | enableV3Signing = true
103 | enableV4Signing = true
104 | }
105 | }
106 | }
107 | buildTypes {
108 | release {
109 | isMinifyEnabled = true
110 | isShrinkResources = true
111 | vcsInfo.include = false
112 | proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules-android.pro")
113 | if (keystorePath != null) signingConfig = signingConfigs.getByName("release")
114 | }
115 | debug {
116 | if (keystorePath != null) signingConfig = signingConfigs.getByName("release")
117 | }
118 | }
119 | dependenciesInfo.includeInApk = false
120 | kotlin.jvmToolchain(21)
121 | packaging {
122 | applicationVariants.all {
123 | outputs.all {
124 | (this as BaseVariantOutputImpl).outputFileName = "$appName-v$versionName($versionCode)-$name.apk"
125 | }
126 | }
127 | }
128 | }
129 |
130 | androidComponents {
131 | onVariants(selector().withBuildType("release")) {
132 | it.packaging.resources.excludes.add("**")
133 | }
134 | }
135 |
136 | compose.desktop {
137 | application {
138 | mainClass = "MainKt"
139 | buildTypes.release.proguard {
140 | optimize = false
141 | configurationFiles.from("proguard-rules-jvm.pro")
142 | }
143 | nativeDistributions {
144 | targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
145 | packageName = appName
146 | packageVersion = verName
147 | description = "Font Weight Test"
148 | copyright = "Copyright © 2024-2025 YuKongA"
149 | linux {
150 | iconFile = file("src/desktopMain/resources/linux/Icon.png")
151 | }
152 | macOS {
153 | bundleID = pkgName
154 | jvmArgs("-Dapple.awt.application.appearance=system")
155 | iconFile = file("src/desktopMain/resources/macos/Icon.icns")
156 | }
157 | windows {
158 | dirChooser = true
159 | perUserInstall = true
160 | iconFile = file("src/desktopMain/resources/windows/Icon.ico")
161 | }
162 | }
163 | nativeApplication {
164 | targets(kotlin.targets.getByName("macosArm64"))
165 | distributions {
166 | targetFormats(TargetFormat.Dmg)
167 | packageName = appName
168 | packageVersion = verName
169 | description = "Font Weight Test"
170 | copyright = "Copyright © 2024-2025 YuKongA"
171 | macOS {
172 | bundleID = pkgName
173 | iconFile = file("src/macosMain/resources/FontWeightTest.icns")
174 | }
175 | }
176 | }
177 | }
178 | }
179 |
180 | fun getGitCommitCount(): Int {
181 | val process = Runtime.getRuntime().exec(arrayOf("git", "rev-list", "--count", "HEAD"))
182 | return process.inputStream.bufferedReader().use { it.readText().trim().toInt() }
183 | }
184 |
185 | fun getVersionCode(): Int {
186 | val commitCount = getGitCommitCount()
187 | val major = 99
188 | return major + commitCount
189 | }
190 |
191 | val generateVersionInfo by tasks.registering {
192 | doLast {
193 | val file = generatedSrcDir.resolve("kotlin/misc/VersionInfo.kt")
194 | if (!file.exists()) {
195 | file.parentFile.mkdirs()
196 | file.createNewFile()
197 | }
198 | file.writeText(
199 | """
200 | package misc
201 |
202 | object VersionInfo {
203 | const val VERSION_NAME = "$verName"
204 | const val VERSION_CODE = $verCode
205 | }
206 | """.trimIndent()
207 | )
208 | val iosPlist = project.rootDir.resolve("iosApp/iosApp/Info.plist")
209 | if (iosPlist.exists()) {
210 | val content = iosPlist.readText()
211 | val updatedContent = content
212 | .replace(
213 | Regex("CFBundleShortVersionString\\s*[^<]*"),
214 | "CFBundleShortVersionString\n\t$verName"
215 | )
216 | .replace(
217 | Regex("CFBundleVersion\\s*[^<]*"),
218 | "CFBundleVersion\n\t$verCode"
219 | )
220 | iosPlist.writeText(updatedContent)
221 | }
222 | }
223 | }
224 |
225 | tasks.named("generateComposeResClass").configure {
226 | dependsOn(generateVersionInfo)
227 | }
228 |
229 | afterEvaluate {
230 | project.extensions.getByType().targets
231 | .withType()
232 | .filter { it.konanTarget == KonanTarget.MACOS_ARM64 }
233 | .forEach { target ->
234 | val targetName = target.targetName.uppercaseFirstChar()
235 | val buildTypes = mapOf(
236 | NativeBuildType.RELEASE to target.binaries.getExecutable(NativeBuildType.RELEASE),
237 | NativeBuildType.DEBUG to target.binaries.getExecutable(NativeBuildType.DEBUG)
238 | )
239 | buildTypes.forEach { (buildType, executable) ->
240 | val buildTypeName = buildType.name.lowercase().uppercaseFirstChar()
241 | target.binaries.withType()
242 | .filter { it.buildType == buildType }
243 | .forEach {
244 | val taskName = "copy${buildTypeName}ComposeResourcesFor${targetName}"
245 | val copyTask = tasks.register(taskName) {
246 | from({
247 | (executable.compilation.associatedCompilations + executable.compilation).flatMap { compilation ->
248 | compilation.allKotlinSourceSets.map { it.resources }
249 | }
250 | })
251 | into(executable.outputDirectory.resolve("compose-resources"))
252 | exclude("*.icns")
253 | }
254 | it.linkTaskProvider.dependsOn(copyTask)
255 | }
256 | }
257 | }
258 | }
259 |
260 | tasks.withType().configureEach {
261 | doLast {
262 | val packageName = packageName.get()
263 | val destinationDir = outputs.files.singleFile
264 | val appDir = destinationDir.resolve("$packageName.app")
265 | val resourcesDir = appDir.resolve("Contents/Resources")
266 | val currentMacosTarget = kotlin.targets.withType()
267 | .find { it.konanTarget == KonanTarget.MACOS_ARM64 }?.targetName
268 | val composeResourcesDir = project.rootDir
269 | .resolve("composeApp/build/bin/$currentMacosTarget/releaseExecutable/compose-resources")
270 | if (composeResourcesDir.exists()) {
271 | project.copy {
272 | from(composeResourcesDir)
273 | into(resourcesDir.resolve("compose-resources"))
274 | }
275 | }
276 | }
277 | }
278 |
--------------------------------------------------------------------------------
/composeApp/src/commonMain/kotlin/top/yukonga/fontWeightTest/ui/HomeView.kt:
--------------------------------------------------------------------------------
1 | package top.yukonga.fontWeightTest.ui
2 |
3 | import androidx.compose.foundation.clickable
4 | import androidx.compose.foundation.layout.Arrangement
5 | import androidx.compose.foundation.layout.Column
6 | import androidx.compose.foundation.layout.PaddingValues
7 | import androidx.compose.foundation.layout.Row
8 | import androidx.compose.foundation.layout.Spacer
9 | import androidx.compose.foundation.layout.calculateEndPadding
10 | import androidx.compose.foundation.layout.calculateStartPadding
11 | import androidx.compose.foundation.layout.height
12 | import androidx.compose.foundation.layout.padding
13 | import androidx.compose.foundation.lazy.LazyColumn
14 | import androidx.compose.foundation.lazy.LazyListScope
15 | import androidx.compose.foundation.text.KeyboardActions
16 | import androidx.compose.foundation.text.KeyboardOptions
17 | import androidx.compose.runtime.Composable
18 | import androidx.compose.runtime.derivedStateOf
19 | import androidx.compose.runtime.getValue
20 | import androidx.compose.runtime.mutableIntStateOf
21 | import androidx.compose.runtime.mutableStateOf
22 | import androidx.compose.runtime.remember
23 | import androidx.compose.runtime.saveable.rememberSaveable
24 | import androidx.compose.runtime.setValue
25 | import androidx.compose.ui.Modifier
26 | import androidx.compose.ui.focus.FocusManager
27 | import androidx.compose.ui.input.nestedscroll.nestedScroll
28 | import androidx.compose.ui.platform.LocalFocusManager
29 | import androidx.compose.ui.platform.LocalLayoutDirection
30 | import androidx.compose.ui.text.font.FontFamily
31 | import androidx.compose.ui.text.font.FontWeight
32 | import androidx.compose.ui.text.input.ImeAction
33 | import androidx.compose.ui.unit.dp
34 | import androidx.compose.ui.unit.sp
35 | import fontweighttest.composeapp.generated.resources.Res
36 | import fontweighttest.composeapp.generated.resources.clear_text
37 | import fontweighttest.composeapp.generated.resources.comparison_display
38 | import fontweighttest.composeapp.generated.resources.custom_text
39 | import fontweighttest.composeapp.generated.resources.device_font
40 | import fontweighttest.composeapp.generated.resources.font_size
41 | import fontweighttest.composeapp.generated.resources.font_weight
42 | import fontweighttest.composeapp.generated.resources.variable_font
43 | import org.jetbrains.compose.resources.Font
44 | import org.jetbrains.compose.resources.stringResource
45 | import top.yukonga.fontWeightTest.ui.components.CardView
46 | import top.yukonga.fontWeightTest.utils.FontDisplayState
47 | import top.yukonga.fontWeightTest.utils.fontWeightDescriptions
48 | import top.yukonga.fontWeightTest.utils.fontWeightsList
49 | import top.yukonga.fontWeightTest.utils.miSansList
50 | import top.yukonga.fontWeightTest.utils.testCharacters
51 | import top.yukonga.miuix.kmp.basic.ScrollBehavior
52 | import top.yukonga.miuix.kmp.basic.Slider
53 | import top.yukonga.miuix.kmp.basic.SmallTitle
54 | import top.yukonga.miuix.kmp.basic.Text
55 | import top.yukonga.miuix.kmp.basic.TextField
56 | import top.yukonga.miuix.kmp.utils.overScrollVertical
57 | import top.yukonga.miuix.kmp.utils.scrollEndHaptic
58 |
59 | @Composable
60 | fun HomeView(
61 | topAppBarScrollBehavior: ScrollBehavior,
62 | padding: PaddingValues
63 | ) {
64 | val focusManager = LocalFocusManager.current
65 | val layoutDirection = LocalLayoutDirection.current
66 |
67 | LazyColumn(
68 | modifier = Modifier
69 | .scrollEndHaptic()
70 | .overScrollVertical()
71 | .nestedScroll(topAppBarScrollBehavior.nestedScrollConnection)
72 | .clickable(
73 | indication = null,
74 | interactionSource = null,
75 | onClick = { focusManager.clearFocus() }
76 | ),
77 | contentPadding = PaddingValues(
78 | top = padding.calculateTopPadding() + 12.dp,
79 | start = padding.calculateStartPadding(layoutDirection),
80 | end = padding.calculateEndPadding(layoutDirection),
81 | bottom = padding.calculateBottomPadding() + 12.dp
82 | ),
83 | ) {
84 | homeContent()
85 | }
86 | }
87 |
88 | private fun LazyListScope.homeContent() {
89 | item(key = "all_weights") {
90 | CardView {
91 | AllWeightText()
92 | }
93 | }
94 |
95 | item(key = "comparison_title") {
96 | SmallTitle(
97 | text = stringResource(Res.string.comparison_display),
98 | modifier = Modifier.padding(top = 6.dp)
99 | )
100 | }
101 |
102 | item(key = "comparison_display") {
103 | CardView {
104 | ComparisonDisplay()
105 | }
106 | }
107 |
108 | item(key = "variable_font_title") {
109 | SmallTitle(
110 | text = stringResource(Res.string.variable_font),
111 | modifier = Modifier.padding(top = 6.dp)
112 | )
113 | }
114 |
115 | item(key = "variable_font") {
116 | CardView {
117 | SliderTestView()
118 | }
119 | }
120 | }
121 |
122 | @Composable
123 | fun ComparisonDisplay() {
124 | DeviceFontTestView(stringResource(Res.string.device_font))
125 | Spacer(Modifier.height(6.dp))
126 | MiSansTestView("MiSans VF")
127 | }
128 |
129 | @Composable
130 | fun AllWeightText() {
131 | Column {
132 | fontWeightsList.forEachIndexed { index, fontWeight ->
133 | WeightText(
134 | "${(index + 1) * 100} - ${fontWeightDescriptions[index]}",
135 | fontWeight
136 | )
137 | }
138 | }
139 | }
140 |
141 | @Composable
142 | fun WeightText(description: String, fontWeight: FontWeight) {
143 | Text(
144 | text = description,
145 | fontWeight = fontWeight,
146 | maxLines = 1
147 | )
148 | }
149 |
150 | @Composable
151 | fun MiSansTestView(text: String) {
152 | Column {
153 | Text(text = text)
154 | testCharacters.forEach { MiSansTest(it) }
155 | }
156 | }
157 |
158 | @Composable
159 | fun MiSansTest(text: String) {
160 | Row {
161 | fontWeightsList.forEachIndexed { index, fontWeight ->
162 | Text(
163 | text = text,
164 | fontWeight = fontWeight,
165 | fontFamily = FontFamily(Font(miSansList[index], weight = fontWeight))
166 | )
167 | }
168 | }
169 | }
170 |
171 | @Composable
172 | fun DeviceFontTestView(text: String) {
173 | Column {
174 | Text(text = text)
175 | testCharacters.forEach { MoreTestText(it) }
176 | }
177 | }
178 |
179 | @Composable
180 | fun MoreTestText(text: String) {
181 | val weightList = fontWeightsList
182 |
183 | Row {
184 | weightList.forEach { fontWeight ->
185 | Text(
186 | text = text,
187 | fontWeight = fontWeight
188 | )
189 | }
190 | }
191 | }
192 |
193 | @Composable
194 | fun SliderTestView() {
195 | var customText by rememberSaveable { mutableStateOf("") }
196 | var fontSizeValue by rememberSaveable { mutableIntStateOf(24) }
197 | var fontSizeText by rememberSaveable { mutableStateOf(fontSizeValue.toString()) }
198 | var fontWeightValue by rememberSaveable { mutableIntStateOf(400) }
199 | var fontWeightText by rememberSaveable { mutableStateOf(fontWeightValue.toString()) }
200 |
201 | val fontDisplayState by remember(customText, fontSizeValue, fontWeightValue) {
202 | derivedStateOf {
203 | FontDisplayState(
204 | customText = customText,
205 | fontSizeValue = fontSizeValue,
206 | fontWeightValue = fontWeightValue
207 | )
208 | }
209 | }
210 |
211 | val focusManager = LocalFocusManager.current
212 |
213 | val onFontWeightTextChange = remember {
214 | { newValue: String ->
215 | if (newValue.isEmpty()) {
216 | fontWeightValue = 1
217 | fontWeightText = ""
218 | } else if (newValue.all { it.isDigit() }) {
219 | fontWeightValue = newValue.toInt().coerceIn(1, 1000)
220 | fontWeightText = fontWeightValue.toString()
221 | }
222 | }
223 | }
224 |
225 | val onFontWeightSliderChange = remember {
226 | { newValue: Float ->
227 | fontWeightValue = newValue.toInt()
228 | fontWeightText = newValue.toInt().toString()
229 | }
230 | }
231 |
232 | val onFontSizeTextChange = remember {
233 | { newValue: String ->
234 | if (newValue.isEmpty()) {
235 | fontSizeValue = 6
236 | fontSizeText = ""
237 | } else if (newValue.all { it.isDigit() }) {
238 | fontSizeValue = newValue.toInt().coerceIn(6, 96)
239 | fontSizeText = fontSizeValue.toString()
240 | }
241 | }
242 | }
243 |
244 | val onFontSizeSliderChange = remember {
245 | { newValue: Float ->
246 | fontSizeValue = newValue.toInt()
247 | fontSizeText = newValue.toInt().toString()
248 | }
249 | }
250 |
251 | Column(
252 | verticalArrangement = Arrangement.spacedBy(12.dp)
253 | ) {
254 | Row(
255 | horizontalArrangement = Arrangement.spacedBy(12.dp)
256 | ) {
257 | FontWeightControl(
258 | modifier = Modifier.weight(0.5f),
259 | value = fontWeightText,
260 | onValueChange = onFontWeightTextChange,
261 | sliderValue = fontWeightValue.toFloat(),
262 | onSliderChange = onFontWeightSliderChange,
263 | focusManager = focusManager
264 | )
265 |
266 | FontSizeControl(
267 | modifier = Modifier.weight(0.5f),
268 | value = fontSizeText,
269 | onValueChange = onFontSizeTextChange,
270 | sliderValue = fontSizeValue.toFloat(),
271 | onSliderChange = onFontSizeSliderChange,
272 | focusManager = focusManager
273 | )
274 | }
275 |
276 | CustomTextInput(
277 | value = customText,
278 | onValueChange = { customText = it },
279 | focusManager = focusManager
280 | )
281 |
282 | Text(
283 | modifier = Modifier.padding(top = 12.dp),
284 | text = fontDisplayState.displayText,
285 | fontSize = fontDisplayState.effectiveFontSize.sp,
286 | fontWeight = fontDisplayState.effectiveFontWeight,
287 | )
288 | }
289 | }
290 |
291 | @Composable
292 | private fun FontWeightControl(
293 | modifier: Modifier,
294 | value: String,
295 | onValueChange: (String) -> Unit,
296 | sliderValue: Float,
297 | onSliderChange: (Float) -> Unit,
298 | focusManager: FocusManager
299 | ) {
300 | Column(
301 | modifier = modifier,
302 | verticalArrangement = Arrangement.spacedBy(12.dp)
303 | ) {
304 | TextField(
305 | value = value,
306 | onValueChange = onValueChange,
307 | label = stringResource(Res.string.font_weight),
308 | useLabelAsPlaceholder = true,
309 | keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
310 | keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
311 | trailingIcon = {
312 | Text(
313 | text = stringResource(Res.string.font_weight),
314 | fontSize = 13.sp,
315 | modifier = Modifier.padding(horizontal = 16.dp)
316 | )
317 | }
318 | )
319 | Slider(
320 | value = sliderValue,
321 | onValueChange = onSliderChange,
322 | valueRange = 1f..1000f
323 | )
324 | }
325 | }
326 |
327 | @Composable
328 | private fun FontSizeControl(
329 | modifier: Modifier,
330 | value: String,
331 | onValueChange: (String) -> Unit,
332 | sliderValue: Float,
333 | onSliderChange: (Float) -> Unit,
334 | focusManager: FocusManager
335 | ) {
336 | Column(
337 | modifier = modifier,
338 | verticalArrangement = Arrangement.spacedBy(12.dp)
339 | ) {
340 | TextField(
341 | value = value,
342 | onValueChange = onValueChange,
343 | label = stringResource(Res.string.font_size),
344 | useLabelAsPlaceholder = true,
345 | keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
346 | keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
347 | trailingIcon = {
348 | Text(
349 | text = stringResource(Res.string.font_size),
350 | fontSize = 13.sp,
351 | modifier = Modifier.padding(horizontal = 16.dp)
352 | )
353 | }
354 | )
355 | Slider(
356 | value = sliderValue,
357 | onValueChange = onSliderChange,
358 | valueRange = 6f..96f
359 | )
360 | }
361 | }
362 |
363 | @Composable
364 | private fun CustomTextInput(
365 | value: String,
366 | onValueChange: (String) -> Unit,
367 | focusManager: FocusManager
368 | ) {
369 | TextField(
370 | value = value,
371 | onValueChange = onValueChange,
372 | label = stringResource(Res.string.custom_text),
373 | useLabelAsPlaceholder = true,
374 | keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
375 | keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
376 | trailingIcon = {
377 | val clearText = stringResource(Res.string.clear_text)
378 | val customTextLabel = stringResource(Res.string.custom_text)
379 | Text(
380 | text = if (value.isEmpty()) customTextLabel else clearText,
381 | fontSize = 14.sp,
382 | modifier = Modifier
383 | .then(
384 | if (value.isNotEmpty())
385 | Modifier.clickable(
386 | indication = null,
387 | interactionSource = null,
388 | onClick = { onValueChange("") }
389 | )
390 | else Modifier
391 | )
392 | .padding(horizontal = 16.dp)
393 | )
394 | }
395 | )
396 | }
397 |
--------------------------------------------------------------------------------
/iosApp/iosApp.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 60;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; };
11 | 2152FB042600AC8F00CF470E /* iosApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iosApp.swift */; };
12 | 7555FF83242A565900829871 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ContentView.swift */; };
13 | /* End PBXBuildFile section */
14 |
15 | /* Begin PBXFileReference section */
16 | 058557BA273AAA24004C7B11 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
17 | 2152FB032600AC8F00CF470E /* iosApp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = iosApp.swift; sourceTree = ""; };
18 | 7555FF7B242A565900829871 /* FontWeightTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FontWeightTest.app; sourceTree = BUILT_PRODUCTS_DIR; };
19 | 7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; };
20 | 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
21 | AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; };
22 | /* End PBXFileReference section */
23 |
24 | /* Begin PBXFrameworksBuildPhase section */
25 | B92378962B6B1156000C7307 /* Frameworks */ = {
26 | isa = PBXFrameworksBuildPhase;
27 | buildActionMask = 2147483647;
28 | runOnlyForDeploymentPostprocessing = 0;
29 | };
30 | /* End PBXFrameworksBuildPhase section */
31 |
32 | /* Begin PBXGroup section */
33 | 7555FF72242A565900829871 = {
34 | isa = PBXGroup;
35 | children = (
36 | AB1DB47929225F7C00F7AF9C /* Configuration */,
37 | 7555FF7D242A565900829871 /* iosApp */,
38 | 7555FF7C242A565900829871 /* Products */,
39 | 42799AB246E5F90AF97AA0EF /* Frameworks */,
40 | );
41 | sourceTree = "";
42 | };
43 | 7555FF7C242A565900829871 /* Products */ = {
44 | isa = PBXGroup;
45 | children = (
46 | 7555FF7B242A565900829871 /* FontWeightTest.app */,
47 | );
48 | name = Products;
49 | sourceTree = "";
50 | };
51 | 7555FF7D242A565900829871 /* iosApp */ = {
52 | isa = PBXGroup;
53 | children = (
54 | 058557BA273AAA24004C7B11 /* Assets.xcassets */,
55 | 7555FF82242A565900829871 /* ContentView.swift */,
56 | 7555FF8C242A565B00829871 /* Info.plist */,
57 | 2152FB032600AC8F00CF470E /* iosApp.swift */,
58 | );
59 | path = iosApp;
60 | sourceTree = "";
61 | };
62 | AB1DB47929225F7C00F7AF9C /* Configuration */ = {
63 | isa = PBXGroup;
64 | children = (
65 | AB3632DC29227652001CCB65 /* Config.xcconfig */,
66 | );
67 | path = Configuration;
68 | sourceTree = "";
69 | };
70 | /* End PBXGroup section */
71 |
72 | /* Begin PBXNativeTarget section */
73 | 7555FF7A242A565900829871 /* iosApp */ = {
74 | isa = PBXNativeTarget;
75 | buildConfigurationList = 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */;
76 | buildPhases = (
77 | 05EA384A2A8A60F800FD98BE /* Compile Kotlin */,
78 | 7555FF77242A565900829871 /* Sources */,
79 | 7555FF79242A565900829871 /* Resources */,
80 | );
81 | buildRules = (
82 | );
83 | dependencies = (
84 | );
85 | name = iosApp;
86 | productName = iosApp;
87 | productReference = 7555FF7B242A565900829871 /* FontWeightTest.app */;
88 | productType = "com.apple.product-type.application";
89 | };
90 | /* End PBXNativeTarget section */
91 |
92 | /* Begin PBXProject section */
93 | 7555FF73242A565900829871 /* Project object */ = {
94 | isa = PBXProject;
95 | attributes = {
96 | BuildIndependentTargetsInParallel = YES;
97 | LastSwiftUpdateCheck = 1130;
98 | LastUpgradeCheck = 1540;
99 | ORGANIZATIONNAME = orgName;
100 | TargetAttributes = {
101 | 7555FF7A242A565900829871 = {
102 | CreatedOnToolsVersion = 11.3.1;
103 | };
104 | };
105 | };
106 | buildConfigurationList = 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */;
107 | compatibilityVersion = "Xcode 15.0";
108 | developmentRegion = en;
109 | hasScannedForEncodings = 0;
110 | knownRegions = (
111 | en,
112 | Base,
113 | );
114 | mainGroup = 7555FF72242A565900829871;
115 | productRefGroup = 7555FF7C242A565900829871 /* Products */;
116 | projectDirPath = "";
117 | projectRoot = "";
118 | targets = (
119 | 7555FF7A242A565900829871 /* iosApp */,
120 | );
121 | };
122 | /* End PBXProject section */
123 |
124 | /* Begin PBXResourcesBuildPhase section */
125 | 7555FF79242A565900829871 /* Resources */ = {
126 | isa = PBXResourcesBuildPhase;
127 | buildActionMask = 2147483647;
128 | files = (
129 | 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */,
130 | );
131 | runOnlyForDeploymentPostprocessing = 0;
132 | };
133 | /* End PBXResourcesBuildPhase section */
134 |
135 | /* Begin PBXShellScriptBuildPhase section */
136 | 05EA384A2A8A60F800FD98BE /* Compile Kotlin */ = {
137 | isa = PBXShellScriptBuildPhase;
138 | buildActionMask = 2147483647;
139 | files = (
140 | );
141 | inputFileListPaths = (
142 | );
143 | inputPaths = (
144 | );
145 | name = "Compile Kotlin";
146 | outputFileListPaths = (
147 | );
148 | outputPaths = (
149 | );
150 | runOnlyForDeploymentPostprocessing = 0;
151 | shellPath = /bin/sh;
152 | shellScript = "if [ \"YES\" = \"$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED\" ]; then\n echo \"Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \\\"YES\\\"\"\n exit 0\nfi\ncd \"$SRCROOT/..\"\n./gradlew :composeApp:embedAndSignAppleFrameworkForXcode\n";
153 | };
154 | /* End PBXShellScriptBuildPhase section */
155 |
156 | /* Begin PBXSourcesBuildPhase section */
157 | 7555FF77242A565900829871 /* Sources */ = {
158 | isa = PBXSourcesBuildPhase;
159 | buildActionMask = 2147483647;
160 | files = (
161 | 2152FB042600AC8F00CF470E /* iosApp.swift in Sources */,
162 | 7555FF83242A565900829871 /* ContentView.swift in Sources */,
163 | );
164 | runOnlyForDeploymentPostprocessing = 0;
165 | };
166 | /* End PBXSourcesBuildPhase section */
167 |
168 | /* Begin XCBuildConfiguration section */
169 | 7555FFA3242A565B00829871 /* Debug */ = {
170 | isa = XCBuildConfiguration;
171 | baseConfigurationReference = AB3632DC29227652001CCB65 /* Config.xcconfig */;
172 | buildSettings = {
173 | ALWAYS_SEARCH_USER_PATHS = NO;
174 | CLANG_ANALYZER_NONNULL = YES;
175 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
176 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
177 | CLANG_CXX_LIBRARY = "libc++";
178 | CLANG_ENABLE_MODULES = YES;
179 | CLANG_ENABLE_OBJC_ARC = YES;
180 | CLANG_ENABLE_OBJC_WEAK = YES;
181 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
182 | CLANG_WARN_BOOL_CONVERSION = YES;
183 | CLANG_WARN_COMMA = YES;
184 | CLANG_WARN_CONSTANT_CONVERSION = YES;
185 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
186 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
187 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
188 | CLANG_WARN_EMPTY_BODY = YES;
189 | CLANG_WARN_ENUM_CONVERSION = YES;
190 | CLANG_WARN_INFINITE_RECURSION = YES;
191 | CLANG_WARN_INT_CONVERSION = YES;
192 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
193 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
194 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
195 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
196 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
197 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
198 | CLANG_WARN_STRICT_PROTOTYPES = YES;
199 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
200 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
201 | CLANG_WARN_UNREACHABLE_CODE = YES;
202 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
203 | CODE_SIGN_IDENTITY = "Apple Development";
204 | COPY_PHASE_STRIP = NO;
205 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
206 | ENABLE_STRICT_OBJC_MSGSEND = YES;
207 | ENABLE_TESTABILITY = YES;
208 | GCC_C_LANGUAGE_STANDARD = gnu11;
209 | GCC_DYNAMIC_NO_PIC = NO;
210 | GCC_NO_COMMON_BLOCKS = YES;
211 | GCC_OPTIMIZATION_LEVEL = 0;
212 | GCC_PREPROCESSOR_DEFINITIONS = (
213 | "DEBUG=1",
214 | "$(inherited)",
215 | );
216 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
217 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
218 | GCC_WARN_UNDECLARED_SELECTOR = YES;
219 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
220 | GCC_WARN_UNUSED_FUNCTION = YES;
221 | GCC_WARN_UNUSED_VARIABLE = YES;
222 | IPHONEOS_DEPLOYMENT_TARGET = 14.1;
223 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
224 | MTL_FAST_MATH = YES;
225 | ONLY_ACTIVE_ARCH = YES;
226 | SDKROOT = iphoneos;
227 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
228 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
229 | };
230 | name = Debug;
231 | };
232 | 7555FFA4242A565B00829871 /* Release */ = {
233 | isa = XCBuildConfiguration;
234 | baseConfigurationReference = AB3632DC29227652001CCB65 /* Config.xcconfig */;
235 | buildSettings = {
236 | ALWAYS_SEARCH_USER_PATHS = NO;
237 | CLANG_ANALYZER_NONNULL = YES;
238 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
239 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
240 | CLANG_CXX_LIBRARY = "libc++";
241 | CLANG_ENABLE_MODULES = YES;
242 | CLANG_ENABLE_OBJC_ARC = YES;
243 | CLANG_ENABLE_OBJC_WEAK = YES;
244 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
245 | CLANG_WARN_BOOL_CONVERSION = YES;
246 | CLANG_WARN_COMMA = YES;
247 | CLANG_WARN_CONSTANT_CONVERSION = YES;
248 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
249 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
250 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
251 | CLANG_WARN_EMPTY_BODY = YES;
252 | CLANG_WARN_ENUM_CONVERSION = YES;
253 | CLANG_WARN_INFINITE_RECURSION = YES;
254 | CLANG_WARN_INT_CONVERSION = YES;
255 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
256 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
257 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
258 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
259 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
260 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
261 | CLANG_WARN_STRICT_PROTOTYPES = YES;
262 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
263 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
264 | CLANG_WARN_UNREACHABLE_CODE = YES;
265 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
266 | CODE_SIGN_IDENTITY = "Apple Development";
267 | COPY_PHASE_STRIP = NO;
268 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
269 | ENABLE_NS_ASSERTIONS = NO;
270 | ENABLE_STRICT_OBJC_MSGSEND = YES;
271 | GCC_C_LANGUAGE_STANDARD = gnu11;
272 | GCC_NO_COMMON_BLOCKS = YES;
273 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
274 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
275 | GCC_WARN_UNDECLARED_SELECTOR = YES;
276 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
277 | GCC_WARN_UNUSED_FUNCTION = YES;
278 | GCC_WARN_UNUSED_VARIABLE = YES;
279 | IPHONEOS_DEPLOYMENT_TARGET = 14.1;
280 | MTL_ENABLE_DEBUG_INFO = NO;
281 | MTL_FAST_MATH = YES;
282 | SDKROOT = iphoneos;
283 | SWIFT_COMPILATION_MODE = wholemodule;
284 | SWIFT_OPTIMIZATION_LEVEL = "-O";
285 | VALIDATE_PRODUCT = YES;
286 | };
287 | name = Release;
288 | };
289 | 7555FFA6242A565B00829871 /* Debug */ = {
290 | isa = XCBuildConfiguration;
291 | buildSettings = {
292 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
293 | CODE_SIGN_IDENTITY = "Apple Development";
294 | CODE_SIGN_STYLE = Automatic;
295 | DEVELOPMENT_ASSET_PATHS = "";
296 | DEVELOPMENT_TEAM = 29M7Z9F684;
297 | ENABLE_PREVIEWS = YES;
298 | FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../composeApp/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)\n";
299 | INFOPLIST_FILE = iosApp/Info.plist;
300 | IPHONEOS_DEPLOYMENT_TARGET = 16.0;
301 | LD_RUNPATH_SEARCH_PATHS = (
302 | "$(inherited)",
303 | "@executable_path/Frameworks",
304 | );
305 | OTHER_LDFLAGS = (
306 | "$(inherited)",
307 | "-framework",
308 | "shared",
309 | );
310 | PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}";
311 | PRODUCT_NAME = "${APP_NAME}";
312 | PROVISIONING_PROFILE_SPECIFIER = "";
313 | SWIFT_VERSION = 5.0;
314 | TARGETED_DEVICE_FAMILY = "1,2";
315 | };
316 | name = Debug;
317 | };
318 | 7555FFA7242A565B00829871 /* Release */ = {
319 | isa = XCBuildConfiguration;
320 | buildSettings = {
321 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
322 | CODE_SIGN_IDENTITY = "Apple Development";
323 | CODE_SIGN_STYLE = Automatic;
324 | DEVELOPMENT_ASSET_PATHS = "";
325 | DEVELOPMENT_TEAM = 29M7Z9F684;
326 | ENABLE_PREVIEWS = YES;
327 | FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../composeApp/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)\n";
328 | INFOPLIST_FILE = iosApp/Info.plist;
329 | IPHONEOS_DEPLOYMENT_TARGET = 16.0;
330 | LD_RUNPATH_SEARCH_PATHS = (
331 | "$(inherited)",
332 | "@executable_path/Frameworks",
333 | );
334 | OTHER_LDFLAGS = (
335 | "$(inherited)",
336 | "-framework",
337 | "shared",
338 | );
339 | PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}";
340 | PRODUCT_NAME = "${APP_NAME}";
341 | PROVISIONING_PROFILE_SPECIFIER = "";
342 | SWIFT_VERSION = 5.0;
343 | TARGETED_DEVICE_FAMILY = "1,2";
344 | };
345 | name = Release;
346 | };
347 | /* End XCBuildConfiguration section */
348 |
349 | /* Begin XCConfigurationList section */
350 | 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */ = {
351 | isa = XCConfigurationList;
352 | buildConfigurations = (
353 | 7555FFA3242A565B00829871 /* Debug */,
354 | 7555FFA4242A565B00829871 /* Release */,
355 | );
356 | defaultConfigurationIsVisible = 0;
357 | defaultConfigurationName = Release;
358 | };
359 | 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */ = {
360 | isa = XCConfigurationList;
361 | buildConfigurations = (
362 | 7555FFA6242A565B00829871 /* Debug */,
363 | 7555FFA7242A565B00829871 /* Release */,
364 | );
365 | defaultConfigurationIsVisible = 0;
366 | defaultConfigurationName = Release;
367 | };
368 | /* End XCConfigurationList section */
369 | };
370 | rootObject = 7555FF73242A565900829871 /* Project object */;
371 | }
372 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU AFFERO GENERAL PUBLIC LICENSE
2 | Version 3, 19 November 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU Affero General Public License is a free, copyleft license for
11 | software and other kinds of works, specifically designed to ensure
12 | cooperation with the community in the case of network server software.
13 |
14 | The licenses for most software and other practical works are designed
15 | to take away your freedom to share and change the works. By contrast,
16 | our General Public Licenses are intended to guarantee your freedom to
17 | share and change all versions of a program--to make sure it remains free
18 | software for all its users.
19 |
20 | When we speak of free software, we are referring to freedom, not
21 | price. Our General Public Licenses are designed to make sure that you
22 | have the freedom to distribute copies of free software (and charge for
23 | them if you wish), that you receive source code or can get it if you
24 | want it, that you can change the software or use pieces of it in new
25 | free programs, and that you know you can do these things.
26 |
27 | Developers that use our General Public Licenses protect your rights
28 | with two steps: (1) assert copyright on the software, and (2) offer
29 | you this License which gives you legal permission to copy, distribute
30 | and/or modify the software.
31 |
32 | A secondary benefit of defending all users' freedom is that
33 | improvements made in alternate versions of the program, if they
34 | receive widespread use, become available for other developers to
35 | incorporate. Many developers of free software are heartened and
36 | encouraged by the resulting cooperation. However, in the case of
37 | software used on network servers, this result may fail to come about.
38 | The GNU General Public License permits making a modified version and
39 | letting the public access it on a server without ever releasing its
40 | source code to the public.
41 |
42 | The GNU Affero General Public License is designed specifically to
43 | ensure that, in such cases, the modified source code becomes available
44 | to the community. It requires the operator of a network server to
45 | provide the source code of the modified version running there to the
46 | users of that server. Therefore, public use of a modified version, on
47 | a publicly accessible server, gives the public access to the source
48 | code of the modified version.
49 |
50 | An older license, called the Affero General Public License and
51 | published by Affero, was designed to accomplish similar goals. This is
52 | a different license, not a version of the Affero GPL, but Affero has
53 | released a new version of the Affero GPL which permits relicensing under
54 | this license.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | TERMS AND CONDITIONS
60 |
61 | 0. Definitions.
62 |
63 | "This License" refers to version 3 of the GNU Affero General Public License.
64 |
65 | "Copyright" also means copyright-like laws that apply to other kinds of
66 | works, such as semiconductor masks.
67 |
68 | "The Program" refers to any copyrightable work licensed under this
69 | License. Each licensee is addressed as "you". "Licensees" and
70 | "recipients" may be individuals or organizations.
71 |
72 | To "modify" a work means to copy from or adapt all or part of the work
73 | in a fashion requiring copyright permission, other than the making of an
74 | exact copy. The resulting work is called a "modified version" of the
75 | earlier work or a work "based on" the earlier work.
76 |
77 | A "covered work" means either the unmodified Program or a work based
78 | on the Program.
79 |
80 | To "propagate" a work means to do anything with it that, without
81 | permission, would make you directly or secondarily liable for
82 | infringement under applicable copyright law, except executing it on a
83 | computer or modifying a private copy. Propagation includes copying,
84 | distribution (with or without modification), making available to the
85 | public, and in some countries other activities as well.
86 |
87 | To "convey" a work means any kind of propagation that enables other
88 | parties to make or receive copies. Mere interaction with a user through
89 | a computer network, with no transfer of a copy, is not conveying.
90 |
91 | An interactive user interface displays "Appropriate Legal Notices"
92 | to the extent that it includes a convenient and prominently visible
93 | feature that (1) displays an appropriate copyright notice, and (2)
94 | tells the user that there is no warranty for the work (except to the
95 | extent that warranties are provided), that licensees may convey the
96 | work under this License, and how to view a copy of this License. If
97 | the interface presents a list of user commands or options, such as a
98 | menu, a prominent item in the list meets this criterion.
99 |
100 | 1. Source Code.
101 |
102 | The "source code" for a work means the preferred form of the work
103 | for making modifications to it. "Object code" means any non-source
104 | form of a work.
105 |
106 | A "Standard Interface" means an interface that either is an official
107 | standard defined by a recognized standards body, or, in the case of
108 | interfaces specified for a particular programming language, one that
109 | is widely used among developers working in that language.
110 |
111 | The "System Libraries" of an executable work include anything, other
112 | than the work as a whole, that (a) is included in the normal form of
113 | packaging a Major Component, but which is not part of that Major
114 | Component, and (b) serves only to enable use of the work with that
115 | Major Component, or to implement a Standard Interface for which an
116 | implementation is available to the public in source code form. A
117 | "Major Component", in this context, means a major essential component
118 | (kernel, window system, and so on) of the specific operating system
119 | (if any) on which the executable work runs, or a compiler used to
120 | produce the work, or an object code interpreter used to run it.
121 |
122 | The "Corresponding Source" for a work in object code form means all
123 | the source code needed to generate, install, and (for an executable
124 | work) run the object code and to modify the work, including scripts to
125 | control those activities. However, it does not include the work's
126 | System Libraries, or general-purpose tools or generally available free
127 | programs which are used unmodified in performing those activities but
128 | which are not part of the work. For example, Corresponding Source
129 | includes interface definition files associated with source files for
130 | the work, and the source code for shared libraries and dynamically
131 | linked subprograms that the work is specifically designed to require,
132 | such as by intimate data communication or control flow between those
133 | subprograms and other parts of the work.
134 |
135 | The Corresponding Source need not include anything that users
136 | can regenerate automatically from other parts of the Corresponding
137 | Source.
138 |
139 | The Corresponding Source for a work in source code form is that
140 | same work.
141 |
142 | 2. Basic Permissions.
143 |
144 | All rights granted under this License are granted for the term of
145 | copyright on the Program, and are irrevocable provided the stated
146 | conditions are met. This License explicitly affirms your unlimited
147 | permission to run the unmodified Program. The output from running a
148 | covered work is covered by this License only if the output, given its
149 | content, constitutes a covered work. This License acknowledges your
150 | rights of fair use or other equivalent, as provided by copyright law.
151 |
152 | You may make, run and propagate covered works that you do not
153 | convey, without conditions so long as your license otherwise remains
154 | in force. You may convey covered works to others for the sole purpose
155 | of having them make modifications exclusively for you, or provide you
156 | with facilities for running those works, provided that you comply with
157 | the terms of this License in conveying all material for which you do
158 | not control copyright. Those thus making or running the covered works
159 | for you must do so exclusively on your behalf, under your direction
160 | and control, on terms that prohibit them from making any copies of
161 | your copyrighted material outside their relationship with you.
162 |
163 | Conveying under any other circumstances is permitted solely under
164 | the conditions stated below. Sublicensing is not allowed; section 10
165 | makes it unnecessary.
166 |
167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168 |
169 | No covered work shall be deemed part of an effective technological
170 | measure under any applicable law fulfilling obligations under article
171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172 | similar laws prohibiting or restricting circumvention of such
173 | measures.
174 |
175 | When you convey a covered work, you waive any legal power to forbid
176 | circumvention of technological measures to the extent such circumvention
177 | is effected by exercising rights under this License with respect to
178 | the covered work, and you disclaim any intention to limit operation or
179 | modification of the work as a means of enforcing, against the work's
180 | users, your or third parties' legal rights to forbid circumvention of
181 | technological measures.
182 |
183 | 4. Conveying Verbatim Copies.
184 |
185 | You may convey verbatim copies of the Program's source code as you
186 | receive it, in any medium, provided that you conspicuously and
187 | appropriately publish on each copy an appropriate copyright notice;
188 | keep intact all notices stating that this License and any
189 | non-permissive terms added in accord with section 7 apply to the code;
190 | keep intact all notices of the absence of any warranty; and give all
191 | recipients a copy of this License along with the Program.
192 |
193 | You may charge any price or no price for each copy that you convey,
194 | and you may offer support or warranty protection for a fee.
195 |
196 | 5. Conveying Modified Source Versions.
197 |
198 | You may convey a work based on the Program, or the modifications to
199 | produce it from the Program, in the form of source code under the
200 | terms of section 4, provided that you also meet all of these conditions:
201 |
202 | a) The work must carry prominent notices stating that you modified
203 | it, and giving a relevant date.
204 |
205 | b) The work must carry prominent notices stating that it is
206 | released under this License and any conditions added under section
207 | 7. This requirement modifies the requirement in section 4 to
208 | "keep intact all notices".
209 |
210 | c) You must license the entire work, as a whole, under this
211 | License to anyone who comes into possession of a copy. This
212 | License will therefore apply, along with any applicable section 7
213 | additional terms, to the whole of the work, and all its parts,
214 | regardless of how they are packaged. This License gives no
215 | permission to license the work in any other way, but it does not
216 | invalidate such permission if you have separately received it.
217 |
218 | d) If the work has interactive user interfaces, each must display
219 | Appropriate Legal Notices; however, if the Program has interactive
220 | interfaces that do not display Appropriate Legal Notices, your
221 | work need not make them do so.
222 |
223 | A compilation of a covered work with other separate and independent
224 | works, which are not by their nature extensions of the covered work,
225 | and which are not combined with it such as to form a larger program,
226 | in or on a volume of a storage or distribution medium, is called an
227 | "aggregate" if the compilation and its resulting copyright are not
228 | used to limit the access or legal rights of the compilation's users
229 | beyond what the individual works permit. Inclusion of a covered work
230 | in an aggregate does not cause this License to apply to the other
231 | parts of the aggregate.
232 |
233 | 6. Conveying Non-Source Forms.
234 |
235 | You may convey a covered work in object code form under the terms
236 | of sections 4 and 5, provided that you also convey the
237 | machine-readable Corresponding Source under the terms of this License,
238 | in one of these ways:
239 |
240 | a) Convey the object code in, or embodied in, a physical product
241 | (including a physical distribution medium), accompanied by the
242 | Corresponding Source fixed on a durable physical medium
243 | customarily used for software interchange.
244 |
245 | b) Convey the object code in, or embodied in, a physical product
246 | (including a physical distribution medium), accompanied by a
247 | written offer, valid for at least three years and valid for as
248 | long as you offer spare parts or customer support for that product
249 | model, to give anyone who possesses the object code either (1) a
250 | copy of the Corresponding Source for all the software in the
251 | product that is covered by this License, on a durable physical
252 | medium customarily used for software interchange, for a price no
253 | more than your reasonable cost of physically performing this
254 | conveying of source, or (2) access to copy the
255 | Corresponding Source from a network server at no charge.
256 |
257 | c) Convey individual copies of the object code with a copy of the
258 | written offer to provide the Corresponding Source. This
259 | alternative is allowed only occasionally and noncommercially, and
260 | only if you received the object code with such an offer, in accord
261 | with subsection 6b.
262 |
263 | d) Convey the object code by offering access from a designated
264 | place (gratis or for a charge), and offer equivalent access to the
265 | Corresponding Source in the same way through the same place at no
266 | further charge. You need not require recipients to copy the
267 | Corresponding Source along with the object code. If the place to
268 | copy the object code is a network server, the Corresponding Source
269 | may be on a different server (operated by you or a third party)
270 | that supports equivalent copying facilities, provided you maintain
271 | clear directions next to the object code saying where to find the
272 | Corresponding Source. Regardless of what server hosts the
273 | Corresponding Source, you remain obligated to ensure that it is
274 | available for as long as needed to satisfy these requirements.
275 |
276 | e) Convey the object code using peer-to-peer transmission, provided
277 | you inform other peers where the object code and Corresponding
278 | Source of the work are being offered to the general public at no
279 | charge under subsection 6d.
280 |
281 | A separable portion of the object code, whose source code is excluded
282 | from the Corresponding Source as a System Library, need not be
283 | included in conveying the object code work.
284 |
285 | A "User Product" is either (1) a "consumer product", which means any
286 | tangible personal property which is normally used for personal, family,
287 | or household purposes, or (2) anything designed or sold for incorporation
288 | into a dwelling. In determining whether a product is a consumer product,
289 | doubtful cases shall be resolved in favor of coverage. For a particular
290 | product received by a particular user, "normally used" refers to a
291 | typical or common use of that class of product, regardless of the status
292 | of the particular user or of the way in which the particular user
293 | actually uses, or expects or is expected to use, the product. A product
294 | is a consumer product regardless of whether the product has substantial
295 | commercial, industrial or non-consumer uses, unless such uses represent
296 | the only significant mode of use of the product.
297 |
298 | "Installation Information" for a User Product means any methods,
299 | procedures, authorization keys, or other information required to install
300 | and execute modified versions of a covered work in that User Product from
301 | a modified version of its Corresponding Source. The information must
302 | suffice to ensure that the continued functioning of the modified object
303 | code is in no case prevented or interfered with solely because
304 | modification has been made.
305 |
306 | If you convey an object code work under this section in, or with, or
307 | specifically for use in, a User Product, and the conveying occurs as
308 | part of a transaction in which the right of possession and use of the
309 | User Product is transferred to the recipient in perpetuity or for a
310 | fixed term (regardless of how the transaction is characterized), the
311 | Corresponding Source conveyed under this section must be accompanied
312 | by the Installation Information. But this requirement does not apply
313 | if neither you nor any third party retains the ability to install
314 | modified object code on the User Product (for example, the work has
315 | been installed in ROM).
316 |
317 | The requirement to provide Installation Information does not include a
318 | requirement to continue to provide support service, warranty, or updates
319 | for a work that has been modified or installed by the recipient, or for
320 | the User Product in which it has been modified or installed. Access to a
321 | network may be denied when the modification itself materially and
322 | adversely affects the operation of the network or violates the rules and
323 | protocols for communication across the network.
324 |
325 | Corresponding Source conveyed, and Installation Information provided,
326 | in accord with this section must be in a format that is publicly
327 | documented (and with an implementation available to the public in
328 | source code form), and must require no special password or key for
329 | unpacking, reading or copying.
330 |
331 | 7. Additional Terms.
332 |
333 | "Additional permissions" are terms that supplement the terms of this
334 | License by making exceptions from one or more of its conditions.
335 | Additional permissions that are applicable to the entire Program shall
336 | be treated as though they were included in this License, to the extent
337 | that they are valid under applicable law. If additional permissions
338 | apply only to part of the Program, that part may be used separately
339 | under those permissions, but the entire Program remains governed by
340 | this License without regard to the additional permissions.
341 |
342 | When you convey a copy of a covered work, you may at your option
343 | remove any additional permissions from that copy, or from any part of
344 | it. (Additional permissions may be written to require their own
345 | removal in certain cases when you modify the work.) You may place
346 | additional permissions on material, added by you to a covered work,
347 | for which you have or can give appropriate copyright permission.
348 |
349 | Notwithstanding any other provision of this License, for material you
350 | add to a covered work, you may (if authorized by the copyright holders of
351 | that material) supplement the terms of this License with terms:
352 |
353 | a) Disclaiming warranty or limiting liability differently from the
354 | terms of sections 15 and 16 of this License; or
355 |
356 | b) Requiring preservation of specified reasonable legal notices or
357 | author attributions in that material or in the Appropriate Legal
358 | Notices displayed by works containing it; or
359 |
360 | c) Prohibiting misrepresentation of the origin of that material, or
361 | requiring that modified versions of such material be marked in
362 | reasonable ways as different from the original version; or
363 |
364 | d) Limiting the use for publicity purposes of names of licensors or
365 | authors of the material; or
366 |
367 | e) Declining to grant rights under trademark law for use of some
368 | trade names, trademarks, or service marks; or
369 |
370 | f) Requiring indemnification of licensors and authors of that
371 | material by anyone who conveys the material (or modified versions of
372 | it) with contractual assumptions of liability to the recipient, for
373 | any liability that these contractual assumptions directly impose on
374 | those licensors and authors.
375 |
376 | All other non-permissive additional terms are considered "further
377 | restrictions" within the meaning of section 10. If the Program as you
378 | received it, or any part of it, contains a notice stating that it is
379 | governed by this License along with a term that is a further
380 | restriction, you may remove that term. If a license document contains
381 | a further restriction but permits relicensing or conveying under this
382 | License, you may add to a covered work material governed by the terms
383 | of that license document, provided that the further restriction does
384 | not survive such relicensing or conveying.
385 |
386 | If you add terms to a covered work in accord with this section, you
387 | must place, in the relevant source files, a statement of the
388 | additional terms that apply to those files, or a notice indicating
389 | where to find the applicable terms.
390 |
391 | Additional terms, permissive or non-permissive, may be stated in the
392 | form of a separately written license, or stated as exceptions;
393 | the above requirements apply either way.
394 |
395 | 8. Termination.
396 |
397 | You may not propagate or modify a covered work except as expressly
398 | provided under this License. Any attempt otherwise to propagate or
399 | modify it is void, and will automatically terminate your rights under
400 | this License (including any patent licenses granted under the third
401 | paragraph of section 11).
402 |
403 | However, if you cease all violation of this License, then your
404 | license from a particular copyright holder is reinstated (a)
405 | provisionally, unless and until the copyright holder explicitly and
406 | finally terminates your license, and (b) permanently, if the copyright
407 | holder fails to notify you of the violation by some reasonable means
408 | prior to 60 days after the cessation.
409 |
410 | Moreover, your license from a particular copyright holder is
411 | reinstated permanently if the copyright holder notifies you of the
412 | violation by some reasonable means, this is the first time you have
413 | received notice of violation of this License (for any work) from that
414 | copyright holder, and you cure the violation prior to 30 days after
415 | your receipt of the notice.
416 |
417 | Termination of your rights under this section does not terminate the
418 | licenses of parties who have received copies or rights from you under
419 | this License. If your rights have been terminated and not permanently
420 | reinstated, you do not qualify to receive new licenses for the same
421 | material under section 10.
422 |
423 | 9. Acceptance Not Required for Having Copies.
424 |
425 | You are not required to accept this License in order to receive or
426 | run a copy of the Program. Ancillary propagation of a covered work
427 | occurring solely as a consequence of using peer-to-peer transmission
428 | to receive a copy likewise does not require acceptance. However,
429 | nothing other than this License grants you permission to propagate or
430 | modify any covered work. These actions infringe copyright if you do
431 | not accept this License. Therefore, by modifying or propagating a
432 | covered work, you indicate your acceptance of this License to do so.
433 |
434 | 10. Automatic Licensing of Downstream Recipients.
435 |
436 | Each time you convey a covered work, the recipient automatically
437 | receives a license from the original licensors, to run, modify and
438 | propagate that work, subject to this License. You are not responsible
439 | for enforcing compliance by third parties with this License.
440 |
441 | An "entity transaction" is a transaction transferring control of an
442 | organization, or substantially all assets of one, or subdividing an
443 | organization, or merging organizations. If propagation of a covered
444 | work results from an entity transaction, each party to that
445 | transaction who receives a copy of the work also receives whatever
446 | licenses to the work the party's predecessor in interest had or could
447 | give under the previous paragraph, plus a right to possession of the
448 | Corresponding Source of the work from the predecessor in interest, if
449 | the predecessor has it or can get it with reasonable efforts.
450 |
451 | You may not impose any further restrictions on the exercise of the
452 | rights granted or affirmed under this License. For example, you may
453 | not impose a license fee, royalty, or other charge for exercise of
454 | rights granted under this License, and you may not initiate litigation
455 | (including a cross-claim or counterclaim in a lawsuit) alleging that
456 | any patent claim is infringed by making, using, selling, offering for
457 | sale, or importing the Program or any portion of it.
458 |
459 | 11. Patents.
460 |
461 | A "contributor" is a copyright holder who authorizes use under this
462 | License of the Program or a work on which the Program is based. The
463 | work thus licensed is called the contributor's "contributor version".
464 |
465 | A contributor's "essential patent claims" are all patent claims
466 | owned or controlled by the contributor, whether already acquired or
467 | hereafter acquired, that would be infringed by some manner, permitted
468 | by this License, of making, using, or selling its contributor version,
469 | but do not include claims that would be infringed only as a
470 | consequence of further modification of the contributor version. For
471 | purposes of this definition, "control" includes the right to grant
472 | patent sublicenses in a manner consistent with the requirements of
473 | this License.
474 |
475 | Each contributor grants you a non-exclusive, worldwide, royalty-free
476 | patent license under the contributor's essential patent claims, to
477 | make, use, sell, offer for sale, import and otherwise run, modify and
478 | propagate the contents of its contributor version.
479 |
480 | In the following three paragraphs, a "patent license" is any express
481 | agreement or commitment, however denominated, not to enforce a patent
482 | (such as an express permission to practice a patent or covenant not to
483 | sue for patent infringement). To "grant" such a patent license to a
484 | party means to make such an agreement or commitment not to enforce a
485 | patent against the party.
486 |
487 | If you convey a covered work, knowingly relying on a patent license,
488 | and the Corresponding Source of the work is not available for anyone
489 | to copy, free of charge and under the terms of this License, through a
490 | publicly available network server or other readily accessible means,
491 | then you must either (1) cause the Corresponding Source to be so
492 | available, or (2) arrange to deprive yourself of the benefit of the
493 | patent license for this particular work, or (3) arrange, in a manner
494 | consistent with the requirements of this License, to extend the patent
495 | license to downstream recipients. "Knowingly relying" means you have
496 | actual knowledge that, but for the patent license, your conveying the
497 | covered work in a country, or your recipient's use of the covered work
498 | in a country, would infringe one or more identifiable patents in that
499 | country that you have reason to believe are valid.
500 |
501 | If, pursuant to or in connection with a single transaction or
502 | arrangement, you convey, or propagate by procuring conveyance of, a
503 | covered work, and grant a patent license to some of the parties
504 | receiving the covered work authorizing them to use, propagate, modify
505 | or convey a specific copy of the covered work, then the patent license
506 | you grant is automatically extended to all recipients of the covered
507 | work and works based on it.
508 |
509 | A patent license is "discriminatory" if it does not include within
510 | the scope of its coverage, prohibits the exercise of, or is
511 | conditioned on the non-exercise of one or more of the rights that are
512 | specifically granted under this License. You may not convey a covered
513 | work if you are a party to an arrangement with a third party that is
514 | in the business of distributing software, under which you make payment
515 | to the third party based on the extent of your activity of conveying
516 | the work, and under which the third party grants, to any of the
517 | parties who would receive the covered work from you, a discriminatory
518 | patent license (a) in connection with copies of the covered work
519 | conveyed by you (or copies made from those copies), or (b) primarily
520 | for and in connection with specific products or compilations that
521 | contain the covered work, unless you entered into that arrangement,
522 | or that patent license was granted, prior to 28 March 2007.
523 |
524 | Nothing in this License shall be construed as excluding or limiting
525 | any implied license or other defenses to infringement that may
526 | otherwise be available to you under applicable patent law.
527 |
528 | 12. No Surrender of Others' Freedom.
529 |
530 | If conditions are imposed on you (whether by court order, agreement or
531 | otherwise) that contradict the conditions of this License, they do not
532 | excuse you from the conditions of this License. If you cannot convey a
533 | covered work so as to satisfy simultaneously your obligations under this
534 | License and any other pertinent obligations, then as a consequence you may
535 | not convey it at all. For example, if you agree to terms that obligate you
536 | to collect a royalty for further conveying from those to whom you convey
537 | the Program, the only way you could satisfy both those terms and this
538 | License would be to refrain entirely from conveying the Program.
539 |
540 | 13. Remote Network Interaction; Use with the GNU General Public License.
541 |
542 | Notwithstanding any other provision of this License, if you modify the
543 | Program, your modified version must prominently offer all users
544 | interacting with it remotely through a computer network (if your version
545 | supports such interaction) an opportunity to receive the Corresponding
546 | Source of your version by providing access to the Corresponding Source
547 | from a network server at no charge, through some standard or customary
548 | means of facilitating copying of software. This Corresponding Source
549 | shall include the Corresponding Source for any work covered by version 3
550 | of the GNU General Public License that is incorporated pursuant to the
551 | following paragraph.
552 |
553 | Notwithstanding any other provision of this License, you have
554 | permission to link or combine any covered work with a work licensed
555 | under version 3 of the GNU General Public License into a single
556 | combined work, and to convey the resulting work. The terms of this
557 | License will continue to apply to the part which is the covered work,
558 | but the work with which it is combined will remain governed by version
559 | 3 of the GNU General Public License.
560 |
561 | 14. Revised Versions of this License.
562 |
563 | The Free Software Foundation may publish revised and/or new versions of
564 | the GNU Affero General Public License from time to time. Such new versions
565 | will be similar in spirit to the present version, but may differ in detail to
566 | address new problems or concerns.
567 |
568 | Each version is given a distinguishing version number. If the
569 | Program specifies that a certain numbered version of the GNU Affero General
570 | Public License "or any later version" applies to it, you have the
571 | option of following the terms and conditions either of that numbered
572 | version or of any later version published by the Free Software
573 | Foundation. If the Program does not specify a version number of the
574 | GNU Affero General Public License, you may choose any version ever published
575 | by the Free Software Foundation.
576 |
577 | If the Program specifies that a proxy can decide which future
578 | versions of the GNU Affero General Public License can be used, that proxy's
579 | public statement of acceptance of a version permanently authorizes you
580 | to choose that version for the Program.
581 |
582 | Later license versions may give you additional or different
583 | permissions. However, no additional obligations are imposed on any
584 | author or copyright holder as a result of your choosing to follow a
585 | later version.
586 |
587 | 15. Disclaimer of Warranty.
588 |
589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597 |
598 | 16. Limitation of Liability.
599 |
600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608 | SUCH DAMAGES.
609 |
610 | 17. Interpretation of Sections 15 and 16.
611 |
612 | If the disclaimer of warranty and limitation of liability provided
613 | above cannot be given local legal effect according to their terms,
614 | reviewing courts shall apply local law that most closely approximates
615 | an absolute waiver of all civil liability in connection with the
616 | Program, unless a warranty or assumption of liability accompanies a
617 | copy of the Program in return for a fee.
618 |
619 | END OF TERMS AND CONDITIONS
620 |
621 | How to Apply These Terms to Your New Programs
622 |
623 | If you develop a new program, and you want it to be of the greatest
624 | possible use to the public, the best way to achieve this is to make it
625 | free software which everyone can redistribute and change under these terms.
626 |
627 | To do so, attach the following notices to the program. It is safest
628 | to attach them to the start of each source file to most effectively
629 | state the exclusion of warranty; and each file should have at least
630 | the "copyright" line and a pointer to where the full notice is found.
631 |
632 |
633 | Copyright (C)
634 |
635 | This program is free software: you can redistribute it and/or modify
636 | it under the terms of the GNU Affero General Public License as published
637 | by the Free Software Foundation, either version 3 of the License, or
638 | (at your option) any later version.
639 |
640 | This program is distributed in the hope that it will be useful,
641 | but WITHOUT ANY WARRANTY; without even the implied warranty of
642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643 | GNU Affero General Public License for more details.
644 |
645 | You should have received a copy of the GNU Affero General Public License
646 | along with this program. If not, see .
647 |
648 | Also add information on how to contact you by electronic and paper mail.
649 |
650 | If your software can interact with users remotely through a computer
651 | network, you should also make sure that it provides a way for users to
652 | get its source. For example, if your program is a web application, its
653 | interface could display a "Source" link that leads users to an archive
654 | of the code. There are many ways you could offer source, and different
655 | solutions will be better for different programs; see section 13 for the
656 | specific requirements.
657 |
658 | You should also get your employer (if you work as a programmer) or school,
659 | if any, to sign a "copyright disclaimer" for the program, if necessary.
660 | For more information on this, and how to apply and follow the GNU AGPL, see
661 | .
662 |
--------------------------------------------------------------------------------