/* Copyright 1997 Acorn Computers Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/***************************************************/
/* File   : FontManage.h                           */
/*                                                 */
/* Purpose: A range of font management veneers.    */
/*                                                 */
/* Author : Merlyn Kline for Customer browser     */
/*          This source adapted by A.D.Hodgkinson  */
/*                                                 */
/* History: 05-Dec-96: Created.                    */
/***************************************************/

/* General definitions */

#define FM_Standard_Size (205) /* Standard system font size. See Merlyn's  */
                               /* comments at the top of FontManage.c.     */

#define FM_Absolute    (1<<2)  /* Absolute coordinates flag for Font_Paint */
#define FM_OSUnits     (1<<4)  /* X and Y are OS units flag for Font_Paint */
#define FM_GivenHandle (1<<8)  /* Font handle passed to Font_Paint         */
#define FM_Kern        (1<<9)  /* Use autokerning if font data supports it */
#define FM_Blend       (1<<11) /* Use font blending (if font manager can!) */

#define FM_System_Handle(x,y) (0x80000000 | ((x)<<14) | (y))
#define FM_System_Size_X(h)   (((h) >> 14) & 0x3FFF)
#define FM_System_Size_Y(h)   ((h) & 0x3FFF)

/* Local structures */

typedef struct fm_typeface
{
  char name            [Limits_FaceName]; /* Typeface name, in lower case */
  char fontnames   [4] [Limits_FontName]; /* RO fonts for normal, italic, bold & bold-italic */
  char alternative     [Limits_FaceName]; /* Name of the alternative typeface */

} fm_typeface;

typedef struct fm_facelist
{
  struct fm_facelist * next; /* Point to next item in typeface list */
  fm_typeface          face; /* A typeface entry (see above)        */

} fm_facelist;

typedef int fm_face; /* Makes the code less ambiguous to have this */

/* Function prototypes */

_kernel_oserror * fm_define_typeface_explicit (fm_typeface * f);
_kernel_oserror * fm_define_typeface          (char * description);
_kernel_oserror * fm_define_default_typefaces (void);
void              fm_claim_basic_typefaces    (int base_size);

int               fm_size                     (int size);

fm_face           fm_find_font                (browser_data * b, char * name, int xsize, int ysize, int italic, int bold);
void              fm_lose_font                (browser_data * b, fm_face h);
void              fm_lose_fonts               (browser_data * b);
_kernel_oserror * fm_rescale_fonts            (browser_data * b);

_kernel_oserror * fm_font_box                 (fm_face h,BBox * box);
_kernel_oserror * fm_set_font_colour          (fm_face h,int fore,int back);
_kernel_oserror * fm_puts                     (fm_face h,int x,int y,const char * s,int os,int blend);
_kernel_oserror * fm_putsl                    (fm_face handle,int x,int y,char * s,int chars,int os,int blend);

_kernel_oserror * fm_write_descriptor         (char * name,char * buffer);
_kernel_oserror * fm_write_name               (char * name,char * buffer,int italic,int bold);
_kernel_oserror * fm_read_typeface            (fm_typeface * face);

void              fm_destroy_typefaces        (void);
void              fm_set_system_font          (int systemfont);
int               fm_system_font              (void);

void              fm_init                     (int systemfont, int base_size);
void              fm_shutdown                 (void);

_kernel_oserror * fm_get_string_width         (fm_face h, const char * s, int maxwid, int maxbytes, int split, int * bytes, int * width);

void              fm_token_font_info          (HStream * t, int * facenum, int * size, int * italic, int * bold);
fm_face           fm_find_token_font          (browser_data * b, HStream * t);

/* These are declared as static inside FontManage.c: */

/* fm_typeface * fm_find_typeface (char * name);                                             */
/* fm_typeface * fm_new_typeface  (void);                                                    */
/* fm_face       fm_sub_find_font (fm_typeface * f,int xsize,int ysize,int italic,int bold); */