diff --git a/wxdata/include/scwx/gr/placefile.hpp b/wxdata/include/scwx/gr/placefile.hpp index 71f26cb3..c4744b17 100644 --- a/wxdata/include/scwx/gr/placefile.hpp +++ b/wxdata/include/scwx/gr/placefile.hpp @@ -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}; diff --git a/wxdata/source/scwx/gr/placefile.cpp b/wxdata/source/scwx/gr/placefile.cpp index 04dc0ae3..765d59dc 100644 --- a/wxdata/source/scwx/gr/placefile.cpp +++ b/wxdata/source/scwx/gr/placefile.cpp @@ -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}; @@ -61,8 +62,8 @@ public: DrawingStatement currentStatement_ {DrawingStatement::Standard}; // References - std::unordered_map iconFiles_ {}; - std::unordered_map fonts_ {}; + std::unordered_map iconFiles_ {}; + std::unordered_map> fonts_ {}; std::vector> 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 tokenList = + util::ParseTokens(line, {",", ",", ",", ","}, fontKey_.size()); - // TODO + if (tokenList.size() >= 4) + { + std::shared_ptr font = std::make_shared(); + + 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_)) {