2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 /*********************************************************************************************/
13 #include <prefs/prefhdr.h>
14 #include <prefs/font.h>
17 #include <aros/debug.h>
19 /*********************************************************************************************/
23 UBYTE fp_Reserved
[4 * 3];
24 UBYTE fp_Reserved2
[2];
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 /*********************************************************************************************/
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",
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
))
78 struct TextFont
*font
;
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
;
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"));
106 GfxBase
->DefaultFont
= font
;
109 D(bug("FontPrefs_Handler: Installed new system font!\n"));
114 D(bug("FontPrefs_Handler: Could not open font!\n"));
119 if ((font
= OpenDiskFont(&ta
)))
121 SetDefaultScreenFont(font
);
123 D(bug("FontPrefs_Handler: Installed new system font!\n"));
127 D(bug("FontPrefs_Handler: Could not open font!\n"));
132 /* Hmm ... should IPrefs handle this, or should Workbench task
133 itself also setup a filenotification on font.prefs :-\ */
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) */
146 } /* if ((iff = CreateIFF(filename))) */
149 D(bug("In IPrefs:FontPrefs_Handler. Done with '%s'.\n", filename
));
152 /*********************************************************************************************/