Skip to content

Add hardcoded baseline offset for Apple Color Emoji.#106666

Merged
Repiteo merged 1 commit into
godotengine:masterfrom
bruvzg:apple_em_blof
May 26, 2025
Merged

Add hardcoded baseline offset for Apple Color Emoji.#106666
Repiteo merged 1 commit into
godotengine:masterfrom
bruvzg:apple_em_blof

Conversation

@bruvzg
Copy link
Copy Markdown
Member

@bruvzg bruvzg commented May 21, 2025

Fixes #80766

See #80766 (comment), seems like offsets are missing from the actual font (issue is not reproducible with default Windows emoji font).

Noto and Apple Color Emoji sample:
Screenshot 2025-05-21 at 12 09 57

@bruvzg bruvzg added this to the 4.5 milestone May 21, 2025
Comment thread modules/text_server_adv/text_server_adv.cpp Outdated
Comment thread modules/text_server_fb/text_server_fb.cpp Outdated
@bruvzg bruvzg marked this pull request as ready for review May 22, 2025 06:17
@bruvzg bruvzg requested a review from a team as a code owner May 22, 2025 06:17
Comment thread modules/text_server_adv/text_server_adv.cpp Outdated
Comment thread modules/text_server_adv/text_server_adv.cpp Outdated
@Koyper
Copy link
Copy Markdown
Contributor

Koyper commented May 23, 2025

For FontFile fonts (non-default fonts), the change below was needed for the correction to work because the fallback font name is "Apple Color Emoji". I tested this modification on IOS 18.4.1 with #77951 and it works correctly. Does it make sense to include IOS_ENABLED so this fix is applied when that PR is merged?

#if defined(MACOS_ENABLED) || defined(IOS_ENABLED)
		if (p_font_data->font_name == ".Apple Color Emoji UI" || p_font_data->font_name == "Apple Color Emoji") {

Also, the fix doesn't work when the fallback is set to "Apple Color Emoji" in the font file import settings, but it does work when no fallback is set (for non-MSDF fonts). The docs about font emoji say the fallback is required, but emojis work now without setting the fallback - is that correct?

Here's the catch: If MSDF is enabled for a font, the emojis won't fallback unless "Apple Color Emoji" is set as a fallback, which then makes the offset correction stop working.

Does this mean there is another place where the system fallback is being rendered that this code needs to be applied to?

FontFile without "Apple Color Emoji" system font fallback applies baseline correction (with allow_system_fallback checked in the import settings):
Screenshot 2025-05-23 at 9 59 06 AM

FontFile with "Apple Color Emoji" system font fallback. You can see the incorrect emoji offset in the preview:
Screenshot 2025-05-23 at 9 59 28 AM

This is with MSDF enabled and no system fallback set (but allow_system_fallback is still checked in the import settings):
Screenshot 2025-05-23 at 10 42 27 AM

@Koyper
Copy link
Copy Markdown
Contributor

Koyper commented May 23, 2025

I just tested the prior suggestion on iOS 18.4.1 with #77951 and it looks like it's working correctly. Still has the issue described regarding system fallback.

@Repiteo Repiteo merged commit 76f28c4 into godotengine:master May 26, 2025
20 checks passed
@Repiteo
Copy link
Copy Markdown
Contributor

Repiteo commented May 26, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Emoji are rendered on baseline y-height instead of on the descender

5 participants