fontspec.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Implementation of FontSpec for Windows.
  3. */
  4. #include "putty.h"
  5. FontSpec *fontspec_new(const char *name, bool bold, int height, int charset)
  6. {
  7. FontSpec *f = snew(FontSpec);
  8. f->name = dupstr(name);
  9. f->isbold = bold;
  10. f->height = height;
  11. f->charset = charset;
  12. return f;
  13. }
  14. FontSpec *fontspec_new_default(void)
  15. {
  16. return fontspec_new("", false, 0, 0);
  17. }
  18. FontSpec *fontspec_copy(const FontSpec *f)
  19. {
  20. return fontspec_new(f->name, f->isbold, f->height, f->charset);
  21. }
  22. void fontspec_free(FontSpec *f)
  23. {
  24. sfree(f->name);
  25. sfree(f);
  26. }
  27. void fontspec_serialise(BinarySink *bs, FontSpec *f)
  28. {
  29. put_asciz(bs, f->name);
  30. put_uint32(bs, f->isbold);
  31. put_uint32(bs, f->height);
  32. put_uint32(bs, f->charset);
  33. }
  34. FontSpec *fontspec_deserialise(BinarySource *src)
  35. {
  36. const char *name = get_asciz(src);
  37. unsigned isbold = get_uint32(src);
  38. unsigned height = get_uint32(src);
  39. unsigned charset = get_uint32(src);
  40. return fontspec_new(name, isbold, height, charset);
  41. }