mirror of
https://github.com/GLEGram/GLEGram-iOS.git
synced 2026-05-01 23:35:13 +02:00
4647310322
Based on Swiftgram 12.5 (Telegram iOS 12.5). All GLEGram features ported and organized in GLEGram/ folder. Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass, Font Replacement, Fake Profile, Chat Export, Plugin System, and more. See CHANGELOG_12.5.md for full details.
104 lines
2.7 KiB
C++
104 lines
2.7 KiB
C++
#ifndef Font_hpp
|
|
#define Font_hpp
|
|
|
|
#include "Lottie/Private/Parsing/JsonParsing.hpp"
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace lottie {
|
|
|
|
class Font {
|
|
public:
|
|
Font(
|
|
std::string const &name_,
|
|
std::string const &familyName_,
|
|
std::string const &style_,
|
|
float ascent_
|
|
) :
|
|
name(name_),
|
|
familyName(familyName_),
|
|
style(style_),
|
|
ascent(ascent_) {
|
|
}
|
|
|
|
explicit Font(lottiejson11::Json::object const &json) noexcept(false) {
|
|
name = getString(json, "fName");
|
|
familyName = getString(json, "fFamily");
|
|
path = getOptionalString(json, "fPath");
|
|
weight = getOptionalString(json, "fWeight");
|
|
fontClass = getOptionalString(json, "fClass");
|
|
style = getString(json, "fStyle");
|
|
ascent = (float)getDouble(json, "ascent");
|
|
origin = getOptionalInt(json, "origin");
|
|
}
|
|
|
|
lottiejson11::Json::object toJson() const {
|
|
lottiejson11::Json::object result;
|
|
|
|
result.insert(std::make_pair("fName", name));
|
|
result.insert(std::make_pair("fFamily", familyName));
|
|
if (path.has_value()) {
|
|
result.insert(std::make_pair("fPath", path.value()));
|
|
}
|
|
if (weight.has_value()) {
|
|
result.insert(std::make_pair("fWeight", weight.value()));
|
|
}
|
|
if (fontClass.has_value()) {
|
|
result.insert(std::make_pair("fClass", fontClass.value()));
|
|
}
|
|
result.insert(std::make_pair("fStyle", style));
|
|
result.insert(std::make_pair("ascent", ascent));
|
|
if (origin.has_value()) {
|
|
result.insert(std::make_pair("origin", origin.value()));
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public:
|
|
std::string name;
|
|
std::string familyName;
|
|
std::optional<std::string> path;
|
|
std::optional<std::string> weight;
|
|
std::optional<std::string> fontClass;
|
|
std::string style;
|
|
float ascent;
|
|
std::optional<int> origin;
|
|
};
|
|
|
|
/// A list of fonts
|
|
class FontList {
|
|
public:
|
|
FontList(std::vector<Font> const &fonts_) :
|
|
fonts(fonts_) {
|
|
}
|
|
|
|
explicit FontList(lottiejson11::Json::object const &json) noexcept(false) {
|
|
if (const auto fontsData = getOptionalObjectArray(json, "list")) {
|
|
for (const auto &fontData : fontsData.value()) {
|
|
fonts.emplace_back(fontData);
|
|
}
|
|
}
|
|
}
|
|
|
|
lottiejson11::Json::object toJson() const {
|
|
lottiejson11::Json::array fontArray;
|
|
|
|
for (const auto &font : fonts) {
|
|
fontArray.push_back(font.toJson());
|
|
}
|
|
|
|
lottiejson11::Json::object result;
|
|
result.insert(std::make_pair("list", fontArray));
|
|
return result;
|
|
}
|
|
|
|
public:
|
|
std::vector<Font> fonts;
|
|
};
|
|
|
|
}
|
|
|
|
#endif /* Font_hpp */
|