您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # figfont libcaca FIGfont test program
  5. # Copyright (c) 2010 Alex Foulon <alxf@lavabit.com>
  6. #
  7. # This file is a Python port of "examples/figfont.c"
  8. # which is:
  9. # Copyright (c) 2007-2010 Sam Hocevar <sam@hocevar.net>
  10. # All Rights Reserverd
  11. #
  12. # This library is free software. It comes without any warranty, to
  13. # the extent permitted by applicable law. You can redistribute it
  14. # and/or modify it under the terms of the Do What The Fuck You Want
  15. # To Public License, Version 2, as published by Sam Hocevar. See
  16. # http://sam.zoy.org/wtfpl/COPYING for more details.
  17. #
  18. import codecs
  19. import os
  20. import sys
  21. import caca
  22. from caca.canvas import Canvas, CanvasError
  23. def main():
  24. """ Main function. """
  25. if len(sys.argv) < 3:
  26. sys.stderr.write("Usage: %s <figfont file> <word>\n" \
  27. % os.path.basename(sys.argv[0]))
  28. sys.exit(2)
  29. try:
  30. cv = Canvas(0, 0)
  31. except CanvasError as err:
  32. sys.stderr.write("%s\n" % err)
  33. sys.exit(2)
  34. if cv.set_figfont(sys.argv[1]):
  35. sys.stderr.write("Could not open font...\n")
  36. sys.exit(2)
  37. if sys.version_info[0:2] >= (3,0):
  38. word = sys.argv[2]
  39. else:
  40. word = codecs.decode(sys.argv[2], "utf8")
  41. for c in word:
  42. cv.put_figchar(c)
  43. sys.stderr.write(cv.export_to_memory("utf8"))
  44. if __name__ == "__main__":
  45. main()