GetHeight

Returns the height of a font. The height is measured as the space between the font baseline and cap height.

Syntax

Returns

Returns the font's height.

Example

#include "Leadwerks.h"

using namespace Leadwerks;

int main(int argc, const char *argv[])
{
Leadwerks::Window* window = Leadwerks::Window::Create();
Context* context = Context::Create(window);
//Load a font
Font* font = Font::Load("Fonts/arial.ttf", 36);

context->SetFont(font);
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;

context->SetColor(0, 0, 0, 0);
context->Clear();
context->SetColor(1, 1, 1, 0);
//Display some centered text
std::string text = "Leadwerks";
int screenwidth = context->GetWidth();
int screenheight = context->GetHeight();
int x = (screenwidth - font->GetTextWidth(text)) / 2;
int y = (screenheight - font->GetHeight()) / 2;

context->SetBlendMode(Blend::Alpha);
context->DrawText(text, x, y);

context->SetBlendMode(Blend::Solid);
context->Sync();
}
return 0;
}