Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/Font.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class Font : public FontUnmanaged {
FontUnmanaged::Load(fileName, fontSize, codepoints, codepointCount);
}

void Load(const std::string& fileName, int fontSize, const std::vector<int>& codepoints) {
Unload();
FontUnmanaged::Load(fileName, fontSize, codepoints);
}

void Load(const ::Image& image, ::Color key, int firstChar) {
Unload();
FontUnmanaged::Load(image, key, firstChar);
Expand Down
19 changes: 19 additions & 0 deletions include/FontUnmanaged.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define RAYLIB_CPP_INCLUDE_FONTUNMANAGED_HPP_

#include <string>
#include <vector>

#include "./RaylibException.hpp"
#include "./TextureUnmanaged.hpp"
Expand Down Expand Up @@ -55,6 +56,15 @@ class FontUnmanaged : public ::Font {
Load(fileName, fontSize, codepoints, codepointCount);
}

/**
* Loads a Font from the given file, with the given codepoints.
*
* @throws raylib::RaylibException Throws if the given font failed to initialize.
*/
FontUnmanaged(const std::string& fileName, int fontSize, const std::vector<int>& codepoints) {
Load(fileName, fontSize, codepoints);
}

/**
* Loads a Font from the given image with a color key.
*
Expand Down Expand Up @@ -123,6 +133,15 @@ class FontUnmanaged : public ::Font {
}
}

/**
* Loads a font from a given file, with the given codepoints.
*
* @throws raylib::RaylibException Throws if the given font failed to initialize.
*/
void Load(const std::string& fileName, int fontSize, const std::vector<int>& codepoints) {
Load(fileName, fontSize, codepoints.data(), static_cast<int>(codepoints.size()));
}

/**
* Loads a font from an image with a color key.
*
Expand Down
18 changes: 18 additions & 0 deletions include/Functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,24 @@ RLCPP_MAYBEUNUSED RLCPPAPI inline std::string TextToCamel(const std::string& tex
return ::TextToCamel(text.c_str());
}

/**
* Load all codepoints from a UTF-8 text string
*/
RLCPP_MAYBEUNUSED RLCPPAPI std::vector<int> LoadCodepoints(const std::string& text) {
int count = 0;
int* codepoints = ::LoadCodepoints(text.c_str(), &count);
std::vector<int> output(codepoints, codepoints + count);
::UnloadCodepoints(codepoints);
return output;
}

/**
* Get total number of codepoints in a UTF-8 encoded string
*/
RLCPP_MAYBEUNUSED RLCPPAPI inline int GetCodepointCount(const std::string& text) {
return ::GetCodepointCount(text.c_str());
}

/**
* Get integer value from text (negative values not supported)
*/
Expand Down
Loading