2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: FontAttr.c /main/8 1996/01/29 12:19:57 cde-hp $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 ** Project: Text Graphic Display Library
31 ** Description: Semi private format utility functions that do not
32 ** require the Display Area, Motif, Xt or X11.
35 ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
37 ** (c) Copyright 1993, 1994 Hewlett-Packard Company
38 ** (c) Copyright 1993, 1994 International Business Machines Corp.
39 ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
40 ** (c) Copyright 1993, 1994 Novell, Inc.
43 ****************************************************************************
44 ************************************<+>*************************************/
53 #include "FontAttrI.h"
58 /******** Private Function Declarations ********/
59 /******** End Public Function Declarations ********/
61 /******************************************************************************
63 * Private variables and defines.
65 *****************************************************************************/
70 static _DtHelpFontHints DefaultFontAttrs =
74 10, 0, /* pointsz, setsize */
76 NULL, NULL, NULL, NULL, /* xlfd strings */
77 NULL, NULL, NULL, NULL, /* MS-Win strings */
78 _DtHelpFontStyleSanSerif,
79 _DtHelpFontSpacingProp ,
80 _DtHelpFontWeightMedium ,
81 _DtHelpFontSlantRoman ,
82 _DtHelpFontSpecialNone ,
86 /******************************************************************************
90 *****************************************************************************/
92 HintDuplicate(char **string)
96 *string = strdup(*string);
104 /******************************************************************************
106 * Semi Public Functions
108 *****************************************************************************/
109 /******************************************************************************
110 * Function: void _DtHelpCeCopyDefFontAttrList (char **font_attr)
112 * Parameters: font_attr Specifies the font attribute list
116 * Purpose: Initialize a font attribute list to the default.
117 * Sets '_DtMB_LEN_MAX' to the default character size.
119 *****************************************************************************/
121 _DtHelpCeCopyDefFontAttrList (_DtHelpFontHints *font_attr )
123 *font_attr = DefaultFontAttrs;
126 /******************************************************************************
127 * Function: void _DtHelpFreeFontHints (
129 * Parameters: font_hints Specifies the font hint structure
133 * Purpose: frees the strings in the font structure.
135 *****************************************************************************/
137 _DtHelpFreeFontHints (_DtHelpFontHints *font_hints )
140 * do the language and charset
142 if (NULL != font_hints->language)
143 free(font_hints->language);
144 if (NULL != font_hints->char_set)
145 free(font_hints->char_set);
150 if (NULL != font_hints->color)
151 free(font_hints->color);
156 if (NULL != font_hints->xlfd)
157 free(font_hints->xlfd);
158 if (NULL != font_hints->xlfdb)
159 free(font_hints->xlfdb);
160 if (NULL != font_hints->xlfdi)
161 free(font_hints->xlfdi);
162 if (NULL != font_hints->xlfdib)
163 free(font_hints->xlfdib);
166 * do the ms-windows fonts
168 if (NULL != font_hints->typenam)
169 free(font_hints->typenam);
170 if (NULL != font_hints->typenamb)
171 free(font_hints->typenamb);
172 if (NULL != font_hints->typenami)
173 free(font_hints->typenami);
174 if (NULL != font_hints->typenamib)
175 free(font_hints->typenamib);
178 /******************************************************************************
179 * Function: void _DtHelpDupFontHints (
181 * Parameters: font_hints Specifies the font hint structure
183 * Return Value: 0 for successful, -1 if failures.
185 * Purpose: to the dup the strings in the font hint structure.
187 *****************************************************************************/
189 _DtHelpDupFontHints (_DtHelpFontHints *font_hints )
194 * do the language and charset
196 if (-1 == HintDuplicate(&(font_hints->language)))
198 if (-1 == HintDuplicate(&(font_hints->char_set)))
204 if (-1 == HintDuplicate(&(font_hints->color)))
210 if (-1 == HintDuplicate(&(font_hints->xlfd)))
212 if (-1 == HintDuplicate(&(font_hints->xlfdb)))
214 if (-1 == HintDuplicate(&(font_hints->xlfdi)))
216 if (-1 == HintDuplicate(&(font_hints->xlfdib)))
220 * do the ms-windows fonts
222 if (-1 == HintDuplicate(&(font_hints->typenam)))
224 if (-1 == HintDuplicate(&(font_hints->typenamb)))
226 if (-1 == HintDuplicate(&(font_hints->typenami)))
228 if (-1 == HintDuplicate(&(font_hints->typenamib)))
232 _DtHelpFreeFontHints(font_hints);