Cobbletext  0.2.0
Complex text layout and rendering engine
Engine.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <memory>
5 
6 #include "AdvanceInfo.hpp"
7 #include "common.hpp"
8 #include "macros.h"
9 #include "Encoding.hpp"
10 #include "FontInfo.hpp"
11 #include "GlyphInfo.hpp"
12 #include "Library.hpp"
13 #include "OutputInfo.hpp"
14 #include "ScriptDirection.hpp"
15 #include "TileInfo.hpp"
16 #include "TextAlignment.hpp"
17 
18 namespace cobbletext {
19 
20 
22 public:
23  uint32_t lineLength = 0;
24  std::string locale;
26  std::string language;
27  std::string script;
29  FontID font = 0;
30  double fontSize = 12;
31  CustomPropertyID customProperty = 0;
33 
34  std::vector<TileInfo> tiles();
35  std::vector<AdvanceInfo> advances();
36 
37  explicit Engine(std::shared_ptr<Library> library);
38  ~Engine();
39 
40  void addText(const uint8_t * data, uint32_t length, Encoding encoding);
41  void addTextUTF8(std::string_view text);
42  void addTextUTF8(const char * text, int32_t length);
43  void addTextUTF16(std::u16string_view text);
44  void addTextUTF16(const char16_t * text, int32_t length);
45  void addTextUTF32(std::u32string_view text);
46  void addTextUTF32(const char32_t * text, int32_t length);
47 
48  void addInlineObject(InlineObjectID id, uint32_t width, uint32_t height);
49 
50  void clear();
51  void layOut();
52 
53  bool tilesValid();
54 
55  void rasterize();
56 
57  bool packTiles(uint32_t width, uint32_t height);
58  void clearTiles();
59 
60 private:
61  class Impl;
62  std::unique_ptr<Impl> impl;
63 };
64 
65 }
cobbletext::ScriptDirection
ScriptDirection
Definition: ScriptDirection.hpp:7
cobbletext::TextAlignment::NotSpecified
@ NotSpecified
Encoding.hpp
Library.hpp
common.hpp
cobbletext::CustomPropertyID
uint32_t CustomPropertyID
Definition: common.hpp:10
GlyphInfo.hpp
TileInfo.hpp
macros.h
cobbletext::OutputInfo
Definition: OutputInfo.hpp:10
COBBLETEXT_CPP_API
#define COBBLETEXT_CPP_API
Macro for Windows C++ symbol import and export.
Definition: macros.h:33
cobbletext::TextAlignment
TextAlignment
Definition: TextAlignment.hpp:5
ScriptDirection.hpp
cobbletext::InlineObjectID
uint32_t InlineObjectID
Definition: common.hpp:9
cobbletext::ScriptDirection::NotSpecified
@ NotSpecified
cobbletext::Engine::locale
std::string locale
Definition: Engine.hpp:24
FontInfo.hpp
cobbletext::Engine
Definition: Engine.hpp:21
cobbletext::FontID
uint32_t FontID
Definition: common.hpp:7
cobbletext
Definition: AdvanceInfo.hpp:8
cobbletext::Engine::outputInfo
OutputInfo outputInfo
Definition: Engine.hpp:32
cobbletext::Encoding
Encoding
Definition: Encoding.hpp:5
AdvanceInfo.hpp
TextAlignment.hpp
cobbletext::Engine::language
std::string language
Definition: Engine.hpp:26
cobbletext::Engine::script
std::string script
Definition: Engine.hpp:27
OutputInfo.hpp