summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornibbbl <63519528+nibbbl@users.noreply.github.com>2026-07-14 12:28:30 -0700
committernibbbl <63519528+nibbbl@users.noreply.github.com>2026-07-14 12:28:30 -0700
commit67d609e5e49cec6f5d2c06ae4af9998ced1df02a (patch)
tree439ccd8c5cd50fc5473c5ad436571e2feee269ef
parentb9a83b97a937f6404ff6932a3ac9e2cc8f797456 (diff)
Address review: cache FcInit, null-check FontConfig allocs, drop unused include
-rw-r--r--indra/llwindow/llwindowsdl.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp
index b6b477ff68..e3ae9493a6 100644
--- a/indra/llwindow/llwindowsdl.cpp
+++ b/indra/llwindow/llwindowsdl.cpp
@@ -45,8 +45,6 @@
#include <glib.h>
#endif
-#include <algorithm>
-
extern "C" {
# include "fontconfig/fontconfig.h"
}
@@ -1889,7 +1887,10 @@ LLFontFallbackMatch LLWindowSDL::findFallbackFontForChar(llwchar wch)
{
LLFontFallbackMatch result;
#if LL_LINUX
- if (!FcInit())
+ // FcInit() is idempotent, but this runs per missing codepoint, so only
+ // attempt initialization once.
+ static bool fc_ready = FcInit();
+ if (!fc_ready)
{
LL_WARNS_ONCE() << "FontConfig failed to initialize." << LL_ENDL;
return result;
@@ -1897,9 +1898,16 @@ LLFontFallbackMatch LLWindowSDL::findFallbackFontForChar(llwchar wch)
// Ask FontConfig for the best font covering this codepoint.
FcCharSet* charset = FcCharSetCreate();
+ FcPattern* pat = FcPatternCreate();
+ if (!charset || !pat)
+ {
+ if (charset) FcCharSetDestroy(charset);
+ if (pat) FcPatternDestroy(pat);
+ return result;
+ }
+
FcCharSetAddChar(charset, (FcChar32)wch);
- FcPattern* pat = FcPatternCreate();
FcPatternAddCharSet(pat, FC_CHARSET, charset);
FcPatternAddBool(pat, FC_SCALABLE, FcTrue);