Skip to content

Comments

chore: opt valid font family check logic in desktop#1360

Merged
yiiqii merged 1 commit intomainfrom
chore/is-valid-font-family
Jan 8, 2026
Merged

chore: opt valid font family check logic in desktop#1360
yiiqii merged 1 commit intomainfrom
chore/is-valid-font-family

Conversation

@wumaolinmaoan
Copy link
Contributor

@wumaolinmaoan wumaolinmaoan commented Jan 5, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved font compatibility. More fonts are now accepted and functional on standard devices while maintaining compatibility on simulator devices.

✏️ Tip: You can customize this high-level summary in your review settings.

@wumaolinmaoan wumaolinmaoan requested a review from yiiqii January 5, 2026 08:37
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 5, 2026

📝 Walkthrough

Walkthrough

The isValidFontFamily utility function is modified to conditionally validate font families. It imports a device detection utility and relaxes font validation on non-simulator devices while preserving stricter regex-based validation on simulator devices.

Changes

Cohort / File(s) Summary
Font validation logic
packages/effects-core/src/utils/text.ts
Added isSimulatorCellPhone import; modified isValidFontFamily to accept fonts on non-simulator devices regardless of regex match, while maintaining original regex validation on simulator devices.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 On devices real, fonts run free,
No regex chains can bind,
But simulators still decree—
Strict rules they must find! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title 'chore: opt valid font family check logic in desktop' directly addresses the main change - optimizing the isValidFontFamily function logic by adding device simulation checks.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/effects-core/src/utils/text.ts (1)

1-2: Function name isSimulatorCellPhone may be misleading.

The imported function detects mobile devices (Android, OpenHarmony, iOS) based on user agent strings, not simulators. This naming could cause confusion when reading the logic at line 12.

Consider whether the function name accurately reflects its purpose in this context.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a466fca and 520e346.

📒 Files selected for processing (1)
  • packages/effects-core/src/utils/text.ts
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-12-09T08:44:15.153Z
Learnt from: Fryt1
Repo: galacean/effects-runtime PR: 1305
File: packages/effects-core/src/fallback/migration.ts:325-330
Timestamp: 2025-12-09T08:44:15.153Z
Learning: In `packages/effects-core/src/fallback/migration.ts`, the `textColor` 0-255 to 0-1 conversion in `version35Migration` is intentionally applied only to `TextComponent` and not to `RichTextComponent`, as confirmed by Fryt1.

Applied to files:

  • packages/effects-core/src/utils/text.ts
🧬 Code graph analysis (1)
packages/effects-core/src/utils/text.ts (1)
packages/effects-core/src/utils/device.ts (1)
  • isSimulatorCellPhone (36-38)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
packages/effects-core/src/utils/text.ts (1)

12-12: This change is intentional and correct—reconsider the premise.

The function validates iOS 11/12 compatibility constraints, not CSS syntax universally. The Chinese comment clarifies: "iOS 11/12 do not support custom fonts starting with numbers."

On mobile devices, strict validation applies. On desktop, the looser validation is correct because:

  • CSS font-family legitimately supports font names with leading digits when quoted (e.g., "123font")
  • Desktop browsers have no restriction against such names (unlike iOS 11/12)
  • The regex pattern only enforces unquoted CSS identifier format, which is device-specific, not a universal CSS requirement

The function still logs warnings when called, so it remains informational. The device-dependent behavior is intentional, though the function documentation could clarify that it validates compatibility constraints rather than CSS syntax.

Likely an incorrect or invalid review comment.

@wumaolinmaoan wumaolinmaoan changed the title chore: opt valid font family check logic in destop chore: opt valid font family check logic in desktop Jan 5, 2026
@yiiqii yiiqii merged commit 0607812 into main Jan 8, 2026
2 checks passed
@yiiqii yiiqii deleted the chore/is-valid-font-family branch January 8, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants