MCPcopy Create free account
hub / github.com/CruiserOne/Astrolog / FEnsureFontInstalled

Function FEnsureFontInstalled

wdriver.cpp:2665–2698  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2663}
2664
2665flag FEnsureFontInstalled(int fi)
2666{
2667 static flag fCheckedInstall = fFalse;
2668 HDC hdc;
2669 char sz[cchSzMax];
2670 FILE *file;
2671
2672 if (!fCheckedInstall) {
2673 // Check whether fonts are installed.
2674 hdc = GetDC(NULL);
2675 if (hdc == NULL)
2676 return fFalse;
2677 EnumFontFamiliesEx(hdc, NULL, (FONTENUMPROC)EnumFontFamExProc,
2678 (LPARAM)0, 0);
2679 ReleaseDC(NULL, hdc);
2680 fCheckedInstall = fTrue;
2681 }
2682 if (rgfFontInstalled[fi] > 0)
2683 return fTrue; // Font already installed.
2684 if (rgfFontInstalled[fi] < 0)
2685 return fFalse; // Font already failed to be installed.
2686
2687 rgfFontInstalled[fi] = -1;
2688 if (!FSzSet(rgszFontFile[fi]))
2689 return fFalse; // Definitely don't have this font file.
2690 file = FileOpen(rgszFontFile[fi], 2, sz);
2691 if (file == NULL)
2692 return fFalse; // Couldn't find font file.
2693 fclose(file);
2694 if (AddFontResourceEx(sz, FR_PRIVATE, NULL) == 0)
2695 return fFalse; // Failed to install font.
2696 rgfFontInstalled[fi] = 2;
2697 return fTrue;
2698}
2699#endif
2700
2701

Callers 1

DrawGlyphFunction · 0.85

Calls 1

FileOpenFunction · 0.85

Tested by

no test coverage detected