Dawn/src/dawn/display/font/FontMeasure.hpp

51 lines
1.4 KiB
C++

// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "dawnlibs.hpp"
#include "assert/assert.hpp"
namespace Dawn {
struct FontLineMeasure {
/** What (real character) index the line starts at */
int32_t start;
/** How many (real) characters the line is in length */
int32_t length;
};
struct FontMeasure {
public:
/** How many raw chars are in the string */
int32_t length;
/** How many real characters (non whitespace) are in the string */
int32_t realLength;
/** The real character info for each line */
std::vector<struct FontLineMeasure> lines;
/** Dimensions of the string */
float_t width, height;
/** Height of a single line */
float_t lineHeight;
/**
* Internal method that adds a line to the text buffer process.
*
* @param start Start character index for the next line.
* @param len Length of the next line.
*/
void addLine(int32_t start, int32_t length);
float_t getWidth();
float_t getHeight();
int32_t getQuadsOnLine(int32_t line);
int32_t getQuadIndexOnLine(int32_t line);
float_t getHeightOfLineCount(int32_t lineCount);
size_t getLineCount();
int32_t getQuadCount();
};
}