using kprintf to output debug, which may be redirected to serial, is not a good idea...
[AROS-Contrib.git] / scalos / main / FontUtil.c
blobf9b96ac3229a2505314d20c044eeed694abaaa50
1 // FontUtil.c
2 // $Date$
3 // $Revision$
6 #include <exec/types.h>
7 #include <graphics/gels.h>
8 #include <graphics/rastport.h>
10 #define __USE_SYSBASE
12 #include <proto/dos.h>
13 #include <proto/exec.h>
14 #include <proto/graphics.h>
15 #include <proto/intuition.h>
16 #include <proto/utility.h>
17 #define USE_INLINE_STDARG
18 #include <proto/ttengine.h>
19 #undef USE_INLINE_STDARG
20 #include "debug.h"
21 #include <proto/scalos.h>
23 #include <clib/alib_protos.h>
25 #include <defs.h>
26 #include <scalos/scalos.h>
28 #include <string.h>
29 #include <ctype.h>
30 #include <stdio.h>
31 #include <stdarg.h>
33 #include "scalos_structures.h"
34 #include "functions.h"
35 #include "Variables.h"
37 //----------------------------------------------------------------------------
39 // local functions
41 static void SetFamilyTTFont(struct RastPort *rp, ULONG style, struct TTFontFamily *ttff);
42 static BOOL FillTTTextAttrFromDesc(struct TTTextAttr *ttta, CONST_STRPTR FontDesc);
43 static SAVEDS(ULONG) FontFunctionDispatcher(struct Hook *hook, Object *o, Msg msg);
45 //----------------------------------------------------------------------------
47 // public data items
49 struct Hook ScalosFontHook =
51 { NULL, NULL },
52 HOOKFUNC_DEF(FontFunctionDispatcher), // h_Entry + h_SubEntry
53 NULL, // h_Data
56 SCALOSSEMAPHORE tteSema;
58 //----------------------------------------------------------------------------
60 // local data items
62 #define USE_SEMA
64 //----------------------------------------------------------------------------
66 BOOL FontUtilInit(void)
68 ScalosInitSemaphore(&tteSema);
70 return TRUE; // Success
74 SAVEDS(WORD) Scalos_TextLength(struct RastPort *rp, CONST_STRPTR string, WORD Length)
76 d1(kprintf("%s/%s/%ld: TTEngineBase=%08lx rp=%08lx\n", __FILE__, __FUNC__, __LINE__, TTEngineBase, rp));
78 if (NULL == rp)
79 return 0;
81 if (TTEngineBase)
83 // TT_GetAttrsA()
84 STRPTR FontName = NULL;
86 TT_GetAttrs(rp, TT_FontName, (IPTR) &FontName,
87 TAG_END);
89 if (FontName)
91 WORD Result;
93 #ifdef USE_SEMA
94 ScalosObtainSemaphore(&tteSema);
95 #endif
96 Result = (WORD) TT_TextLength(rp, (STRPTR) string, Length);
97 #ifdef USE_SEMA
98 ScalosReleaseSemaphore(&tteSema);
99 #endif
101 return Result;
105 return TextLength(rp, (STRPTR) string, Length);
109 SAVEDS(ULONG) Scalos_TextFit(struct RastPort *rp, CONST_STRPTR string, WORD Length,
110 struct TextExtent *textExtent, struct TextExtent *constrainingExtent,
111 WORD strDirection, UWORD constrainingBitWidth, UWORD constrainingBitHeight)
113 ULONG Result;
115 d1(kprintf("%s/%s/%ld: TTEngineBase=%08lx rp=%08lx\n", __FILE__, __FUNC__, __LINE__, TTEngineBase, rp));
117 if (NULL == rp)
118 return 0;
120 if (TTEngineBase)
122 // TT_GetAttrsA()
123 STRPTR FontName = NULL;
125 TT_GetAttrs(rp, TT_FontName, (IPTR) &FontName,
126 TAG_END);
128 d1(kprintf("%s/%s/%ld: FontName=%08lx\n", __FILE__, __FUNC__, __LINE__, FontName));
129 if (FontName)
131 d1(kprintf("%s/%s/%ld: textExtent: %ld %ld %ld %ld\n", __FILE__, __FUNC__, __LINE__, \
132 textExtent->te_Extent.MinX, textExtent->te_Extent.MinY,\
133 textExtent->te_Extent.MaxX, textExtent->te_Extent.MaxY));
134 d1(kprintf("%s/%s/%ld: constrainingExtent=%08lx\n", __FILE__, __FUNC__, __LINE__, constrainingExtent));
135 d1(kprintf("%s/%s/%ld: constrainingBitWidth=%ld constrainingBitHeight=%ld\n", __FILE__, __FUNC__, __LINE__, constrainingBitWidth, constrainingBitHeight));
136 #ifdef USE_SEMA
137 ScalosObtainSemaphore(&tteSema);
138 #endif
139 Result = TT_TextFit(rp,
140 (STRPTR) string,
141 Length,
142 textExtent,
143 constrainingExtent,
144 strDirection,
145 constrainingBitWidth,
146 constrainingBitWidth);
147 #ifdef USE_SEMA
148 ScalosReleaseSemaphore(&tteSema);
149 #endif
150 d1(kprintf("%s/%s/%ld: Result=%lu\n", __FILE__, __FUNC__, __LINE__, Result));
152 return Result;
156 Result = TextFit(rp, (STRPTR) string, Length, textExtent, constrainingExtent,
157 strDirection, constrainingBitWidth, constrainingBitHeight);
159 d1(kprintf("%s/%s/%ld: Result=%lu\n", __FILE__, __FUNC__, __LINE__, Result));
161 return Result;
165 SAVEDS(void) Scalos_TextExtent(struct RastPort *rp, CONST_STRPTR string, WORD Length, struct TextExtent *tExt)
167 d1(kprintf("%s/%s/%ld: TTEngineBase=%08lx rp=%08lx\n", __FILE__, __FUNC__, __LINE__, TTEngineBase, rp));
169 if (NULL == rp)
171 memset(tExt, 0, sizeof(struct TextExtent));
172 return;
175 if (TTEngineBase)
177 // TT_GetAttrsA()
178 STRPTR FontName = NULL;
180 TT_GetAttrs(rp, TT_FontName, (IPTR) &FontName,
181 TAG_END);
183 d1(kprintf("%s/%s/%ld: FontName=%08lx\n", __FILE__, __FUNC__, __LINE__, FontName));
185 if (FontName)
187 d1(kprintf("%s/%s/%ld: FontName=<%s> rp=%08lx TextExtent=%08lx\n", \
188 __FILE__, __FUNC__, __LINE__, FontName, rp, tExt));
190 d1(kprintf("%s/%s/%ld: string=<%s> Length=%ld\n", __FILE__, __FUNC__, __LINE__, string, Length));
192 #ifdef USE_SEMA
193 ScalosObtainSemaphore(&tteSema);
194 #endif
195 d1(kprintf("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
197 TT_TextExtent(rp, (STRPTR) string, Length, tExt);
199 d1(kprintf("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
201 #ifdef USE_SEMA
202 ScalosReleaseSemaphore(&tteSema);
203 #endif
204 d1(kprintf("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
206 return;
210 TextExtent(rp, (STRPTR) string, Length, tExt);
214 SAVEDS(void) Scalos_Text(struct RastPort *rp, CONST_STRPTR string, WORD Length)
216 if (rp)
218 if (TTEngineBase)
220 // TT_GetAttrsA()
221 STRPTR FontName = NULL;
223 TT_GetAttrs(rp, TT_FontName, (IPTR) &FontName,
224 TAG_END);
226 d1(kprintf("%s/%s/%ld: FontName=%08lx\n", __FILE__, __FUNC__, __LINE__, FontName));
228 if (FontName)
230 d1(kprintf("%s/%s/%ld: rp=%08lx string=<%s> Length=%ld\n", \
231 __FILE__, __FUNC__, __LINE__, rp, string, Length));
233 #ifdef USE_SEMA
234 ScalosObtainSemaphore(&tteSema);
235 #endif
236 TT_Text(rp, (STRPTR) string, Length);
237 #ifdef USE_SEMA
238 ScalosReleaseSemaphore(&tteSema);
239 #endif
241 return;
245 Text(rp, (STRPTR) string, Length);
250 SAVEDS(UWORD) Scalos_GetFontHeight(struct RastPort *rp)
252 if (TTEngineBase && rp)
254 STRPTR FontName = NULL;
256 // TT_GetAttrsA()
257 TT_GetAttrs(rp, TT_FontName, (IPTR) &FontName,
258 TAG_END);
260 d1(kprintf("%s/%s/%ld: rp=%08lx FontName=%08lx\n", __FILE__, __FUNC__, __LINE__, rp, FontName));
262 if (FontName)
264 ULONG Height = 0;
265 ULONG asc = 0, desc = 0;
267 TT_GetAttrs(rp, TT_FontDesignHeight, (IPTR) &Height,
268 TT_FontRealAscender, (IPTR) &asc,
269 TT_FontRealDescender, (IPTR) &desc,
270 TAG_END);
272 d1(kprintf("%s/%s/%ld: FontName=<%s> DesignHeight=%ld\n", __FILE__, __FUNC__, __LINE__, FontName, Height));
273 d1(kprintf("%s/%s/%ld: ascender=%ld descender=%ld\n", __FILE__, __FUNC__, __LINE__, asc, desc));
274 return (UWORD) Height;
278 return rp->TxHeight;
282 SAVEDS(UWORD) Scalos_GetFontBaseline(struct RastPort *rp)
284 d1(kprintf("%s/%s/%ld: rp=%08lx\n", __FILE__, __FUNC__, __LINE__, rp));
286 if (TTEngineBase && rp)
288 STRPTR FontName = NULL;
290 // TT_GetAttrsA()
291 TT_GetAttrs(rp, TT_FontName, (IPTR) &FontName,
292 TAG_END);
295 d1(kprintf("%s/%s/%ld: FontName=%08lx\n", __FILE__, __FUNC__, __LINE__, FontName));
297 if (FontName)
299 ULONG Baseline = 0;
301 TT_GetAttrs(rp, TT_FontAccentedAscender, (IPTR) &Baseline,
302 TAG_END);
304 return (UWORD) (Baseline - 2);
308 d1(kprintf("%s/%s/%ld: TxBaseline=%ld tf_Baseline=%ld\n", __FILE__, __FUNC__, __LINE__, rp->TxBaseline, rp->Font->tf_Baseline));
310 return (UWORD) rp->Font->tf_Baseline;
314 SAVEDS(void) Scalos_SetFontTransparency(struct RastPort *rp, ULONG Transparency)
316 if (TTEngineBase && rp)
318 STRPTR FontName = NULL;
320 // TT_GetAttrsA()
321 TT_GetAttrs(rp, TT_FontName, (IPTR) &FontName,
322 TAG_END);
324 if (FontName)
326 d1(kprintf("%s/%s/%ld: rp=%08lx FamilyName=<%s> Transparency=%ld\n", \
327 __FILE__, __FUNC__, __LINE__, rp, FontName, Transparency));
329 #ifdef USE_SEMA
330 ScalosObtainSemaphore(&tteSema);
331 #endif
332 // TT_SetAttrsA()
333 TT_SetAttrs(rp, TT_Transparency, Transparency,
334 TAG_END);
336 #ifdef USE_SEMA
337 ScalosReleaseSemaphore(&tteSema);
338 #endif
344 SAVEDS(ULONG) Scalos_SetSoftStyle(struct RastPort *rp, ULONG style, ULONG enable, struct TTFontFamily *ttff)
346 if (TTEngineBase)
348 STRPTR FontName = NULL;
350 // TT_GetAttrsA()
351 TT_GetAttrs(rp, TT_FontName, (IPTR) &FontName,
352 TAG_END);
354 if (FontName)
356 d1(kprintf("%s/%s/%ld: rp=%08lx FamilyName=<%s> style=%08lx enable=%08lx\n", \
357 __FILE__, __FUNC__, __LINE__, rp, FontName, style, enable));
359 #ifdef USE_SEMA
360 ScalosObtainSemaphore(&tteSema);
361 #endif
362 TT_SetAttrs(rp,
363 TT_SoftStyle, ((style & enable) == FSF_UNDERLINED)
364 ? TT_SoftStyle_Underlined : TT_SoftStyle_None,
365 TAG_END);
367 #ifdef USE_SEMA
368 ScalosReleaseSemaphore(&tteSema);
369 #endif
370 SetFamilyTTFont(rp, style & enable, ttff);
374 d1(kprintf("%s/%s/%ld: TxBaseline=%ld tf_Baseline=%ld\n", __FILE__, __FUNC__, __LINE__, rp->TxBaseline, rp->Font->tf_Baseline));
376 return SetSoftStyle(rp, style, enable);
380 SAVEDS(void) Scalos_SetFont(struct RastPort *rp, struct TextFont *tf, struct TTFontFamily *ttff)
382 d1(kprintf("%s/%s/%ld: TTEngineBase=%08lx ttFont=%08lx\n", __FILE__, __FUNC__, __LINE__, TTEngineBase, ttff));
384 if (tf && (rp->Font != tf))
385 SetFont(rp, tf);
387 if (TTEngineBase && ttff && (ttff->ttff_BoldItalic || ttff->ttff_Bold || ttff->ttff_Italic || ttff->ttff_Normal))
389 SetFamilyTTFont(rp, FS_NORMAL, ttff);
391 #ifdef USE_SEMA
392 ScalosObtainSemaphore(&tteSema);
393 #endif
394 // TT_SetAttrsA()
395 TT_SetAttrs(rp,
396 TT_Antialias, CurrentPrefs.pref_TTFontAntialias,
397 TT_Gamma, CurrentPrefs.pref_TTFontGamma,
398 TT_ColorMap, (IPTR) iInfos.xii_iinfos.ii_Screen->ViewPort.ColorMap,
399 // TT_Screen, iInfos.xii_iinfos.ii_Screen,
400 TAG_END);
401 #ifdef USE_SEMA
402 ScalosReleaseSemaphore(&tteSema);
403 #endif
406 if (NULL == ttff || (NULL == ttff->ttff_BoldItalic && NULL == ttff->ttff_Bold &&
407 NULL == ttff->ttff_Italic && NULL == ttff->ttff_Normal))
408 Scalos_DoneRastPort(rp); // remove TT font
412 static void SetFamilyTTFont(struct RastPort *rp, ULONG style, struct TTFontFamily *ttff)
414 BOOL isBold = style & FSF_BOLD;
415 BOOL isItalic = style & FSF_ITALIC;
416 APTR ttFont;
418 if (isBold && isItalic)
420 d1(kprintf("%s/%s/%ld: rp=%08lx BoldItalic font=%08lx\n", __FILE__, __FUNC__, __LINE__, rp, ttff->ttff_BoldItalic));
421 ttFont = ttff->ttff_BoldItalic;
423 else if (isBold)
425 d1(kprintf("%s/%s/%ld: rp=%08lx Bold font=%08lx\n", __FILE__, __FUNC__, __LINE__, rp, ttff->ttff_Bold));
426 ttFont = ttff->ttff_Bold;
428 else if (isItalic)
430 d1(kprintf("%s/%s/%ld: rp=%08lx Italic font=%08lx\n", __FILE__, __FUNC__, __LINE__, rp, ttff->ttff_Italic));
431 ttFont = ttff->ttff_Italic;
433 else
435 d1(kprintf("%s/%s/%ld: rp=%08lx Normal font=%08lx\n", __FILE__, __FUNC__, __LINE__, rp, ttff->ttff_Normal));
436 ttFont = ttff->ttff_Normal;
439 if (NULL == ttFont)
441 d1(kprintf("%s/%s/%ld: rp=%08lx Fallback to Normal font=%08lx\n", __FILE__, __FUNC__, __LINE__, rp, ttff->ttff_Normal));
442 ttFont = ttff->ttff_Normal;
445 if (ttFont)
447 #ifdef USE_SEMA
448 ScalosObtainSemaphore(&tteSema);
449 #endif
450 TT_SetFont(rp, ttFont);
451 d1(kprintf("%s/%s/%ld: rp=%08lx ttFont=%08lx\n", __FILE__, __FUNC__, __LINE__, rp, ttFont));
453 //TT_SetAttrsA()
454 TT_SetAttrs(rp,
455 TT_Antialias, CurrentPrefs.pref_TTFontAntialias,
456 TT_Gamma, CurrentPrefs.pref_TTFontGamma,
457 TT_ColorMap, (IPTR) iInfos.xii_iinfos.ii_Screen->ViewPort.ColorMap,
458 TAG_END);
459 #ifdef USE_SEMA
460 ScalosReleaseSemaphore(&tteSema);
461 #endif
466 APTR Scalos_OpenTTFont(CONST_STRPTR FontDesc, struct TTFontFamily *ttff)
468 d1(kprintf("%s/%s/%ld: FontDesc=<%s>\n", __FILE__, __FUNC__, __LINE__, FontDesc));
469 memset(ttff, 0, sizeof(struct TTFontFamily));
471 if (TTEngineBase && FontDesc)
473 struct TTTextAttr ttta;
475 d1(kprintf("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
477 if (FillTTTextAttrFromDesc(&ttta, FontDesc))
479 d1(kprintf("%s/%s/%ld: FamilyName=<%s> Size=%ld\n", \
480 __FILE__, __FUNC__, __LINE__, ttta.ttta_FamilyTable[0], ttta.ttta_FontSize));
482 #ifdef USE_SEMA
483 ScalosObtainSemaphore(&tteSema);
484 #endif
486 // TT_OpenFontA()
487 ttff->ttff_Normal = TT_OpenFont(
488 TT_FamilyTable, (IPTR) ttta.ttta_FamilyTable,
489 TT_FontSize, ttta.ttta_FontSize,
490 TT_FontStyle, ttta.ttta_FontStyle,
491 TT_FontWeight, ttta.ttta_FontWeight,
492 TAG_END);
493 d1(kprintf("%s/%s/%ld: Normal font=%08lx\n", __FILE__, __FUNC__, __LINE__, ttff->ttff_Normal));
495 ttff->ttff_Bold = TT_OpenFont(
496 TT_FamilyTable, (IPTR) ttta.ttta_FamilyTable,
497 TT_FontSize, ttta.ttta_FontSize,
498 TT_FontStyle, TT_FontStyle_Regular,
499 TT_FontWeight, TT_FontWeight_Bold,
500 TAG_END);
501 d1(kprintf("%s/%s/%ld: Bold font=%08lx\n", __FILE__, __FUNC__, __LINE__, ttff->ttff_Bold));
503 ttff->ttff_Italic = TT_OpenFont(
504 TT_FamilyTable, (IPTR) ttta.ttta_FamilyTable,
505 TT_FontSize, ttta.ttta_FontSize,
506 TT_FontStyle, TT_FontStyle_Italic,
507 TT_FontWeight, TT_FontWeight_Normal,
508 TAG_END);
509 d1(kprintf("%s/%s/%ld: Italic font=%08lx\n", __FILE__, __FUNC__, __LINE__, ttff->ttff_Italic));
511 ttff->ttff_BoldItalic = TT_OpenFont(
512 TT_FamilyTable, (IPTR) ttta.ttta_FamilyTable,
513 TT_FontSize, ttta.ttta_FontSize,
514 TT_FontStyle, TT_FontStyle_Italic,
515 TT_FontWeight, TT_FontWeight_Bold,
516 TAG_END);
517 d1(kprintf("%s/%s/%ld: BoldItalic font=%08lx\n", __FILE__, __FUNC__, __LINE__, ttff->ttff_BoldItalic));
519 #ifdef USE_SEMA
520 ScalosReleaseSemaphore(&tteSema);
521 #endif
525 return ttff->ttff_Normal;
529 void Scalos_CloseFont(struct TextFont **tf, struct TTFontFamily *ttFont)
531 if (TTEngineBase && ttFont)
533 d1(kprintf("%s/%s/%ld: Normal font=%08lx\n", __FILE__, __FUNC__, __LINE__, ttFont->ttff_Normal));
535 #ifdef USE_SEMA
536 ScalosObtainSemaphore(&tteSema);
537 #endif
538 TT_CloseFont(ttFont->ttff_Normal);
539 TT_CloseFont(ttFont->ttff_Bold);
540 TT_CloseFont(ttFont->ttff_Italic);
541 TT_CloseFont(ttFont->ttff_BoldItalic);
543 #ifdef USE_SEMA
544 ScalosReleaseSemaphore(&tteSema);
545 #endif
546 ttFont->ttff_Normal = NULL;
547 ttFont->ttff_Bold = NULL;
548 ttFont->ttff_Italic = NULL;
549 ttFont->ttff_BoldItalic = NULL;
552 if (tf && *tf)
554 CloseFont(*tf);
555 *tf = NULL;
560 SAVEDS(void) Scalos_InitRastPort(struct RastPort *rp)
562 InitRastPort(rp);
564 if (TTEngineBase)
566 #ifdef USE_SEMA
567 ScalosObtainSemaphore(&tteSema);
568 #endif
569 TT_SetAttrs(rp,
570 TT_ColorMap, (IPTR) iInfos.xii_iinfos.ii_Screen->ViewPort.ColorMap,
571 TAG_END);
573 #ifdef USE_SEMA
574 ScalosReleaseSemaphore(&tteSema);
575 #endif
576 d1(kprintf("%s/%s/%ld: rp=%08lx cm=%08lx\n", \
577 __FILE__, __FUNC__, __LINE__, rp, iInfos.xii_iinfos.ii_Screen->ViewPort.ColorMap));
582 SAVEDS(void) Scalos_DoneRastPort(struct RastPort *rp)
584 d1(kprintf("%s/%s/%ld: rp=%08lx\n", __FILE__, __FUNC__, __LINE__, rp));
586 if (TTEngineBase)
588 #ifdef USE_SEMA
589 ScalosObtainSemaphore(&tteSema);
590 #endif
591 TT_DoneRastPort(rp);
592 #ifdef USE_SEMA
593 ScalosReleaseSemaphore(&tteSema);
594 #endif
599 static BOOL FillTTTextAttrFromDesc(struct TTTextAttr *ttta, CONST_STRPTR FontDesc)
601 // Font Desc format:
602 // "style/weight/size/fontname"
603 char Buffer[10];
604 size_t n;
606 ttta->ttta_FontStyle = TT_FontStyle_Regular;
607 ttta->ttta_FontWeight = TT_FontWeight_Normal;
609 d1(kprintf("%s/%s/%ld: ttta=%08lx FontDesc=<%s>\n", __FILE__, __FUNC__, __LINE__, ttta, FontDesc));
611 for (n = 0; *FontDesc && '/' != *FontDesc && n < sizeof(Buffer) - 1; n++)
612 Buffer[n] = *FontDesc++;
613 Buffer[n] = '\0';
614 d1(kprintf("%s/%s/%ld: Buffer=<%s>\n", __FILE__, __FUNC__, __LINE__, Buffer));
616 if (StrToLong(Buffer, (LONG *) &ttta->ttta_FontStyle) <= 0)
617 return FALSE;
619 if ('/' == *FontDesc)
620 FontDesc++; // Skip "/" between style and weight
621 else
622 return FALSE;
624 for (n = 0; *FontDesc && '/' != *FontDesc && n < sizeof(Buffer) - 1; n++)
625 Buffer[n] = *FontDesc++;
626 Buffer[n] = '\0';
627 d1(kprintf("%s/%s/%ld: Buffer=<%s>\n", __FILE__, __FUNC__, __LINE__, Buffer));
629 if (StrToLong(Buffer, (LONG *) &ttta->ttta_FontWeight) <= 0)
630 return FALSE;
632 if ('/' == *FontDesc)
633 FontDesc++; // Skip "/" between weight and size
634 else
635 return FALSE;
637 for (n = 0; *FontDesc && '/' != *FontDesc && n < sizeof(Buffer) - 1; n++)
638 Buffer[n] = *FontDesc++;
639 Buffer[n] = '\0';
640 d1(kprintf("%s/%s/%ld: Buffer=<%s>\n", __FILE__, __FUNC__, __LINE__, Buffer));
642 if (StrToLong(Buffer, (LONG *) &ttta->ttta_FontSize) <= 0)
643 return FALSE;
645 d1(kprintf("%s/%s/%ld: ttta=%08lx\n", __FILE__, __FUNC__, __LINE__, ttta));
647 if ('/' == *FontDesc)
648 FontDesc++; // Skip "/" between size and name
649 else
650 return FALSE;
652 d1(kprintf("%s/%s/%ld: FontDesc=<%s>\n", __FILE__, __FUNC__, __LINE__, FontDesc));
654 // copy font name
655 stccpy(ttta->ttta_NameSpace, FontDesc, sizeof(ttta->ttta_NameSpace));
656 ttta->ttta_FamilyTable[0] = ttta->ttta_NameSpace;
657 ttta->ttta_FamilyTable[1] = NULL;
659 return TRUE; // Success!
663 static SAVEDS(ULONG) FontFunctionDispatcher(struct Hook *hook, Object *o, Msg msg)
665 ULONG Result = 0;
667 d1(kprintf("%s/%s/%ld: hook=%08lx o=%08lx msg=%08lx\n", __FILE__, __FUNC__, __LINE__, hook, o, msg));
668 d1(kprintf("%s/%s/%ld: MethodID=%08lx\n", __FILE__, __FUNC__, __LINE__, msg->MethodID));
670 switch (msg->MethodID)
672 case iofMsg_DONERASTPORT:
674 struct ioFontMsg_DoneRastPort *iofdr = (struct ioFontMsg_DoneRastPort *) msg;
676 Scalos_DoneRastPort(iofdr->iofdr_RastPort);
678 break;
679 case iofMsg_SETFONT:
681 struct ioFontMsg_SetFont *iofsf = (struct ioFontMsg_SetFont *) msg;
683 Scalos_SetFont(iofsf->iofsf_RastPort, iofsf->iofsf_TextFont, iofsf->iofsf_FontHandle);
685 break;
686 case iofMsg_TEXT:
688 struct ioFontMsg_Text *ioft = (struct ioFontMsg_Text *) msg;
690 Scalos_Text(ioft->ioft_RastPort, ioft->ioft_String, ioft->ioft_Length);
692 break;
693 case iofMsg_SETFONTSTYLE:
695 struct ioFontMsg_SetFontStyle *iofsfs = (struct ioFontMsg_SetFontStyle *) msg;
697 Result = Scalos_SetSoftStyle(iofsfs->iofsfs_RastPort,
698 iofsfs->iofsfs_Style, iofsfs->iofsfs_Enable,
699 iofsfs->iofsfs_FontHandle);
701 break;
702 case iofMsg_TEXTEXTENT:
704 struct ioFontMsg_TextExtent *iofte = (struct ioFontMsg_TextExtent *) msg;
706 d1(kprintf("%s/%s/%ld: rp=%08lx string=%08lx length=%lu\n", \
707 __FILE__, __FUNC__, __LINE__, iofte->iofte_RastPort, iofte->iofte_String, iofte->iofte_Length));
709 Scalos_TextExtent(iofte->iofte_RastPort, iofte->iofte_String,
710 iofte->iofte_Length, iofte->iofte_TextExtent);
712 break;
713 case iofMsg_TEXTFIT:
715 struct ioFontMsg_TextFit *ioftf = (struct ioFontMsg_TextFit *) msg;
717 Result = Scalos_TextFit(ioftf->ioftf_RastPort, ioftf->ioftf_String,
718 ioftf->ioftf_Length, ioftf->ioftf_TextExtent,
719 ioftf->ioftf_ConstrainingTextExtent, ioftf->ioftf_StrDirection,
720 ioftf->ioftf_ConstrainingBitWidth, ioftf->ioftf_ConstrainingBitHeight);
722 break;
723 case iofMsg_GETFONTHEIGHT:
725 struct ioFontMsg_GetFontHeight *iofgfh = (struct ioFontMsg_GetFontHeight *) msg;
727 Result = Scalos_GetFontHeight(iofgfh->iofgfh_RastPort);
729 break;
730 case iofMsg_GETFONTBASELINE:
732 struct ioFontMsg_GetFontBaseline *iofgfb = (struct ioFontMsg_GetFontBaseline *) msg;
734 Result = Scalos_GetFontBaseline(iofgfb->iofgfb_RastPort);
736 break;
737 case iofMsg_SETTRANSPARENCY:
739 struct ioFontMsg_SetTransparency *iofst = (struct ioFontMsg_SetTransparency *) msg;
741 Scalos_SetFontTransparency(iofst->iofst_RastPort, iofst->iofst_Transparency);
743 break;
744 default:
745 break;
748 d1(kprintf("%s/%s/%ld: Result=%08lx\n", __FILE__, __FUNC__, __LINE__, Result));
750 return Result;