4 Original GPL release version 4.12
5 Copyright 1993-2000 Jonathan Potter
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 All users of Directory Opus 4 (including versions distributed
22 under the GPL) are entitled to upgrade to the latest version of
23 Directory Opus version 5 at a reduced price. Please see
24 http://www.gpsoft.com.au for more information.
26 The release of Directory Opus 4 under the GPL in NO WAY affects
27 the existing commercial status of Directory Opus 5.
33 #define ABS(x) ((x)<0?-(x):(x))
35 int initfontlist(num
,move
,flags
)
38 int a
,b
,dist
=0,one
,val
,size
=-1;
41 if (!fontlist
) return(0);
42 if (!flags
) fontlistview
.items
=fontlist
;
43 else if (flags
==FFLAG_8ONLY
) fontlistview
.items
=only8list
;
44 else if (flags
==FFLAG_NOPROP
) fontlistview
.items
=noproplist
;
45 strcpy(name
,config
->fontbufs
[num
]);
46 if (ptr
=strstri(name
,".font")) *ptr
=0;
48 if (!fontlistview
.items
[a
]) break;
49 if (strcmp(name
,fontlistview
.items
[a
])==0) {
50 fontlistview
.itemselected
=a
;
52 if (a
<fontlistview
.topitem
|| a
>fontlistview
.topitem
+7)
53 fontlistview
.topitem
=a
;
56 if (!flags
) fontsizelistview
.items
=fontsizelist
[a
];
57 else if (flags
==FFLAG_8ONLY
) fontsizelistview
.items
=only8sizelist
;
58 else if (flags
==FFLAG_NOPROP
) fontsizelistview
.items
=nopropsizelist
[a
];
59 if (fontsizelistview
.items
) {
62 if (!fontsizelistview
.items
[b
]) break;
63 if ((val
=atoi(fontsizelistview
.items
[b
]))==(int)config
->fontsizes
[num
]) {
64 fontsizelistview
.itemselected
=b
;
66 if (b
<fontsizelistview
.topitem
||
67 b
>fontsizelistview
.topitem
+fontsizelistview
.lines
)
68 fontsizelistview
.topitem
=b
;
73 else if (one
==-1 || ABS((val
-(int)config
->fontsizes
[num
]))<dist
) {
74 dist
=ABS((val
-(int)config
->fontsizes
[num
]));
80 size
=config
->fontsizes
[num
];
81 lsprintf(fontsize_buf
,"%ld",(long int)size
);
82 RefreshStrGad(&fontsizegadget
,Window
);
83 fontsizelistview
.itemselected
=-1;
86 size=atoi(fontsizelistview.items[one]);
87 fontsizelistview.itemselected=one;
89 if (one<fontsizelistview.topitem ||
90 one>fontsizelistview.topitem+fontsizelistview.lines-1)
91 fontsizelistview.topitem=one;
95 else size
=(int)config
->fontsizes
[num
];
101 RefreshListView(&fontlistview
,2);
103 strcat(name
,".font");
104 dofontdemo(name
,size
);
109 void sortfontlist(avail
,num
,type
)
110 struct AvailFonts
*avail
;
115 for (gap
=num
/2;gap
>0;gap
/=2)
116 for (i
=gap
;i
<num
;i
++)
117 for (j
=i
-gap
;j
>=0;j
-=gap
) {
120 if (LStrCmpI((char *)avail
[j
].af_Attr
.ta_Name
,
121 (char *)avail
[k
].af_Attr
.ta_Name
)<=0) break;
124 if (LStrCmpI((char *)avail
[j
].af_Attr
.ta_Name
,
125 (char *)avail
[k
].af_Attr
.ta_Name
)) break;
126 if (avail
[j
].af_Attr
.ta_YSize
<=avail
[k
].af_Attr
.ta_YSize
) break;
128 SwapMem((char *)&avail
[j
],(char *)&avail
[k
],sizeof(struct AvailFonts
));
132 void dofontdemo(name
,size
)
136 struct TextFont
*font
;
137 struct Region
*reg
,*oldreg
;
138 struct Rectangle clip
;
149 screen_pens
[config
->gadgetbotcol
].pen
,screen_pens
[config
->gadgettopcol
].pen
);
150 SetAPen(rp
,screen_pens
[0].pen
);
151 RectFill(rp
,x_off
+146,y_off
+93,x_off
+613,y_off
+167);
152 SetAPen(rp
,screen_pens
[1].pen
);
155 cfg_string
[STR_LOADING_FONT
],
158 if (font
=getfont(name
,&size
,0)) {
159 SetAPen(rp
,screen_pens
[0].pen
);
162 x_off
+613,y_off
+167);
163 SetAPen(rp
,screen_pens
[1].pen
);
165 if (reg
=NewRegion()) {
166 OrRectRegion(reg
,&clip
);
167 oldreg
=InstallClipRegion(Window
->WLayer
,reg
);
170 else l
=464/font
->tf_XSize
;
173 for (a
=0;a
<256;a
++) {
177 for (a
=0;a
<256;a
++) {
178 if (isupper(buf
[0][a
])) buf
[1][a
]=ToLower(buf
[0][a
]);
179 else buf
[1][a
]=ToUpper(buf
[0][a
]);
182 while (y
<76+font
->tf_Baseline
) {
183 Move(rp
,x_off
+148,y
+y_off
+94);
189 InstallClipRegion(Window
->WLayer
,oldreg
);
196 cfg_string
[STR_FONT_COULD_NOT_BE_LOADED
],