1 /* 2 * Copyright 2008 Department of Mathematical Sciences, New Mexico State University 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * DEPARTMENT OF MATHEMATICAL SCIENCES OR NEW MEXICO STATE UNIVERSITY BE 18 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 19 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 #ifndef _h_bdf 23 #define _h_bdf 24 25 #include <stdio.h> 26 #include <stdlib.h> 27 #ifndef __digital__ 28 #include <unistd.h> 29 #endif 30 #include <string.h> 31 32 #ifdef HAVE_XLIB 33 #include <X11/Xlib.h> 34 #include <X11/Xutil.h> 35 #include <X11/Xatom.h> 36 #endif /* HAVE_XLIB */ 37 38 #ifdef HAVE_FREETYPE 39 #include <ft2build.h> 40 #include FT_FREETYPE_H 41 #endif /* HAVE_FREETYPE */ 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 /************************************************************************** 48 * 49 * BDF font options macros and types. 50 * 51 **************************************************************************/ 52 53 #define BDF_UNIX_EOL 1 /* Save fonts with Unix LF. */ 54 #define BDF_DOS_EOL 2 /* Save fonts with DOS CRLF. */ 55 #define BDF_MAC_EOL 3 /* Save fonts with Mac CR. */ 56 57 #define BDF_CORRECT_METRICS 0x01 /* Correct invalid metrics when loading. */ 58 #define BDF_KEEP_COMMENTS 0x02 /* Preserve the font comments. */ 59 #define BDF_KEEP_UNENCODED 0x04 /* Keep the unencoded glyphs. */ 60 #define BDF_PROPORTIONAL 0x08 /* Font has proportional spacing. */ 61 #define BDF_MONOWIDTH 0x10 /* Font has mono width. */ 62 #define BDF_CHARCELL 0x20 /* Font has charcell spacing. */ 63 64 #define BDF_ALL_SPACING (BDF_PROPORTIONAL|BDF_MONOWIDTH|BDF_CHARCELL) 65 66 #define BDF_DEFAULT_LOAD_OPTIONS \ 67 (BDF_CORRECT_METRICS|BDF_KEEP_COMMENTS|BDF_KEEP_UNENCODED|BDF_PROPORTIONAL) 68 69 typedef struct { 70 int otf_flags; 71 int correct_metrics; 72 int keep_unencoded; 73 int keep_comments; 74 int pad_cells; 75 int font_spacing; 76 int point_size; 77 unsigned int resolution_x; 78 unsigned int resolution_y; 79 int bits_per_pixel; 80 int eol; 81 int psf_flags; 82 int cursor_font; 83 } bdf_options_t; 84 85 /* 86 * Callback function type for unknown configuration options. 87 */ 88 typedef int (*bdf_options_callback_t)(bdf_options_t *opts, 89 char **params, 90 unsigned int nparams, 91 void *client_data); 92 93 /************************************************************************** 94 * 95 * BDF font property macros and types. 96 * 97 **************************************************************************/ 98 99 #define BDF_ATOM 1 100 #define BDF_INTEGER 2 101 #define BDF_CARDINAL 3 102 103 /* 104 * This structure represents a particular property of a font. 105 * There are a set of defaults and each font has their own. 106 */ 107 typedef struct { 108 char *name; /* Name of the property. */ 109 int format; /* Format of the property. */ 110 int builtin; /* A builtin property. */ 111 union { 112 char *atom; 113 int int32; 114 unsigned int card32; 115 } value; /* Value of the property. */ 116 } bdf_property_t; 117 118 /************************************************************************** 119 * 120 * SBIT metrics specific structures. 121 * 122 **************************************************************************/ 123 124 /* 125 * Boolean flags for SBIT metrics files. 126 */ 127 #define BDF_SBIT_MONO_ADVANCE 0x0001 128 #define BDF_SBIT_ADD_EBLC 0x0002 129 #define BDF_SBIT_APPLE_COMPAT 0x0004 130 131 /* 132 * Direction macros (inclusive, can be combined). 133 */ 134 #define BDF_SBIT_HORIZONTAL 0x0008 135 #define BDF_SBIT_VERTICAL 0x0010 136 137 /* 138 * Bitmap storage options (exclusive, cannot be combined). 139 */ 140 #define BDF_SBIT_STORE_SMALL 0x0020 141 #define BDF_SBIT_STORE_FAST 0x0040 142 143 typedef struct { 144 short cnum; /* Caret slope numerator. */ 145 short cdenom; /* Caret slope denominator. */ 146 short coff; /* Caret offset. */ 147 short sx; /* Scaled version horizontal PPEM size. */ 148 short sy; /* Scaled version vertical PPEM size (optional).*/ 149 short flags; /* Booleans and other non-numeric values. */ 150 } bdf_sbit_t; 151 152 /************************************************************************** 153 * 154 * BDF opaque undo information types. 155 * 156 **************************************************************************/ 157 158 typedef struct _bdf_undo_t *bdf_undo_t; 159 160 /************************************************************************** 161 * 162 * PSF font flags and Unicode mapping tables. Stored internally in UTF-8. 163 * 164 **************************************************************************/ 165 166 /* 167 * Flags used for exporting PSF fonts and their Unicode maps. 168 */ 169 #define BDF_PSF_FONT 0x01 170 #define BDF_PSF_UNIMAP 0x02 171 #define BDF_PSF_ALL (BDF_PSF_FONT|BDF_PSF_UNIMAP) 172 173 typedef struct { 174 unsigned char *map; 175 unsigned int map_used; 176 unsigned int map_size; 177 } bdf_psf_unimap_t; 178 179 /************************************************************************** 180 * 181 * BDF font metric and glyph types. 182 * 183 **************************************************************************/ 184 185 /* 186 * A general bitmap type, mostly used when the glyph bitmap is being edited. 187 */ 188 typedef struct { 189 short x; 190 short y; 191 unsigned short width; 192 unsigned short height; 193 unsigned short bpp; 194 unsigned short pad; 195 unsigned char *bitmap; 196 unsigned int bytes; 197 } bdf_bitmap_t; 198 199 typedef struct { 200 int font_spacing; 201 unsigned short swidth; 202 unsigned short dwidth; 203 unsigned short width; 204 unsigned short height; 205 short x_offset; 206 short y_offset; 207 short ascent; 208 short descent; 209 } bdf_metrics_t; 210 211 typedef struct { 212 unsigned short width; 213 unsigned short height; 214 short x_offset; 215 short y_offset; 216 short ascent; 217 short descent; 218 } bdf_bbx_t; 219 220 typedef struct { 221 char *name; /* Glyph name. */ 222 int encoding; /* Glyph encoding. */ 223 unsigned short swidth; /* Scalable width. */ 224 unsigned short dwidth; /* Device width. */ 225 bdf_bbx_t bbx; /* Glyph bounding box. */ 226 unsigned char *bitmap; /* Glyph bitmap. */ 227 unsigned short bytes; /* Number of bytes used for the bitmap. */ 228 bdf_psf_unimap_t unicode; /* PSF Unicode mappings. */ 229 } bdf_glyph_t; 230 231 typedef struct { 232 unsigned short pad; /* Pad to 4-byte boundary. */ 233 unsigned short bpp; /* Bits per pixel. */ 234 int start; /* Beginning encoding value of glyphs. */ 235 int end; /* Ending encoding value of glyphs. */ 236 bdf_glyph_t *glyphs; /* Glyphs themselves. */ 237 unsigned int glyphs_size; /* Glyph structures allocated. */ 238 unsigned int glyphs_used; /* Glyph structures used. */ 239 bdf_bbx_t bbx; /* Overall bounding box of glyphs. */ 240 } bdf_glyphlist_t; 241 242 typedef struct { 243 char *name; /* Name of the font. */ 244 bdf_bbx_t bbx; /* Font bounding box. */ 245 246 int point_size; /* Point size of the font. */ 247 unsigned int resolution_x; /* Font horizontal resolution. */ 248 unsigned int resolution_y; /* Font vertical resolution. */ 249 250 int hbf; /* Font came from an HBF font. */ 251 252 int spacing; /* Font spacing value. */ 253 254 unsigned short monowidth; /* Logical width for monowidth font. */ 255 256 int default_glyph; /* Encoding of the default glyph. */ 257 258 int font_ascent; /* Font ascent. */ 259 int font_descent; /* Font descent. */ 260 261 int glyphs_size; /* Glyph structures allocated. */ 262 int glyphs_used; /* Glyph structures used. */ 263 bdf_glyph_t *glyphs; /* Glyphs themselves. */ 264 265 int unencoded_size; /* Unencoded glyph structures allocated. */ 266 int unencoded_used; /* Unencoded glyph structures used. */ 267 bdf_glyph_t *unencoded; /* Unencoded glyphs themselves. */ 268 269 unsigned int props_size; /* Font properties allocated. */ 270 unsigned int props_used; /* Font properties used. */ 271 bdf_property_t *props; /* Font properties themselves. */ 272 273 char *comments; /* Font comments. */ 274 unsigned int comments_len; /* Length of comment string. */ 275 276 char *acmsgs; /* Auto-correction messages. */ 277 unsigned int acmsgs_len; /* Length of auto-correction messages. */ 278 279 bdf_glyphlist_t overflow; /* Storage used for glyph insertion. */ 280 281 void *internal; /* Internal data for the font. */ 282 283 unsigned int nmod[2048]; /* Bitmap indicating modified glyphs. */ 284 unsigned int umod[2048]; /* Bitmap indicating modified unencoded. */ 285 286 unsigned short modified; /* Boolean indicating font modified. */ 287 unsigned short bpp; /* Bits per pixel. */ 288 289 bdf_sbit_t *sbits; /* Associcated SBIT metrics. */ 290 unsigned int sbits_used; /* Number of SBIT metrics entries. */ 291 unsigned int sbits_size; /* Amount of entries allocated. */ 292 293 bdf_undo_t *undo_stack; /* Record of undoable operations. */ 294 unsigned int undo_used; /* Amount of undo stack used. */ 295 unsigned int undo_size; /* Amount of undo stack allocated. */ 296 297 bdf_psf_unimap_t unicode; /* PSF Unicode table. */ 298 } bdf_font_t; 299 300 /************************************************************************** 301 * 302 * BDF glyph grid structures for editing glyph bitmaps. 303 * 304 **************************************************************************/ 305 306 typedef struct { 307 char *name; 308 int encoding; /* The glyph encoding. */ 309 unsigned short unencoded; /* Whether the glyph was unencoded. */ 310 unsigned short bpp; /* Bits per pixel. */ 311 int spacing; /* Font spacing. */ 312 int resolution_x; /* Horizontal resolution. */ 313 int resolution_y; /* Vertical resolution. */ 314 unsigned int point_size; /* Font point size. */ 315 unsigned short swidth; /* Scalable width. */ 316 unsigned short dwidth; /* Device width. */ 317 bdf_bbx_t font_bbx; /* Font bounding box. */ 318 bdf_bbx_t glyph_bbx; /* Glyph bounding box. */ 319 unsigned char *bitmap; /* The grid bitmap. */ 320 unsigned short bytes; /* Number of bytes in the grid bitmap. */ 321 short grid_width; /* Width of the grid. */ 322 short grid_height; /* Height of the grid. */ 323 short base_x; /* Baseline X coordinate. */ 324 short base_y; /* Baseline Y coordinate. */ 325 short glyph_x; /* Top-left X position of glyph. */ 326 short glyph_y; /* Top-left Y position of glyph. */ 327 unsigned short modified; /* Flag indicating if bitmap modified. */ 328 short cap_height; /* Font CAP_HEIGHT if it exists. */ 329 short x_height; /* Font X_HEIGHT if it exists. */ 330 bdf_bitmap_t sel; /* Selected portion of the glyph bitmap.*/ 331 bdf_psf_unimap_t unicode; /* PSF Unicode mappings for this glyph. */ 332 } bdf_glyph_grid_t; 333 334 /************************************************************************** 335 * 336 * Types for load/save callbacks. 337 * 338 **************************************************************************/ 339 340 /* 341 * Callback reasons. 342 */ 343 #define BDF_LOAD_START 1 344 #define BDF_LOADING 2 345 #define BDF_SAVE_START 3 346 #define BDF_SAVING 4 347 #define BDF_TRANSLATE_START 5 348 #define BDF_TRANSLATING 6 349 #define BDF_ROTATE_START 7 350 #define BDF_ROTATING 8 351 #define BDF_SHEAR_START 9 352 #define BDF_SHEARING 10 353 #define BDF_GLYPH_NAME_START 11 354 #define BDF_GLYPH_NAME 12 355 #define BDF_EXPORT_START 13 356 #define BDF_EXPORTING 14 357 #define BDF_EMBOLDEN_START 15 358 #define BDF_EMBOLDENING 16 359 #define BDF_WARNING 20 360 #define BDF_ERROR 21 361 362 /* 363 * Error codes. 364 */ 365 #define BDF_OK 0 366 #define BDF_MISSING_START -1 367 #define BDF_MISSING_FONTNAME -2 368 #define BDF_MISSING_SIZE -3 369 #define BDF_MISSING_FONTBBX -4 370 #define BDF_MISSING_CHARS -5 371 #define BDF_MISSING_STARTCHAR -6 372 #define BDF_MISSING_ENCODING -7 373 #define BDF_MISSING_BBX -8 374 375 #define BDF_NOT_CONSOLE_FONT -10 376 #define BDF_NOT_MF_FONT -11 377 #define BDF_NOT_PSF_FONT -12 378 #define BDF_PSF_SHORT_TABLE -13 379 #define BDF_PSF_LONG_TABLE -14 380 #define BDF_PSF_CORRUPT_UTF8 -15 381 #define BDF_PSF_BUFFER_OVRFL -16 382 #define BDF_PSF_UNSUPPORTED -17 383 #define BDF_BAD_RANGE -98 384 #define BDF_EMPTY_FONT -99 385 #define BDF_INVALID_LINE -100 386 387 typedef struct { 388 unsigned int reason; 389 unsigned int current; 390 unsigned int total; 391 unsigned int errlineno; 392 } bdf_callback_struct_t; 393 394 typedef void (*bdf_callback_t)(bdf_callback_struct_t *call_data, 395 void *client_data); 396 397 /************************************************************************** 398 * 399 * BDF font API. 400 * 401 **************************************************************************/ 402 403 /* 404 * Startup and shutdown functions. 405 */ 406 extern void bdf_setup(void); 407 extern void bdf_cleanup(void); 408 409 /* 410 * Configuration file loading and saving. 411 */ 412 extern void bdf_load_options(FILE *in, bdf_options_t *opts, 413 bdf_options_callback_t callback, 414 void *client_data); 415 extern void bdf_save_options(FILE *out, bdf_options_t *opts); 416 417 /* 418 * Font options functions. 419 */ 420 extern void bdf_default_options(bdf_options_t *opts); 421 422 /* 423 * Font load, create, save and free functions. 424 */ 425 extern bdf_font_t *bdf_new_font(char *name, int point_size, 426 int resolution_x, int resolution_y, 427 int spacing, int bpp); 428 extern bdf_font_t *bdf_load_font(FILE *in, bdf_options_t *opts, 429 bdf_callback_t callback, void *data); 430 #ifdef HAVE_HBF 431 extern bdf_font_t *bdf_load_hbf_font(char *filename, bdf_options_t *opts, 432 bdf_callback_t callback, void *data); 433 #endif 434 435 #ifdef HAVE_XLIB 436 extern bdf_font_t *bdf_load_server_font(Display *d, XFontStruct *f, 437 char *name, bdf_options_t *opts, 438 bdf_callback_t callback, 439 void *data); 440 #endif /* HAVE_XLIB */ 441 442 extern int bdf_load_console_font(FILE *in, bdf_options_t *opts, 443 bdf_callback_t callback, void *data, 444 bdf_font_t *fonts[3], int *nfonts); 445 446 extern int bdf_load_mf_font(FILE *in, bdf_options_t *opts, 447 bdf_callback_t callback, void *data, 448 bdf_font_t **font); 449 450 extern void bdf_save_font(FILE *out, bdf_font_t *font, bdf_options_t *opts, 451 bdf_callback_t callback, void *data); 452 453 extern void bdf_save_sbit_metrics(FILE *out, bdf_font_t *font, 454 bdf_options_t *opts, char *appname); 455 456 extern void bdf_export_hex(FILE *out, bdf_font_t *font, bdf_options_t *opts, 457 bdf_callback_t callback, void *data); 458 459 extern int bdf_export_psf(FILE *out, bdf_font_t *font, bdf_options_t *opts, 460 int start, int end); 461 462 extern void bdf_free_font(bdf_font_t *font); 463 464 #ifdef HAVE_FREETYPE 465 466 /* 467 * OpenType related macros and functions. 468 */ 469 470 /* 471 * ID numbers of the strings that can appear in an OpenType font. 472 */ 473 #define BDFOTF_COPYRIGHT_STRING 0 474 #define BDFOTF_FAMILY_STRING 1 475 #define BDFOTF_SUBFAMILY_STRING 2 476 #define BDFOTF_UNIQUEID_STRING 3 477 #define BDFOTF_FULLNAME_STRING 4 478 #define BDFOTF_VENDOR_STRING 5 479 #define BDFOTF_POSTSCRIPT_STRING 6 480 #define BDFOTF_TRADEMARK_STRING 7 481 #define BDFOTF_FOUNDRY_STRING 8 482 #define BDFOTF_DESIGNER_STRING 9 483 #define BDFOTF_DESCRIPTION_STRING 10 484 #define BDFOTF_VENDORURL_STRING 11 485 #define BDFOTF_DESIGNERURL_STRING 12 486 #define BDFOTF_LICENSE_STRING 13 487 #define BDFOTF_LICENSEURL_STRING 14 488 #define BDFOTF_RESERVED_STRING 15 489 #define BDFOTF_PREFFAMILY_STRING 16 490 #define BDFOTF_PREFSUBFAMILY_STRING 17 491 #define BDFOTF_COMPATIBLEMAC_STRING 18 492 #define BDFOTF_SAMPLETEXT_STRING 19 493 #define BDFOTF_PSCIDFF_STRING 20 494 495 extern char *bdfotf_platform_name(short pid); 496 extern char *bdfotf_encoding_name(short pid, short eid); 497 extern int bdfotf_get_english_string(FT_Face face, int nameID, 498 int dash_to_space, char *name); 499 500 extern int bdfotf_load_font(FT_Face face, short pid, short eid, 501 bdf_options_t *opts, bdf_callback_t callback, 502 void *data, bdf_font_t **font); 503 504 #endif /* HAVE_FREETYPE */ 505 506 /* 507 * FON/FNT related functions. 508 */ 509 510 /* 511 * String ID numbers for FON/FNT fonts. 512 */ 513 #define BDFFNT_COPYRIGHT 1 514 #define BDFFNT_TYPEFACE 2 515 516 /* 517 * Opaque font type. 518 */ 519 typedef struct _bdffnt_font_t *bdffnt_font_t; 520 521 extern int bdffnt_open_font(char *path, bdffnt_font_t *font); 522 extern void bdffnt_close_font(bdffnt_font_t font); 523 extern int bdffnt_font_count(bdffnt_font_t font); 524 extern int bdffnt_get_copyright(bdffnt_font_t font, unsigned int fontID, 525 unsigned char *string); 526 extern int bdffnt_get_facename(bdffnt_font_t font, unsigned int fontID, 527 int for_xlfd, unsigned char *string); 528 extern int bdffnt_char_count(bdffnt_font_t font, unsigned int fontID); 529 extern int bdffnt_font_pointsize(bdffnt_font_t font, unsigned int fontID); 530 extern int bdffnt_load_font(bdffnt_font_t font, unsigned int fontID, 531 bdf_callback_t callback, void *data, 532 bdf_font_t **out); 533 534 /* 535 * PSF font section. 536 * 537 * In PSF fonts, a Unicode table on the end of the font may map a single 538 * glyph to several locations. The BDFPSF_SOURCE_GLYPH marks the glyphs that 539 * are source glyphs and the BDFPSF_PSEUDO_GLYPH flag marks glyphs that are 540 * clones of a source glyph. 541 */ 542 #define BDFPSF_SOURCE_GLYPH 0x0001 543 #define BDFPSF_PSEUDO_GLYPH 0x0002 544 545 extern bdf_font_t *bdf_load_psf(FILE *in, unsigned char *magic, 546 bdf_options_t *opts, 547 bdf_callback_t callback, void *data, 548 int *awidth); 549 550 /* 551 * Font property functions. 552 */ 553 extern void bdf_create_property(char *name, int type); 554 extern bdf_property_t *bdf_get_property(char *name); 555 extern unsigned int bdf_property_list(bdf_property_t **props); 556 557 extern void bdf_add_font_property(bdf_font_t *font, bdf_property_t *property); 558 extern void bdf_delete_font_property(bdf_font_t *font, char *name); 559 extern bdf_property_t *bdf_get_font_property(bdf_font_t *font, char *name); 560 extern unsigned int bdf_font_property_list(bdf_font_t *font, 561 bdf_property_t **props); 562 extern int bdf_is_xlfd_property(char *name); 563 564 /* 565 * Font comment functions. 566 */ 567 extern int bdf_replace_comments(bdf_font_t *font, char *comments, 568 unsigned int comments_len); 569 570 /* 571 * Other miscellaneous functions. 572 */ 573 extern void bdf_set_default_metrics(bdf_font_t *font); 574 575 /* 576 * Font glyph editing functions. 577 */ 578 extern int bdf_glyph_modified(bdf_font_t *font, int which, int unencoded); 579 580 extern void bdf_copy_glyphs(bdf_font_t *font, int start, int end, 581 bdf_glyphlist_t *glyphs, int unencoded); 582 583 extern int bdf_delete_glyphs(bdf_font_t *font, int start, int end, 584 int unencoded); 585 586 extern int bdf_insert_glyphs(bdf_font_t *font, int start, 587 bdf_glyphlist_t *glyphs); 588 589 extern int bdf_replace_glyphs(bdf_font_t *font, int start, 590 bdf_glyphlist_t *glyphs, int unencoded); 591 592 extern int bdf_merge_glyphs(bdf_font_t *font, int start, 593 bdf_glyphlist_t *glyphs, int unencoded); 594 595 extern int bdf_replace_mappings(bdf_font_t *font, int encoding, 596 bdf_psf_unimap_t *map, int unencoded); 597 598 /************************************************************************** 599 * 600 * Other API functions. 601 * 602 **************************************************************************/ 603 604 extern int bdf_set_font_bbx(bdf_font_t *font, bdf_metrics_t *metrics); 605 606 extern void bdf_set_modified(bdf_font_t *font, int modified); 607 608 extern int bdf_has_xlfd_name(bdf_font_t *font); 609 610 extern char *bdf_make_xlfd_name(bdf_font_t *font, char *foundry, 611 char *family); 612 613 extern void bdf_update_name_from_properties(bdf_font_t *font); 614 615 extern int bdf_update_properties_from_name(bdf_font_t *font); 616 617 extern int bdf_update_average_width(bdf_font_t *font); 618 619 extern int bdf_set_unicode_glyph_names(FILE *in, bdf_font_t *font, 620 bdf_callback_t callback); 621 622 extern int bdf_set_adobe_glyph_names(FILE *in, bdf_font_t *font, 623 bdf_callback_t callback); 624 625 extern int bdf_set_glyph_code_names(int prefix, bdf_font_t *font, 626 bdf_callback_t callback); 627 628 /* 629 * Routine to add Unicode mappings when editing PSF fonts. 630 */ 631 extern int bdf_psf_add_unicode_mapping(bdf_psf_unimap_t *u, 632 unsigned int *mapping, 633 unsigned int mapping_cnt); 634 635 /************************************************************************** 636 * 637 * Glyph grid API. 638 * 639 **************************************************************************/ 640 641 /* 642 * Glyph grid allocation and deallocation functions. 643 */ 644 extern bdf_glyph_grid_t *bdf_make_glyph_grid(bdf_font_t *font, 645 int code, 646 int unencoded); 647 extern void bdf_free_glyph_grid(bdf_glyph_grid_t *grid); 648 649 /* 650 * Glyph grid information functions. 651 */ 652 extern void bdf_grid_image(bdf_glyph_grid_t *grid, bdf_bitmap_t *image); 653 extern void bdf_grid_origin(bdf_glyph_grid_t *grid, short *x, short *y); 654 extern bdf_glyph_t *bdf_grid_glyph(bdf_glyph_grid_t *grid); 655 656 /* 657 * Glyph grid editing functions. 658 */ 659 extern int bdf_grid_enlarge(bdf_glyph_grid_t *grid, unsigned short width, 660 unsigned short height); 661 extern int bdf_grid_resize(bdf_glyph_grid_t *grid, 662 bdf_metrics_t *metrics); 663 extern int bdf_grid_crop(bdf_glyph_grid_t *grid, int grid_modified); 664 665 extern int bdf_grid_set_pixel(bdf_glyph_grid_t *grid, short x, short y, 666 int val); 667 extern int bdf_grid_clear_pixel(bdf_glyph_grid_t *grid, short x, short y); 668 extern int bdf_grid_invert_pixel(bdf_glyph_grid_t *grid, 669 short x, short y, int val); 670 extern int bdf_grid_shift(bdf_glyph_grid_t *grid, short xcount, 671 short ycount); 672 extern int bdf_grid_flip(bdf_glyph_grid_t *grid, short dir); 673 extern int bdf_grid_rotate(bdf_glyph_grid_t *grid, short degrees, 674 int *resize); 675 extern int bdf_grid_shear(bdf_glyph_grid_t *grid, short degrees, 676 int *resize); 677 extern int bdf_grid_embolden(bdf_glyph_grid_t *grid); 678 679 /* 680 * Glyph grid selection functions. 681 */ 682 extern int bdf_has_selection(bdf_glyph_grid_t *grid, short *x, short *y, 683 short *width, short *height); 684 extern void bdf_set_selection(bdf_glyph_grid_t *grid, short x, short y, 685 short width, short height); 686 extern void bdf_lose_selection(bdf_glyph_grid_t *grid); 687 extern void bdf_detach_selection(bdf_glyph_grid_t *grid); 688 extern void bdf_attach_selection(bdf_glyph_grid_t *grid); 689 extern void bdf_delete_selection(bdf_glyph_grid_t *grid); 690 extern int bdf_in_selection(bdf_glyph_grid_t *grid, short x, short y, 691 short *set); 692 extern void bdf_add_selection(bdf_glyph_grid_t *grid, bdf_bitmap_t *sel); 693 694 /* 695 * Glyph grid misc functions. 696 */ 697 extern int bdf_grid_color_at(bdf_glyph_grid_t *grid, short x, short y); 698 699 /* 700 * Graphical transformation functions. 701 */ 702 extern int bdf_translate_glyphs(bdf_font_t *font, short dx, short dy, 703 int start, int end, 704 bdf_callback_t callback, void *data, 705 int unencoded); 706 707 extern int bdf_rotate_glyphs(bdf_font_t *font, short degrees, 708 int start, int end, 709 bdf_callback_t callback, void *data, 710 int unencoded); 711 712 extern int bdf_shear_glyphs(bdf_font_t *font, short degrees, 713 int start, int end, 714 bdf_callback_t callback, void *data, 715 int unencoded); 716 717 extern int bdf_embolden_glyphs(bdf_font_t *font, int start, int end, 718 bdf_callback_t callback, void *data, 719 int unencoded, int *resize); 720 721 extern int bdf_little_endian(void); 722 723 #ifdef __cplusplus 724 } 725 #endif 726 727 #endif /* _h_bdf */ 728