Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Sources/Private/CoreAnimation/Layers/TextLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ final class TextLayer: BaseCompositionLayer {
renderLayer.text = sourceText.text
}

// Apply the custom contents scale for this layer if it was provided
if let contentsScale = (context.textProvider as? TextContentsScaleProvider)?.contentsScale(for: textAnimationContext.currentKeypath) {
renderLayer.contentsScale = contentsScale
}

renderLayer.sizeToFit()
}

Expand Down
11 changes: 11 additions & 0 deletions Sources/Public/TextProvider/AnimationTextProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// Created by Alexandr Goncharov on 07/06/2019.
//

import Foundation

// MARK: - AnimationKeypathTextProvider

/// Protocol for providing dynamic text to for a Lottie animation.
Expand Down Expand Up @@ -45,6 +47,15 @@ extension LegacyAnimationTextProvider {
}
}

// MARK: - TextContentScaleProvider

/// `AnimationKeypathTextProvider` that can additionally customize the content scale of the rendered text
public protocol TextContentsScaleProvider: AnimationKeypathTextProvider {
/// The `contentsScale` value to use when rendering text for the given layer keypath.
/// Customizing the `contentsScale` can help reduce aliasing caused by text resizing.
func contentsScale(for keypath: AnimationKeypath) -> CGFloat?
}

// MARK: - DictionaryTextProvider

/// Text provider that simply map values from dictionary.
Expand Down
1 change: 1 addition & 0 deletions Tests/Samples/Issues/pr_2559.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions Tests/SnapshotConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ import UIKit
struct SnapshotConfiguration {
/// The precision that should be used when comparing the
/// captured snapshot with the reference image in `Tests/__Snapshots`
/// - Defaults to 1.0 (the snapshot must match exactly).
/// - This can be lowered for snapshots that render somewhat nondeterministically,
/// but should be kept as high as possible (while still permitting the diff to succeed)
var precision: Float = 1
var precision: Float = 0.985
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a comment about why this is not 1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea


/// Dynamic value providers that should be applied to the animation
var customValueProviders: [AnimationKeypath: AnyValueProvider] = [:]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Supports Core Animation engine
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading