From: jsancho Date: Fri, 16 Mar 2012 10:25:29 +0000 (+0000) Subject: Storing original font size. X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=b8b635a078699b0d6dd36348f0324d192fec95ac;p=gacela.git Storing original font size. --- diff --git a/src/ftgl.c b/src/ftgl.c index 57fbbf8..ca39ad9 100644 --- a/src/ftgl.c +++ b/src/ftgl.c @@ -57,6 +57,16 @@ get_font_address (SCM font_smob) return font->font_address; } +SCM +get_font_size (SCM font_smob) +{ + struct font *font; + + scm_assert_smob_type (font_tag, font_smob); + font = (struct font *) SCM_SMOB_DATA (font_smob); + return scm_from_int (font->size); +} + SCM mark_font (SCM font_smob) { @@ -113,6 +123,12 @@ gacela_ftglSetFontFaceSize (SCM font, SCM size, SCM res) return scm_from_int (ftglSetFontFaceSize (get_font_address (font), scm_to_int (size), scm_to_int (res))); } +SCM +gacela_ftglGetFontFaceSize (SCM font) +{ + return scm_from_int (ftglGetFontFaceSize (get_font_address (font))); +} + SCM gacela_ftglSetFontCharMap (SCM font, SCM encoding) { @@ -135,12 +151,14 @@ init_gacela_ftgl (void *data) scm_set_smob_free (font_tag, free_font); scm_set_smob_print (font_tag, print_font); // scm_set_smob_equalp (surface_tag, equalp_surface); + scm_c_define_gsubr ("font-size", 1, 0, 0, get_font_size); scm_c_define ("ft_encoding_unicode", scm_from_int (ft_encoding_unicode)); scm_c_define ("FTGL_RENDER_ALL", scm_from_int (FTGL_RENDER_ALL)); scm_c_define_gsubr ("ftglCreateTextureFont", 2, 0, 0, gacela_ftglCreateTextureFont); scm_c_define_gsubr ("ftglSetFontFaceSize", 3, 0, 0, gacela_ftglSetFontFaceSize); + scm_c_define_gsubr ("ftglGetFontFaceSize", 1, 0, 0, gacela_ftglGetFontFaceSize); scm_c_define_gsubr ("ftglSetFontCharMap", 2, 0, 0, gacela_ftglSetFontCharMap); scm_c_define_gsubr ("ftglRenderFont", 3, 0, 0, gacela_ftglRenderFont); } diff --git a/src/video.scm b/src/video.scm index 5a5ef2b..726694a 100644 --- a/src/video.scm +++ b/src/video.scm @@ -408,5 +408,9 @@ font)) (define* (render-text text font #:key (size #f)) - (cond (size (ftglSetFontFaceSize font size 72))) + (cond (size + (cond ((not (= (ftglGetFontFaceSize font) size)) + (ftglSetFontFaceSize font size 72)))) + ((not (= (ftglGetFontFaceSize font) (font-size font))) + (ftglSetFontFaceSize font (font-size font) 72))) (ftglRenderFont font text FTGL_RENDER_ALL))