Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ladybird: Restore ability to load emoji from Ladybird #23643

Merged
merged 5 commits into from
Mar 23, 2024

Conversation

trflynn89
Copy link
Member

For example, this allows emoji to render on Strava.

Before:
before

After:
after

@github-actions github-actions bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label Mar 19, 2024
@trflynn89 trflynn89 requested a review from ADKaster March 19, 2024 20:28
@@ -26,7 +26,7 @@ FontPlugin::FontPlugin(bool is_layout_test_mode)
Gfx::FontDatabase::set_default_font_query("Katica 10 400 0");
Gfx::FontDatabase::set_fixed_width_font_query("Csilla 10 400 0");

Gfx::Emoji::set_emoji_lookup_path(String::formatted("{}/res/emoji", s_serenity_resource_root).release_value_but_fixme_should_propagate_errors());
Gfx::Emoji::set_emoji_lookup_path(String::formatted("{}/emoji", s_serenity_resource_root).release_value_but_fixme_should_propagate_errors());
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe good to be consistent with https://github.com/SerenityOS/serenity/pull/23016/files (?)

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think that will work with installations, and that Ladybird has to load resources from s_serenity_resource_root (which changes depending on whether this is a dev build or a packaged installation)

Copy link
Member Author

Choose a reason for hiding this comment

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

It's probably more correct for Ladybird to be using Core::Resource here actually, @ADKaster ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Iirc MacPDF always sets s_serenity_source_root to the bundle dir, and the command line Lagom tools set it to the build dir instead. That could work for cocoa ladybird too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Looking at it closer, I think AK has us spiritually doing the same thing in Ladybird. We default to the bundle path on mac, starting from the exe path:

u32 size = sizeof(path);
auto ret = _NSGetExecutablePath(path, &size);
if (ret != 0)
return Error::from_errno(ENAMETOOLONG);

And then from that path, we get:
return LexicalPath(app_dir).parent().append("Resources"sv).string();

Dunno what Andrew's long term plan here is for multiple lagom apps, but sounds like he has some consolidation ideas floating around:
#23304 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

I pushed Core::Resource usage for now - that would have at least told us we forgot to bundle the emoji in #23304

Copy link
Member

Choose a reason for hiding this comment

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

Yeah in theory we should be copying the files to Build/lagom/share/emoji as part of the build, and then any app that needs them can get them from that path (app_path/../share). For macOS app bundles, we'd need to copy the files into the app bundle under resources like I did for Ladybird in that PR.

Still feels like a CFAppBundle Resource backend would be neat, then we could pretend that paths don't exist for these app bundles.

@trflynn89 trflynn89 force-pushed the emoji branch 2 times, most recently from 8d595a2 to 7691cba Compare March 20, 2024 19:20
And add a verification step to the emoji data generator to ensure all
emoji are listed in this file. This file will be used as a sources list
in both the CMake and GN build systems.

It is probably possible to generate this list. But in a first attempt,
the CMake code to set the file as a dependency of a pseudo target, which
would then parse the file and install the listed emoji was getting quite
verbose and complicated. So for now, let's just maintain this list.
Otherwise, we are unable to render emoji on websites.
The path we were using is no longer correct, and we've been silently
dropping this error. Use Core::Resource instead, which we use for most
other Ladybird resources. This would have made it much more obvious that
emoji were not installed with the application.
@trflynn89 trflynn89 merged commit 8af140f into SerenityOS:master Mar 23, 2024
12 checks passed
@trflynn89 trflynn89 deleted the emoji branch March 23, 2024 21:26
@github-actions github-actions bot removed the 👀 pr-needs-review PR needs review from a maintainer or community member label Mar 23, 2024
@ADKaster ADKaster mentioned this pull request May 1, 2024
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.

None yet

3 participants