SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
VBF.h
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <filesystem>
5
7#include <sourcepp/Macros.h>
8#include <sourcepp/Math.h>
9
10namespace vtfpp {
11
13
14class VBF {
15public:
16 enum Flags : uint16_t {
18 FLAG_BOLD = 1 << 0,
19 FLAG_ITALIC = 1 << 1,
20 FLAG_OUTLINE = 1 << 2,
22 FLAG_BLUR = 1 << 4,
23 FLAG_SCANLINE = 1 << 5,
25 FLAG_CUSTOM = 1 << 7,
26 };
27
28 struct Glyph {
29 sourcepp::math::Vec2ui16 position;
30 sourcepp::math::Vec2ui16 size;
31 sourcepp::math::Vec3i16 abcSpacing;
32 };
33
34 explicit VBF(std::span<const std::byte> vbfData);
35
36 explicit VBF(const std::filesystem::path& vbfPath);
37
38 [[nodiscard]] explicit operator bool() const;
39
40 [[nodiscard]] sourcepp::math::Vec2ui16 getPageSize() const;
41
42 [[nodiscard]] sourcepp::math::Vec2ui16 getMaxGlyphSize() const;
43
44 [[nodiscard]] Flags getFlags() const;
45
46 [[nodiscard]] uint16_t getAscent() const;
47
48 [[nodiscard]] const std::array<Glyph, 256>& getGlyphs() const;
49
50protected:
51 uint32_t version = 0;
52 sourcepp::math::Vec2ui16 pageSize{};
53 sourcepp::math::Vec2ui16 maxGlyphSize{};
55 uint16_t ascent = 0;
56 std::array<Glyph, 256> glyphs{};
57};
59
60} // namespace vtfpp
#define SOURCEPP_BITFLAGS_ENUM(Enum)
Defines bitwise operators for an enum or enum class.
Definition Macros.h:26
sourcepp::math::Vec2ui16 maxGlyphSize
Definition VBF.h:53
Flags getFlags() const
Definition VBF.cpp:59
sourcepp::math::Vec2ui16 getPageSize() const
Definition VBF.cpp:51
@ FLAG_ANTIALIASED
Definition VBF.h:24
@ FLAG_BLUR
Definition VBF.h:22
@ FLAG_ITALIC
Definition VBF.h:19
@ FLAG_DROP_SHADOW
Definition VBF.h:21
@ FLAG_NONE
Definition VBF.h:17
@ FLAG_BOLD
Definition VBF.h:18
@ FLAG_OUTLINE
Definition VBF.h:20
@ FLAG_SCANLINE
Definition VBF.h:23
@ FLAG_CUSTOM
Definition VBF.h:25
uint16_t ascent
Definition VBF.h:55
sourcepp::math::Vec2ui16 getMaxGlyphSize() const
Definition VBF.cpp:55
std::array< Glyph, 256 > glyphs
Definition VBF.h:56
sourcepp::math::Vec2ui16 pageSize
Definition VBF.h:52
uint32_t version
Definition VBF.h:51
const std::array< Glyph, 256 > & getGlyphs() const
Definition VBF.cpp:67
uint16_t getAscent() const
Definition VBF.cpp:63
VBF(std::span< const std::byte > vbfData)
Definition VBF.cpp:11
Flags flags
Definition VBF.h:54
consteval uint32_t makeFourCC(const char fourCC[4])
Creates a FourCC identifier from a string of 4 characters.
Definition Binary.h:20
Definition HOT.h:11
constexpr uint32_t VBF_SIGNATURE
Definition VBF.h:12
sourcepp::math::Vec2ui16 size
Definition VBF.h:30
sourcepp::math::Vec2ui16 position
Definition VBF.h:29
sourcepp::math::Vec3i16 abcSpacing
Definition VBF.h:31