UIOnboarding icon indicating copy to clipboard operation
UIOnboarding copied to clipboard

Fix layout issue with title font sizing in attributed strings

Open FelixLisczyk opened this issue 3 months ago • 0 comments

Fixes a critical bug where title labels (icon and "Welcome to" text) were rendering at approximately 1/4 screen size on iPad when using attributed strings without explicit font attributes.

Problem

The updateFontSize(_:) method in UIOnboardingTitleLabel was calculating font size multipliers incorrectly when attributed strings didn't have font attributes pre-set. This caused the title labels to render at the wrong size on iPad.

Root Cause

The original implementation (from PR #27) captured originalFont = font before updating the label's font property, then used this stale value to calculate multipliers. When attributed strings had no font attributes set, the multiplier calculation would use mismatched font sizes, resulting in incorrect rendering.

Additionally, the method only updated fonts that were already present in the attributed string, leaving ranges without font attributes unstyled.

Solution

Updated updateFontSize(_:) to:

  1. Update the label's base font first - Sets self.font to the target size before any calculations
  2. Handle attributed strings with font attributes - Calculates multipliers using the updated base font, preserving PR #27's multi-font feature
  3. Handle attributed strings without font attributes - Explicitly applies the base font to ranges that don't have a font set

Screenshots

Before

IMG_0122 IMG_0123

After

IMG_0124 IMG_0125

FelixLisczyk avatar Sep 30 '25 13:09 FelixLisczyk