Makes possible to use icons from a font in JetBrains Compose Multiplatform. Currently supported targets are Android, Desktop (JVM), Web (JS and WASM), macOS, and iOS.
Note
iOS and macOS are not tested as much as the other targets. There should not be any issue however, since they use the same rendering as every other non-Android target.
This library supports the Compose Multiplatform Common resources API alongside platform-specific resources like resource IDs for Android, classpath resources for JVM...
Variable fonts are supported, the optical size (opsz
) and weight (wgth
) axes will be set automatically depending on the
icon size and provided parameters.
Important
Due to a limitation in the Android API, Android versions older that Oreo (API 26) don't support variable fonts.
This library is available on Maven Central and GitHub Packages.
Add this to your build.gradle(.kts):
dependencies {
implementation("dev.tclement.fonticons:MODULE:VERSION")
}
The main module, providing the core functionality of the library.
An additional module providing support for AndroidX Glance (Android App Widgets / WearOS Tiles). This is the only module that is only compatible with Android.
This module provides support for the Font Awesome Free font. An icon can be referenced by its name, for example
FontAwesome.Regular.Star
. The fonts are not provided in this module, they must either be provided by the user or by
using the packaged font modules.
Packaged variants of the Font Awesome Free font1. These modules provide their corresponding font as a resource and a
function to create this font (rememberBrandsFontAwesomeFont
, rememberRegularFontAwesomeFont
or
rememberSolidFontAwesomeFont
).
This module provides support for the Material Symbols variable font. An icon can be referenced by its name, for example
MaterialSymbols.Star
. The fonts are not provided in this module, they must either be provided by the user or by using
one of the packaged font modules.
Caution
Android API 25 and lower don't support variable fonts, this means that variations won't be applied. This font will default to its default settings on those versions.
Packaged variants of the Material Symbols variable font2. These modules provide their corresponding font as a
resource and a function to create this font (rememberOutlinedSymbolsFont
, rememberRoundedSymbolsFont
or
rememberMaterialSymbolsFont
).
(Optional) Set the default icon parameters:
ProvideIconParameters(
iconFont = your_font, // ex: for outlined Material Symbols: rememberOutlinedMaterialSymbolsFont()
tintProvider = LocalContentColor
) {
// icons here will have by default the params declared above
}
Tip
Using ProvideIconParameters
(or equivalent) is recommended. Otherwise, the parameters iconFont
and tint
must be
provided for each icon.
You can then use the FontIcon
composable to display an icon:
FontIcon(
icon = MaterialSymbols.Star,
contentDescription = null
)
An alternative function that takes a String
instead of a Char
is also available, for fonts that supports ligatures:
FontIcon(
iconName = "star",
contentDescription = null
)
Read the full API reference here for advanced usage and additional information.
Copyright 2024 T. Clément (@tclement0922) and contributors
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.
Footnotes
-
The Font Awesome Free fonts are licensed under the SIL OFL 1.1 license ↩
-
The Material Symbols fonts are licensed under the Apache 2.0 license ↩