35 lines
741 B
C++
35 lines
741 B
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <types/ptr/ref_counted.h>
|
|
#include <vector>
|
|
|
|
namespace extra2d {
|
|
|
|
class Font : public RefCounted {
|
|
public:
|
|
Font();
|
|
~Font() override;
|
|
|
|
bool loadFromFile(const std::string &path);
|
|
bool loadFromMemory(const uint8_t *data, size_t size);
|
|
|
|
bool isLoaded() const { return loaded_; }
|
|
int ascent() const { return ascent_; }
|
|
int descent() const { return descent_; }
|
|
int lineGap() const { return lineGap_; }
|
|
float scaleForPixelHeight(float pixelHeight) const;
|
|
float lineHeight(float pixelHeight) const;
|
|
|
|
private:
|
|
std::vector<uint8_t> data_;
|
|
bool loaded_ = false;
|
|
int ascent_ = 0;
|
|
int descent_ = 0;
|
|
int lineGap_ = 0;
|
|
};
|
|
|
|
} // namespace extra2d
|