# Changes 0.2.4-1

- Add GIT_BRANCH (for development and stable)
- Write  Documentation of
  - pd-core (exept of vec.hpp)
  - pd-app
  - pd-drivers
  - pd-lib3ds
  - pd-image
  - pd-image
  - pd-ui7
This commit is contained in:
2025-03-02 21:11:58 +01:00
parent af3d3e0b5b
commit 7d3f619169
56 changed files with 2481 additions and 536 deletions

View File

@ -25,70 +25,156 @@ SOFTWARE.
*/
#include <pd/core/common.hpp>
#include <pd/core/vec.hpp>
#include <pd/lithium/rect.hpp>
#include <pd/lithium/texture.hpp>
#include <pd/core/vec.hpp>
namespace PD {
namespace LI {
/** Font Loader for Lithium */
class Font : public SmartCtor<Font> {
public:
/** Codepoint Data holder */
class Codepoint {
public:
Codepoint() {}
~Codepoint() {}
Codepoint() = default;
~Codepoint() = default;
/**
* Codepoint ID Getter
* @return 32Bit codepoint value
*/
u32 cp() const { return m_cp; }
/**
* Codepoint ID Setter
* @param v codepoint id
* @return DataHolder reference
*/
Codepoint& cp(u32 v) {
m_cp = v;
return *this;
}
/**
* Getter for the UV Coords
* @return uv coords
*/
vec4 uv() const { return m_uv; }
/**
* Setter for the UV Coords
* @param v uv coords
* @return DataHolder Reference
*/
Codepoint& uv(const vec4& v) {
m_uv = v;
return *this;
}
/**
* Getter for the Texture reference
* @return Texture Reference
*/
Texture::Ref tex() const { return m_tex; }
/**
* Setter for the Texture Reference
* @param v Texture Reference
* @return DataHolder Reference
*/
Codepoint& tex(Texture::Ref v) {
m_tex = v;
return *this;
}
/**
* Getter for the size
* @return Size
*/
vec2 size() const { return m_size; }
/**
* Setter for the Size
* @param v size
* @return DataHolder Reference
*/
Codepoint& size(const vec2& v) {
m_size = v;
return *this;
}
/**
* Getter for the Position offset
* @return offset
*/
float off() const { return m_off; }
/**
* Setter for the Render Offset
* @param v offset
* @return DataHolder Reference
*/
Codepoint& off(float v) {
m_off = v;
return *this;
}
/**
* Getter to check if Codepoint is invalid
* @return true if invalid
*/
bool invalid() const { return m_invalid; }
/**
* Setter for invald state
* @param v true or false
* @return DataHolder Reference
*/
Codepoint& invalid(bool v) {
m_invalid = v;
return *this;
}
private:
/** 32Bit Codepoint ID */
u32 m_cp = 0;
/** UvMap */
vec4 m_uv;
/** Texture Reference */
Texture::Ref m_tex = nullptr;
/** Codepoint Size */
vec2 m_size;
/** Render Position Offset */
float m_off = 0;
/** Invalid check (for skip in renderer) */
bool m_invalid = false;
};
Font() {}
~Font() {}
Font() = default;
~Font() = default;
/**
* Load a TTF File
* @param path Path to the TTF file
* @param px_height Pixelheight of the codepoints (limit by 64)
*/
void LoadTTF(const std::string& path, int px_height = 32);
/**
* Load 3DS System FOnt
*/
void LoadSystemFont();
/**
* Getter for PixelHeight
* @return pixelheigt
*/
int PixelHeight() const { return pixel_height; }
/**
* Getter for Codepoint reference
* @return codepoint dataholder reference
*/
Codepoint& GetCodepoint(u32 c);
/**
* Check if Systemfont is used
* @return true if is system font
*/
bool SystemFont() const { return sysfont; }
private:
/** sysfont set to true if LoadSystemFont got called */
bool sysfont;
/** Pixelheight */
int pixel_height;
/** List of textures (codepoints are using) */
std::vector<Texture::Ref> textures;
/** 32Bit Codepoint Dataholder Reference Map */
std::map<u32, Codepoint> cpmap;
};
} // namespace LI