Add placefile font

This commit is contained in:
Dan Paulat 2023-07-22 00:24:17 -05:00
parent 8be32a8998
commit 783e8f3490
2 changed files with 30 additions and 3 deletions

View file

@ -47,6 +47,14 @@ public:
Unknown
};
struct Font
{
std::size_t fontNumber_ {};
std::size_t pixels_ {};
std::int32_t flags_ {};
std::string face_ {};
};
struct DrawItem
{
ItemType itemType_ {ItemType::Unknown};

View file

@ -48,6 +48,7 @@ public:
double& y);
void ProcessLine(const std::string& line);
static void ProcessEscapeCharacters(std::string& s);
static void TrimQuotes(std::string& s);
std::chrono::seconds refresh_ {-1};
@ -62,7 +63,7 @@ public:
// References
std::unordered_map<std::size_t, bool> iconFiles_ {};
std::unordered_map<std::size_t, bool> fonts_ {};
std::unordered_map<std::size_t, std::shared_ptr<Font>> fonts_ {};
std::vector<std::shared_ptr<DrawItem>> drawItems_ {};
};
@ -282,8 +283,26 @@ void Placefile::Impl::ProcessLine(const std::string& line)
else if (boost::istarts_with(line, fontKey_))
{
// Font: fontNumber, pixels, flags, "face"
std::vector<std::string> tokenList =
util::ParseTokens(line, {",", ",", ",", ","}, fontKey_.size());
// TODO
if (tokenList.size() >= 4)
{
std::shared_ptr<Font> font = std::make_shared<Font>();
font->fontNumber_ = std::stoul(tokenList[0]);
font->pixels_ = std::stoul(tokenList[1]);
font->flags_ = std::stoi(tokenList[2]);
TrimQuotes(tokenList[3]);
font->face_.swap(tokenList[3]);
fonts_.insert_or_assign(font->fontNumber_, font);
}
else
{
logger_->warn("Font statement malformed: {}", line);
}
}
else if (boost::istarts_with(line, textKey_))
{