From 7c08d8c02cf03bcc3036d7d47547cd5bb273fa85 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Thu, 20 Jan 2022 06:01:49 +0200 Subject: App: Font Library cmap includes pack sizes --- src/app.c | 17 ++++++++++++++--- src/app.h | 1 + src/fontpack.c | 8 +++++--- 3 files changed, 20 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/app.c b/src/app.c index 31f506b5..4d0e0f79 100644 --- a/src/app.c +++ b/src/app.c @@ -1362,6 +1362,10 @@ void processEvents_App(enum iAppEventMode eventMode) { dispatchCommands_Periodic(&d->periodic); continue; } + if (ev.type == SDL_USEREVENT && ev.user.code == releaseObject_UserEventCode) { + iRelease(ev.user.data1); + continue; + } #if defined (LAGRANGE_ENABLE_IDLE_SLEEP) if (ev.type == SDL_USEREVENT && ev.user.code == asleep_UserEventCode) { if (SDL_GetTicks() - d->lastEventTime > idleThreshold_App_ && @@ -2394,12 +2398,19 @@ iBool handleCommand_App(const char *cmd) { setCStr_String(src, "# ${heading.glyphfinder.results}\n\n"); iRangecc path = iNullRange; iBool isFirst = iTrue; - while (nextSplit_Rangecc(range_Command(cmd, "packs"), ";", &path)) { + while (nextSplit_Rangecc(range_Command(cmd, "packs"), ",", &path)) { if (isFirst) { appendCStr_String(src, "${glyphfinder.results}\n\n"); } - const char *fp = cstr_Rangecc(path); - appendFormat_String(src, "=> gemini://skyjake.fi/fonts/%s %s\n", fp, fp); + iRangecc fpath = path; + iRangecc fsize = path; + fpath.end = strchr(fpath.start, ';'); + fsize.start = fpath.end + 1; + const uint32_t size = strtoul(fsize.start, NULL, 10); + appendFormat_String(src, "=> gemini://skyjake.fi/fonts/%s %s (%.1f MB)\n", + cstr_Rangecc(fpath), + cstr_Rangecc(fpath), + (double) size / 1.0e6); isFirst = iFalse; } if (isFirst) { diff --git a/src/app.h b/src/app.h index 1a4aa556..22fe5d46 100644 --- a/src/app.h +++ b/src/app.h @@ -67,6 +67,7 @@ enum iUserEventCode { take, it could turn into a tap-and-hold for example. */ widgetTapBegins_UserEventCode, widgetTouchEnds_UserEventCode, /* finger lifted, but momentum may continue */ + releaseObject_UserEventCode, /* object that needs releasing in the main thread */ }; const iString *execPath_App (void); diff --git a/src/fontpack.c b/src/fontpack.c index 3faf0e92..924d4781 100644 --- a/src/fontpack.c +++ b/src/fontpack.c @@ -1114,7 +1114,7 @@ static void findCharactersInCMap_(iGmRequest *d, iGmRequest *req) { format_String(&result, "font.found chars:%s packs:", cstr_String(missingChars)); iConstForEach(StringList, s, matchingPacks) { if (s.pos != 0) { - appendCStr_String(&result, ";"); + appendCStr_String(&result, ","); } append_String(&result, s.value); } @@ -1131,9 +1131,11 @@ static void findCharactersInCMap_(iGmRequest *d, iGmRequest *req) { cstr_String(meta_GmRequest(d)), cstr_String(url_GmRequest(d))); } - fflush(stdout); +// fflush(stdout); delete_String(userData_Object(d)); - iReleaseLater(d); + /* We can't delete ourselves; threads must be joined from another thread. */ + SDL_PushEvent((SDL_Event *) &(SDL_UserEvent){ + .type = SDL_USEREVENT, .code = releaseObject_UserEventCode, .data1 = d }); } void searchOnlineLibraryForCharacters_Fonts(const iString *chars) { -- cgit v1.2.3