2 Copyright © 1995-2008, 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 BOOL closed
= FALSE
, cancel
= FALSE
;
122 TEXT screen_name
[MAXPUBSCREENNAME
+ 1];
124 SetDefaultScreenFont(font
);
125 D(bug("FontPrefs_Handler: Installed new screen font!\n"));
127 /* Keep trying to close WB screen unless user
128 cancels or it wasn't open in the first
130 while (!(closed
|| cancel
||
131 NextPubScreen(NULL
, screen_name
) == NULL
))
133 closed
= CloseWorkBench();
135 cancel
= ShowMessage("System Request",
136 "Intuition is attempting to reset"
137 " the Workbench Screen.\n"
138 "Please close all windows,"
140 "Retry|Cancel") == 0;
147 D(bug("FontPrefs_Handler: Could not open font!\n"));
152 /* Hmm ... should IPrefs handle this, or should Workbench task
153 itself also setup a filenotification on font.prefs :-\ */
158 } /* if (ReadChunkBytes(iff, &fontprefs, sizeof(fontprefs)) == sizeof(fontprefs)) */
160 } /* if ((cn->cn_ID == ID_FONT) && (cn->cn_Size == sizeof(fontprefs))) */
162 } /* while(ParseIFF(iff, IFFPARSE_SCAN) == 0) */
166 } /* if ((iff = CreateIFF(filename))) */
169 D(bug("In IPrefs:FontPrefs_Handler. Done with '%s'.\n", filename
));
172 /*********************************************************************************************/