VN System improved.
This commit is contained in:
@ -37,6 +37,17 @@ namespace Dawn {
|
||||
struct FontMeasure *info
|
||||
) = 0;
|
||||
|
||||
/**
|
||||
* Fonts need to be initialized before they can actually be used, but I
|
||||
* really want to keep things kind-of non-blocking, so for the time being
|
||||
* this hack works around it, fonts can decide to return false if they are
|
||||
* not "ready for buffering", and the item intending to use the font is
|
||||
* required to decide when it should actually request buffering.
|
||||
*
|
||||
* @return True if ready for buffering, otherwise false.
|
||||
*/
|
||||
virtual bool_t isReady() = 0;
|
||||
|
||||
/**
|
||||
* Returns the texture that is used for a given font.
|
||||
*
|
||||
|
@ -40,12 +40,56 @@ namespace Dawn {
|
||||
*/
|
||||
void addLine(int32_t start, int32_t length);
|
||||
|
||||
/**
|
||||
* Returns the width of this measured string.
|
||||
*
|
||||
* @return Width of the pre measured string.
|
||||
*/
|
||||
float_t getWidth();
|
||||
|
||||
/**
|
||||
* Returns the height of the measured string.
|
||||
*
|
||||
* @return Height of the pre measured string.
|
||||
*/
|
||||
float_t getHeight();
|
||||
|
||||
/**
|
||||
* Returns the count of quads on the given line.
|
||||
*
|
||||
* @param line Which line to get the count of quads for.
|
||||
* @return Count of quads on that line.
|
||||
*/
|
||||
int32_t getQuadsOnLine(int32_t line);
|
||||
|
||||
/**
|
||||
* Returns the index, of which quad is the first quad on the given line.
|
||||
*
|
||||
* @param line Line to get the quad index of.
|
||||
* @return The quad index of that line.
|
||||
*/
|
||||
int32_t getQuadIndexOnLine(int32_t line);
|
||||
|
||||
/**
|
||||
* Returns the height of the count of lines provided.
|
||||
*
|
||||
* @param lineCount Count of lines to get the height of.
|
||||
* @return Height of the given count of lines.
|
||||
*/
|
||||
float_t getHeightOfLineCount(int32_t lineCount);
|
||||
|
||||
/**
|
||||
* Returns the count of lines in this string.
|
||||
*
|
||||
* @return Count of lines.
|
||||
*/
|
||||
size_t getLineCount();
|
||||
|
||||
/**
|
||||
* Returns the count of quads in this string.
|
||||
*
|
||||
* @return Total count of quads.
|
||||
*/
|
||||
int32_t getQuadCount();
|
||||
};
|
||||
}
|
@ -56,6 +56,7 @@ void TrueTypeFont::buffer(
|
||||
assertNotNull(info);
|
||||
assertTrue(fontSize > 0);
|
||||
assertTrue(maxWidth == -1 || maxWidth > 0);
|
||||
assertTrue(this->isReady());
|
||||
|
||||
auto stringLength = text.length();
|
||||
if(stringLength == 0) {
|
||||
@ -189,6 +190,10 @@ void TrueTypeFont::buffer(
|
||||
delete quads;
|
||||
}
|
||||
|
||||
bool_t TrueTypeFont::isReady() {
|
||||
return this->texture.isReady();
|
||||
}
|
||||
|
||||
Texture * TrueTypeFont::getTexture() {
|
||||
return &this->texture;
|
||||
}
|
||||
|
@ -74,6 +74,7 @@ namespace Dawn {
|
||||
Mesh *mesh,
|
||||
struct FontMeasure *info
|
||||
) override;
|
||||
bool_t isReady() override;
|
||||
Texture * getTexture() override;
|
||||
void draw(Mesh *mesh, int32_t startCharacter, int32_t length) override;
|
||||
float_t getLineHeight(float_t fontSize) override;
|
||||
|
Reference in New Issue
Block a user