25[[deprecated(
"FntParser is no longer maintained, and should not be used.")]]
41[[deprecated(
"FntParser is no longer maintained, and should not be used.")]]
65[[deprecated(
"FntParser is no longer maintained, and should not be used.")]]
67 auto x = (float) chr.
x;
68 auto y = (float) chr.
y;
69 auto width = (float) chr.
width;
70 auto height = (float) chr.
height;
72 float reX = ((float) x) / atlasWidth;
73 float reY = ((float) y) / atlasHeight;
74 float newX = ((float) x + width) / atlasWidth;
75 float newY = ((float) y + height) / atlasHeight;
91[[deprecated(
"FntParser is no longer maintained, and should not be used.")]]
92inline std::map<std::string, std::any>
parseLine(
const std::string& line) {
93 std::map<std::string, std::any> keys;
95 size_t i = line.find(
' ') + 1;
102 auto eq = line.find(
'=', i),
103 sp = line.find(
' ', i);
104 if (sp == std::string::npos) sp = line.size();
107 auto fragment = line.substr(i, sp - i);
108 auto k = fragment.substr(0, eq - i);
109 auto v = fragment.substr(eq - i + 1, sp - eq);
112 if (v.find(
'"') != std::string::npos) {
113 if (v ==
"\"\"") value = std::string(
"");
114 else value = v.substr(1, v.size() - 2);
115 }
else if (v.find(
',') != std::string::npos) {
116 std::vector<int> tmp;
119 std::stringstream ss(v);
120 while (std::getline(ss, buff,
',')) {
121 tmp.push_back(std::stoi(buff));
126 value = std::stoi(v);
130 }
while (i < line.size());
134[[deprecated(
"FntParser is no longer maintained, and should not be used.")]]
136 if (!std::filesystem::exists(fileName)) {
137 throw std::runtime_error(
"File doesn't exist");
140 std::filesystem::path p(fileName);
144 throw std::runtime_error(
"File not found");
154 if (buff.starts_with(
"info")) {
155 info.faceName = std::any_cast<std::string>(vars.at(
"face"));
156 info.size = std::any_cast<int>(vars.at(
"size"));
157 info.bold = std::any_cast<int>(vars.at(
"bold"));
158 info.italic = std::any_cast<int>(vars.at(
"italic"));
159 info.unicode = std::any_cast<int>(vars.at(
"unicode"));
160 info.smooth = std::any_cast<int>(vars.at(
"smooth"));
161 info.antiAliasing = std::any_cast<int>(vars.at(
"aa"));
162 auto padding = std::any_cast<std::vector<int>>(vars.at(
"padding"));
164 info.padTop = padding.at(0);
165 info.padRight = padding.at(1);
166 info.padBottom = padding.at(2);
167 info.padLeft = padding.at(3);
169 auto spacing = std::any_cast<std::vector<int>>(vars.at(
"spacing"));
170 info.spaceLeft = spacing.at(0);
171 info.spaceTop = spacing.at(1);
172 }
else if (buff.starts_with(
"common")) {
173 info.lineHeight = std::any_cast<int>(vars.at(
"lineHeight"));
174 info.base = std::any_cast<int>(vars.at(
"base"));
175 info.scaleW = std::any_cast<int>(vars.at(
"scaleW"));
176 info.scaleH = std::any_cast<int>(vars.at(
"scaleH"));
178 }
else if (buff.starts_with(
"page")) {
179 info.pages.push_back(std::any_cast<std::string>(vars.at(
"file")));
180 }
else if (buff.starts_with(
"chars")) {
182 }
else if (buff.starts_with(
"char")) {
184 chr.
id = std::any_cast<int>(vars.at(
"id"));
185 chr.
x = std::any_cast<int>(vars.at(
"x"));
186 chr.
y = std::any_cast<int>(vars.at(
"y"));
187 chr.
width = std::any_cast<int>(vars.at(
"width"));
188 chr.
height = std::any_cast<int>(vars.at(
"height"));
189 chr.
xOffset = std::any_cast<int>(vars.at(
"xoffset"));
190 chr.
yOffset = std::any_cast<int>(vars.at(
"yoffset"));
191 chr.
xAdvance = std::any_cast<int>(vars.at(
"xadvance"));
192 chr.
page = std::any_cast<int>(vars.at(
"page"));
200 info.characters[chr.
id] = chr;
FntInfo loadAndParseFnt(const std::string &fileName)
Definition FntParser.hpp:135
std::map< std::string, std::any > parseLine(const std::string &line)
Definition FntParser.hpp:92
std::vector< float > generateUVCoords(int atlasWidth, int atlasHeight, const FntCharInfo &chr)
Definition FntParser.hpp:66
std::istream & getline(std::istream &is, std::string &str)
Definition StdFix.hpp:21
Definition CaptureStream.hpp:6
Definition FntParser.hpp:26
int x
Definition FntParser.hpp:28
int page
Definition FntParser.hpp:35
int id
Definition FntParser.hpp:27
std::vector< float > uvCoordinates
Definition FntParser.hpp:38
int width
Definition FntParser.hpp:30
int channel
Definition FntParser.hpp:36
int height
Definition FntParser.hpp:31
int y
Definition FntParser.hpp:29
int yOffset
Definition FntParser.hpp:33
int xAdvance
Definition FntParser.hpp:34
int xOffset
Definition FntParser.hpp:32
Definition FntParser.hpp:42
size_t scaleH
Definition FntParser.hpp:45
bool antiAliasing
Definition FntParser.hpp:51
std::map< int, FntCharInfo > characters
Definition FntParser.hpp:61
std::vector< std::string > pages
Definition FntParser.hpp:59
size_t spaceLeft
Definition FntParser.hpp:54
size_t padBottom
Definition FntParser.hpp:53
int base
Definition FntParser.hpp:56
bool smooth
Definition FntParser.hpp:50
int size
Definition FntParser.hpp:44
bool bold
Definition FntParser.hpp:47
std::string faceName
Definition FntParser.hpp:43
bool italic
Definition FntParser.hpp:48
bool unicode
Definition FntParser.hpp:49