Rework font system
* Fonts not loaded automatically anymore, load with SLK_draw_[DRAWTYPE]_load_font(path) * Changed included font, because of unknown license/origin * Included some more fonts
14
data/README.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Asset credits/collection
|
||||
|
||||
Here is a list of all assets used by SoftLK and its examples.
|
||||
|
||||
## Fonts
|
||||
|
||||
Not all fonts listed here are actively used in the examples, but they can be found in the data/fonts directory and used by you.
|
||||
|
||||
|File name|Image|License|Source|
|
||||
|---|---|---|---|
|
||||
|techno.png|![techno](fonts/techno.png)|CC0/public domain|[usr_share](https://opengameart.org/content/new-original-grafx2-font-collection)
|
||||
|solar.png|![solar](fonts/solar.png)|CC0/public domain|[usr_share](https://opengameart.org/content/new-original-grafx2-font-collection)
|
||||
|cursive1.png|![cursive1](fonts/cursive1.png)|CC0/public domain|[usr_share](https://opengameart.org/content/new-original-grafx2-font-collection)
|
||||
|cursive2.png|![cursive2](fonts/cursive2.png)|CC0/public domain|[usr_share](https://opengameart.org/content/new-original-grafx2-font-collection)
|
BIN
data/fonts/cursive1.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
data/fonts/cursive1.slk
Normal file
BIN
data/fonts/cursive2.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
data/fonts/cursive2.slk
Normal file
BIN
data/fonts/solar.png
Normal file
After Width: | Height: | Size: 983 B |
BIN
data/fonts/solar.slk
Normal file
BIN
data/fonts/techno.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
data/fonts/techno.slk
Normal file
Before Width: | Height: | Size: 14 KiB |
|
@ -1,20 +0,0 @@
|
|||
JASC-PAL
|
||||
0100
|
||||
17
|
||||
0 0 0
|
||||
69 36 52
|
||||
20 12 28
|
||||
211 170 154
|
||||
223 239 215
|
||||
211 125 44
|
||||
219 215 93
|
||||
211 69 73
|
||||
134 77 48
|
||||
77 73 77
|
||||
48 52 109
|
||||
117 113 97
|
||||
109 195 203
|
||||
134 150 162
|
||||
109 170 44
|
||||
52 101 36
|
||||
89 125 207
|
|
@ -79,7 +79,7 @@ static char text_help[GUI_HELP_LINES][36] = //only use 34 letters
|
|||
"You should have received a copy of",
|
||||
"the GNU General Public License ",
|
||||
"along with this program. If not, ",
|
||||
", see www.gnu.org/licenses/. ",
|
||||
"see www.gnu.org/licenses/. ",
|
||||
"..................................",
|
||||
"Using this program should be ",
|
||||
"fairly easy, but I will try to ",
|
||||
|
|
|
@ -72,6 +72,8 @@ int main(int argc, char *argv[])
|
|||
SLK_layer_activate(5,1);
|
||||
SLK_layer_set_dynamic(5,1);
|
||||
|
||||
SLK_draw_rgb_load_font("../../data/fonts/cursive1.png");
|
||||
|
||||
gui_init();
|
||||
|
||||
calculate();
|
||||
|
|
Before Width: | Height: | Size: 14 KiB |
|
@ -1,19 +0,0 @@
|
|||
JASC-PAL
|
||||
0100
|
||||
16
|
||||
69 36 52
|
||||
20 12 28
|
||||
211 170 154
|
||||
223 239 215
|
||||
211 125 44
|
||||
219 215 93
|
||||
211 69 73
|
||||
134 77 48
|
||||
77 73 77
|
||||
48 52 109
|
||||
117 113 97
|
||||
109 195 203
|
||||
134 150 162
|
||||
109 170 44
|
||||
52 101 36
|
||||
89 125 207
|
|
@ -67,6 +67,7 @@ int main(int argc, char *argv[])
|
|||
load_pal_sprites();
|
||||
load_rgb_sprites();
|
||||
|
||||
SLK_draw_rgb_load_font("../../data/fonts/cursive1.png");
|
||||
gui_00 = SLK_rgb_sprite_load("assets/gui_00.png");
|
||||
gui_01 = SLK_rgb_sprite_load("assets/gui_01.png");
|
||||
SLK_RGB_sprite *gui_02 = SLK_rgb_sprite_load("assets/gui_02.png");
|
||||
|
|
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 14 KiB |
|
@ -23,12 +23,12 @@ int main(int argc, char *argv[])
|
|||
SLK_layer_set_scale(0,canvas_scale);
|
||||
SLK_draw_pal_set_clear_paxel(SLK_color_create_paxel(0,0));
|
||||
SLK_draw_pal_clear();
|
||||
SLK_Pal_sprite *logo = SLK_pal_sprite_load("assets/0.slk");
|
||||
SLK_Pal_sprite *logo = SLK_pal_sprite_load("assets/image.slk");
|
||||
SLK_layer_set_size(0,logo->width,logo->height);
|
||||
SLK_draw_pal_clear();
|
||||
SLK_draw_pal_sprite(logo,0,0);
|
||||
SLK_pal_sprite_destroy(logo);
|
||||
SLK_layer_set_palette(0,SLK_palette_load("data/3-3-2.pal"));
|
||||
SLK_layer_set_palette(0,SLK_palette_load("assets/3-3-2.pal"));
|
||||
|
||||
|
||||
while(SLK_core_running())
|
||||
|
|
|
@ -55,6 +55,8 @@ SLK_Pal_sprite *SLK_pal_sheet_get(const SLK_Pal_sheet *sheet, int index);
|
|||
void SLK_draw_pal_set_target(SLK_Pal_sprite *s);
|
||||
SLK_Pal_sprite *SLK_draw_pal_get_target();
|
||||
void SLK_draw_pal_set_clear_paxel(SLK_Paxel paxel);
|
||||
void SLK_draw_pal_load_font(const char *path);
|
||||
void SLK_draw_pal_set_font_sprite(SLK_Pal_sprite *font);
|
||||
void SLK_draw_pal_clear();
|
||||
void SLK_draw_pal_paxel(int x, int y, SLK_Paxel paxel);
|
||||
void SLK_draw_pal_string(int x, int y, int scale, const char *text, SLK_Paxel paxel);
|
||||
|
@ -92,6 +94,8 @@ SLK_RGB_sprite *SLK_draw_rgb_get_target();
|
|||
void SLK_draw_rgb_set_target(SLK_RGB_sprite *s);
|
||||
void SLK_draw_rgb_set_clear_color(SLK_Color color);
|
||||
void SLK_draw_rgb_set_changed(int changed);
|
||||
void SLK_draw_rgb_load_font(const char *path);
|
||||
void SLK_draw_rgb_set_font_sprite(SLK_RGB_sprite *font);
|
||||
void SLK_draw_rgb_clear();
|
||||
void SLK_draw_rgb_color(int x, int y, SLK_Color color);
|
||||
void SLK_draw_rgb_string(int x, int y, int scale, const char *text, SLK_Color color);
|
||||
|
|
|
@ -8,7 +8,7 @@ DEPENDENCIES = SLK_core.o SLK_color.o SLK_draw_pal.o SLK_draw_rgb.o SLK_input.o
|
|||
backend_sdl2_gl: $(DEPENDENCIES) backend_sdl2_gl.o
|
||||
ar cr libSLK.a $^
|
||||
|
||||
SLK_core.o: ../src/SLK_core.c ../include/SLK/SLK_types.h ../include/SLK/SLK_functions.h ../src/backend.h ../src/SLK_draw_rgb_i.h ../src/SLK_draw_pal_i.h ../src/SLK_layer_i.h
|
||||
SLK_core.o: ../src/SLK_core.c ../include/SLK/SLK_types.h ../include/SLK/SLK_functions.h ../src/backend.h ../src/SLK_layer_i.h
|
||||
$(CC) -O3 -c $< $(CFLAGS)
|
||||
|
||||
SLK_color.o: ../src/SLK_color.c ../include/SLK/SLK_functions.h ../include/SLK/SLK_types.h
|
||||
|
|
|
@ -23,8 +23,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|||
#include "../include/SLK/SLK_types.h"
|
||||
#include "../include/SLK/SLK_functions.h"
|
||||
#include "backend.h"
|
||||
#include "SLK_draw_rgb_i.h"
|
||||
#include "SLK_draw_pal_i.h"
|
||||
#include "SLK_layer_i.h"
|
||||
//-------------------------------------
|
||||
|
||||
|
@ -118,10 +116,6 @@ void SLK_setup(int width, int height, int layer_num, const char *title, int full
|
|||
running = 1;
|
||||
SLK_core_set_fullscreen(fullscreen);
|
||||
|
||||
//Load font sprites.
|
||||
text_sprite_pal = SLK_pal_sprite_load("data/font8x8.slk");
|
||||
text_sprite_rgb = SLK_rgb_sprite_load("data/font8x8.png");
|
||||
|
||||
//Setup keymaps, or whatever you favourite backend does here.
|
||||
backend_input_init();
|
||||
}
|
||||
|
|
|
@ -36,6 +36,9 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|||
//-------------------------------------
|
||||
|
||||
//Variables
|
||||
static SLK_Paxel target_pal_clear;
|
||||
static SLK_Pal_sprite *text_sprite_pal;
|
||||
static SLK_Pal_sprite *text_sprite_pal_default;
|
||||
//-------------------------------------
|
||||
|
||||
//Function prototypes
|
||||
|
@ -64,6 +67,29 @@ void SLK_draw_pal_set_target(SLK_Pal_sprite *s)
|
|||
target_pal = s;
|
||||
}
|
||||
|
||||
//Loads a new font sprite.
|
||||
//Replaces the default font sprite.
|
||||
void SLK_draw_pal_load_font(const char *path)
|
||||
{
|
||||
SLK_pal_sprite_destroy(text_sprite_pal_default);
|
||||
text_sprite_pal_default = SLK_pal_sprite_load(path);
|
||||
text_sprite_pal = text_sprite_pal_default;
|
||||
}
|
||||
|
||||
//Sets the current font sprite from a
|
||||
//sprite you have loaded in your code.
|
||||
//Pass NULL to reset to default.
|
||||
void SLK_draw_pal_set_font_sprite(SLK_Pal_sprite *font)
|
||||
{
|
||||
if(font==NULL)
|
||||
{
|
||||
text_sprite_pal = text_sprite_pal_default;
|
||||
return;
|
||||
}
|
||||
|
||||
text_sprite_pal = font;
|
||||
}
|
||||
|
||||
//Sets the color wich the target is to be cleared to
|
||||
//when calling SLK_draw_pal_clear.
|
||||
void SLK_draw_pal_set_clear_paxel(SLK_Paxel paxel)
|
||||
|
@ -96,34 +122,35 @@ void SLK_draw_pal_string(int x, int y, int scale, const char *text, SLK_Paxel pa
|
|||
int sx = 0;
|
||||
int sy = 0;
|
||||
|
||||
for(int i = 0;text[i];i++)
|
||||
for (int i = 0;text[i];i++)
|
||||
{
|
||||
if(text[i]=='\n')
|
||||
if (text[i]=='\n')
|
||||
{
|
||||
sx = 0;
|
||||
sy+=8*scale;
|
||||
}
|
||||
else
|
||||
{
|
||||
int ox = (text[i]-32) % 16;
|
||||
int oy = (text[i]-32) / 16;
|
||||
int ox = (text[i]-32)&15;
|
||||
int oy = (text[i]-32)/16;
|
||||
|
||||
if(scale>1)
|
||||
{
|
||||
for(int x_ = 0;x_<8;x_++)
|
||||
for(int y_ = 0;y_<8;y_++)
|
||||
if(!text_sprite_pal->data[(y_+oy*8)*128+x_+ox*8].mask)
|
||||
for(int is = 0;is<scale;is++)
|
||||
for(int js = 0;js<scale;js++)
|
||||
SLK_draw_pal_paxel(x+sx+(x_*scale)+is,y+sy+(y_*scale)+js,paxel);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int x_ = 0; x_ < 8; x_++)
|
||||
for(int y_ = 0; y_ < 8; y_++)
|
||||
for(int y_ = 0;y_<8;y_++)
|
||||
{
|
||||
if(!text_sprite_pal->data[(y_+oy*8)*128+x_+ox*8].mask)
|
||||
SLK_draw_pal_paxel(x+sx+x_,y+sy+y_,paxel);
|
||||
{
|
||||
for(int o = 0;o<scale;o++)
|
||||
{
|
||||
for(int m = 0;m<scale;m++)
|
||||
{
|
||||
SLK_draw_pal_paxel(x+sx+(x_*scale)+o,y+sy+(y_*scale)+m,paxel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sx += 8*scale;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,5 @@
|
|||
|
||||
SLK_Pal_sprite *target_pal;
|
||||
SLK_Pal_sprite *target_pal_default;
|
||||
SLK_Paxel target_pal_clear;
|
||||
SLK_Pal_sprite *text_sprite_pal;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -36,6 +36,9 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|||
//-------------------------------------
|
||||
|
||||
//Variables
|
||||
static SLK_Color target_rgb_clear;
|
||||
static SLK_RGB_sprite *text_sprite_rgb;
|
||||
static SLK_RGB_sprite *text_sprite_rgb_default;
|
||||
//-------------------------------------
|
||||
|
||||
//Function prototypes
|
||||
|
@ -78,6 +81,30 @@ void SLK_draw_rgb_set_changed(int changed)
|
|||
target_rgb->changed = changed;
|
||||
}
|
||||
|
||||
//Loads a new font sprite.
|
||||
//Replaces the default font sprite.
|
||||
void SLK_draw_rgb_load_font(const char *path)
|
||||
{
|
||||
SLK_rgb_sprite_destroy(text_sprite_rgb_default);
|
||||
text_sprite_rgb_default = SLK_rgb_sprite_load(path);
|
||||
text_sprite_rgb= text_sprite_rgb_default;
|
||||
}
|
||||
|
||||
//Sets the current font sprite from a
|
||||
//sprite you have loaded in your code.
|
||||
//Pass NULL to reset to default.
|
||||
void SLK_draw_rgb_set_font_sprite(SLK_RGB_sprite *font)
|
||||
{
|
||||
if(font==NULL)
|
||||
{
|
||||
text_sprite_rgb = text_sprite_rgb_default;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
text_sprite_rgb = font;
|
||||
}
|
||||
|
||||
//Clears the draw target to the color specified
|
||||
//by SKL_draw_rgb_set_clear_color.
|
||||
void SLK_draw_rgb_clear()
|
||||
|
@ -109,25 +136,26 @@ void SLK_draw_rgb_string(int x, int y, int scale, const char *text, SLK_Color co
|
|||
}
|
||||
else
|
||||
{
|
||||
int ox = (text[i]-32) % 16;
|
||||
int oy = (text[i]-32) / 16;
|
||||
int ox = (text[i]-32)&15;
|
||||
int oy = (text[i]-32)/16;
|
||||
|
||||
if(scale>1)
|
||||
{
|
||||
for(int x_ = 0;x_<8;x_++)
|
||||
for(int y_ = 0;y_<8;y_++)
|
||||
if(text_sprite_rgb->data[(y_+oy*8)*128+x_+ox*8].a)
|
||||
for(int is = 0;is<scale;is++)
|
||||
for(int js = 0;js<scale;js++)
|
||||
SLK_draw_rgb_color(x+sx+(x_*scale)+is,y+sy+(y_*scale)+js,color);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int x_ = 0; x_ < 8; x_++)
|
||||
for(int y_ = 0; y_ < 8; y_++)
|
||||
for(int y_ = 0;y_<8;y_++)
|
||||
{
|
||||
if(text_sprite_rgb->data[(y_+oy*8)*128+x_+ox*8].a)
|
||||
SLK_draw_rgb_color(x+sx+x_,y+sy+y_,color);
|
||||
{
|
||||
for(int o = 0;o<scale;o++)
|
||||
{
|
||||
for(int m = 0;m<scale;m++)
|
||||
{
|
||||
SLK_draw_rgb_color(x+sx+(x_*scale)+o,y+sy+(y_*scale)+m,color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sx += 8*scale;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,5 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|||
|
||||
SLK_RGB_sprite *target_rgb;
|
||||
SLK_RGB_sprite *target_rgb_default;
|
||||
SLK_Color target_rgb_clear;
|
||||
SLK_RGB_sprite *text_sprite_rgb;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -60,6 +60,9 @@ SLK_Pal_sprite *SLK_pal_sprite_create(int width, int height)
|
|||
//needs to be freed.
|
||||
void SLK_pal_sprite_destroy(SLK_Pal_sprite *s)
|
||||
{
|
||||
if(s==NULL)
|
||||
return;
|
||||
|
||||
free(s->data);
|
||||
free(s);
|
||||
}
|
||||
|
|
|
@ -65,6 +65,9 @@ SLK_RGB_sprite *SLK_rgb_sprite_create(int width, int height)
|
|||
//to be freed.
|
||||
void SLK_rgb_sprite_destroy(SLK_RGB_sprite *s)
|
||||
{
|
||||
if(s==NULL)
|
||||
return;
|
||||
|
||||
free(s->data);
|
||||
free(s);
|
||||
}
|
||||
|
|