yet another api rework, removal of integer types in public api, optionals at the end, some cleaning

This commit is contained in:
veclavtalica
2024-10-29 12:25:24 +03:00
parent 6464d14b3e
commit 9121da0675
30 changed files with 191 additions and 342 deletions

View File

@ -275,8 +275,8 @@ void text_cache_reset_arena(TextCache *cache) {
}
void draw_text(const char *string, Vec2 position, int height_px, Color color, const char *font_path) {
ensure_font_cache(font_path, height_px);
void draw_text(const char *string, Vec2 position, float height, Color color, const char *font) {
ensure_font_cache(font, (int)height);
/* the original string might not be around by the time it's used, so copy it */
size_t str_length = SDL_strlen(string) + 1;
@ -290,8 +290,8 @@ void draw_text(const char *string, Vec2 position, int height_px, Color color, co
.color = color,
.position = position,
.text = dup_string,
.font = font_path,
.height_px = height_px,
.font = font,
.height_px = (int)height,
};
Primitive2D primitive = {
@ -303,9 +303,9 @@ void draw_text(const char *string, Vec2 position, int height_px, Color color, co
}
int draw_text_width(const char *string, int height_px, const char *font_path) {
ensure_font_cache(font_path, height_px);
FontData *font_data = get_font_data(font_path, height_px);
float draw_text_width(const char *string, float height, const char *font) {
ensure_font_cache(font, (int)height);
FontData *font_data = get_font_data(font, (int)height);
int length = 0;
for (const char *p = string; *p != '\0'; ++p) {
@ -316,5 +316,5 @@ int draw_text_width(const char *string, int height_px, const char *font_path) {
length += advance_width;
}
return (int)((float)length * font_data->scale_factor);
return (float)length * font_data->scale_factor;
}