diff options
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | credits.txt | 2 | ||||
-rw-r--r-- | main.c | 3 | ||||
-rw-r--r-- | stb_truetype.c | 4 | ||||
-rw-r--r-- | text.c | 18 |
6 files changed, 32 insertions, 4 deletions
@@ -7,8 +7,10 @@ PROFILE_CFLAGS=$(ALL_CFLAGS) -O3 -g -DPROFILE=1 GLOBAL_DATA_DIR=/usr/share/ted LOCAL_DATA_DIR=/home/`logname`/.local/share/ted INSTALL_BIN_DIR=/usr/bin -ted: *.[ch] libpcre2-32.a - $(CC) main.c -o ted $(DEBUG_CFLAGS) $(LIBS) +ted: *.[ch] libpcre2-32.a stb_truetype.o + $(CC) main.c stb_truetype.o -o ted $(DEBUG_CFLAGS) $(LIBS) +stb_truetype.o: stb_truetype.c + $(CC) $< -c -o $@ release: *.[ch] libpcre2-32.a $(CC) main.c -o ted $(RELEASE_CFLAGS) $(LIBS) profile: *.[ch] libpcre2-32.a @@ -48,7 +48,8 @@ wget https://ftp.pcre.org/pub/pcre/pcre2-10.36.zip sudo make install -j4 ``` -On Windows (64-bit), you will need the SDL2 VC development libraries: https://www.libsdl.org/download-2.0.php +On Windows (64-bit), first you will need to install Microsoft Visual Studio, then find and add vcvarsall.bat to your PATH. +Next you will need the SDL2 VC development libraries: https://www.libsdl.org/download-2.0.php Extract the zip, copy SDL2-2.x.y into the ted directory, and rename it to SDL2. Also copy SDL2\lib\x64\SDL2.dll to the ted directory. You will also need PCRE2. Download it here: https://ftp.pcre.org/pub/pcre/pcre2-10.36.zip, diff --git a/credits.txt b/credits.txt index ce26dd1..3f7a6f4 100644 --- a/credits.txt +++ b/credits.txt @@ -1,5 +1,5 @@ assets/font.ttf (Noto Sans Mono Regular), assets/font-bold.ttf (Noto Sans Mono Bold): These are from the Noto font family, licensed under the Apache License, version 2.0, as found in apache2.txt. They can be found here: https://www.google.com/get/noto/ -stb_truetype.h: +lib/stb_truetype.h: See https://github.com/nothings/stb @@ -15,6 +15,9 @@ no_warn_start #if _WIN32 #include <SDL.h> #else +#if DEBUG || __TINYC__ // speed up compile time on debug, also tcc doesn't have immintrin.h +#define SDL_DISABLE_IMMINTRIN_H +#endif #include <SDL2/SDL.h> #endif no_warn_end diff --git a/stb_truetype.c b/stb_truetype.c new file mode 100644 index 0000000..444b245 --- /dev/null +++ b/stb_truetype.c @@ -0,0 +1,4 @@ +// used for debug build to speed things up +// just exports everything in stb_truetype.h +#define STB_TRUETYPE_IMPLEMENTATION +#include "lib/stb_truetype.h" @@ -1,11 +1,29 @@ #include "base.h" #include "text.h" #include "unicode.h" +#if DEBUG +typedef struct +{ + unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap + float xoff,yoff,xadvance; +} stbtt_bakedchar; +typedef struct +{ + float x0,y0,s0,t0; // top-left + float x1,y1,s1,t1; // bottom-right +} stbtt_aligned_quad; + +extern void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule); +extern int stbtt_BakeFontBitmap(const unsigned char *data, int offset, float pixel_height, unsigned char *pixels, int pw, int ph, int first_char, int num_chars, stbtt_bakedchar *chardata); +#else #define STB_TRUETYPE_IMPLEMENTATION #define STBTT_STATIC no_warn_start #include "lib/stb_truetype.h" no_warn_end +#endif + + #include <stdlib.h> // We split up code points into a bunch of pages, so we don't have to load all of the font at |