CoreTextSwift

0.2

CoreText Swift bindings
krzyzanowskim/CoreTextSwift

What's New

2024-06-23T22:56:29Z

CoreTextSwift

Swifty CoreText API.

CoreText is C API. This library is a set of wrappers and extensions that makes it convenient to work with Swift.

Example

Draw line in currect graphics context

guard let ctx = UIGraphicsGetCurrentContext() else {
  return
}

let attributedString = NSAttributedString(string: "abcdefgh")
ctx.draw(attributedString.line())

Use Glyph Run

let attributedString = NSAttributedString(string: "abcdefgh")

for run in attributedString.line().glyphRuns() {
  let font = run.font
  for glyph in run.glyphs() {
    let glyphPath = font.path(for: glyph)
  }
}

Draw Glyph Run to CGContext

guard let ctx = UIGraphicsGetCurrentContext() else {
  return
}

for run in attributedString.line().glyphRuns() {
  run.draw(in: ctx)
}

Description

  • Swift Tools 5.5.0
View More Packages from this Author

Dependencies

  • None
Last updated: Thu Oct 17 2024 19:26:39 GMT-0900 (Hawaii-Aleutian Daylight Time)