subfont.c 975 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include <u.h>
  10. #include <libc.h>
  11. #include <draw.h>
  12. #include <memdraw.h>
  13. Memsubfont*
  14. allocmemsubfont(char *name, int n, int height, int ascent,
  15. Fontchar *info, Memimage *i)
  16. {
  17. Memsubfont *f;
  18. f = malloc(sizeof(Memsubfont));
  19. if(f == 0)
  20. return 0;
  21. f->n = n;
  22. f->height = height;
  23. f->ascent = ascent;
  24. f->info = info;
  25. f->bits = i;
  26. if(name)
  27. f->name = strdup(name);
  28. else
  29. f->name = 0;
  30. return f;
  31. }
  32. void
  33. freememsubfont(Memsubfont *f)
  34. {
  35. if(f == 0)
  36. return;
  37. free(f->info); /* note: f->info must have been malloc'ed! */
  38. freememimage(f->bits);
  39. free(f);
  40. }