2 Copyright © 1995-2011, 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>
66 const TEXT version
[] = "$VER: SetDefaultFont 41.1 (1.2.2001)\n";
68 #define ARG_TEMPLATE "FONTNAME/A,FONTSIZE/N/A,SCREEN/S"
78 static struct RDArgs
*myargs
;
79 static IPTR args
[NOOFARGS
];
81 static char *fontname
;
83 static BOOL screenfont
;
85 static void Cleanup(char *msg
)
89 Printf("SetDefaultFont: %s\n",msg
);
95 int GfxBase_version
= 0;
96 int IntuitionBase_version
= 0;
97 int DiskFontBase_version
= 0;
99 static ULONG
GetArguments(void)
101 if (!(myargs
= ReadArgs(ARG_TEMPLATE
, args
, 0)))
103 Fault(IoErr(), 0, s
, 255);
108 fontname
= (char *)args
[ARG_FONTNAME
];
109 fontsize
= *(IPTR
*)args
[ARG_FONTSIZE
];
110 screenfont
= args
[ARG_SCREEN
] ? TRUE
: FALSE
;
115 static ULONG
Action(void)
118 struct TextFont
*font
;
121 if (!strstr(fontname
, ".font")) strcat(s
, ".font");
124 ta
.ta_YSize
= fontsize
;
128 font
= OpenDiskFont(&ta
);
131 Cleanup("Can't open font!");
137 SetDefaultScreenFont(font
);
141 if (font
->tf_Flags
& FPF_PROPORTIONAL
)
144 Cleanup("The font must be mono spaced (non-proportional)!");
149 GfxBase
->DefaultFont
= font
;