1 /************************************************************************/
2 /*									*/
3 /*  Make a font family name the could be correctly picked up in a CSS	*/
4 /*  stylesheet or a SVG file.						*/
5 /*									*/
6 /************************************************************************/
7 
8 #   include	"docFontConfig.h"
9 
10 #   include	<string.h>
11 
12 #   include	<appDebugon.h>
13 
14 #   include	"utilDocFont.h"
15 #   include	<psDocumentFontStyle.h>
16 
17 /************************************************************************/
18 /*									*/
19 /*  Translate an RTF font designation to an HTML/CSS1 style one.	*/
20 /*									*/
21 /************************************************************************/
22 
cssFontFamilyIndicator(char * target,int maxSize,int styleInt,const char * familyName)23 int cssFontFamilyIndicator(		char *		target,
24 					int		maxSize,
25 					int		styleInt,
26 					const char *	familyName )
27     {
28     const char *	genericFamily= (const char *)0;
29     const char *	hintFamily= (const char *)0;
30 
31     int			genericSize= 0;
32     int			hintSize= 0;
33     int			nameSize= 0;
34     int			size= 0;
35 
36     int			commas= 0;
37 
38     switch( styleInt )
39 	{
40 	case DFstyleFROMAN:
41 	    genericFamily= "serif";
42 	    hintFamily= "Times\",\"Times New Roman";
43 	    break;
44 
45 	case DFstyleFNIL:
46 	case DFstyleFSWISS:
47 	    genericFamily= "sans-serif";
48 	    hintFamily= "Helvetica\",\"Arial";
49 	    break;
50 
51 	case DFstyleFMODERN:
52 	    genericFamily= "monospace";
53 	    hintFamily= "Courier";
54 	    break;
55 
56 	case DFstyleFSCRIPT:
57 	case DFstyleFDECOR:
58 	    genericFamily= "cursive";
59 	    hintFamily= "Zapf-Chancery";
60 	    break;
61 
62 	case DFstyleFTECH:
63 	    hintFamily= "Symbol";
64 	    break;
65 	}
66 
67     if  ( genericFamily )
68 	{
69 	commas++;
70 	genericSize= strlen( genericFamily ); /* keyword -> no quotes */
71 	}
72     if  ( hintFamily )
73 	{
74 	commas++;
75 	hintSize= 1+ strlen( hintFamily )+ 1;
76 	}
77     nameSize= 1+ strlen( familyName )+ 1;
78 
79     size= nameSize+ genericSize+ hintSize+ commas;
80     if  ( size > maxSize )
81 	{ LLLLDEB(nameSize,genericSize,hintSize,maxSize); return -1; }
82 
83     *(target++)= '"';
84     strcpy( target, familyName ); target += nameSize- 2;
85     *(target++)= '"';
86 
87     if  ( hintFamily )
88 	{
89 	*(target++)= ',';
90 	*(target++)= '"';
91 	strcpy( target, hintFamily ); target += hintSize- 2;
92 	*(target++)= '"';
93 	}
94 
95     if  ( genericFamily )
96 	{
97 	*(target++)= ',';
98 	strcpy( target, genericFamily ); target += genericSize;
99 	}
100 
101     *(target  )= '\0';
102     return size;
103     }
104 
105