diff --git a/data/blackboard.art b/data/blackboard.art index e455bee..20132b3 100644 Binary files a/data/blackboard.art and b/data/blackboard.art differ diff --git a/src/AssetManager.c b/src/AssetManager.c index 78656d5..f02758d 100644 --- a/src/AssetManager.c +++ b/src/AssetManager.c @@ -266,7 +266,8 @@ const i32 asset_loadTTFont(AssetManager *assetManager, const char *filePath) i32 startingGlyphIndex = 0; i32 glyphsRemaining = numGlyphs; - i32 glyphsOnCurrRow = glyphsPerRow; + i32 glyphsOnCurrRow = + (glyphsPerRow < glyphsRemaining) ? glyphsPerRow : glyphsRemaining; // TODO(doyle): We copy over the bitmap direct to the font sheet, should we // align the baselines up so we don't need to do baseline adjusting at diff --git a/src/Renderer.c b/src/Renderer.c index 27bf989..4888a9f 100644 --- a/src/Renderer.c +++ b/src/Renderer.c @@ -23,12 +23,16 @@ void renderer_string(Renderer *const renderer, v4 cameraBounds, f32 rotate, v4 color) { i32 strLen = common_strlen(string); + // TODO(doyle): Scale, not too important .. but rudimentary infrastructure + // laid out here + f32 scale = 1.0f; + // TODO(doyle): Slightly incorrect string length in pixels calculation, // because we use the advance metric of each character for length not // maximum character size in rendering v2 rightAlignedP = - v2_add(pos, V2((CAST(f32) font->maxSize.w * CAST(f32) strLen), - CAST(f32) font->maxSize.h)); + v2_add(pos, V2(scale *(CAST(f32) font->maxSize.w * CAST(f32) strLen), + scale * CAST(f32) font->maxSize.h)); v2 leftAlignedP = pos; if ((leftAlignedP.x < cameraBounds.z && rightAlignedP.x >= cameraBounds.x) && (leftAlignedP.y < cameraBounds.y && rightAlignedP.y >= cameraBounds.w)) @@ -49,12 +53,12 @@ void renderer_string(Renderer *const renderer, v4 cameraBounds, i32 codepoint = string[i]; i32 relativeIndex = codepoint - font->codepointRange.x; CharMetrics charMetric = font->charMetrics[relativeIndex]; - pos.y = baseline - charMetric.offset.y; + pos.y = baseline - (scale * charMetric.offset.y); const v4 charRectOnScreen = getRect( - pos, V2(CAST(f32) font->maxSize.w, CAST(f32) font->maxSize.h)); + pos, V2(scale * CAST(f32) font->maxSize.w, scale * CAST(f32) font->maxSize.h)); - pos.x += charMetric.advance; + pos.x += scale * charMetric.advance; /* Get texture out */ v4 charTexRect = font->atlas->texRect[relativeIndex];