;;; ;;; sdl-ttf-lib.stub - glue functions for SDL_ttf ;;; ;;; Copyright(C) 2003 by Michael Vess (mvess@michaelvess.com) ;;; ;;; Permission to use, copy, modify, distribute this software and ;;; accompanying documentation for any purpose is hereby granted, ;;; provided that existing copyright notices are retained in all ;;; copies and that this notice is included verbatim in all ;;; distributions. ;;; This software is provided as is, without express or implied ;;; warranty. In no circumstances the author(s) shall be liable ;;; for any damages arising out of the use of this software. ;;; ;;; $Id: sdl-ttf-lib.stub,v 1.3 2003/02/25 02:23:14 mikiso Exp $ ;;; " #include \"gauche-sdl-ttf.h\" " ;;============================================================= ;; Color ;; (define-type "SDL_Color*" #f "SCM_SDL_COLOR_P" "SCM_SDL_COLOR") ;;============================================================= ;; Font ;; (define-type "TTF_Font*" #f "SCM_TTF_FONT_P" "SCM_TTF_FONT") (define-cproc ttf-font? (obj) (return "SCM_TTF_FONT_P")) ;;============================================================= ;; Functions ;; (define-cproc ttf-init () (return "TTF_Init")) (define-cproc ttf-open-font (file:: ptsize::) "ScmTtfFont *f = SCM_NEW(ScmTtfFont); SCM_SET_CLASS(f, SCM_CLASS_TTF_FONT); f->font = TTF_OpenFont(Scm_GetStringConst(file), ptsize); if (f->font == NULL) SCM_RETURN(SCM_UNDEFINED); Scm_RegisterFinalizer(SCM_OBJ(f), ttf_font_finalize, NULL); SCM_RETURN(SCM_OBJ(f));") (define-cproc ttf-get-font-style (font::) (return "TTF_GetFontStyle")) (define-cproc ttf-set-font-style (font:: style::) (return "TTF_SetFontStyle")) (define-cproc ttf-font-height (font::) (return "TTF_FontHeight")) (define-cproc ttf-font-ascent (font::) (return "TTF_FontAscent")) (define-cproc ttf-font-descent (font::) (return "TTF_FontDescent")) (define-cproc ttf-font-line-skip (font::) (return "TTF_FontLineSkip")) (define-cproc ttf-glyph-metrics (font:: ch::) "int minx, maxx, miny, maxy, advance; int result = TTF_GlyphMetrics(font, ch, &minx, &maxx, &miny, &maxy, &advance); SCM_RETURN(SCM_LIST5(SCM_MAKE_INT(minx), SCM_MAKE_INT(maxx), SCM_MAKE_INT(miny), SCM_MAKE_INT(maxy), SCM_MAKE_INT(advance)));") (define-cproc ttf-size-text (font:: text::) "int w, h; int result = TTF_SizeUTF8(font, Scm_GetStringConst(text), &w, &h); SCM_RETURN(SCM_LIST2(SCM_MAKE_INT(w), SCM_MAKE_INT(h)));") (define-cproc ttf-render-text-solid (font:: text:: fg::) "ScmSdlSurface *s = SCM_NEW(ScmSdlSurface); SCM_SET_CLASS(s, SCM_CLASS_SDL_SURFACE); s->surface = TTF_RenderUTF8_Solid(font, Scm_GetStringConst(text), *fg); if (s->surface == NULL) SCM_RETURN(SCM_UNDEFINED); Scm_RegisterFinalizer(SCM_OBJ(s), sdl_surface_finalize, NULL); SCM_RETURN(SCM_OBJ(s));") (define-cproc ttf-render-glyph-solid (font:: ch:: fg::) "ScmSdlSurface *s = SCM_NEW(ScmSdlSurface); SCM_SET_CLASS(s, SCM_CLASS_SDL_SURFACE); s->surface = TTF_RenderGlyph_Solid(font, ch, *fg); if (s->surface == NULL) SCM_RETURN(SCM_UNDEFINED); Scm_RegisterFinalizer(SCM_OBJ(s), sdl_surface_finalize, NULL); SCM_RETURN(SCM_OBJ(s));") (define-cproc ttf-render-text-shaded (font:: text:: fg:: bg::) "ScmSdlSurface *s = SCM_NEW(ScmSdlSurface); SCM_SET_CLASS(s, SCM_CLASS_SDL_SURFACE); s->surface = TTF_RenderUTF8_Shaded(font, Scm_GetStringConst(text), *fg, *bg); if (s->surface == NULL) SCM_RETURN(SCM_UNDEFINED); Scm_RegisterFinalizer(SCM_OBJ(s), sdl_surface_finalize, NULL); SCM_RETURN(SCM_OBJ(s));") (define-cproc ttf-render-glyph-shaded (font:: ch:: fg:: bg::) "ScmSdlSurface *s = SCM_NEW(ScmSdlSurface); SCM_SET_CLASS(s, SCM_CLASS_SDL_SURFACE); s->surface = TTF_RenderGlyph_Shaded(font, ch, *fg, *bg); if (s->surface == NULL) SCM_RETURN(SCM_UNDEFINED); Scm_RegisterFinalizer(SCM_OBJ(s), sdl_surface_finalize, NULL); SCM_RETURN(SCM_OBJ(s));") (define-cproc ttf-render-text-blended (font:: text:: fg::) "ScmSdlSurface *s = SCM_NEW(ScmSdlSurface); SCM_SET_CLASS(s, SCM_CLASS_SDL_SURFACE); s->surface = TTF_RenderUTF8_Blended(font, Scm_GetStringConst(text), *fg); if (s->surface == NULL) SCM_RETURN(SCM_UNDEFINED); Scm_RegisterFinalizer(SCM_OBJ(s), sdl_surface_finalize, NULL); SCM_RETURN(SCM_OBJ(s));") (define-cproc ttf-render-glyph-blended (font:: ch:: fg::) "ScmSdlSurface *s = SCM_NEW(ScmSdlSurface); SCM_SET_CLASS(s, SCM_CLASS_SDL_SURFACE); s->surface = TTF_RenderGlyph_Blended(font, ch, *fg); if (s->surface == NULL) SCM_RETURN(SCM_UNDEFINED); Scm_RegisterFinalizer(SCM_OBJ(s), sdl_surface_finalize, NULL); SCM_RETURN(SCM_OBJ(s));") (define-cproc ttf-quit () (return "TTF_Quit")) ;; Local variables: ;; mode: scheme ;; end: