Add text shadow, fix font issues

This commit is contained in:
2023-12-22 08:28:15 +01:00
parent dbb5ac5382
commit a0291d0523
2 changed files with 32 additions and 18 deletions

View File

@@ -133,7 +133,7 @@ static void calculateAxisSizePreorder(const BzUIAxis axis, BzUINode *node) {
break;
case BZ_UI_SIZE_FIT:
BZ_ASSERT(node->string);
Vector2 size = MeasureTextEx(GetFontDefault(), node->string, node->style.fontSize, 2);
Vector2 size = MeasureTextEx(node->style.font, node->string, node->style.fontSize, node->style.fontSpacing);
compSize = (axis == BZ_UI_AXIS_X) ? size.x : size.y;
break;
case BZ_UI_SIZE_PARENT_PERCENT:
@@ -357,11 +357,20 @@ static void renderNode(BzUI *ui, BzUINode *node) {
if (inter->down) color = style->borderActiveColor;
DrawRectangleRoundedLines(rect, style->roundness, 0, style->borderThickness, color);
}
if (node->flags & BZ_UI_DRAW_TEXT_SHADOW) {
Color color = style->textShadowColor;
if (inter->hovering) color = style->textShadowHoverColor;
if (inter->down) color = style->textShadowActiveColor;
DrawTextEx(style->font, node->string, (Vector2){
drawRect.x + style->shadowOffset[BZ_UI_AXIS_X],
drawRect.y + style->shadowOffset[BZ_UI_AXIS_Y]
}, style->fontSize, style->fontSpacing, color);
}
if (node->flags & BZ_UI_DRAW_TEXT) {
Color color = style->textColor;
if (inter->hovering) color = style->textHoverColor;
if (inter->down) color = style->textActiveColor;
DrawTextEx(GetFontDefault(), node->string, (Vector2){drawRect.x, drawRect.y}, style->fontSize, 1, color);
DrawTextEx(style->font, node->string, (Vector2){drawRect.x, drawRect.y}, style->fontSize, style->fontSpacing, color);
}
node->changed = false;