PageRenderTime 96ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/xorg-x11-font-utils-7.5/fonttosfnt-1.0.3/fonttosfnt.c

#
C | 118 lines | 85 code | 10 blank | 23 comment | 35 complexity | ae6ea9b56b93aecba2260b3c942b01d8 MD5 | raw file
Possible License(s): MIT
  1. /*
  2. Copyright (c) 2002-2003 by Juliusz Chroboczek
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. THE SOFTWARE.
  18. */
  19. /* $XdotOrg: xc/programs/fonttosfnt/fonttosfnt.c,v 1.4 2003/12/19 02:16:36 dawes Exp $ */
  20. /* $XFree86: xc/programs/fonttosfnt/fonttosfnt.c,v 1.3 2003/07/08 15:39:49 tsi Exp $ */
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <string.h>
  24. #include "fonttosfnt.h"
  25. int verbose_flag = 0;
  26. int reencode_flag = 1;
  27. int glyph_flag = 2;
  28. int metrics_flag = 1;
  29. int crop_flag = 1;
  30. int bit_aligned_flag = 1;
  31. static void
  32. usage(void)
  33. {
  34. fprintf(stderr, "Usage:\n");
  35. fprintf(stderr,
  36. "fonttosfnt [ -v ] [ -c ] [ -b ] [ -r ] [ -g n ] [ -m n ] -o font.ttf "
  37. "[ -- ] font ...\n");
  38. }
  39. int
  40. main(int argc, char **argv)
  41. {
  42. int i;
  43. int rc;
  44. char *output = NULL;
  45. FontPtr font;
  46. i = 1;
  47. while(i < argc) {
  48. if(argv[i][0] != '-')
  49. break;
  50. if(argv[i][1] == 'o') {
  51. if(argv[i][2] == '\0') {
  52. output = sprintf_reliable("%s", argv[i + 1]);
  53. i += 2;
  54. } else {
  55. output = sprintf_reliable("%s", argv[i] + 2);
  56. i++;
  57. }
  58. } else if(strcmp(argv[i], "-v") == 0) {
  59. verbose_flag = 1;
  60. i++;
  61. } else if(strcmp(argv[i], "-c") == 0) {
  62. crop_flag = 0;
  63. i++;
  64. } else if(strcmp(argv[i], "-b") == 0) {
  65. bit_aligned_flag = 0;
  66. i++;
  67. } else if(strcmp(argv[i], "-r") == 0) {
  68. reencode_flag = 0;
  69. i++;
  70. } else if(strcmp(argv[i], "-g") == 0) {
  71. if(argc <= i + 1) {
  72. usage();
  73. exit(1);
  74. }
  75. glyph_flag = atoi(argv[i + 1]);
  76. i += 2;
  77. } else if(strcmp(argv[i], "-m") == 0) {
  78. if(argc <= i + 1) {
  79. usage();
  80. exit(1);
  81. }
  82. metrics_flag = atoi(argv[i + 1]);
  83. i += 2;
  84. } else if(strcmp(argv[i], "--") == 0) {
  85. i++;
  86. break;
  87. } else {
  88. usage();
  89. exit(1);
  90. }
  91. }
  92. if(output == NULL) {
  93. usage();
  94. exit(1);
  95. }
  96. font = makeFont();
  97. while(i < argc) {
  98. rc = readFile(argv[i], font);
  99. if(rc != 0)
  100. exit(1);
  101. i++;
  102. }
  103. writeFile(output, font);
  104. return 0;
  105. }