home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / os2 / hpgl312.zip / CHARDRAW.H < prev    next >
C/C++ Source or Header  |  1993-04-18  |  5KB  |  145 lines

  1. /*
  2.    Copyright (c) 1991 - 1993 Heinz W. Werntges.  All rights reserved.
  3.    Distributed by Free Software Foundation, Inc.
  4.  
  5. This file is part of HP2xx.
  6.  
  7. HP2xx is distributed in the hope that it will be useful, but
  8. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  9. to anyone for the consequences of using it or for whether it serves any
  10. particular purpose or works at all, unless he says so in writing.  Refer
  11. to the GNU General Public License, Version 2 or later, for full details.
  12.  
  13. Everyone is granted permission to copy, modify and redistribute
  14. HP2xx, but only under the conditions described in the GNU General Public
  15. License.  A copy of this license is supposed to have been
  16. given to you along with HP2xx so you can know your rights and
  17. responsibilities.  It should be in a file named COPYING.  Among other
  18. things, the copyright notice and this notice must be preserved on all
  19. copies.
  20.  
  21. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  22. */
  23.  
  24. /** chardraw.h
  25.  **
  26.  ** 92/02/19  V 1.01  HWW  Derived from sprite.h (V 2.01)
  27.  ** 92/05/28  V 1.02  HWW  plot_symbol_char() added
  28.  **
  29.  ** Structure definition as used by pplib for character drawing
  30.  **/
  31.  
  32.  
  33. #define JOFF    4
  34.  
  35. #define    _BS    '\010'        /* Backspace        */
  36. #define    _HT    '\011'        /* Horizontal Tab    */
  37. #define    _LF    '\012'        /* Line Feed        */
  38. #define    _VT    '\013'        /* Vertical Tab        */
  39. #define    _CR    '\015'        /* Carriage Return    */
  40. #define    _SO    '\016'        /* Shift Out        */
  41. #define    _SI    '\017'        /* Shift In        */
  42.  
  43. /**
  44.  ** Description of struct TextPar (used for internal font drawing):
  45.  **
  46.  ** A character size is defined by its WIDTH and HEIGHT.
  47.  ** The distance from char. to char. is given by SPACE, from
  48.  ** text line to text line by LINE.
  49.  ** WIDTH, SPACE are fractions of the P1,P2 window width,
  50.  ** SPACE, LINE  are fractions of the P1,P2 window height.
  51.  ** The writing direction is DIR, which is the angle [0,2*M_PI]
  52.  ** between text line & x direction.
  53.  ** Set SLANT to an angle != 0 if characters are to appear e.g. italics-like.
  54.  ** Stroked fonts selectable by setting FONT to > 0
  55.  **      (not yet supported).
  56.  **
  57.  ** NOTE: struct TextPar was inherited from former project "plib" (a plot
  58.  **       library which also featured character drawing). It was not
  59.  **       designed from scratch for the purpose of HP-GL font management.
  60.  **       However, for charset 0 it does a fair job here, mainly because
  61.  **       plib itself had been inspired by HP-GL.
  62.  **/
  63.  
  64. typedef struct
  65. {
  66.   float width;    /* Width of a char (x dirc.)        */
  67.   float height;    /* Height of a char (y dirc.)        */
  68.   float space;    /* Distance between characters        */
  69.   float line;    /* Distance betw. char. lines        */
  70.   float espace;    /* Extra char space rel. to 'space'    */
  71.   float eline;    /* Extra line space rel. to 'line'    */
  72.   float dir;    /* Direction to x axis (rad)        */
  73.   float slant;    /* Character slant (tan angle)        */
  74.   int   font;    /* Font number: Currently, only 0     */
  75.   int   orig;    /* Label origin code            */
  76.  
  77.  
  78. /**
  79.  ** Internally needed for character resizing and positioning
  80.  **
  81.  ** T = matrix, mapping (relative) sprite coordinates into norm coord.,
  82.  ** chardiff & linediff are used to advance the graphical text cursor,
  83.  ** pref is a pointer to the current text reference point (origin):
  84.  **/
  85.  
  86.   double    Txx,Txy,Tyx,Tyy;    /* Transformation matrix    */
  87.   HPGL_Pt    chardiff,    /* Horiz. distance between characters    */
  88.         linediff,    /* Vertical distance between characters    */
  89.         refpoint,    /* Current reference point    */
  90.         CR_point,    /* Returns point after a <CR>    */
  91.         offset;    /* Needed for HP-GL command ``LO;''    */
  92. }
  93.   TEXTPAR, *TextPar;
  94.  
  95.  
  96.  
  97.  
  98. typedef    enum {LB_direct, LB_buffered, LB_buffered_in_use}
  99.     LB_Mode;        /* LB and PB work differently !    */
  100.  
  101.  
  102. /**
  103.  ** Remnant of former BGI font support by project plib,
  104.  ** currently inactive. Leave it here in case of a future revival
  105.  **/
  106.  
  107. #ifdef STROKED_FONTS
  108. typedef struct {
  109.   unsigned int    buff[16000];    /* Buffer for font data        */
  110.   unsigned int    vector_off;    /* Offset of start of plot data    */
  111.   unsigned int    size_off;    /* Offset of size tab        */
  112.   unsigned int    first;    /* ASCII code of first character*/
  113.   unsigned int    num;        /* Number of defined  character    */
  114.   unsigned int    height;
  115.   unsigned int    depth;
  116.   char           *name;
  117. }
  118.   FONT, *Font;
  119. #endif
  120.  
  121.  
  122. /**
  123.  ** Prototypes:
  124.  **/
  125.  
  126. #ifdef    __cplusplus
  127. extern    "C" {
  128. #endif
  129.  
  130. void    code_to_ucoord    (char, HPGL_Pt *);
  131.  
  132. int    init_font    (int);
  133. void    init_text_par    (void);
  134. void    adjust_text_par    (void);
  135. void    ASCII_to_char    (int);
  136. void    plot_string    (char *, LB_Mode);
  137. void    plot_symbol_char(char);
  138.  
  139. #ifdef    __cplusplus
  140. }
  141. #endif
  142.  
  143.  
  144.  
  145.