Branch: Tag:

1999-05-24

1999-05-24 14:33:42 by Mirar (Pontus Hagland) <pike@sort.mirar.org>

added default font

Rev: src/modules/Image/Makefile.in:1.24
Rev: src/modules/Image/font.c:1.49
Rev: src/modules/Image/module_testsuite.in:1.8
Rev: src/modules/Image/testsuite.in.in:1.16

1: - /* $Id: font.c,v 1.48 1999/05/23 17:46:40 mirar Exp $ */ + /* $Id: font.c,v 1.49 1999/05/24 14:33:10 mirar Exp $ */   #include "global.h"   #include <config.h>      #define SPACE_CHAR 'i'    -  + extern unsigned char * image_default_font; + #define IMAGE_DEFAULT_FONT_SIZE 30596 +    /*   **! module Image   **! note - **! $Id: font.c,v 1.48 1999/05/23 17:46:40 mirar Exp $ + **! $Id: font.c,v 1.49 1999/05/24 14:33:10 mirar Exp $   **! class Font   **!   **! note
219:   {    if (font)    { -  if (font->mem) +  if (font->mem && font->mem!=image_default_font)    {   #ifdef HAVE_MMAP    munmap(font->mem,font->mmaped_size);
335:      void font_create(INT32 args)   { -  if (args) -  { +     font_load(args);    pop_stack();   } - } +       void font_load(INT32 args)   {    int fd; -  +  size_t size;    -  if (args<1 -  || sp[-args].type!=T_STRING) -  error("font->read: illegal or wrong number of arguments\n"); -  +     if (THIS)    {    free_font_struct(THIS);    THIS=NULL;    } -  +  +  if (!args) +  { +  THIS=(struct font *)xalloc(sizeof(struct font)); +  THIS->mem=image_default_font; +  size=IMAGE_DEFAULT_FONT_SIZE; +  goto loading_default; +  } +  +  if (sp[-args].type!=T_STRING) +  error("font->read: illegal or wrong number of arguments\n"); +     do    {   #ifdef FONT_DEBUG
365:       if (fd >= 0)    { -  size_t size; +     struct font *new_font;       size = (size_t) file_size(fd);
391:   #endif    THREADS_DISALLOW();    + loading_default: +     if (THIS->mem)    {    struct file_head
473:       }    +  if (!args) goto done; +     fd_close(fd);    pop_n_elems(args);    ref_push_object(THISOBJ); /* success */
488: Inside #if defined(FONT_DEBUG)
  #ifdef FONT_DEBUG    else fprintf(stderr,"FONT wrong cookie\n");   #endif +  if (!args) goto done; /* just in case */    } /* mem failure */   #ifdef FONT_DEBUG    else fprintf(stderr,"FONT mem failure\n");
504:    else fprintf(stderr,"FONT fd failure\n");   #endif    + done: +     pop_n_elems(args);    push_int(0);    return;
888:    ADD_FUNCTION("create",font_create,tFunc(tOr(tVoid,tStr),tVoid),0);       /* function(string:object) */ -  ADD_FUNCTION("write",font_write,tFunc(tStr,tObj),0); +  ADD_FUNCTION("write",font_write,tFuncV(,tStr,tObj),0);       /* function(:int) */    ADD_FUNCTION("height",font_height,tFunc(,tInt),0);