-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Arabic and Persian zero turned into an elevated dot. Other additions: - Makefile watch and ttftest rules - build script for watching using inodewatch - README updates - Update the glyphs picture
- Loading branch information
1 parent
6f266fc
commit 161d571
Showing
6 changed files
with
243 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
.PHONY: clean all | ||
.PHONY: clean all watch | ||
|
||
all: noqte.ttf | ||
|
||
noqte.ttf: noqte.sfd | ||
fontforge -quiet -lang ff -c "Open(\"noqte.sfd\",1);Generate(\"noqte.ttf\")" | ||
|
||
ttftest: *.c | ||
gcc *.c \ | ||
-I/usr/include/SDL2 -lSDL2 -lSDL2_ttf \ | ||
-I/usr/include/harfbuzz -I/usr/include/freetype2 \ | ||
-I/usr/include/glib-2.0 \ | ||
-I/usr/lib/glib-2.0/include \ | ||
-o ttftest | ||
|
||
watch: | ||
./build.sh noqte.sfd ttftest.c | ||
|
||
clean: | ||
rm noqte.ttf | ||
rm -f noqte.ttf ttftest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
if [ "$#" -lt 2 ]; then | ||
echo 'Usage: build.sh <FILE> [ ... ]' | ||
fi | ||
|
||
PID= | ||
while inotifywait -e CLOSE_WRITE $@; do | ||
test "$PID" && kill -9 "$PID" | ||
cp -r $1 backup/$(date --iso-8601=seconds)_$1 | ||
fontforge -quiet -lang ff -c "Open(\"$1\",1);Generate(\"noqte.ttf\")" | ||
echo Starting... | ||
make noqte.ttf ttftest | ||
./ttftest & | ||
PID=$! | ||
echo PID=$PID | ||
sleep 3 | ||
done |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
#include <SDL.h> | ||
#include <SDL_ttf.h> | ||
#include <hb.h> | ||
|
||
void blit(SDL_Texture *texture, int x, int y, int rtl); | ||
SDL_Texture *loadTXTTexture(char *text, TTF_Font *font, int rtl); | ||
|
||
static TTF_Font *noqte; | ||
static TTF_Font *dejavu; | ||
static TTF_Font *noto; | ||
static TTF_Font *console; | ||
static TTF_Font *consolereg; | ||
static SDL_Window *window; | ||
static SDL_Renderer *renderer; | ||
|
||
int main(int argc, char ** argv) | ||
{ | ||
if (SDL_Init(SDL_INIT_VIDEO) < 0) | ||
{ | ||
printf("Couldn't initialize SDL: %s\n", SDL_GetError()); | ||
exit(1); | ||
} | ||
|
||
if (TTF_Init() < 0) | ||
{ | ||
printf("Couldn't initialize SDL_ttf"); | ||
exit(1); | ||
} | ||
|
||
int major, minor, patch; | ||
TTF_GetHarfBuzzVersion(&major, &minor, &patch); | ||
if (!(major || minor || patch)) | ||
{ | ||
printf("SDL_ttf compiled without HarfBuz support"); | ||
exit(1); | ||
} | ||
|
||
noqte = TTF_OpenFont("noqte.ttf", 50); | ||
if (noqte == NULL) | ||
{ | ||
printf("Couldn't load the font"); | ||
exit(1); | ||
} | ||
|
||
window = SDL_CreateWindow("ttftest", | ||
SDL_WINDOWPOS_UNDEFINED, | ||
SDL_WINDOWPOS_UNDEFINED, | ||
1280, 720, | ||
SDL_WINDOW_RESIZABLE); | ||
if (!window) | ||
{ | ||
printf("Failed to open window: %s\n", SDL_GetError()); | ||
exit(1); | ||
} | ||
|
||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); | ||
|
||
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); | ||
if (!renderer) | ||
{ | ||
printf("Failed to create renderer: %s\n", SDL_GetError()); | ||
exit(1); | ||
} | ||
|
||
SDL_Texture *t01 = loadTXTTexture("ء ا آ ب پ ت ث ج چ ح خ د ذ ر ز ژ س ش", noqte, 1); | ||
SDL_Texture *t02 = loadTXTTexture("ص ض ط ظ ع غ ف ق ک گ ل م ن و ه ی ", noqte, 1); | ||
SDL_Texture *t03 = loadTXTTexture( | ||
"۱۲°۳۴۵۶۷۸۹۰!" | ||
"÷ ! ٬ ٫ ٪ ﷼ × ، * ) ( ـ + - = " | ||
, noqte, 1); | ||
SDL_Texture *t04 = loadTXTTexture( | ||
//"ْ ٌ ٍ ً ُ ِ َ ّ ٓ ٔ " | ||
"ْ ٌ ٍ ً ُ ِ َ ّ ] [ } { » « : ;" | ||
" > < ؟ < . /" | ||
, noqte, 1); | ||
SDL_Texture *t05 = loadTXTTexture( | ||
"در صورت حذف این چند واژه غلط به شکیل، ثابت و جامعتر ساختن ", | ||
noqte, 1); | ||
SDL_Texture *t06 = loadTXTTexture( | ||
"پاراگراف شعر از لحاظ دوری از قافیههای اضافه کمک میشود.", | ||
noqte, 1); | ||
SDL_Texture *t07 = loadTXTTexture("äüößabcdefghijklmnñopqrstuvwxyz", noqte, 0); | ||
SDL_Texture *t08 = loadTXTTexture("ÄÜÖABCDEFGHIJKLMNÑOPQRSTUVWXYZ", noqte, 0); | ||
SDL_Texture *t09 = loadTXTTexture("0123456789°!\"§$%&/()=?`" , noqte, 0); | ||
|
||
SDL_Texture *t10 = loadTXTTexture("The quick brown fox jumps over the lazy dog", noqte, 0); | ||
SDL_Texture *t11 = loadTXTTexture("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG", noqte, 0); | ||
SDL_Texture *t12 = loadTXTTexture("el veloz murciélago hindú comía feliz cardillo y kiwi.", noqte, 0); | ||
SDL_Texture *t13 = loadTXTTexture("la cigüeña tocaba el saxofón detrás del palenque de paja", noqte, 0); | ||
|
||
|
||
SDL_Event event; | ||
|
||
while (1) | ||
{ | ||
SDL_RenderClear(renderer); | ||
|
||
while (SDL_PollEvent(&event)) | ||
{ | ||
switch (event.type) | ||
{ | ||
case SDL_QUIT: | ||
exit(0); | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
|
||
int right = 1075; | ||
|
||
blit(t01, right, 25, 1); | ||
blit(t02, right, 100, 1); | ||
blit(t03, right, 175, 1); | ||
blit(t04, right, 250, 1); | ||
|
||
blit(t05, right, 325, 1); | ||
blit(t06, right, 400, 1); | ||
|
||
blit(t07, 10, 475, 0); | ||
blit(t08, 10, 550, 0); | ||
|
||
blit(t09, 10, 625, 0); | ||
blit(t10, 10, 700, 0); | ||
blit(t11, 10, 775, 0); | ||
blit(t12, 10, 850, 0); | ||
|
||
SDL_Delay(32); | ||
SDL_RenderPresent(renderer); | ||
} | ||
|
||
SDL_DestroyRenderer(renderer); | ||
SDL_DestroyWindow(window); | ||
TTF_CloseFont(noqte); | ||
TTF_Quit(); | ||
SDL_Quit(); | ||
} | ||
|
||
SDL_Texture *loadTXTTexture(char *text, TTF_Font *font, int rtl) | ||
{ | ||
SDL_Rect dest; | ||
|
||
SDL_Color colorA = { 0xff, 0x99, 0x00, 0xff }; | ||
|
||
if (rtl) | ||
{ | ||
TTF_SetDirection(HB_DIRECTION_RTL); | ||
TTF_SetScript(HB_SCRIPT_ARABIC); | ||
} else { | ||
TTF_SetDirection(HB_DIRECTION_LTR); | ||
TTF_SetScript(HB_SCRIPT_LATIN); | ||
} | ||
|
||
SDL_Surface *surface; | ||
|
||
surface = TTF_RenderUTF8_Blended(font, text, colorA); | ||
|
||
SDL_Texture * texture = SDL_CreateTextureFromSurface(renderer, surface); | ||
|
||
SDL_FreeSurface(surface); | ||
|
||
return texture; | ||
} | ||
|
||
void blit(SDL_Texture *texture, int x, int y, int rtl) | ||
{ | ||
SDL_Rect dest; | ||
|
||
dest.x = x; | ||
dest.y = y; | ||
|
||
SDL_QueryTexture(texture, NULL, NULL, &dest.w, &dest.h); | ||
|
||
if (rtl) | ||
dest.x -= dest.w; | ||
|
||
SDL_RenderCopy(renderer, texture, NULL, &dest); | ||
} |