libsdl-org / SDL_ttf

Support for TrueType (.ttf) font files with Simple Directmedia Layer.
zlib License
403 stars 131 forks source link

Added the ability to go between a string offset and render position. #391

Closed slouken closed 1 month ago

slouken commented 1 month ago

This allows things like implementing a cursor that automatically follows font size and text direction changes.

1bsyl commented 1 month ago

@slouken since you're in a middle of modification, there are a few shadow variables:

showfont.c:457:33: warning: declaration of ‘outline’ shadows a previous local [-Wshadow] 457 | int outline = TTF_GetFontOutline(font); | ^~~ /showfont.c:128:9: note: shadowed declaration is here 128 | int outline; | ^~~ showfont.c:501:35: warning: declaration of ‘ptsize’ shadows a previous local [-Wshadow] 501 | float ptsize = TTF_GetFontSize(font); | ^~ showfont.c:118:11: note: shadowed declaration is here 118 | float ptsize; | ^~ showfont.c:508:35: warning: declaration of ‘ptsize’ shadows a previous local [-Wshadow] 508 | float ptsize = TTF_GetFontSize(font); | ^~ showfont.c:118:11: note: shadowed declaration is here 118 | float ptsize;

sezero commented 1 month ago

This breaks build if harfbuzz is disabled:

src/SDL_ttf.c: In function ‘TTF_OpenFontWithProperties’:
src/SDL_ttf.c:1922: error: ‘TTF_Font’ has no member named ‘hb_direction’
src/SDL_ttf.c:1922: error: ‘HB_DIRECTION_LTR’ undeclared (first use in this function)
src/SDL_ttf.c:1922: error: (Each undeclared identifier is reported only once
src/SDL_ttf.c:1922: error: for each function it appears in.)
src/SDL_ttf.c:1923: error: ‘TTF_Font’ has no member named ‘hb_script’
src/SDL_ttf.c:1923: error: ‘HB_SCRIPT_UNKNOWN’ undeclared (first use in this function)