From e4d2aa82e2e0fa3ef34c7bc4f1749823e723f5ce Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Fri, 29 Sep 2023 21:02:14 -0400 Subject: [PATCH] MacPDF: Don't hardcode my serenity directory https://www.africau.edu/images/default/sample.pdf is a good document for testing that the built-in fonts load. --- Meta/Lagom/Contrib/MacPDF/AppDelegate.mm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Meta/Lagom/Contrib/MacPDF/AppDelegate.mm b/Meta/Lagom/Contrib/MacPDF/AppDelegate.mm index b82e438769..6d33ebae34 100644 --- a/Meta/Lagom/Contrib/MacPDF/AppDelegate.mm +++ b/Meta/Lagom/Contrib/MacPDF/AppDelegate.mm @@ -16,9 +16,14 @@ - (void)applicationDidFinishLaunching:(NSNotification*)aNotification { - // FIXME: copy the fonts to the bundle or something - auto source_root = DeprecatedString("/Users/thakis/src/serenity"); - Gfx::FontDatabase::set_default_fonts_lookup_path(DeprecatedString::formatted("{}/Base/res/fonts", source_root)); + // FIXME: Copy the fonts to the bundle or something + + // Get from `Build/lagom/bin/MacPDF.app/Contents/MacOS/MacPDF` to `.`. + NSString* source_root = [[NSBundle mainBundle] executablePath]; + for (int i = 0; i < 7; ++i) + source_root = [source_root stringByDeletingLastPathComponent]; + auto source_root_string = DeprecatedString([source_root UTF8String]); + Gfx::FontDatabase::set_default_fonts_lookup_path(DeprecatedString::formatted("{}/Base/res/fonts", source_root_string)); } - (void)applicationWillTerminate:(NSNotification*)aNotification