Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions Sources/Private/CoreAnimation/Layers/TextLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ final class TextLayer: BaseCompositionLayer {
renderLayer.text = sourceText.text
}

// Apply the custom contents scale for this layer if it was provided
if
let contentsScaleProvider = context.textProvider as? TextContentsScaleProvider,
let contentsScale = contentsScaleProvider.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.

5 changes: 3 additions & 2 deletions Tests/SnapshotConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ 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
/// - Defaults to 0.985 to reduce the number of flaky snapshots due to small differences
/// in rendering based on OS version.
var precision: Float = 0.985

/// 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