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 ************************************<+>*************************************/
54 #include "FontAttrI.h"
59 /******** Private Function Declarations ********/
60 /******** End Public Function Declarations ********/
62 /******************************************************************************
64 * Private variables and defines.
66 *****************************************************************************/
71 static _DtHelpFontHints DefaultFontAttrs =
75 10, 0, /* pointsz, setsize */
77 NULL, NULL, NULL, NULL, /* xlfd strings */
78 NULL, NULL, NULL, NULL, /* MS-Win strings */
79 _DtHelpFontStyleSanSerif,
80 _DtHelpFontSpacingProp ,
81 _DtHelpFontWeightMedium ,
82 _DtHelpFontSlantRoman ,
83 _DtHelpFontSpecialNone ,
87 /******************************************************************************
91 *****************************************************************************/
93 HintDuplicate(char **string)
97 *string = strdup(*string);
105 /******************************************************************************
107 * Semi Public Functions
109 *****************************************************************************/
110 /******************************************************************************
111 * Function: void _DtHelpCeCopyDefFontAttrList (char **font_attr)
113 * Parameters: font_attr Specifies the font attribute list
117 * Purpose: Initialize a font attribute list to the default.
118 * Sets '_DtMB_LEN_MAX' to the default character size.
120 *****************************************************************************/
122 _DtHelpCeCopyDefFontAttrList (_DtHelpFontHints *font_attr )
124 *font_attr = DefaultFontAttrs;
127 /******************************************************************************
128 * Function: void _DtHelpFreeFontHints (
130 * Parameters: font_hints Specifies the font hint structure
134 * Purpose: frees the strings in the font structure.
136 *****************************************************************************/
138 _DtHelpFreeFontHints (_DtHelpFontHints *font_hints )
141 * do the language and charset
143 if (NULL != font_hints->language)
144 free(font_hints->language);
145 if (NULL != font_hints->char_set)
146 free(font_hints->char_set);
151 if (NULL != font_hints->color)
152 free(font_hints->color);
157 if (NULL != font_hints->xlfd)
158 free(font_hints->xlfd);
159 if (NULL != font_hints->xlfdb)
160 free(font_hints->xlfdb);
161 if (NULL != font_hints->xlfdi)
162 free(font_hints->xlfdi);
163 if (NULL != font_hints->xlfdib)
164 free(font_hints->xlfdib);
167 * do the ms-windows fonts
169 if (NULL != font_hints->typenam)
170 free(font_hints->typenam);
171 if (NULL != font_hints->typenamb)
172 free(font_hints->typenamb);
173 if (NULL != font_hints->typenami)
174 free(font_hints->typenami);
175 if (NULL != font_hints->typenamib)
176 free(font_hints->typenamib);
179 /******************************************************************************
180 * Function: void _DtHelpDupFontHints (
182 * Parameters: font_hints Specifies the font hint structure
184 * Return Value: 0 for successful, -1 if failures.
186 * Purpose: to the dup the strings in the font hint structure.
188 *****************************************************************************/
190 _DtHelpDupFontHints (_DtHelpFontHints *font_hints )
195 * do the language and charset
197 if (-1 == HintDuplicate(&(font_hints->language)))
199 if (-1 == HintDuplicate(&(font_hints->char_set)))
205 if (-1 == HintDuplicate(&(font_hints->color)))
211 if (-1 == HintDuplicate(&(font_hints->xlfd)))
213 if (-1 == HintDuplicate(&(font_hints->xlfdb)))
215 if (-1 == HintDuplicate(&(font_hints->xlfdi)))
217 if (-1 == HintDuplicate(&(font_hints->xlfdib)))
221 * do the ms-windows fonts
223 if (-1 == HintDuplicate(&(font_hints->typenam)))
225 if (-1 == HintDuplicate(&(font_hints->typenamb)))
227 if (-1 == HintDuplicate(&(font_hints->typenami)))
229 if (-1 == HintDuplicate(&(font_hints->typenamib)))
233 _DtHelpFreeFontHints(font_hints);