Skip to content

Commit

Permalink
include font in program binary, add installation to makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
laamaa committed Apr 18, 2021
1 parent 90098c6 commit 2efb88c
Show file tree
Hide file tree
Showing 4 changed files with 1,111 additions and 8 deletions.
16 changes: 11 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#Change output_file_name.a below to your desired executible filename

#Set all your object files (the object files of all the .c files in your project, e.g. main.o my_sub_functions.o )
#OBJ = modbuddy.o launchpad.o soft_lcd.o soft_i2c.o
OBJ = main.o serial.o slip.o command.o write.o render.o input.o

#Set any dependant header files so that if they are edited they cause a complete re-compile (e.g. main.h some_subfunctions.h some_definitions_file.h ), or leave blank
DEPS = serial.h slip.h command.h write.h render.h input.h
DEPS = serial.h slip.h command.h write.h render.h input.h stealth57_ttf.h

#Any special libraries you are using in your project (e.g. -lbcm2835 -lrt `pkg-config --libs gtk+-3.0` ), or leave blank
INCLUDES = -lSDL2_ttf
Expand All @@ -32,4 +29,13 @@ m8c: $(OBJ)
.PHONY: clean

clean:
rm -f *.o *~ core *~
rm -f *.o *~ m8c *~

# PREFIX is environment variable, but if it is not set, then set default value
ifeq ($(PREFIX),)
PREFIX := /usr/local
endif

install: m8c
install -d $(DESTDIR)$(PREFIX)/bin/
install -m 755 m8c $(DESTDIR)$(PREFIX)/bin/
8 changes: 5 additions & 3 deletions render.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include "render.h"

#include "command.h"

#include <SDL2/SDL.h>
#include <SDL2/SDL_rwops.h>
#include <SDL2/SDL_ttf.h>

#include "command.h"
#include "stealth57_ttf.h"

SDL_Window *win;
SDL_Renderer *rend;
TTF_Font *font;
Expand Down Expand Up @@ -45,7 +47,7 @@ int initialize_sdl() {

rend = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED);

font = TTF_OpenFont("stealth57.ttf", font_size);
font = TTF_OpenFontRW(SDL_RWFromMem(stealth57_ttf, stealth57_ttf_len), 1, font_size);

surface =
SDL_CreateRGBSurfaceWithFormat(0, 320, 240, 8, SDL_PIXELFORMAT_ARGB8888);
Expand Down
Binary file removed stealth57.ttf
Binary file not shown.
Loading

0 comments on commit 2efb88c

Please sign in to comment.