OdbDesignLib
OdbDesign ODB++ Parsing Library
 
Loading...
Searching...
No Matches
StandardFontsFile.h
1#pragma once
2
3#include "../OdbFile.h"
4#include "../../odbdesign_export.h"
5#include "../../enums.h"
6#include <string>
7#include <vector>
8#include "../../IProtoBuffable.h"
9#include "standardfontsfile.pb.h"
10#include "../IStreamSaveable.h"
11
12namespace Odb::Lib::FileModel::Design
13{
14 class ODBDESIGN_EXPORT StandardFontsFile : public OdbFile, public IProtoBuffable<Odb::Lib::Protobuf::StandardFontsFile>, public IStreamSaveable
15 {
16 public:
17 StandardFontsFile() = default;
19
20 bool Parse(std::filesystem::path path) override;
21 // Inherited via IStreamSaveable
22 bool Save(std::ostream& os) override;
23
24 // Inherited via IProtoBuffable
25 std::unique_ptr<Odb::Lib::Protobuf::StandardFontsFile> to_protobuf() const override;
26 void from_protobuf(const Odb::Lib::Protobuf::StandardFontsFile& message) override;
27
28 struct CharacterBlock : public IProtoBuffable<Odb::Lib::Protobuf::StandardFontsFile::CharacterBlock>
29 {
31
32 struct LineRecord : public IProtoBuffable<Odb::Lib::Protobuf::StandardFontsFile::CharacterBlock::LineRecord>
33 {
34 double xStart;
35 double yStart;
36 double xEnd;
37 double yEnd;
38 Polarity polarity;
39 LineShape shape;
40 double width;
41
42 std::unique_ptr<Odb::Lib::Protobuf::StandardFontsFile::CharacterBlock::LineRecord> to_protobuf() const override;
43 void from_protobuf(const Odb::Lib::Protobuf::StandardFontsFile::CharacterBlock::LineRecord& message) override;
44
45 typedef std::vector<std::shared_ptr<LineRecord>> Vector;
46
47 inline static constexpr const char* RECORD_TOKEN = "LINE";
48 };
49
50 inline static constexpr const char* BEGIN_TOKEN = "CHAR";
51 inline static constexpr const char* END_TOKEN = "ECHAR";
52
53 // Glyph key as read from the fonts/standard file: a single byte that
54 // may be a high CP1252 byte. A string (not a char) so from_protobuf()
55 // can hold the multi-byte sanitized glyph. Sanitized to UTF-8 only at
56 // the protobuf boundary in to_protobuf(); the reverse direction is
57 // lossy for high bytes — after a protobuf round trip this member
58 // holds the sanitized UTF-8 glyph, not the original raw byte.
59 std::string character;
60 LineRecord::Vector m_lineRecords;
61
62 std::unique_ptr<Odb::Lib::Protobuf::StandardFontsFile::CharacterBlock> to_protobuf() const override;
63 void from_protobuf(const Odb::Lib::Protobuf::StandardFontsFile::CharacterBlock& message) override;
64
65 typedef std::vector<std::shared_ptr<CharacterBlock>> Vector;
66
67 };
68
69 private:
70 double m_xSize;
71 double m_ySize;
72 double m_offset;
73
74 CharacterBlock::Vector m_characterBlocks;
75 };
76}
77