2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
9 /******************************************************************************
17 FONTNAME/A,FONTSIZE/N/A,SCREEN/S
25 Set the default system/screen Font
29 FONTNAME -- the name of the font
30 FONTSIZE -- the size of the font
31 SCREEN -- if specified set the default screen font otherwise
32 set the default system font.
37 The default system font must be mono spaced (non-proportional)
41 SetDefaultFont ttcourier 12
51 ******************************************************************************/
54 #include <exec/exec.h>
56 #include <graphics/gfxbase.h>
57 #include <graphics/text.h>
58 #include <proto/exec.h>
59 #include <proto/dos.h>
60 #include <proto/graphics.h>
61 #include <proto/intuition.h>
62 #include <proto/diskfont.h>
68 const TEXT version
[] = "$VER: SetDefaultFont 41.1 (1.2.2001)\n";
70 #define ARG_TEMPLATE "FONTNAME/A,FONTSIZE/N/A,SCREEN/S"
80 static struct RDArgs
*myargs
;
81 static IPTR args
[NOOFARGS
];
83 static char *fontname
;
85 static BOOL screenfont
;
87 static void Cleanup(char *msg
, WORD rc
)
91 printf("SetDefaultFont: %s\n",msg
);
102 int GfxBase_version
= 0;
103 int IntuitionBase_version
= 0;
104 int DiskFontBase_version
= 0;
106 static void GetArguments(void)
108 if (!(myargs
= ReadArgs(ARG_TEMPLATE
, args
, 0)))
110 Fault(IoErr(), 0, s
, 255);
111 Cleanup(s
, RETURN_FAIL
);
114 fontname
= (char *)args
[ARG_FONTNAME
];
115 fontsize
= *(IPTR
*)args
[ARG_FONTSIZE
];
116 screenfont
= args
[ARG_SCREEN
] ? TRUE
: FALSE
;
119 static void Action(void)
122 struct TextFont
*font
;
125 if (!strstr(fontname
, ".font")) strcat(s
, ".font");
128 ta
.ta_YSize
= fontsize
;
132 font
= OpenDiskFont(&ta
);
135 Cleanup("Can't open font!", RETURN_FAIL
);
140 SetDefaultScreenFont(font
);
144 if (font
->tf_Flags
& FPF_PROPORTIONAL
)
147 Cleanup("The font must be mono spaced (non-proportional)!",
152 GfxBase
->DefaultFont
= font
;
161 Cleanup(0, RETURN_OK
);