PhotoEditor+Font.swift 722 B

12345678910111213141516171819202122232425262728
  1. //
  2. // PhotoEditor+Font.swift
  3. //
  4. //
  5. // Created by Mohamed Hamed on 6/16/17.
  6. //
  7. //
  8. import Foundation
  9. import UIKit
  10. extension PhotoEditorViewController {
  11. //Resources don't load in main bundle we have to register the font
  12. func registerFont(){
  13. let bundle = Bundle(for: PhotoEditorViewController.self)
  14. let url = bundle.url(forResource: "icomoon", withExtension: "ttf")
  15. guard let fontDataProvider = CGDataProvider(url: url! as CFURL) else {
  16. return
  17. }
  18. guard let font = CGFont(fontDataProvider) else {return}
  19. var error: Unmanaged<CFError>?
  20. guard CTFontManagerRegisterGraphicsFont(font, &error) else {
  21. return
  22. }
  23. }
  24. }