diff options
author | Loïc Hoguin <[email protected]> | 2018-02-13 14:42:06 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2018-02-13 14:42:06 +0100 |
commit | 913937277fec521a704fc29253198da1a7dbeb82 (patch) | |
tree | 32e193598e6f08f4cd39bf0137069f0951880ff2 /src | |
parent | 6e2c3832d850497fe715c813869a5e52a454bb1a (diff) | |
download | esdl2-913937277fec521a704fc29253198da1a7dbeb82.tar.gz esdl2-913937277fec521a704fc29253198da1a7dbeb82.tar.bz2 esdl2-913937277fec521a704fc29253198da1a7dbeb82.zip |
Add functions for obtaining glyph informations
Diffstat (limited to 'src')
-rw-r--r-- | src/esdl2.erl | 12 | ||||
-rw-r--r-- | src/sdl_ttf.erl | 24 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/esdl2.erl b/src/esdl2.erl index 308ffe6..a5c901e 100644 --- a/src/esdl2.erl +++ b/src/esdl2.erl @@ -183,8 +183,11 @@ -export([ttf_font_line_skip/1]). -export([ttf_get_font_hinting/1]). -export([ttf_get_font_kerning/1]). +-export([ttf_get_font_kerning_size_glyphs/3]). -export([ttf_get_font_outline/1]). -export([ttf_get_font_style/1]). +-export([ttf_glyph_is_provided/2]). +-export([ttf_glyph_metrics/2]). -export([ttf_init/0]). -export([ttf_open_font/2]). -export([ttf_open_font_index/3]). @@ -712,12 +715,21 @@ ttf_get_font_hinting(_) -> ttf_get_font_kerning(_) -> erlang:nif_error({not_loaded, ?MODULE}). +ttf_get_font_kerning_size_glyphs(_, _, _) -> + erlang:nif_error({not_loaded, ?MODULE}). + ttf_get_font_outline(_) -> erlang:nif_error({not_loaded, ?MODULE}). ttf_get_font_style(_) -> erlang:nif_error({not_loaded, ?MODULE}). +ttf_glyph_is_provided(_, _) -> + erlang:nif_error({not_loaded, ?MODULE}). + +ttf_glyph_metrics(_, _) -> + erlang:nif_error({not_loaded, ?MODULE}). + ttf_init() -> erlang:nif_error({not_loaded, ?MODULE}). diff --git a/src/sdl_ttf.erl b/src/sdl_ttf.erl index 314f70a..acacdcd 100644 --- a/src/sdl_ttf.erl +++ b/src/sdl_ttf.erl @@ -19,6 +19,8 @@ -export([get_ascent/1]). -export([get_descent/1]). -export([get_family_name/1]). +-export([get_glyph_metrics/2]). +-export([get_glyphs_kerning_size/3]). -export([get_height/1]). -export([get_hinting/1]). -export([get_line_skip/1]). @@ -26,6 +28,7 @@ -export([get_outline/1]). -export([get_style/1]). -export([get_style_name/1]). +-export([has_glyph/2]). -export([is_fixed_width/1]). -export([is_kerning_enabled/1]). -export([is_started/0]). @@ -45,6 +48,9 @@ -opaque font() :: reference(). -export_type([font/0]). +-type glyph() :: 0..65535. +-export_type([glyph/0]). + -type hinting() :: normal | light | mono | none. -export_type([hinting/0]). @@ -74,6 +80,19 @@ get_family_name(Font) -> esdl2:ttf_font_face_family_name(Font), receive {'_nif_thread_ret_', Ret} -> Ret end. +-spec get_glyph_metrics(font(), glyph()) + -> {ok, {integer(), integer(), integer(), integer(), integer()}} + | sdl:error(). +get_glyph_metrics(Font, Glyph) -> + esdl2:ttf_glyph_metrics(Font, Glyph), + receive {'_nif_thread_ret_', Ret} -> Ret end. + +-spec get_glyphs_kerning_size(font(), glyph(), glyph()) + -> {ok, integer()} | sdl:error(). +get_glyphs_kerning_size(Font, PreviousGlyph, Glyph) -> + esdl2:ttf_get_font_kerning_size_glyphs(Font, PreviousGlyph, Glyph), + receive {'_nif_thread_ret_', Ret} -> Ret end. + -spec get_height(font()) -> non_neg_integer(). get_height(Font) -> esdl2:ttf_font_height(Font), @@ -109,6 +128,11 @@ get_style_name(Font) -> esdl2:ttf_font_face_style_name(Font), receive {'_nif_thread_ret_', Ret} -> Ret end. +-spec has_glyph(font(), glyph()) -> boolean(). +has_glyph(Font, Glyph) -> + esdl2:ttf_glyph_is_provided(Font, Glyph), + receive {'_nif_thread_ret_', Ret} -> Ret end. + -spec is_fixed_width(font()) -> boolean(). is_fixed_width(Font) -> esdl2:ttf_font_face_is_fixed_width(Font), |