FontManage 4.58 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/* 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                           */
17 18 19
/*                                                 */
/* Purpose: A range of font management veneers.    */
/*                                                 */
20 21
/* Author : Merlyn Kline for Customer browser     */
/*          This source adapted by A.D.Hodgkinson  */
22 23
/*                                                 */
/* History: 05-Dec-96: Created.                    */
24 25 26 27 28 29 30 31
/***************************************************/

/* General definitions */

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

#define FM_OSUnits     (1<<4)  /* X and Y are OS units flag for Font_Paint */
32 33
#define FM_GivenBuffer (1<<5)  /* Buffer given for Font_ScanString         */
#define FM_GivenLength (1<<7)  /* String length given in Font_ScanString   */
34 35 36 37 38 39 40 41 42 43 44 45
#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
{
46 47 48
  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 */
49 50 51 52 53 54 55 56 57 58 59 60 61 62

} 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 */

63 64
fm_typeface     * fm_find_typeface            (char * name);

65 66 67 68 69 70 71 72 73 74 75 76
_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);

77
_kernel_oserror * fm_font_box                 (fm_face h, BBox * box);
78
_kernel_oserror * fm_char_box                 (fm_face h, char c, BBox * box);
79 80 81
_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);
82

83 84
_kernel_oserror * fm_write_descriptor         (char * name, char * buffer);
_kernel_oserror * fm_write_name               (int number, char * buffer, int italic, int bold);
85 86 87 88 89 90 91
_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);
David Brown's avatar
David Brown committed
92
void              fm_init_sizes               (int base_size);
93 94
void              fm_shutdown                 (void);

Kevin Bracey's avatar
Kevin Bracey committed
95
_kernel_oserror * fm_get_string_width         (fm_face h, const char * s, int maxwid, int maxbytes, int split, int * bytes, int * width);
96 97

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