subfont.c 913 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. Subfont*
  13. allocsubfont(char *name, int n, int height, int ascent, Fontchar *info,
  14. Image *i)
  15. {
  16. Subfont *f;
  17. assert(height != 0 /* allocsubfont */);
  18. f = malloc(sizeof(Subfont));
  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. f->ref = 1;
  27. if(name){
  28. f->name = strdup(name);
  29. if(lookupsubfont(i->display, name) == 0)
  30. installsubfont(name, f);
  31. }else
  32. f->name = 0;
  33. return f;
  34. }