sync
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
include_directories(../font)
|
||||
#include_directories(SYSTEM ${FREETYPE_INCLUDE_DIRS})
|
||||
|
||||
set(TTF_SOURCES glue.c schrift.c)
|
||||
set(TTF_SOURCES allegro_schrift.c schrift.c)
|
||||
|
||||
set(TTF_INCLUDE_FILES allegro5/allegro_schrift.h)
|
||||
|
||||
set_our_header_properties(${TTF_INCLUDE_FILES})
|
||||
#set_our_header_properties(${TTF_INCLUDE_FILES})
|
||||
|
||||
#configure_file(
|
||||
# allegro5/internal/aintern_ttf_cfg.h.cmake
|
||||
|
||||
14
README.md
14
README.md
@@ -3,7 +3,15 @@ Drop-in replacement for Allegro_TTF that contains libschrift, instead of using F
|
||||
|
||||
It is 100% API compatible with the vanilla TrueType addon. Compile Allegro with these files inside of `/addons/ttf`.
|
||||
|
||||
Pros:
|
||||
- It doesn't require NT 6 kernel calls
|
||||
- It doesn't dynamically link against hundreds of thousands of lines of ugly corporate-backed C code you can't read
|
||||
- Our addon is only a couple or few hundred lines, and libschrift is less than 2,000. They're compiled together.
|
||||
The original Allegro_TTF is over 1,000 lines (for a good reason) and has a relatively massive dependency weight (for a stupid reason).
|
||||
|
||||
Caveats:
|
||||
- Stretching is not implemented. Maybe later.
|
||||
- The entire caching system is gone, fonts are baked to textures immediately and no further. If your usecase doesn't need every fancy rendering feature and can use schrift, you probably aren't supporting enough characters and languages to need on-the-fly caching.
|
||||
- The `cache_text` setting in allegro5.cfg is now reused to determine what glyphs can be rendered at all. `skip_cache_misses` has no effect.
|
||||
- Pre-stretching is not implemented.
|
||||
- The entire caching system is gone, fonts are baked to textures immediately and no further. This makes supporting some languages with this add-on inconvenient, or impossible.
|
||||
If your usecase doesn't need every fancy rendering feature and can use schrift, you probably aren't supporting enough characters and languages to need on-the-fly caching, so we consider this an acceptable tradeoff.
|
||||
- The `cache_text` setting in allegro5.cfg is now reused to determine what glyphs can be rendered at all. `skip_cache_misses` has no effect.
|
||||
When `cache_text` is undefined, the English and Romance alphabets will be generated by default.
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
ALLEGRO_DEBUG_CHANNEL("font")
|
||||
#define CANI_ALLEGRO_SCHRIFT_VER 1
|
||||
#define delimit_color al_map_rgba(0, 0, 255, 255)
|
||||
|
||||
/* globals */
|
||||
static bool ttf_inited;
|
||||
@@ -30,6 +31,7 @@ ALLEGRO_BITMAP *grow_bitmap(ALLEGRO_BITMAP *bmp, uint16_t add) {
|
||||
ALLEGRO_BITMAP *grown = al_create_bitmap(al_get_bitmap_width(bmp), h);
|
||||
al_set_target_bitmap(grown);
|
||||
al_draw_bitmap(bmp, 0, 0, 0);
|
||||
al_draw_filled_rectangle(0, h - add, al_get_bitmap_width(bmp), h, delimit_color);
|
||||
al_set_target_bitmap(tgt);
|
||||
al_destroy_bitmap(bmp);
|
||||
return grown;
|
||||
@@ -86,7 +88,7 @@ ALLEGRO_FONT *al_load_ttf_font_f(ALLEGRO_FILE *file,
|
||||
int32_t woff = 1, hoff = 1, hmax = 128; // signed to calculate difference at texture edges
|
||||
gtex = al_create_bitmap(wmax, hmax);
|
||||
al_set_target_bitmap(gtex);
|
||||
al_clear_to_color(al_map_rgba(0, 0, 0, 0)); // todo invert alpha at final pass
|
||||
al_clear_to_color(delimit_color); // todo invert alpha at final pass
|
||||
|
||||
unsigned int i = 0;
|
||||
const unsigned int len = strlen(cache_text_str);
|
||||
Reference in New Issue
Block a user