home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / pascal / !Pascal / h / font < prev    next >
Encoding:
Text File  |  1992-10-21  |  16.9 KB  |  468 lines

  1. (*
  2.  * Title  : font.h
  3.  * Purpose: access to RISC OS font facilities
  4.  *
  5.  *)
  6.  
  7. # ifndef __font_h
  8. # define __font_h
  9.  
  10. # ifndef __os_h
  11. # include "os.h"
  12. # endif
  13.  
  14. # include "drawmod.h"
  15.  
  16. type font_ptr = ^font;
  17.      font = integer;    (* abstract font handle *)
  18.  
  19.  
  20. (* ---------------------------- font_cacheaddress --------------------------
  21.  * Description:   Informs caller of font cache used and font cache size.
  22.  *
  23.  * Parameters:    int *version -- version number
  24.  *                int *cacheused -- amount of font cache used (in bytes)
  25.  *                int *cachesize -- total size of font cache (in bytes)
  26.  * Returns:       os_error* -- possible error condition
  27.  * Other Info:    Version number is *100, so v.1.07 would be returned as 107.
  28.  *
  29.  *)
  30. function font_cacheaddress(var version : integer;
  31.                 var cacheused : integer;
  32.                 var cachesize : integer) : os_error; extern;
  33.  
  34.  
  35. (* ------------------------------- font_find -------------------------------
  36.  * Description:   Gives caller a handle to font, given its name.
  37.  *
  38.  * Parameters:    char *name -- the font name
  39.  *                int xsize, ysize -- x/y point size (in 16ths of a point)
  40.  *                int xres, yres -- x/y resolution in dots per inch
  41.  *                font* -- the returned font handle
  42.  * Returns:       Possible error condition.
  43.  * Other Info:    none.
  44.  *
  45.  *)
  46. function font_find(name : string;
  47.                 xsize, ysize : integer;    (* in 16ths of a point *)
  48.                 xres, yres : integer;      (* dots per inch of resolution: *)
  49.                                            (* 0->use default *)
  50.                 var result : font) : os_error; extern;
  51.  
  52.  
  53. (* ------------------------------- font_lose -------------------------------
  54.  * Description:   Informs font manager that a font is no longer needed
  55.  *
  56.  * Parameters:    font f -- the font
  57.  * Returns:       possible error condition.
  58.  * Other Info:    none.
  59.  *
  60.  *)
  61. function font_lose(f : font) : os_error; extern;
  62.  
  63. type font_def_ptr = ^font_def;
  64.      font_def =
  65.        record
  66.          name : packed array[1..15] of char;
  67.          xsize, ysize, xres, yres : integer;  (* as above *)
  68.          usage, age : integer
  69.        end;
  70.  
  71.  
  72. (* ------------------------------ font_readdef -----------------------------
  73.  * Description:   Get details about a font, given its handle.
  74.  * 
  75.  * Parameters:    font -- the font handle
  76.  *                font_def* -- pointer to buffer to hold returned details
  77.  * Returns:       possible error condition.
  78.  * Other Info:    This function fills in details re: font, into the supplied
  79.  *                buffer(a variable of type 'font_def').
  80.  *                fields of this buffer are as follows:
  81.  *                          name -- font name
  82.  *                          xsize, ysize -- x/y point size * 16
  83.  *                          xres, yres -- x/y resolution (dots per inch)
  84.  *                          usage -- number of times Font_FindFont has found
  85.  *                                   the font minus number of times 
  86.  *                                   Font_LoseFont has been used on it
  87.  *                          age -- number of font accesses made since this
  88.  *                                 one was last accessed.
  89.  *
  90.  *)
  91. function font_readdef(f : font;
  92.                 result : font_def_ptr) : os_error; extern;
  93.  
  94. type font_info_ptr = ^font_info;
  95.      font_info =
  96.        record
  97.          minx, miny, maxx, maxy : integer
  98.        end;
  99.  
  100.  
  101. (* ------------------------------- font_readinfo ---------------------------
  102.  * Description:   Informs caller of minimal area covering any character in
  103.  *                the font bounding box.
  104.  *
  105.  * Parameters:    font -- the font handle
  106.  *                font_info* -- pointer to buffer to hold returned details
  107.  * Returns:       possible error condition.
  108.  * Other Info:    Fills in details re: font in supplied buffer (variable of
  109.  *                type 'font_info').
  110.  *                fields of this buffer are as follows:
  111.  *                       minx -- min x coord in pixels (inclusive)
  112.  *                       maxx -- max x coord in pixels (inclusive)
  113.  *                       miny -- min y coord in pixels (exclusive)
  114.  *                       maxy -- max y coord in pixels (exclusive).
  115.  *
  116.  *)
  117. function font_readinfo(f : font;
  118.                 result : font_info_ptr) : os_error; extern;
  119.  
  120.  
  121. type font_string_ptr = ^font_string;
  122.      font_string =
  123.        record
  124.          s : string;
  125.          x : integer;          (* inout, in 1/72000 inch *)
  126.          y : integer;          (* inout, in 1/72000 inch *)
  127.          split : integer;      (* inout: space char, or -1 *)
  128.                                (* on exit, = count of space or printable *)
  129.          term : integer        (* inout, index into s *)
  130.        end;
  131.  
  132.  
  133. (* -------------------------------- font_strwidth --------------------------
  134.  * Description:   Determine 'width' of string.
  135.  *
  136.  * Parameters:    font_string *fs -- the string, with fields:
  137.  *                              s -- string itself
  138.  *                              x -- max x offset before termination
  139.  *                              y -- max y offset before termination
  140.  *                          split -- string split character
  141.  *                           term -- index of char to terminate by
  142.  * Returns:       possible error condition.
  143.  * Other Info:    On exit fs fields hold:
  144.  *                              s -- unchanged
  145.  *                              x -- x offset after printing string
  146.  *                              y -- y offset after printing string
  147.  *                          split -- no. of split chars found
  148.  *                                   no. of printable chars if split was -1
  149.  *                           term -- index into string at which terminated.
  150.  *
  151.  *)
  152. function font_strwidth(fs : font_string_ptr) : os_error; extern;
  153.  
  154.  
  155. (* paint options *)
  156. const   font_JUSTIFY  = $01;  (* justify text *)
  157.         font_RUBOUT   = $02;  (* rub-out box required *)
  158.         font_ABS      = $04;  (* absolute co-ordinates *)
  159.         (* 8 not used *)
  160.         font_OSCOORDS = $10;  (* os coords supplied otherwise 1/72000 inch *)
  161.  
  162.  
  163. (* ------------------------------- font_paint -----------------------------
  164.  * Description:   Paint the given string at coords x,y.
  165.  * 
  166.  * Parameters:    char * -- the string
  167.  *                int options -- set using "paint options" defined above
  168.  *                int x, y -- coords (either os or 1/72000 inch)
  169.  * Returns:       possible error condition.
  170.  * Other Info:    none.
  171.  *
  172.  *)
  173. function font_paint(s : string;
  174.                 options : integer;
  175.                 x, y : integer) : os_error; extern;
  176.  
  177.  
  178. (* ------------------------------- font_caret -----------------------------
  179.  * Description:   Set colour, size and position of the caret.
  180.  *
  181.  * Parameters:    int colour -- EORed onto screen
  182.  *                int height -- in OS coordinates
  183.  *                int flags -- bit 4 set ==> OS coords, else 1/72000 inch
  184.  *                int x,y   -- x/y coords
  185.  * Returns:       possible error condition.
  186.  * Other Info:    none.
  187.  *
  188.  *)
  189. function font_caret(colour : integer;
  190.                 height : integer;
  191.                 flags : integer;
  192.                 x, y : integer) : os_error; extern;
  193.  
  194.  
  195. (* ---------------------------- font_converttoos ---------------------------
  196.  * Description:   Converts coords in 1/72000 inch to OS units.
  197.  *
  198.  * Parameters:    int x_inch, y_inch -- x/y coords in 1/72000 inch
  199.  *                int *x_os, *y_os -- x/y coords in OS units
  200.  * Returns:       possible error condition.
  201.  * Other Info:    none.
  202.  *
  203.  *)
  204. function font_converttoos(x_inch, y_inch : integer;
  205.                 var x_os, y_os : integer) : os_error; extern;
  206.  
  207.  
  208. (* --------------------------- font_converttopoints ------------------------
  209.  * Description:   Converts OS units to 1/72000 inch.
  210.  *
  211.  * Parameters:    int x_os, y_os -- x/y coords in OS units
  212.  *                int *x_inch, *y_inch -- x/y coords in 1/72000 inch
  213.  * Returns:       possible error condition.
  214.  * Other Info:    none.
  215.  *
  216.  *)
  217. function font_converttopoints(x_os, y_os : integer;
  218.                 var x_inch, y_inch : integer) : os_error; extern;
  219.  
  220.  
  221. (* ------------------------------- font_setfont ----------------------------
  222.  * Description:   Sets up font used for subsequent painting or size-requests.
  223.  *
  224.  * Parameters:    font -- the font handle
  225.  * Returns:       possible error condition.
  226.  * Other Info:    none.
  227.  *
  228.  *)
  229. function font_setfont(f : font) : os_error; extern;
  230.  
  231.  
  232. type font_state_ptr = ^font_state;
  233.      font_state =
  234.        record
  235.          f : font;
  236.          back_colour : integer;
  237.          fore_colour : integer;
  238.          offset : integer
  239.        end;
  240.  
  241.  
  242. (* --------------------------------- font_current --------------------------
  243.  * Description:   Informs caller of current font state.
  244.  *
  245.  * Parameters:    font_state *f -- pointer to buffer to hold font state
  246.  * Returns:       possible error condition.
  247.  * Other Info:    returned buffer(into variable of type 'font_state'):
  248.  *                         font f -- handle of current font
  249.  *                         int back_colour -- current background colour
  250.  *                         int fore_colour -- current foreground colour
  251.  *                         int offset -- foreground colour offset.
  252.  *
  253.  *)
  254. function font_current(f : font_state_ptr) : os_error; extern;
  255.  
  256.  
  257. (* -------------------------------- font_future ----------------------------
  258.  * Description:   Informs caller of font characteristics after a future
  259.  *                font_paint.
  260.  *
  261.  * Parameters:    font_state *f -- pointer to buffer to hold font state
  262.  * Returns:       possible error condition.
  263.  * Other Info:    buffer contents:
  264.  *                          font f -- handle of font which would be selected
  265.  *                          int back_colour -- future background colour
  266.  *                          int fore_colour -- future foreground colour
  267.  *                          int offset -- foreground colour offset.
  268.  *
  269.  *)
  270. function font_future(f : font_state_ptr) : os_error; extern;
  271.  
  272.  
  273. (* ------------------------------- font_findcaret --------------------------
  274.  * Description:   Informs caller of nearest point in a string to the caret
  275.  *                position.
  276.  *
  277.  * Parameters:    font_string *fs -- the string
  278.  *                         fields:  char *s -- the string itself
  279.  *                                  int x,y -- x/y coords of caret
  280.  * Returns:       possible error condition.
  281.  * Other Info:    returned fields of fs as in font_strwidth.
  282.  *
  283.  *)
  284. function font_findcaret(fs : font_string_ptr) : os_error; extern;
  285.  
  286.  
  287. (* ----------------------------- font_charbbox -----------------------------
  288.  * Description:   Informs caller of bounding box of char in given font.
  289.  *
  290.  * Parameters:    font -- the font handle
  291.  *                char -- the ASCII character
  292.  *                int options -- only relevant option if font_OSCOORDS
  293.  *                font_info * -- pointer to buffer to hold font info
  294.  * Returns:       possible error condition.
  295.  * Other Info:    if OS coords are used and font has been scaled, box may
  296.  *                be surrounded by area of blank pixels.
  297.  *
  298.  *)
  299. function font_charbbox(f : font;
  300.                 c : char;
  301.                 options : integer;
  302.                 result : font_info_ptr) : os_error; extern;
  303.  
  304.  
  305. (* -------------------------- font_readscalefactor -------------------------
  306.  * Description:   Informs caller of x and y scale factors used by font.
  307.  *                manager for converting between OS coords and 1/72000 inch
  308.  *
  309.  * Parameters:    int *x, *y -- returned scale factors
  310.  * Returns:       possible error condition.
  311.  * Other Info:    none.
  312.  *
  313.  *)
  314. function font_readscalefactor(var x, y : integer) : os_error; extern;
  315.  
  316.  
  317. (* ---------------------------- font_setscalefactor -----------------------
  318.  * Description:   Sets the scale factors used by font manager.
  319.  *
  320.  * Parameters:    int x,y -- the new scale factors
  321.  * Returns:       possible error condition.
  322.  * Other Info:    scale factors may have been changed by another application
  323.  *                well-behaved applications save and restore scale factors.
  324.  *
  325.  *)
  326. function font_setscalefactor(x, y : integer) : os_error; extern;
  327.  
  328.  
  329. (* ------------------------------- font_list -------------------------------
  330.  * Description:   Gives name of an available font.
  331.  *
  332.  * Parameters:    char* -- pointer to buffer to hold font name
  333.  *                int*  -- count of fonts found (0 on first call)
  334.  * Returns:       possible error condition.
  335.  * Other Info:    count is -1 if no more names
  336.  *                typically used in loop until count == -1.
  337.  *
  338.  *)
  339. function font_list(s : string; var n : integer) : os_error; extern;
  340.  
  341.                  
  342. (* ------------------------------ font_setcolour ---------------------------
  343.  * Description:   Sets the current font(optionally), changes foreground
  344.  *                and background colours, and offset for that font.
  345.  * 
  346.  * Parameters:    font -- the font handle (0 for current font)
  347.  *                int background, foreground -- back/foreground colours
  348.  *                int offset -- foreground offset colour (-14 to +14) 
  349.  * Returns:       possible error condition.
  350.  * Other Info:    none.
  351.  *
  352.  *)
  353. function font_setcolour(f : font;
  354.                 background, foreground : integer;
  355.                 offset : integer) : os_error; extern;
  356.  
  357.  
  358. const font_BlueGun  = $01000000; (* 8-bit field: phsical colour blue gun.  *)
  359.       font_GreenGun = $00010000; (* 8-bit field: phsical colour green gun. *)
  360.       font_RedGun   = $00000100; (* 8-bit field: phsical colour red gun.   *)
  361.  
  362.  
  363. (* --------------------------- font_setpalette -----------------------------
  364.  * Description:   Sets the anti-alias palette
  365.  *
  366.  * Parameters:    int background -- logical background colour
  367.  *                int foreground -- logical foreground colour
  368.  *                int offset -- foreground colour offset
  369.  *                int physical_back -- physical background colour
  370.  *                int physical_fore -- physical foreground colour
  371.  * Returns:       possible error condition.
  372.  * Other Info:    physical_back and physical_fore are of the form:
  373.  *                        0xBBGGRR00 (see #defines above).
  374.  *
  375.  *)
  376. function font_setpalette(background, foreground : integer;
  377.                 offset : integer;
  378.                 physical_back : integer;
  379.                 physical_fore : integer) : os_error; extern;
  380.  
  381. type font_threshold_ptr = ^font_threshold;
  382.      font_threshold =
  383.        record
  384.          offset : byte;
  385.          thresholds : array[0..14] of byte
  386.        end;
  387.                                         
  388.  
  389. (* ------------------------- font_readthresholds ---------------------------
  390.  * Description:   Reads the list of threshold values that the font manager
  391.  *                uses when painting characters.
  392.  *
  393.  * Parameters:    font_theshold *th -- pointer to result buffer
  394.  * Returns:       possible error condition.
  395.  * Other Info:    none.
  396.  *
  397.  *)
  398. function font_readthresholds(th : font_threshold_ptr) : os_error; extern;
  399.  
  400.  
  401. (* ------------------------- font_setthresholds ----------------------------
  402.  * Description:   Sets up threshold values for painting colours.
  403.  *
  404.  * Parameters:    font_threshold *th -- pointer to a threshold table
  405.  * Returns:       possible error condition.
  406.  * Other Info:    none.
  407.  *
  408.  *)
  409. function font_setthresholds(th : font_threshold_ptr) : os_error; extern;
  410.  
  411.  
  412. (* ------------------------- font_findcaretj -------------------------------
  413.  * Description:   Finds nearest point where the caret can go (using
  414.  *                justification offsets).
  415.  *
  416.  * Parameters:    font_string *fs -- the string (set up as in font_findcaret)
  417.  *                int offset_x, offset-y -- the justification offsets
  418.  * Returns:       possible error condition.
  419.  * Other Info:    if offsets are both zero then same as font_findcaret.
  420.  *
  421.  *)
  422. function font_findcaretj(fs : font_string_ptr;
  423.                 offset_x, offset_y : integer) : os_error; extern;
  424.  
  425.  
  426. (* ------------------------ font_stringbbox --------------------------------
  427.  * Description:   Measures the size of a string (without printing it).
  428.  *
  429.  * Parameters:    char *s -- the string
  430.  *                font_info *fi -- pointer to buffer to hold font info
  431.  * Returns:       possible error condition.
  432.  * Other Info:    fields returned in fi are:
  433.  *                    minx, miny -- bounding box min x/y
  434.  *                    maxx, maxy -- bounding box min x/y.
  435.  *
  436.  *)
  437. function font_stringbbox(s : string;
  438.                 fi : font_info_ptr) : os_error; extern;
  439.  
  440. (* new SWIS *)
  441.  
  442. (*---------------------------------------------------------------------------*)
  443. (*Routines to create a draw module path object from calls to font_paint*)
  444.  
  445. const font_CONVERT = 0;
  446.       font_IGNORE = 1;
  447.       font_ERROR = 2;
  448.  
  449. type font_action_on_bitmap_ptr = ^font_action_on_bitmap;
  450.      font_action_on_bitmap = integer;
  451.  
  452. function font_output_to_null(add_hints : boolean;
  453.            output_skeleton : boolean;
  454.            action_on_bitmap : font_action_on_bitmap) : os_error; extern;
  455.  
  456. function font_output_size(var size : integer) : os_error; extern;
  457.  
  458. function font_output_to_buffer(buff_ptr : drawmod_buffer_ptr;
  459.            add_hints : boolean;
  460.            output_skeleton : boolean;
  461.            action_on_bitmap : font_action_on_bitmap) : os_error; extern;
  462.  
  463. function font_output_to_screen : os_error; extern;
  464.  
  465. # endif
  466.  
  467. (* end font.h *)
  468.