1 /* $XConsortium: udcimp.c /main/4 1996/09/02 18:51:02 cde-fuj $ */
3 * (c) Copyright 1995 FUJITSU LIMITED
4 * This is source code modified by FUJITSU LIMITED under the Joint
5 * Development Agreement for the CDEnext PST.
6 * This is unpublished proprietary source code of FUJITSU LIMITED
16 extern FalGlyphRegion *gr;
17 extern FalFontData fullFontData;
19 void udcimp(Exc_data * ed)
21 ed->function = IMPORT;
22 strcpy(ed->bdfmode,"r");
26 int checkcode(int code)
31 for (i = 0; i < num_gr; i++) {
32 code1 = smaller(gr[i].start, gr[i].end);
33 code2 = bigger(gr[i].start, gr[i].end);
34 if ((code >= code1) && (code <= code2)) { /*in udc area */
35 for (j = 0; j < ld->existcode_num; j++) {
36 if (code == ld->existcode[j])
37 return (1); /* the font has same glyph index */
42 return (-1); /* out of udc area */
46 int checkcodes(int code_num, int * code_list)
53 for (i = 0; i < code_num; i++) {
54 ans = checkcode(*codep);
57 } else if (ans == 1) {
65 void getcharcd(Exc_data * ed)
75 msg = GETMESSAGE(12, 2, "Glyph images in this BDF file can't be added to the font.");
76 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.");
77 msg3 = GETMESSAGE(12, 6, "There are one or more glyph images being overwritten. Overwrite?");
79 i = ImpBDFCodeList(ed->bdffile, &code_num, &code_list);
81 if (i != 0) { /* bad BDF format */
82 AskUser(ed->toplevel, ed, msg2, &ans, "error");
87 ans2 = checkcodes(code_num, code_list);
88 if (ans2 == -1) { /* out of UDC code exists */
89 AskUser(ed->toplevel, ed, msg, &ans, "error");
92 } else if (ans2 == 1) { /* font file has same glyph index */
93 AskUser(ed->toplevel, ed, msg3, &ans, "warning");
100 /* set twe codelists */
101 setcodelists(ld, code_num, code_list);
103 if (ImpBDFCodeListFree(&code_list) != 0) {
104 fprintf(stderr,"error in ImpBDFCodeListFree\n");
107 /* add gryph images to font */
111 void addcharptn(Exc_data * ed)
120 FalFontDataList *fulllist = NULL;
123 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.");
124 msg2 = GETMESSAGE(12, 10, "Glyph images in this BDF file can't be added to the font.");
125 msg3 = GETMESSAGE(12, 12, "Failed in the registration of the font file.");
127 mask = FAL_FONT_MASK_XLFDNAME | FAL_FONT_MASK_GLYPH_INDEX |
128 FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UPDATE |
129 FAL_FONT_MASK_UNDEFINED | FAL_FONT_MASK_CODE_SET;
131 i = ImpBDFCheck(ed->bdffile, ed->fontfile);
133 AskUser(ed->toplevel, ed, msg2, &ans, "error");
137 fontid = FalOpenSysFont(&fullFontData, mask, &fulllist);
139 AskUser(ld->ed->toplevel, ld->ed, msg, &ans, "error");
143 i = ImpBDFtoGpf(ed->bdffile, ed->fontfile,
144 ed->code_num, ed->bdf_code_list);
145 FalCloseFont( fontid );
147 AskUser(ed->toplevel, ed, msg3, &ans, "error");
153 void setcodelists(ListData *ld, int code_num, int *code_list)
159 ld->ed->code_num = code_num;
161 if ((c1 = (int *) calloc(code_num, sizeof(int))) == NULL) {
164 excerror(ed, EXCERRMALLOC, "setcodelists", "exit");
166 ld->ed->bdf_code_list = c1;
168 for (i = 0; i < code_num; i++)
175 if ((c1 = (int *) calloc(code_num, sizeof(int))) == NULL) {
178 excerror(ed, EXCERRMALLOC, "setcodelists", "exit");
180 ld->ed->gpf_code_list = c1;
182 for (i = 0; i < code_num; i++)