Skip to content

tclement0922/compose-font-icons

Repository files navigation

Compose Font Icons for Kotlin Multiplatform

License GitHub release

Makes possible to use icons from a font in JetBrains Compose Multiplatform. Currently supported targets are Android, Desktop (JVM) and Web (JS). An additional library is available for AndroidX Glance (Android App Widgets / WearOS Tiles).

Setup

This library is (for now) only available in GitHub Packages.

For Gradle Kotlin Dsl:

repositories {
    maven {
        url = uri("https://maven.pkg.github.com/tclement0922/compose-font-icons")
        credentials {
            // replace with your username
            username = "YOUR_USERNAME"
            // replace with a personal access token (classic) that has at least the :read_packages scope and linked to the username above
            password = "YOUR_GITHUB_TOKEN"
        }
    }
}

dependencies {
    implementation("dev.tclement.fonticons:ARTIFACT:VERSION")
    ...
}

Available artifacts

Artifact Artifact description Supported platforms
Android Desktop (JVM) Web (JS)
core Main artifact ✔️ ✔️ ✔️
core-glance AndroidX Glance support ✔️
font-symbols Material Symbols common class ✔️ ✔️ ✔️
font-symbols-[outlined|rounded|sharp] Material Symbols variants ✔️ ✔️

Note

Web (WASM) support is planned, but won't happen until JetBrains releases compatible artifacts in their stable maven repo

IOS won't be supported unless I get a Mac (or someone else contributes)

Usage

Set the default icon parameters:

ProvideIconParameters(
    iconFont = rememberVariableIconFont(params...), // ex: for outlined symbols: rememberOutlinedMaterialSymbolsFont()
    tintProvider = LocalContentColor
) {
    // icons here will have by default the params declared above
}

Then:

FontIcon(
    iconName = "account_circle",
    contentDescription = null
)

Or for Material Symbols:

FontIcon(
    icon = MaterialSymbols.AccountCircle,
    contentDescription = null
)

Read the full doc here.

License

     Copyright 2024 T. Clément (@tclement0922)
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
      http://www.apache.org/licenses/LICENSE-2.0
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.