You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
758 B

2 years ago
2 years ago
2 years ago
  1. //
  2. // LayerFontProvider.swift
  3. // Lottie
  4. //
  5. // Created by Brandon Withrow on 8/5/20.
  6. // Copyright © 2020 YurtvilleProds. All rights reserved.
  7. //
  8. import Foundation
  9. /// Connects a LottieFontProvider to a group of text layers
  10. final class LayerFontProvider {
  11. // MARK: Lifecycle
  12. init(fontProvider: AnimationFontProvider) {
  13. self.fontProvider = fontProvider
  14. textLayers = []
  15. reloadTexts()
  16. }
  17. // MARK: Internal
  18. private(set) var textLayers: [TextCompositionLayer]
  19. var fontProvider: AnimationFontProvider {
  20. didSet {
  21. reloadTexts()
  22. }
  23. }
  24. func addTextLayers(_ layers: [TextCompositionLayer]) {
  25. textLayers += layers
  26. }
  27. func reloadTexts() {
  28. textLayers.forEach {
  29. $0.fontProvider = fontProvider
  30. }
  31. }
  32. }