Rev 193 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 193 | Rev 259 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | This file is part of a common library |
2 | This file is part of a common library |
3 | Copyright (C) 1990-2006 Toby Thain, toby@telegraphics.com.au |
3 | Copyright (C) 1990-2006 Toby Thain, toby@telegraphics.com.au |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify |
5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by |
6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or |
7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. |
8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, |
10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. |
13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License |
15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software |
16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | */ |
18 | */ |
19 | 19 | ||
20 | #include <memory.h> |
20 | #include <memory.h> |
21 | #include <fonts.h> |
21 | #include <fonts.h> |
22 | #include <stdlib.h> |
22 | #include <stdlib.h> |
23 | 23 | ||
24 | void base_font_name(char *s,Handle FOND){ |
24 | void base_font_name(char *s,Handle FOND){ |
25 | StyleTable *st; |
25 | StyleTable *st; |
26 | unsigned char *p,*q,**nt,**n,hs; |
26 | unsigned char *p,*q,**nt,**n,hs; |
27 | int i; |
27 | int i; |
28 | FamRec *f; |
28 | FamRec *f; |
29 | 29 | ||
30 | hs = HGetState(FOND); |
30 | hs = HGetState(FOND); |
31 | HLock(FOND); |
31 | HLock(FOND); |
32 | f = (FamRec*)*FOND; |
32 | f = (FamRec*)*FOND; |
33 | 33 | ||
34 | if(f->ffStylOff){ |
34 | if(f->ffStylOff){ |
35 | st = (StyleTable*)((char*)f + f->ffStylOff); |
35 | st = (StyleTable*)((char*)f + f->ffStylOff); |
36 | p = (unsigned char*)st->indexes + 48; |
36 | p = (unsigned char*)st->indexes + 48; |
37 | i = *(short*)p; |
37 | i = *(short*)p; |
38 | p += 2; |
38 | p += 2; |
39 | nt = n = malloc(i*sizeof(char*)); |
39 | nt = n = malloc(i*sizeof(char*)); |
40 | while(i--){ |
40 | while(i--){ |
41 | *n++ = p; |
41 | *n++ = p; |
42 | p += *p + 1; |
42 | p += *p + 1; |
43 | } |
43 | } |
44 | memcpy(s,nt[0]+1,*nt[0]); // base font name |
44 | memcpy(s,nt[0]+1,*nt[0]); // base font name |
45 | s += *nt[0]; |
45 | s += *nt[0]; |
46 | // *s++ = '.'; |
46 | // *s++ = '.'; |
47 | if(i = st->indexes[0/*plain*/] - 1) |
47 | if(i = st->indexes[0/*plain*/] - 1) |
48 | for(p = nt[i], i = *p++; i--;){ |
48 | for(p = nt[i], i = *p++; i--;){ |
49 | q = nt[*p++ - 1]; |
49 | q = nt[*p++ - 1]; |
50 | memcpy(s,q+1,*q); // append suffix |
50 | memcpy(s,q+1,*q); // append suffix |
51 | s += *q; |
51 | s += *q; |
52 | // *s++ = '.'; |
52 | // *s++ = '.'; |
53 | } |
53 | } |
54 | free(nt); |
54 | free(nt); |
55 | } |
55 | } |
56 | *s = 0; |
56 | *s = 0; |
57 | 57 | ||
58 | HSetState(FOND,hs); |
58 | HSetState(FOND,hs); |
59 | } |
59 | } |
60 | 60 | ||
61 | #if 0 |
61 | #if 0 |
62 | class(char c){ |
62 | class(char c){ |
63 | if(isupper(c)) |
63 | if(isupper(c)) |
64 | return 1; |
64 | return 1; |
65 | else if(islower(c)) |
65 | else if(islower(c)) |
66 | return 2; |
66 | return 2; |
67 | else if(isalpha(c)) |
67 | else if(isalpha(c)) |
68 | return 3; |
68 | return 3; |
69 | else |
69 | else |
70 | return 4; |
70 | return 4; |
71 | } |
71 | } |
72 | 72 | ||
73 | void convert53(char *d,char *s){ |
73 | void convert53(char *d,char *s){ |
74 | int cl = class(*s),n = 5; |
74 | int cl = class(*s),n = 5; |
75 | for(;*s;s++){ |
75 | for(;*s;s++){ |
76 | if((newcl = class(*s)) != cl){ |
76 | if((newcl = class(*s)) != cl){ |
77 | n = 3; |
77 | n = 3; |
78 | cl = newcl; |
78 | cl = newcl; |
79 | } |
79 | } |
80 | if(n){ |
80 | if(n){ |
81 | *d++ = *s; |
81 | *d++ = *s; |
82 | n--; |
82 | n--; |
83 | } |
83 | } |
84 | } |
84 | } |
85 | } |
85 | } |
86 | #endif |
86 | #endif |