1 /************************************************************************/
2 /* © Acorn Computers Ltd, 1992. */
4 /* This file forms part of an unsupported source release of RISC_OSLib. */
6 /* It may be freely used to create executable images for saleable */
7 /* products but cannot be sold in source form or as an object library */
8 /* without the prior written consent of Acorn Computers Ltd. */
10 /* If this file is re-distributed (even if modified) it should retain */
11 /* this copyright notice. */
13 /************************************************************************/
17 * Purpose: access to RISC OS font facilities
18 * History: IDJ: 06-Feb-92: prepared for source release
29 /* F O N T S W I 's */
30 #define CacheAddr 0x40080
31 #define FindFont 0x40081
32 #define LoseFont 0x40082
33 #define ReadDefn 0x40083
34 #define ReadInfo 0x40084
35 #define StringWidth 0x40085
38 #define ConverttoOS 0x40088
39 #define Converttopoints 0x40089
40 #define SetFont 0x4008A
41 #define CurrentFont 0x4008B
42 #define FutureFont 0x4008C
43 #define FindCaret 0x4008D
44 #define CharBBox 0x4008E
45 #define ReadScaleFactor 0x4008F
46 #define SetScaleFactor 0x40090
47 #define ListFonts 0x40091
48 #define SetFontColours 0x40092
49 #define SetPalette 0x40093
50 #define ReadThresholds 0x40094
51 #define SetThresholds 0x40095
52 #define FindCaretJ 0x40096
53 #define StringBBox 0x40097
54 #define ReadColourTable 0x40098
55 #define MakeBitmap 0x40099
56 #define UnCacheFile 0x4009A
57 #define SetFontMax 0x4009B
58 #define ReadFontMax 0x4009C
59 #define ReadFontPrefix 0x4009D
60 #define SwitchOutputToBuffer 0x4009E
61 #define ReadFontMetrics 0x4009F
63 #pragma no_check_stack
65 os_error *font_cacheaddress(int *version, int *cacheused, int *cachesize)
71 e = os_swix(CacheAddr, &r);
84 os_error *font_find(char *name, int xsize, int ysize, int xres, int yres, font *fontadd)
95 e = os_swix(FindFont, &r);
97 *fontadd = (font) r.r[0];
103 os_error *font_lose(font f)
109 e = os_swix(LoseFont, &r);
114 os_error * font_readdef(font f, font_def *d)
120 r.r[1] = (int)&d->name;
122 e = os_swix(ReadDefn, &r);
135 os_error *font_readinfo(font f, font_info *i)
142 e = os_swix(ReadInfo, &r);
153 os_error *font_strwidth(font_string *fs)
164 e = os_swix(StringWidth, &r);
175 os_error *font_paint(char *s, int options, int x, int y)
185 e = os_swix(Paint, &r);
191 os_error *font_caret(int colour, int height, int flags, int x, int y)
202 e = os_swix(Caret, &r);
208 os_error *font_converttoos(int x_inch, int y_inch, int *x_os, int *y_os)
216 e = os_swix(ConverttoOS, &r);
225 os_error *font_converttopoints(int x_os, int y_os, int *x_inch, int *y_inch)
233 e = os_swix(Converttopoints, &r);
242 os_error *font_setfont(font f)
249 e = os_swix(SetFont, &r);
255 os_error *font_current(font_state *f)
260 e = os_swix(CurrentFont, &r);
263 f->back_colour = r.r[1];
264 f->fore_colour = r.r[2];
271 os_error *font_future(font_state *f)
276 e = os_swix(FutureFont, &r);
279 f->back_colour = r.r[1];
280 f->fore_colour = r.r[2];
287 os_error *font_findcaret(font_string *fs)
296 e = os_swix(FindCaret, &r);
307 os_error *font_charbbox(font f, char ch, int options, font_info *i)
316 e = os_swix(CharBBox, &r);
327 os_error *font_readscalefactor(int *x, int *y)
332 e = os_swix(ReadScaleFactor, &r);
341 os_error *font_setscalefactor(int x, int y)
349 e = os_swix(SetScaleFactor, &r);
355 os_error *font_list(char *a, int *count)
365 e = os_swix(ListFonts, &r);
373 while (a[i] >= 32 && i <= 99)
380 else /* error return: probably some filing system error */
381 *count = -1; /* signal end of list */
388 os_error *font_setcolour(font f, int background, int foreground, int offset)
398 e = os_swix(SetFontColours, &r);
404 os_error *font_setpalette(int background, int foreground, int offset,
405 int physical_back, int physical_fore)
414 r.r[4] = physical_back;
415 r.r[5] = physical_fore;
417 e = os_swix(SetPalette, &r);
423 os_error *font_readthresholds(font_threshold *th)
430 e = os_swix(ReadThresholds, &r);
436 os_error *font_setthresholds(font_threshold *th)
443 e = os_swix(SetThresholds, &r);
449 os_error *font_findcaretj(font_string *fs, int offset_x, int offset_y)
460 e = os_swix(FindCaretJ, &r);
471 os_error *font_stringbbox(char *s, font_info *fi)
478 e = os_swix(StringBBox, &r);
488 /*-----------------------------------------------------------------*/
489 /*Routines for conversion of fonts to Draw module path objects. See
490 the documentation of SWI Font_SwitchOutputToBuffer.*/
492 os_error *font_output_to_null (BOOL add_hints, BOOL output_skeleton,
493 font_action_on_bitmap action_on_bitmap)
499 tracef0 ("font_output_to_null\n");
503 (add_hints? 1 << 1: 0) +
504 (output_skeleton? 1 << 2: 0) +
505 ( action_on_bitmap == font_ERROR?
507 action_on_bitmap == font_CONVERT?
513 if ((error = os_swix (SwitchOutputToBuffer, ®_set)) != NULL)
520 os_error *font_output_size (size_t *size_ptr)
525 tracef0 ("font_output_size\n");
530 if ((error = os_swix (SwitchOutputToBuffer, ®_set)) != NULL)
533 *size_ptr = reg_set.r [1];
534 tracef1 ("font_output_size: made %d bytes of path\n", *size_ptr);
539 os_error *font_output_to_buffer(drawmod_buffer *buff_ptr, BOOL add_hints,
540 BOOL output_skeleton,
541 font_action_on_bitmap action_on_bitmap)
547 tracef0 ("font_output_to_buffer\n");
550 (add_hints? 1 << 1: 0) +
551 (output_skeleton? 1 << 2: 0) +
552 ( action_on_bitmap == font_ERROR?
554 action_on_bitmap == font_CONVERT?
558 reg_set.r[1] = (int) buff_ptr;
560 tracef1 ("font_output_to_buffer: path going to 0x%p\n", buff_ptr);
561 if ((error = os_swix (SwitchOutputToBuffer, ®_set)) != NULL)
568 os_error *font_output_to_screen (void)
573 tracef0 ("font_output_to_screen\n");
578 if ((error = os_swix (SwitchOutputToBuffer, ®_set)) != NULL)