Skip to content

Commit

Permalink
updated to silicon.h
Browse files Browse the repository at this point in the history
  • Loading branch information
ColleagueRiley committed Oct 22, 2023
1 parent 6b9b01f commit f9365c1
Show file tree
Hide file tree
Showing 28 changed files with 3,222 additions and 4,137 deletions.
13 changes: 10 additions & 3 deletions RSGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ keys will not be reincluded into RSGL
#endif
#endif

#define RGFWDEF RSGLDEF

#if !defined(u8)
#include <stdint.h>

Expand Down Expand Up @@ -351,6 +353,7 @@ RSGLDEF void RSGL_setFont(u32 font);
typedef struct RFont_font RFont_font;
RSGLDEF void RSGL_setRFont(RFont_font* font);

RSGLDEF void RSGL_drawText_len(const char* text, size_t len, RSGL_circle c, RSGL_color color);
RSGLDEF void RSGL_drawText(const char* text, RSGL_circle c, RSGL_color color);
#define RSGL_drawTextF(text, font, c, color) \
RSGL_setFont(font);\
Expand Down Expand Up @@ -1249,7 +1252,7 @@ void RSGL_setRFont(RFont_font* font) {
RSGL_font.f = font;
}

void RSGL_drawText(const char* text, RSGL_circle c, RSGL_color color) {
void RSGL_drawText_len(const char* text, size_t len, RSGL_circle c, RSGL_color color) {
glEnable(GL_BLEND);

if (text == NULL || text[0] == '\0')
Expand All @@ -1260,13 +1263,17 @@ void RSGL_drawText(const char* text, RSGL_circle c, RSGL_color color) {
glPrerequisites((RSGL_rect) {c.x, c.y + (c.d - (c.d/4)), w, c.d}, color);

RFont_set_color(color.r / 255.0f, color.b / 255.0f, color.g / 255.0f, color.a / 255.0f);
RFont_draw_text(RSGL_font.f, text, c.x, c.y, c.d);
RFont_draw_text_len(RSGL_font.f, text, len, c.x, c.y, c.d, 0.0f);

rglPopMatrix();
}

void RSGL_drawText(const char* text, RSGL_circle c, RSGL_color color) {
RSGL_drawText_len(text, 0, c, color);
}

u32 RSGL_textWidth(const char* text, u32 fontSize, size_t textEnd) {
return RFont_text_width(RSGL_font.f, text, fontSize);
return RFont_text_width_len(RSGL_font.f, text, fontSize, textEnd);
}
#endif /* RSGL_NO_TEXT */

Expand Down
8 changes: 6 additions & 2 deletions deps/RFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,10 @@ size_t RFont_text_width_len(RFont_font* font, const char* text, size_t len, u32
if (RFont_decode_utf8(&utf8state, &codepoint, *(const u8*)str) != RFONT_UTF8_ACCEPT)
continue;

const u8 i = codepoint - ' ';
u32 i;
for (i = 0; i < font->glyph_len; i++)
if (font->glyphs[i].codepoint == codepoint && font->glyphs[i].size == size)
break;

if (font->glyphs[i].codepoint == codepoint && font->glyphs[i].size == size) {
glyph = font->glyphs[i].src;
Expand Down Expand Up @@ -595,7 +598,8 @@ size_t RFont_text_width_len(RFont_font* font, const char* text, size_t len, u32

if (x > width)
width = x;


printf("%i\n", width);
return width;
}

Expand Down
Loading

0 comments on commit f9365c1

Please sign in to comment.