Avara3D 0.2.0
C++ API reference
Font.h
1//
2// Font.h
3// avara3d
4//
5// Created by Morgan Davis on 9/5/18.
6// Copyright © 2026 Morgan K Davis. All rights reserved.
7//
8
9#ifndef AVARA3D_FONT_H
10#define AVARA3D_FONT_H
11
12#include <filesystem>
13#include <memory>
14#include <optional>
15
16namespace a3d {
17
18 class Buffer;
19
25 class Font {
26
27 public:
28 // [Public Types]
29
31 enum class Type : uint8_t {
32 Unknown,
33 OTF,
34 TTF,
35 };
36
37 // [Public Lifecycle Functions]
38
47 explicit Font(const std::filesystem::path& path);
48
52 explicit Font(std::unique_ptr<Buffer> buffer);
53
54 Font(const Font& other);
55 Font& operator=(const Font& other);
56
57 Font(Font&& other) noexcept;
58 Font& operator=(Font&& other) noexcept;
59
60 ~Font();
61
62 // [Public Member Functions]
63
65 const std::optional<std::string>& name() const;
66
68 Type type() const;
69
71 const Buffer* buffer() const;
72
73 private:
74 // [Private Member Variables]
75
76 std::optional<std::string> _name;
77 Type _type;
78 std::unique_ptr<Buffer> _buffer;
79 };
80
81}
82
83#endif // AVARA3D_FONT_H
Container for a contiguous byte buffer.
Definition: Buffer.h:23
Owns font file data and basic format metadata.
Definition: Font.h:25
Font(const std::filesystem::path &path)
Loads font data from path and derives its name and type from the path.
Type
Recognized font container types.
Definition: Font.h:31
Type type() const
Returns the detected or assigned font type.
const Buffer * buffer() const
Returns the owned font-data Buffer, or nullptr when no Buffer is owned.
Font(std::unique_ptr< Buffer > buffer)
Takes ownership of buffer as font data with no name or known type.
const std::optional< std::string > & name() const
Returns the font name, or an empty optional when no name is known.