Skip to content

A library to read/write UFO fonts on the JVM.

License

Notifications You must be signed in to change notification settings

adrientetar/kotlin-ufo

Repository files navigation

kotlin-ufo

A library to read/write UFO fonts

Kotlin Apache 2.0 Code coverage

With this library, one can generate UFO fonts, which in turn allows using the fontmake compiler.

This project is currently in very early stage and cannot be used to make fonts. Only UFO 3 is supported.

  • Font info ✅
  • Foreground layer glyphs ✅
  • Font lib ✅
  • Remaining: other layers, features, groups/kerning, other libs, data...

Usage

Read

import com.google.common.truth.Truth.assertThat
import dev.adrientetar.kotlin.ufo.UFOReader
import java.nio.file.Paths

val path = Paths.get("/usr/share/MyFont-Regular.ufo")

val reader = UFOReader(path)
val info = reader.readFontInfo()

assertThat(info.familyName).isEqualTo("My Font")
assertThat(info.styleName).isEqualTo("Regular")

Write

import dev.adrientetar.kotlin.ufo.FontInfoValues
import dev.adrientetar.kotlin.ufo.UFOWriter
import java.nio.file.Paths

val path = Paths.get("/usr/share/MyFont-Regular.ufo")

val info = FontInfoValues().apply {
    familyName = "My Font"
    styleName = "Regular"
}

val writer = UFOWriter(path)
writer.writeFontInfo(info)

See the tests for more sample code.

Contributions

I would like to have help with the following:

  • Adding support to read/write more things (with tests 😀)
  • Writing tests: we can port some tests from fontTools.ufoLib, and write to a virtual filesystem to keep the tests fast to run.
  • Adding a pipeline to validate exported API, so that we don’t export unintended symbols in the library and can monitor backwards incompatible changes.

If you want to make a non-trivial contribution, consider coordinating with me and sharing design details beforehand if applicable. Thanks!

About

A library to read/write UFO fonts on the JVM.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages