option-manager.js 690 B

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. const path = require('path');
  3. const opentype = require('opentype.js');
  4. const charPreset = require('./char-preset');
  5. const fontPath = path.join(__dirname, '../fonts/Comismsh.ttf');
  6. const font = opentype.loadSync(fontPath);
  7. const ascender = font.ascender;
  8. const descender = font.descender;
  9. const options = {
  10. width: 150,
  11. height: 50,
  12. noise: 1,
  13. color: false,
  14. background: '',
  15. size: 4,
  16. ignoreChars: '',
  17. fontSize: 56,
  18. charPreset, font, ascender, descender
  19. };
  20. const loadFont = filepath => {
  21. const font = opentype.loadSync(filepath);
  22. options.font = font;
  23. options.ascender = font.ascender;
  24. options.descender = font.descender;
  25. };
  26. module.exports = {
  27. options, loadFont
  28. };