Keep on improving fonts.

This commit is contained in:
2023-01-24 14:49:31 -08:00
parent 6f75e8b7a4
commit dd83f2cefa
9 changed files with 133 additions and 8 deletions

View File

@ -37,17 +37,17 @@ float_t TrueTypeFont::getScale(float_t scale) {
float_t TrueTypeFont::getSpaceSize(float_t fontSize) {
assertTrue(fontSize > 0);
return mathRound<float_t>(this->getScale(fontSize) * 18);
return this->getScale(fontSize) * 18;
}
float_t TrueTypeFont::getInitialLineHeight(float_t fontSize) {
assertTrue(fontSize > 0);
return mathRound<float_t>(42.0f * this->getScale(fontSize));
return 42.0f * this->getScale(fontSize);
}
float_t TrueTypeFont::getLineHeight(float_t fontSize) {
assertTrue(fontSize > 0);
return mathRound<float_t>(58.0f * this->getScale(fontSize));
return 96.0f * this->getScale(fontSize);
}
void TrueTypeFont::buffer(
@ -105,7 +105,14 @@ void TrueTypeFont::buffer(
// Setup the initial loop state, and X/Y coords for the quad.
int32_t i = 0;
float_t x = 0;
float_t y = this->getInitialLineHeight(fontSize) / scale;
float_t y = 0;
// Bake the first quad.
this->bakeQuad(quads, &x, &y, 'D');
y = -(quads->y0);
x = 0;
// y = this->getInitialLineHeight(fontSize) / scale;
float_t wordX = 0;
char c;
while(c = text[i++]) {

View File

@ -0,0 +1,38 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "prefab/SceneItemPrefab.hpp"
#include "display/mesh/CubeMesh.hpp"
#include "scene/components/display/MeshRenderer.hpp"
#include "scene/components/display/MeshHost.hpp"
#include "scene/components/display/material/SimpleTexturedMaterial.hpp"
#include "scene/components/example/ExampleSpin.hpp"
namespace Dawn {
class SimpleSpinningCubePrefab :
public SceneItemPrefab<SimpleSpinningCubePrefab>
{
public:
std::vector<Asset*> prefabAssets(AssetManager *man) {
return std::vector<Asset*>();
}
SimpleSpinningCubePrefab(Scene *s, sceneitemid_t i) :
SceneItemPrefab(s, i)
{
}
void prefabInit(AssetManager *man) override {
auto meshRenderer = this->addComponent<MeshRenderer>();
auto meshHost = this->addComponent<MeshHost>();
auto spinning = this->addComponent<ExampleSpin>();
auto material = this->addComponent<SimpleTexturedMaterial>();
meshHost->mesh.createBuffers(CUBE_VERTICE_COUNT, CUBE_INDICE_COUNT);
CubeMesh::buffer(&meshHost->mesh, glm::vec3(-0.5f, -0.5f, -0.5f), glm::vec3(1, 1, 1), 0, 0);
}
};
}

View File

@ -91,7 +91,7 @@ std::vector<struct ShaderPassItem> UILabel::getSelfPassItems(
this->z
);
item.start = this->startQuad * QUAD_INDICE_COUNT;
item.count = this->quadCount * QUAD_INDICE_COUNT;
item.count = this->quadCount == -1 ? -1 : this->quadCount * QUAD_INDICE_COUNT;
items.push_back(item);
return items;
}

View File

@ -135,7 +135,6 @@ void VisualNovelTextbox::textboxOnSceneUpdate() {
}
}
if(this->talkSound != nullptr) {
auto vnManager = this->getVisualNovelManager();
assertNotNull(vnManager);