Skip to content

Commit

Permalink
Use a local config instead of global
Browse files Browse the repository at this point in the history
  • Loading branch information
cspiegel committed Apr 21, 2024
1 parent 177976c commit 25177bb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions garglk/fontfc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "glk.h"
#include "garglk.h"

static bool initialized = false;
static FcConfig *cfg;

static std::string findfont(const std::string &fontname)
{
Expand All @@ -42,7 +42,7 @@ static std::string findfont(const std::string &fontname)
return "";
}

auto fs = garglk::unique(FcFontList(nullptr, p.get(), os.get()), FcFontSetDestroy);
auto fs = garglk::unique(FcFontList(cfg, p.get(), os.get()), FcFontSetDestroy);
if (fs->nfont == 0) {
return "";
}
Expand Down Expand Up @@ -81,7 +81,7 @@ static std::string find_font_by_styles(const std::string &basefont, const std::v

void garglk::fontreplace(const std::string &font, FontType type)
{
if (!initialized || font.empty()) {
if (cfg == nullptr || font.empty()) {
return;
}

Expand Down Expand Up @@ -172,12 +172,12 @@ void garglk::fontreplace(const std::string &font, FontType type)

void fontload()
{
initialized = FcInit() != 0;
cfg = FcInitLoadConfigAndFonts();
}

void fontunload()
{
if (initialized) {
FcFini();
if (cfg != nullptr) {
FcConfigDestroy(cfg);
}
}

0 comments on commit 25177bb

Please sign in to comment.