Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This will solve hang issue when starting mpv if someone has 1000+ fonts installed in his windows :)
- Loading branch information
Showing
2 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
138 changes: 138 additions & 0 deletions
138
packages/fontconfig-0002-custom-changes-for-mpv-builds.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
From 9a17cadaa905b8866ef8c8e0ca09fb37dcb53b9d Mon Sep 17 00:00:00 2001 | ||
From: shinchiro <shinchiro@users.noreply.github.com> | ||
Date: Fri, 3 Jan 2020 23:02:52 +0800 | ||
Subject: [PATCH] Custom changes for mpv builds | ||
|
||
Based on original lachs0r's patch for fontconfig | ||
--- | ||
src/fcdir.c | 36 ++++++++++++++++++++++++------------ | ||
src/fcinit.c | 35 +++++++++++++++++++++++++++++++++++ | ||
2 files changed, 59 insertions(+), 12 deletions(-) | ||
|
||
diff --git a/src/fcdir.c b/src/fcdir.c | ||
index 693c845..6addf48 100644 | ||
--- a/src/fcdir.c | ||
+++ b/src/fcdir.c | ||
@@ -69,18 +69,9 @@ FcFileScanFontConfig (FcFontSet *set, | ||
int old_nfont = set->nfont; | ||
const FcChar8 *sysroot = FcConfigGetSysRoot (config); | ||
|
||
- if (FcDebug () & FC_DBG_SCAN) | ||
- { | ||
- printf ("\tScanning file %s...", file); | ||
- fflush (stdout); | ||
- } | ||
- | ||
if (!FcFreeTypeQueryAll (file, -1, NULL, NULL, set)) | ||
return FcFalse; | ||
|
||
- if (FcDebug () & FC_DBG_SCAN) | ||
- printf ("done\n"); | ||
- | ||
for (i = old_nfont; i < set->nfont; i++) | ||
{ | ||
FcPattern *font = set->fonts[i]; | ||
@@ -221,8 +212,8 @@ FcDirScanConfig (FcFontSet *set, | ||
base = file + strlen ((char *) file); | ||
|
||
if (FcDebug () & FC_DBG_SCAN) | ||
- printf ("\tScanning dir %s\n", dir); | ||
- | ||
+ fprintf (stderr, "[fontconfig] Scanning dir %s\n", dir); | ||
+ | ||
d = opendir ((char *) dir); | ||
if (!d) | ||
{ | ||
@@ -258,8 +249,29 @@ FcDirScanConfig (FcFontSet *set, | ||
/* | ||
* Scan file files to build font patterns | ||
*/ | ||
+ char buf1[512], buf2[512], pad[512], *str = &buf1[0], *prev = &buf2[0], *tmp; | ||
+ int j, diff; | ||
+ prev[0] = pad[0] = 0; | ||
+ | ||
for (i = 0; i < files->num; i++) | ||
- FcFileScanConfig (set, dirs, files->strs[i], config); | ||
+ { | ||
+ snprintf (str, 512, "\r[%d/%d] %s", i+1, files->num, files->strs[i]); | ||
+ | ||
+ for (diff = strlen (prev) - strlen (str), j = 0; diff > 0; diff--, j++) | ||
+ pad[j] = ' '; | ||
+ | ||
+ pad[j] = 0; | ||
+ | ||
+ if (FcDebug () & FC_DBG_SCAN) | ||
+ fprintf (stderr, "%s%s", str, pad); | ||
+ | ||
+ tmp = str; str = prev; prev = tmp; | ||
+ | ||
+ FcFileScanConfig (set, dirs, files->strs[i], config); | ||
+ } | ||
+ | ||
+ if (FcDebug () & FC_DBG_SCAN) | ||
+ fprintf (stderr, "\n[fontconfig] Finished scanning dir %s\n", dir); | ||
|
||
bail2: | ||
FcStrSetDestroy (files); | ||
diff --git a/src/fcinit.c b/src/fcinit.c | ||
index 6f82ebd..3202a2c 100644 | ||
--- a/src/fcinit.c | ||
+++ b/src/fcinit.c | ||
@@ -35,6 +35,12 @@ | ||
#pragma message("To suppress these warnings, define FC_NO_MT.") | ||
#endif | ||
|
||
+#ifdef _WIN32 | ||
+#define _WIN32_IE 0x0500 | ||
+#include <shlobj.h> | ||
+#include <malloc.h> | ||
+#endif | ||
+ | ||
static FcConfig * | ||
FcInitFallbackConfig (const FcChar8 *sysroot) | ||
{ | ||
@@ -52,12 +58,41 @@ FcInitFallbackConfig (const FcChar8 *sysroot) | ||
config = FcConfigCreate (); | ||
if (!config) | ||
goto bail0; | ||
+ | ||
+#ifdef _WIN32 | ||
+ char *buf = malloc (MAX_PATH+1); | ||
+ if (!buf) goto bail1; | ||
+ if (SHGetFolderPathA (NULL, CSIDL_FONTS|CSIDL_FLAG_CREATE, NULL, | ||
+ SHGFP_TYPE_CURRENT, buf) == S_OK) { | ||
+ if (!FcConfigAddConfigDir (config, (FcChar8 *) buf)) | ||
+ goto bail2; | ||
+ } | ||
+ | ||
+ char *buf2 = malloc (MAX_PATH+1); | ||
+ if (!buf) goto bail2; | ||
+ if (SHGetFolderPathA (NULL, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE, NULL, | ||
+ SHGFP_TYPE_CURRENT, buf2) == S_OK) { | ||
+ if (buf2[strlen(buf2)-1] != '\\') | ||
+ strcat (buf2, "\\"); | ||
+ strcat (buf2, "fontconfig"); | ||
+ if (!FcConfigAddCacheDir (config, (FcChar8 *) buf2)) | ||
+ goto bail3; | ||
+ } | ||
+#else | ||
FcConfigSetSysRoot (config, sysroot); | ||
if (!FcConfigParseAndLoadFromMemory (config, fallback, FcFalse)) | ||
goto bail1; | ||
+#endif | ||
|
||
return config; | ||
|
||
+#ifdef _WIN32 | ||
+bail3: | ||
+ free(buf2); | ||
+bail2: | ||
+ free(buf); | ||
+#endif | ||
+ | ||
bail1: | ||
FcConfigDestroy (config); | ||
bail0: | ||
-- | ||
2.17.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters