Code quality, safety, stability, and cleanups.
- Replace header include guards with `#pragma once` and perform minor optimizations. - Replaced traditional include guards with `#pragma once` for simplicity and to reduce boilerplate in all headers. - Improved CLI line number handling with clamping and error messaging. - Enhanced `chdir` error handling for macOS GUI builds. - Removed redundant logic for GUI builds. - Adjusted font constructor and registry to handle `const` data pointers consistently.
This commit is contained in:
@@ -12,7 +12,7 @@ inline const unsigned int *DefaultFontData = BrassMonoCode::DefaultFontBoldCompr
|
||||
|
||||
class Font {
|
||||
public:
|
||||
Font(std::string name, unsigned int *data, const unsigned int size)
|
||||
Font(std::string name, const unsigned int *data, const unsigned int size)
|
||||
: name_(std::move(name)),
|
||||
data_(data),
|
||||
size_(size) {}
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
unsigned int *data_{nullptr};
|
||||
const unsigned int *data_{nullptr};
|
||||
unsigned int size_{0};
|
||||
};
|
||||
}
|
||||
@@ -7,87 +7,87 @@ InstallDefaultFonts()
|
||||
{
|
||||
FontRegistry::Instance().Register(std::make_unique<Font>(
|
||||
"default",
|
||||
const_cast<unsigned int *>(BrassMono::DefaultFontBoldCompressedData),
|
||||
BrassMono::DefaultFontBoldCompressedData,
|
||||
BrassMono::DefaultFontBoldCompressedSize
|
||||
));
|
||||
FontRegistry::Instance().Register(std::make_unique<Font>(
|
||||
"b612",
|
||||
const_cast<unsigned int *>(B612Mono::DefaultFontRegularCompressedData),
|
||||
B612Mono::DefaultFontRegularCompressedData,
|
||||
B612Mono::DefaultFontRegularCompressedSize
|
||||
));
|
||||
FontRegistry::Instance().Register(std::make_unique<Font>(
|
||||
"brassmono",
|
||||
const_cast<unsigned int *>(BrassMono::DefaultFontBoldCompressedData),
|
||||
BrassMono::DefaultFontBoldCompressedData,
|
||||
BrassMono::DefaultFontBoldCompressedSize
|
||||
));
|
||||
FontRegistry::Instance().Register(std::make_unique<Font>(
|
||||
"brassmonocode",
|
||||
const_cast<unsigned int *>(BrassMonoCode::DefaultFontBoldCompressedData),
|
||||
BrassMonoCode::DefaultFontBoldCompressedData,
|
||||
BrassMonoCode::DefaultFontBoldCompressedSize
|
||||
));
|
||||
FontRegistry::Instance().Register(std::make_unique<Font>(
|
||||
"fira",
|
||||
const_cast<unsigned int *>(FiraCode::DefaultFontRegularCompressedData),
|
||||
FiraCode::DefaultFontRegularCompressedData,
|
||||
FiraCode::DefaultFontRegularCompressedSize
|
||||
));
|
||||
FontRegistry::Instance().Register(std::make_unique<Font>(
|
||||
"go",
|
||||
const_cast<unsigned int *>(Go::DefaultFontRegularCompressedData),
|
||||
Go::DefaultFontRegularCompressedData,
|
||||
Go::DefaultFontRegularCompressedSize
|
||||
));
|
||||
FontRegistry::Instance().Register(std::make_unique<Font>(
|
||||
"ibm",
|
||||
const_cast<unsigned int *>(IBMPlexMono::DefaultFontRegularCompressedData),
|
||||
IBMPlexMono::DefaultFontRegularCompressedData,
|
||||
IBMPlexMono::DefaultFontRegularCompressedSize
|
||||
));
|
||||
FontRegistry::Instance().Register(std::make_unique<Font>(
|
||||
"idealist",
|
||||
const_cast<unsigned int *>(Idealist::DefaultFontRegularCompressedData),
|
||||
Idealist::DefaultFontRegularCompressedData,
|
||||
Idealist::DefaultFontRegularCompressedSize
|
||||
));
|
||||
FontRegistry::Instance().Register(std::make_unique<Font>(
|
||||
"inconsolata",
|
||||
const_cast<unsigned int *>(Inconsolata::DefaultFontRegularCompressedData),
|
||||
Inconsolata::DefaultFontRegularCompressedData,
|
||||
Inconsolata::DefaultFontRegularCompressedSize
|
||||
));
|
||||
FontRegistry::Instance().Register(std::make_unique<Font>(
|
||||
"inconsolataex",
|
||||
const_cast<unsigned int *>(InconsolataExpanded::DefaultFontRegularCompressedData),
|
||||
InconsolataExpanded::DefaultFontRegularCompressedData,
|
||||
InconsolataExpanded::DefaultFontRegularCompressedSize
|
||||
));
|
||||
FontRegistry::Instance().Register(std::make_unique<Font>(
|
||||
"iosevka",
|
||||
const_cast<unsigned int *>(Iosoveka::DefaultFontRegularCompressedData),
|
||||
Iosoveka::DefaultFontRegularCompressedData,
|
||||
Iosoveka::DefaultFontRegularCompressedSize
|
||||
));
|
||||
FontRegistry::Instance().Register(std::make_unique<Font>(
|
||||
"iosevkaex",
|
||||
const_cast<unsigned int *>(IosevkaExtended::DefaultFontRegularCompressedData),
|
||||
IosevkaExtended::DefaultFontRegularCompressedData,
|
||||
IosevkaExtended::DefaultFontRegularCompressedSize
|
||||
));
|
||||
FontRegistry::Instance().Register(std::make_unique<Font>(
|
||||
"sharetech",
|
||||
const_cast<unsigned int *>(ShareTech::DefaultFontRegularCompressedData),
|
||||
ShareTech::DefaultFontRegularCompressedData,
|
||||
ShareTech::DefaultFontRegularCompressedSize
|
||||
));
|
||||
FontRegistry::Instance().Register(std::make_unique<Font>(
|
||||
"space",
|
||||
const_cast<unsigned int *>(SpaceMono::DefaultFontRegularCompressedData),
|
||||
SpaceMono::DefaultFontRegularCompressedData,
|
||||
SpaceMono::DefaultFontRegularCompressedSize
|
||||
));
|
||||
FontRegistry::Instance().Register(std::make_unique<Font>(
|
||||
"syne",
|
||||
const_cast<unsigned int *>(Syne::DefaultFontRegularCompressedData),
|
||||
Syne::DefaultFontRegularCompressedData,
|
||||
Syne::DefaultFontRegularCompressedSize
|
||||
));
|
||||
FontRegistry::Instance().Register(std::make_unique<Font>(
|
||||
"triplicate",
|
||||
const_cast<unsigned int *>(Triplicate::DefaultFontRegularCompressedData),
|
||||
Triplicate::DefaultFontRegularCompressedData,
|
||||
Triplicate::DefaultFontRegularCompressedSize
|
||||
));
|
||||
FontRegistry::Instance().Register(std::make_unique<Font>(
|
||||
"unispace",
|
||||
const_cast<unsigned int *>(Unispace::DefaultFontRegularCompressedData),
|
||||
Unispace::DefaultFontRegularCompressedData,
|
||||
Unispace::DefaultFontRegularCompressedSize
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user