bmf.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. * CDDL HEADER START
  3. *
  4. * The contents of this file are subject to the terms of the
  5. * Common Development and Distribution License (the "License").
  6. * You may not use this file except in compliance with the License.
  7. *
  8. * You can obtain a copy of the license at src/OPENSOLARIS.LICENSE
  9. * or http://www.opensolaris.org/os/licensing.
  10. * See the License for the specific language governing permissions
  11. * and limitations under the License.
  12. *
  13. * When distributing Covered Code, include this CDDL HEADER in each
  14. * file and include the License file at src/OPENSOLARIS.LICENSE.
  15. * If applicable, add the following below this CDDL HEADER, with the
  16. * fields enclosed by brackets "[]" replaced with your own identifying
  17. * information: Portions Copyright [yyyy] [name of copyright owner]
  18. *
  19. * CDDL HEADER END
  20. */
  21. /*
  22. * Copyright (c) 1999 by Sun Microsystems, Inc.
  23. * All rights reserved.
  24. */
  25. /*
  26. * Copyright (C) 1994 X Consortium
  27. *
  28. * Permission is hereby granted, free of charge, to any person obtaining a copy
  29. * of this software and associated documentation files (the "Software"), to
  30. * deal in the Software without restriction, including without limitation the
  31. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  32. * sell copies of the Software, and to permit persons to whom the Software is
  33. * furnished to do so, subject to the following conditions:
  34. *
  35. * The above copyright notice and this permission notice shall be included in
  36. * all copies or substantial portions of the Software.
  37. *
  38. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  39. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  40. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  41. * X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  42. * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
  43. * TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  44. *
  45. * Except as contained in this notice, the name of the X Consortium shall not
  46. * be used in advertising or otherwise to promote the sale, use or other deal-
  47. * ings in this Software without prior written authorization from the X Consor-
  48. * tium.
  49. *
  50. * X Window System is a trademark of X Consortium, Inc.
  51. */
  52. #ifndef _BMF_H
  53. #define _BMF_H
  54. #define FONT_COUNT 7
  55. #define FONT_FILE_DEFAULT "text.bmf"
  56. #define FONT_FILE_ITALIC "texti.bmf"
  57. #define FONT_FILE_TITLE "title.bmf"
  58. #define FONT_FILE_SUBTITLE "subtitle.bmf"
  59. #define FONT_FILE_DEFAULT_ALL "textall.bmf"
  60. #define FONT_FILE_TITLE_ALL "titleall.bmf"
  61. #define FONT_FILE_SUBTITLE_ALL "subtlall.bmf"
  62. #ifdef WIKIPCF
  63. #define openfile open
  64. #define seekfile lseek
  65. #define readfile read
  66. #define closefile close
  67. #else
  68. #define openfile wl_open
  69. #define seekfile wl_seek
  70. #define readfile wl_read
  71. #define closefile wl_close
  72. #endif
  73. #include <inttypes.h>
  74. typedef unsigned char bmf_bm_t;
  75. typedef unsigned int ucs4_t;
  76. #define bzero(b,n) (memset((b),0,(n)))
  77. typedef unsigned char_bm_t;
  78. struct fontmetric {
  79. int ptsz;
  80. int Xres;
  81. int Yres;
  82. int ascent;
  83. int descent;
  84. int linespace;
  85. int firstchar;
  86. int firstCol;
  87. int lastCol;
  88. int lastchar;
  89. int default_char;
  90. };
  91. struct charmetric {
  92. int width;
  93. int height;
  94. int widthBits;
  95. int widthBytes;
  96. int ascent;
  97. int descent;
  98. int LSBearing;
  99. int RSBearing;
  100. int origin_xoff;
  101. };
  102. struct scaled_charmetric {
  103. double width;
  104. double height;
  105. double widthBits;
  106. double ascent;
  107. double descent;
  108. double origin_xoff;
  109. };
  110. typedef struct charmetric_bmf{
  111. int8_t width;
  112. int8_t height;
  113. int8_t widthBytes;
  114. int8_t widthBits;
  115. int8_t ascent;
  116. int8_t descent;
  117. int8_t LSBearing;
  118. int8_t widthDevice;
  119. char bitmap[48];
  120. }charmetric_bmf;
  121. typedef struct charmetric_bmf_header{
  122. int8_t width;
  123. int8_t height;
  124. int8_t widthBytes;
  125. int8_t widthBits;
  126. int8_t ascent;
  127. int8_t descent;
  128. int8_t LSBearing;
  129. int8_t RSBearing;
  130. int32_t pos;
  131. }charmetric_bmf_header;
  132. typedef struct font_bmf_header{
  133. int8_t linespace;
  134. int8_t ascent;
  135. int8_t descent;
  136. int8_t bmp_buffer_len;
  137. int32_t default_char;
  138. }font_bmf_header;
  139. typedef struct fontmetric pcf_fontmet_t;
  140. struct pcffont_bmf {
  141. char *file;
  142. int fd;
  143. pcf_fontmet_t Fmetrics;
  144. int bPartialFont;
  145. struct pcffont_bmf *supplement_font;
  146. char *charmetric;
  147. int file_size;
  148. int bmp_buffer_len;
  149. };
  150. typedef struct pcffont_bmf pcffont_bmf_t;
  151. int load_bmf(pcffont_bmf_t *font);
  152. int pres_bmfbm(ucs4_t val, pcffont_bmf_t *font, bmf_bm_t **bitmap,charmetric_bmf *Cmetrics);
  153. unsigned long * Xalloc(int);
  154. #endif /* _PCF_H */