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: udcimp.c /main/4 1996/09/02 18:51:02 cde-fuj $ */
25 * (c) Copyright 1995 FUJITSU LIMITED
26 * This is source code modified by FUJITSU LIMITED under the Joint
27 * Development Agreement for the CDEnext PST.
28 * This is unpublished proprietary source code of FUJITSU LIMITED
38 extern FalGlyphRegion *gr;
39 extern FalFontData fullFontData;
41 void udcimp(Exc_data * ed)
43 ed->function = IMPORT;
44 strcpy(ed->bdfmode,"r");
48 int checkcode(int code)
53 for (i = 0; i < num_gr; i++) {
54 code1 = smaller(gr[i].start, gr[i].end);
55 code2 = bigger(gr[i].start, gr[i].end);
56 if ((code >= code1) && (code <= code2)) { /*in udc area */
57 for (j = 0; j < ld->existcode_num; j++) {
58 if (code == ld->existcode[j])
59 return (1); /* the font has same glyph index */
64 return (-1); /* out of udc area */
68 int checkcodes(int code_num, int * code_list)
75 for (i = 0; i < code_num; i++) {
76 ans = checkcode(*codep);
79 } else if (ans == 1) {
87 void getcharcd(Exc_data * ed)
97 msg = GETMESSAGE(12, 2, "Glyph images in this BDF file can't be added to the font.");
98 msg2 = GETMESSAGE(12, 4, "Failed to open the selected BDF font. You have no right to access for the font file, or the format of the file is not consistent.");
99 msg3 = GETMESSAGE(12, 6, "There are one or more glyph images being overwritten. Overwrite?");
101 i = ImpBDFCodeList(ed->bdffile, &code_num, &code_list);
103 if (i != 0) { /* bad BDF format */
104 AskUser(ed->toplevel, ed, msg2, &ans, "error");
109 ans2 = checkcodes(code_num, code_list);
110 if (ans2 == -1) { /* out of UDC code exists */
111 AskUser(ed->toplevel, ed, msg, &ans, "error");
114 } else if (ans2 == 1) { /* font file has same glyph index */
115 AskUser(ed->toplevel, ed, msg3, &ans, "warning");
122 /* set twe codelists */
123 setcodelists(ld, code_num, code_list);
125 if (ImpBDFCodeListFree(&code_list) != 0) {
126 fprintf(stderr,"error in ImpBDFCodeListFree\n");
129 /* add gryph images to font */
133 void addcharptn(Exc_data * ed)
142 FalFontDataList *fulllist = NULL;
145 msg = GETMESSAGE(12, 8, "Failed to open the selected font. You have no right to access for the font file, or the format of the file is not consistent.");
146 msg2 = GETMESSAGE(12, 10, "Glyph images in this BDF file can't be added to the font.");
147 msg3 = GETMESSAGE(12, 12, "Failed in the registration of the font file.");
149 mask = FAL_FONT_MASK_XLFDNAME | FAL_FONT_MASK_GLYPH_INDEX |
150 FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UPDATE |
151 FAL_FONT_MASK_UNDEFINED | FAL_FONT_MASK_CODE_SET;
153 i = ImpBDFCheck(ed->bdffile, ed->fontfile);
155 AskUser(ed->toplevel, ed, msg2, &ans, "error");
159 fontid = FalOpenSysFont(&fullFontData, mask, &fulllist);
161 AskUser(ld->ed->toplevel, ld->ed, msg, &ans, "error");
165 i = ImpBDFtoGpf(ed->bdffile, ed->fontfile,
166 ed->code_num, ed->bdf_code_list);
167 FalCloseFont( fontid );
169 AskUser(ed->toplevel, ed, msg3, &ans, "error");
175 void setcodelists(ListData *ld, int code_num, int *code_list)
181 ld->ed->code_num = code_num;
183 if ((c1 = (int *) calloc(code_num, sizeof(int))) == NULL) {
186 excerror(ed, EXCERRMALLOC, "setcodelists", "exit");
188 ld->ed->bdf_code_list = c1;
190 for (i = 0; i < code_num; i++)
197 if ((c1 = (int *) calloc(code_num, sizeof(int))) == NULL) {
200 excerror(ed, EXCERRMALLOC, "setcodelists", "exit");
202 ld->ed->gpf_code_list = c1;
204 for (i = 0; i < code_num; i++)