目录
目录README.md

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)
}
关于
51.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号