Skip to content

Commit

Permalink
Add --disable-texture-name-zero-padding flag for disable texture name…
Browse files Browse the repository at this point in the history
… zero padding
  • Loading branch information
vladimirgamalyan committed Dec 1, 2021
1 parent eb7d841 commit 7acde7c
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 23 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ option | default | comment
--texture-height | 256 | texture height
--monochrome | | disable anti-aliasing
--extra-info | | write extra information to data file
--max-texture-count | | maximum generated texture count (unlimited if not defined)
--disable-texture-name-zero-padding | | disable texture name zero padding
--max-texture-count | 0 | maximum generated texture count (unlimited if zero)

## Building Linux

Expand Down
3 changes: 1 addition & 2 deletions src/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ std::vector<std::string> App::renderTextures(const Glyphs& glyphs, const Config&
{
std::vector<std::string> fileNames;

//TODO: should we decrement pageCount before calculate?
const auto pageNameDigits = getNumberLen(pageCount);
const auto pageNameDigits = config.disableTextureNameZeroPadding ? 0 : getNumberLen(pageCount - 1);

for (std::uint32_t page = 0; page < pageCount; ++page)
{
Expand Down
1 change: 1 addition & 0 deletions src/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ struct Config
std::uint32_t maxTextureCount = 0;
bool monochrome = false;
bool extraInfo = false;
bool disableTextureNameZeroPadding = false;

void validate() const
{
Expand Down
19 changes: 0 additions & 19 deletions src/FontInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ std::string FontInfo::getCharSetName(std::uint8_t charSet)

void FontInfo::writeToXmlFile(const std::string &fileName) const
{
testPages();

tinyxml2::XMLDocument doc;
tinyxml2::XMLDeclaration* declaration = doc.NewDeclaration("xml version=\"1.0\"");
doc.InsertFirstChild(declaration);
Expand Down Expand Up @@ -178,8 +176,6 @@ void FontInfo::writeToXmlFile(const std::string &fileName) const

void FontInfo::writeToTextFile(const std::string &fileName) const
{
testPages();

std::ofstream f(fileName);

f << "info"
Expand Down Expand Up @@ -255,8 +251,6 @@ void FontInfo::writeToTextFile(const std::string &fileName) const

void FontInfo::writeToBinFile(const std::string &fileName) const
{
testPages();

std::ofstream f(fileName, std::ios::binary);

#pragma pack(push, 1)
Expand Down Expand Up @@ -487,16 +481,3 @@ void FontInfo::writeToJsonFile(const std::string &fileName) const
std::ofstream f(fileName);
f << j.dump(4);
}

void FontInfo::testPages() const
{
if (!pages.empty())
{
size_t l = pages[0].length();
if (!l)
throw std::runtime_error("page name is empty");
for (size_t i = 1; i < pages.size(); ++i)
if (l != pages[i].length())
throw std::runtime_error("page names have different length");
}
}
1 change: 0 additions & 1 deletion src/FontInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,5 @@ struct FontInfo
void writeToJsonFile(const std::string &fileName) const;

private:
void testPages() const;
static std::string getCharSetName(std::uint8_t charSet);
};
1 change: 1 addition & 0 deletions src/ProgramOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Config ProgramOptions::parseCommandLine(int argc, char* argv[])
("include-kerning-pairs", "include kerning pairs to output file", cxxopts::value<bool>(config.includeKerningPairs))
("monochrome", "disable antialiasing", cxxopts::value<bool>(config.monochrome))
("extra-info", "write extra information to data file", cxxopts::value<bool>(config.extraInfo))
("disable-texture-name-zero-padding", "disable texture name zero padding", cxxopts::value<bool>(config.disableTextureNameZeroPadding))
("max-texture-count", "maximum generated textures", cxxopts::value<std::uint32_t>(config.maxTextureCount)->default_value("0"));

auto result = options.parse(argc, argv);
Expand Down

0 comments on commit 7acde7c

Please sign in to comment.