added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / c / iprefs / fontprefs.c
blobb5568a4fbbf9e93d0b7f080991eb8ac174fb5610
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 /*********************************************************************************************/
11 #include "global.h"
13 #include <prefs/prefhdr.h>
14 #include <prefs/font.h>
16 #define DEBUG 0
17 #include <aros/debug.h>
19 /*********************************************************************************************/
21 struct FileFontPrefs
23 UBYTE fp_Reserved[4 * 3];
24 UBYTE fp_Reserved2[2];
25 UBYTE fp_Type[2];
26 UBYTE fp_FrontPen;
27 UBYTE fp_BackPen;
28 UBYTE fp_Drawmode;
29 UBYTE fp_pad;
30 UBYTE fp_TextAttr_ta_Name[4];
31 UBYTE fp_TextAttr_ta_YSize[2];
32 UBYTE fp_TextAttr_ta_Style;
33 UBYTE fp_TextAttr_ta_Flags;
34 BYTE fp_Name[FONTNAMESIZE];
37 /*********************************************************************************************/
39 LONG stopchunks[] =
41 ID_PREF, ID_FONT
44 /*********************************************************************************************/
46 void FontPrefs_Handler(STRPTR filename)
48 struct IFFHandle *iff;
50 D(bug("In IPrefs:FontPrefs_Handler\n"));
52 if ((iff = CreateIFF(filename, stopchunks, 1)))
54 while(ParseIFF(iff, IFFPARSE_SCAN) == 0)
56 struct ContextNode *cn;
57 struct FileFontPrefs fontprefs;
59 cn = CurrentChunk(iff);
61 D(bug("FontPrefs_Handler: ParseIFF okay. Chunk Type = %c%c%c%c ChunkID = %c%c%c%c\n",
62 cn->cn_Type >> 24,
63 cn->cn_Type >> 16,
64 cn->cn_Type >> 8,
65 cn->cn_Type,
66 cn->cn_ID >> 24,
67 cn->cn_ID >> 16,
68 cn->cn_ID >> 8,
69 cn->cn_ID));
71 if ((cn->cn_ID == ID_FONT) && (cn->cn_Size == sizeof(fontprefs)))
73 D(bug("FontPrefs_Handler: ID_FONT chunk with correct size found.\n"));
75 if (ReadChunkBytes(iff, &fontprefs, sizeof(fontprefs)) == sizeof(fontprefs))
77 struct TextAttr ta;
78 struct TextFont *font;
79 UWORD type;
81 D(bug("FontPrefs_Handler: Reading of ID_FONT chunk okay.\n"));
83 type = (fontprefs.fp_Type[0] << 8) + fontprefs.fp_Type[1];
85 D(bug("Type = %d Name = %s\n", type, fontprefs.fp_Name));
87 ta.ta_Name = fontprefs.fp_Name;
88 ta.ta_YSize = (fontprefs.fp_TextAttr_ta_YSize[0] << 8) +
89 fontprefs.fp_TextAttr_ta_YSize[1];
90 ta.ta_Style = fontprefs.fp_TextAttr_ta_Style;
91 ta.ta_Flags = fontprefs.fp_TextAttr_ta_Flags;
93 switch(type)
95 case FP_SYSFONT:
96 if ((font = OpenDiskFont(&ta)))
98 if (font->tf_Flags & FPF_PROPORTIONAL)
100 D(bug("FontPrefs_Handler: FP_SYSFONT Font is proportional although it may not be!\n"));
101 CloseFont(font);
103 else
105 Forbid();
106 GfxBase->DefaultFont = font;
107 Permit();
109 D(bug("FontPrefs_Handler: Installed new system font!\n"));
112 else
114 D(bug("FontPrefs_Handler: Could not open font!\n"));
116 break;
118 case FP_SCREENFONT:
119 if ((font = OpenDiskFont(&ta)))
121 SetDefaultScreenFont(font);
123 D(bug("FontPrefs_Handler: Installed new system font!\n"));
125 else
127 D(bug("FontPrefs_Handler: Could not open font!\n"));
129 break;
131 case FP_WBFONT:
132 /* Hmm ... should IPrefs handle this, or should Workbench task
133 itself also setup a filenotification on font.prefs :-\ */
134 break;
136 } /* switch(type) */
138 } /* if (ReadChunkBytes(iff, &fontprefs, sizeof(fontprefs)) == sizeof(fontprefs)) */
140 } /* if ((cn->cn_ID == ID_FONT) && (cn->cn_Size == sizeof(fontprefs))) */
142 } /* while(ParseIFF(iff, IFFPARSE_SCAN) == 0) */
144 KillIFF(iff);
146 } /* if ((iff = CreateIFF(filename))) */
149 D(bug("In IPrefs:FontPrefs_Handler. Done with '%s'.\n", filename));
152 /*********************************************************************************************/