2 Copyright 1985, 1986, 1987, 1991, 1998 The Open Group
4 Permission is hereby granted, free of charge, to any person obtaining a
5 copy of this software and associated documentation files (the
6 "Software"), to deal in the Software without restriction, including
7 without limitation the rights to use, copy, modify, merge, publish,
8 distribute, sublicense, and/or sell copies of the Software, and to
9 permit persons to whom the Software is furnished to do so, subject to
10 the following conditions: The above copyright notice and this
11 permission notice shall be included in all copies or substantial
12 portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
21 EVEN IF ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
24 Except as contained in this notice, the name of The Open Group shall not be
25 used in advertising or otherwise to promote the sale, use or other dealings
26 in this Software without prior written authorization from The Open Group.
29 X Window System is a trademark of The Open Group
31 OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
32 logo, LBX, X Window System, and Xinerama are trademarks of the Open
33 Group. All other trademarks and registered trademarks mentioned herein
34 are the property of their respective owners. No right, title or
35 interest in or to any trademark, service mark, logo or trade name of
36 Sun Microsystems, Inc. or its licensors is granted.
40 * Copyright 2000 Oracle and/or its affiliates. All rights reserved.
42 * Permission is hereby granted, free of charge, to any person obtaining a
43 * copy of this software and associated documentation files (the "Software"),
44 * to deal in the Software without restriction, including without limitation
45 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
46 * and/or sell copies of the Software, and to permit persons to whom the
47 * Software is furnished to do so, subject to the following conditions:
49 * The above copyright notice and this permission notice (including the next
50 * paragraph) shall be included in all copies or substantial portions of the
53 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
54 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
55 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
56 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
57 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
58 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
59 * DEALINGS IN THE SOFTWARE.
68 #include "XlcPublic.h"
70 #include <X11/Xatom.h>
75 #define XOM_GENERIC(om) (&((XOMGeneric) om)->gen)
76 #define XOC_GENERIC(font_set) (&((XOCGeneric) font_set)->gen)
78 #define DefineLocalBuf char local_buf[BUFSIZ]
79 #define AllocLocalBuf(length) (length > BUFSIZ ? Xmalloc(length) : local_buf)
80 #define FreeLocalBuf(ptr) if (ptr != local_buf) Xfree(ptr)
82 typedef struct _FontDataRec {
84 } FontDataRec, *FontData;
86 typedef struct _OMDataRec {
91 typedef struct _XOMGenericPart {
95 typedef struct _XOMGenericRec {
99 } XOMGenericRec, *XOMGeneric;
101 typedef struct _FontSetRec {
108 } FontSetRec, *FontSet;
110 typedef struct _XOCGenericPart {
115 typedef struct _XOCGenericRec {
119 } XOCGenericRec, *XOCGeneric;
129 data = XOM_GENERIC(oc->core.om)->data;
131 font_set = Xcalloc(1, sizeof(FontSetRec));
132 if (font_set == NULL)
135 gen = XOC_GENERIC(oc);
136 gen->font_set = font_set;
138 font_set->font_data_count = data->font_data_count;
139 font_set->font_data = data->font_data;
151 if (XGetFontProperty(fs, XA_FONT, &fp))
152 return XGetAtomName(dpy, fp);
154 return (char *) NULL;
165 ssize_t length, name_len;
167 name_len = strlen(font_name);
168 last = font_name + name_len;
170 count = font_set->font_data_count;
171 font_data = font_set->font_data;
173 for ( ; count-- > 0; font_data++) {
174 length = strlen(font_data->name);
176 if (length > name_len)
179 if (_XlcCompareISOLatin1(last - length, font_data->name) == 0)
182 return (FontData) NULL;
191 Display *dpy = oc->core.om->core.display;
192 XOCGenericPart *gen = XOC_GENERIC(oc);
195 XFontStruct *fs_list;
196 char **fn_list, *fname, *prop_fname = NULL;
199 char **fn2_list = NULL;
202 fn_list = XListFonts(dpy, name, MAXFONTS, &list_num);
206 for (i = 0; i < list_num; i++) {
209 font_set = gen->font_set;
211 if ((data = check_charset(font_set, fname)) == NULL) {
212 if ((fn2_list = XListFontsWithInfo(dpy, name, MAXFONTS,
213 &list2_num, &fs_list))
214 && (prop_fname = get_prop_name(dpy, fs_list))
215 && (data = check_charset(font_set, prop_fname)))
219 font_set->font_name = strdup(fname);
220 if (font_set->font_name) {
225 XFreeFontInfo(fn2_list, fs_list, list2_num);
235 XFreeFontNames(fn_list);
244 Display *dpy = oc->core.om->core.display;
245 XOCGenericPart *gen = XOC_GENERIC(oc);
246 FontSet font_set = gen->font_set;
248 if (font_set->font_name == NULL)
251 if (font_set->font == NULL) {
252 font_set->font = XLoadQueryFont(dpy, font_set->font_name);
253 if (font_set->font == NULL)
264 Display *dpy = oc->core.om->core.display;
265 XOCGenericPart *gen = XOC_GENERIC(oc);
266 FontSet font_set = gen->font_set;
270 if (font_set->font_name == NULL)
273 if (font_set->info == NULL) {
274 fn_list = XListFontsWithInfo(dpy, font_set->font_name, 1, &fn_num,
276 if (font_set->info == NULL)
279 font_set->info->fid = XLoadFont(dpy, font_set->font_name);
281 if (fn_list) XFreeFontNames(fn_list);
291 XRectangle *ink = &oc->core.font_set_extents.max_ink_extent;
292 XRectangle *logical = &oc->core.font_set_extents.max_logical_extent;
293 XFontStruct **font_list, *font;
295 int logical_ascent, logical_descent;
297 font_list = oc->core.font_info.font_struct_list;
299 overall = font->max_bounds;
300 overall.lbearing = font->min_bounds.lbearing;
301 logical_ascent = font->ascent;
302 logical_descent = font->descent;
304 ink->x = overall.lbearing;
305 ink->y = -(overall.ascent);
306 ink->width = overall.rbearing - overall.lbearing;
307 ink->height = overall.ascent + overall.descent;
310 logical->y = -(logical_ascent);
311 logical->width = overall.width;
312 logical->height = logical_ascent + logical_descent;
319 XOCGenericPart *gen = XOC_GENERIC(oc);
321 XFontStruct **font_struct_list;
322 char **font_name_list, *font_name_buf;
325 font_set = gen->font_set;
328 if (font_set->font_name != NULL) {
329 length += strlen(font_set->font_name) + 1;
335 font_struct_list = Xmalloc(sizeof(XFontStruct *));
336 if (font_struct_list == NULL)
339 font_name_list = Xmalloc(sizeof(char *));
340 if (font_name_list == NULL)
343 font_name_buf = Xmalloc(length);
344 if (font_name_buf == NULL)
347 oc->core.font_info.num_font = 1;
348 oc->core.font_info.font_name_list = font_name_list;
349 oc->core.font_info.font_struct_list = font_struct_list;
351 font_set = gen->font_set;
353 if (font_set->font_name != NULL) {
356 *font_struct_list++ = font_set->font;
358 *font_struct_list++ = font_set->info;
359 strcpy(font_name_buf, font_set->font_name);
360 Xfree(font_set->font_name);
361 *font_name_list++ = font_set->font_name = font_name_buf;
362 font_name_buf += strlen(font_name_buf) + 1;
365 set_fontset_extents(oc);
371 Xfree(font_name_list);
372 Xfree(font_struct_list);
385 Display *dpy = oc->core.om->core.display;
387 list = XListFonts(dpy, pattern, 1, &count);
389 name = strdup(*list);
391 XFreeFontNames(list);
393 fs = XLoadQueryFont(dpy, pattern);
394 if (fs == NULL) return NULL;
396 name = get_prop_name(dpy, fs);
406 XOCGenericPart *gen = XOC_GENERIC(oc);
409 char *pattern, *last, buf[BUFSIZ];
410 int font_data_count, found_num = 0;
412 int count, num_fields;
413 char *base_name, *font_name, **name_list, **cur_name_list;
414 char *charset_p = NULL;
417 append_charset flag should be set to True when the XLFD fontname
418 doesn't contain a chaset part.
421 name_list = _XParseBaseFontNameList(oc->core.base_name_list, &count);
422 if (name_list == NULL)
424 cur_name_list = name_list;
426 while (count-- > 0) {
427 pattern = *cur_name_list++;
428 if (pattern == NULL || *pattern == '\0')
431 append_charset = False;
433 if (strchr(pattern, '*') == NULL &&
434 (font_name = get_font_name(oc, pattern))) {
436 font_set = gen->font_set;
438 font_data = check_charset(font_set, font_name);
439 if (font_data == NULL) {
440 Display *dpy = oc->core.om->core.display;
441 char **fn_list = NULL, *prop_fname = NULL;
443 XFontStruct *fs_list;
444 if ((fn_list = XListFontsWithInfo(dpy, font_name,
446 &list_num, &fs_list))
447 && (prop_fname = get_prop_name(dpy, fs_list))
448 && (font_data = check_charset(font_set, prop_fname))) {
450 XFreeFontInfo(fn_list, fs_list, list_num);
453 font_name = prop_fname;
456 if (font_data == NULL)
459 font_set->font_name = strdup(font_name);
461 if (font_set->font_name == NULL) {
469 Limit the length of the string copy to prevent stack corruption.
470 strcpy(buf, pattern);
472 strncpy(buf, pattern, BUFSIZ);
473 buf[BUFSIZ-1] = '\0';
474 length = strlen(buf);
475 last = buf + length - 1;
477 for (num_fields = 0, base_name = buf; *base_name != '\0'; base_name++)
478 if (*base_name == '-') num_fields++;
479 if (strchr(pattern, '*') == NULL) {
480 if (num_fields == 12) {
481 append_charset = True;
487 if (num_fields == 13 || num_fields == 14) {
489 * There are 14 fields in an XLFD name -- make certain the
490 * charset (& encoding) is placed in the correct field.
492 append_charset = True;
493 last = strrchr (buf, '-');
494 if (num_fields == 14) {
496 last = strrchr (buf, '-');
499 } else if (*last == '*') {
500 append_charset = True;
501 if (length > 3 && *(last-3) == '-' && *(last-2) == '*'
502 && *(last-1) == '-') {
508 last = strrchr (buf, '-');
510 charset_p = strrchr (buf, '-');
511 while (*(--charset_p) != '-');
516 font_set = gen->font_set;
518 font_data = font_set->font_data;
519 font_data_count = font_set->font_data_count;
520 for ( ; font_data_count-- > 0; font_data++) {
525 Limit the length of the string copy to prevent stack corruption.
526 strcpy(last, font_data->name);
528 strncpy(last, font_data->name, BUFSIZ - length);
529 buf[BUFSIZ-1] = '\0';
532 if (_XlcCompareISOLatin1(charset_p,
537 if ((font_set->font_name = get_font_name(oc, buf)))
540 if (font_set->font_name != NULL) {
546 base_name = strdup(oc->core.base_name_list);
547 if (base_name == NULL)
550 oc->core.base_name_list = base_name;
552 XFreeStringList(name_list);
556 XFreeStringList(name_list);
565 XOCGenericPart *gen = XOC_GENERIC(oc);
567 char **charset_list, *charset_buf;
570 font_set = gen->font_set;
573 if (!font_set->info && !font_set->font) {
574 length += strlen(font_set->font_data->name) + 1;
581 charset_list = Xmalloc(sizeof(char *));
582 if (charset_list == NULL)
585 charset_buf = Xmalloc(length);
586 if (charset_buf == NULL) {
591 oc->core.missing_list.charset_list = charset_list;
593 font_set = gen->font_set;
595 if (!font_set->info && !font_set->font) {
596 strcpy(charset_buf, font_set->font_data->name);
597 *charset_list++ = charset_buf;
598 charset_buf += strlen(charset_buf) + 1;
609 if (init_fontset(oc) == False)
612 found_num = parse_fontname(oc);
613 if (found_num <= 0) {
615 set_missing_list(oc);
619 if (load_font(oc) == False)
622 if (init_core_part(oc) == False)
625 if (set_missing_list(oc) == False)
635 Display *dpy = oc->core.om->core.display;
636 XOCGenericPart *gen = XOC_GENERIC(oc);
637 XFontStruct **font_list, *font;
640 Xfree(gen->font_set);
642 if (oc->core.base_name_list)
643 Xfree(oc->core.base_name_list);
645 if (oc->core.font_info.font_name_list)
646 XFreeStringList(oc->core.font_info.font_name_list);
648 if ((font_list = oc->core.font_info.font_struct_list)) {
649 if ((font = *font_list)) {
651 XFreeFont(dpy, font);
653 XFreeFontInfo(NULL, font, 1);
655 Xfree(oc->core.font_info.font_struct_list);
658 if (oc->core.missing_list.charset_list)
659 XFreeStringList(oc->core.missing_list.charset_list);
662 if (oc->core.res_name)
663 Xfree(oc->core.res_name);
664 if (oc->core.res_class)
665 Xfree(oc->core.res_class);
677 if (oc->core.resources == NULL)
680 return _XlcSetValues((XPointer) oc, oc->core.resources,
681 oc->core.num_resources, args, num_args, XlcSetMask);
690 if (oc->core.resources == NULL)
693 return _XlcGetValues((XPointer) oc, oc->core.resources,
694 oc->core.num_resources, args, num_args, XlcGetMask);
701 _Xconst wchar_t *from,
704 XlcConv conv = XOC_GENERIC(oc)->wcs_to_cs;
706 int ret, to_left = length;
709 lcd = oc->core.om->core.lcd;
710 conv = _XlcOpenConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte);
713 XOC_GENERIC(oc)->wcs_to_cs = conv;
715 _XlcResetConverter(conv);
717 ret = _XlcConvert(conv, (XPointer *) &from, &length, (XPointer *) &to,
719 if (ret != 0 || length > 0)
726 _XmbDefaultTextEscapement(XOC oc, _Xconst char *text, int length)
728 return XTextWidth(*oc->core.font_info.font_struct_list, text, length);
732 _XwcDefaultTextEscapement(XOC oc, _Xconst wchar_t *text, int length)
735 char *buf = AllocLocalBuf(length);
741 if (wcs_to_mbs(oc, buf, text, length) == False)
744 ret = _XmbDefaultTextEscapement(oc, buf, length);
753 _XmbDefaultTextExtents(XOC oc, _Xconst char *text, int length,
754 XRectangle *overall_ink, XRectangle *overall_logical)
756 int direction, logical_ascent, logical_descent;
759 XTextExtents(*oc->core.font_info.font_struct_list, text, length, &direction,
760 &logical_ascent, &logical_descent, &overall);
763 overall_ink->x = overall.lbearing;
764 overall_ink->y = -(overall.ascent);
765 overall_ink->width = overall.rbearing - overall.lbearing;
766 overall_ink->height = overall.ascent + overall.descent;
769 if (overall_logical) {
770 overall_logical->x = 0;
771 overall_logical->y = -(logical_ascent);
772 overall_logical->width = overall.width;
773 overall_logical->height = logical_ascent + logical_descent;
776 return overall.width;
780 _XwcDefaultTextExtents(XOC oc, _Xconst wchar_t *text, int length,
781 XRectangle *overall_ink, XRectangle *overall_logical)
784 char *buf = AllocLocalBuf(length);
790 if (wcs_to_mbs(oc, buf, text, length) == False)
793 ret = _XmbDefaultTextExtents(oc, buf, length, overall_ink, overall_logical);
802 _XmbDefaultTextPerCharExtents(XOC oc, _Xconst char *text, int length,
803 XRectangle *ink_buf, XRectangle *logical_buf,
804 int buf_size, int *num_chars,
805 XRectangle *overall_ink,
806 XRectangle *overall_logical)
808 XFontStruct *font = *oc->core.font_info.font_struct_list;
809 XCharStruct *def, *cs, overall;
812 if (buf_size < length)
815 bzero((char *) &overall, sizeof(XCharStruct));
818 CI_GET_DEFAULT_INFO_1D(font, def)
820 while (length-- > 0) {
821 CI_GET_CHAR_INFO_1D(font, *text, def, cs)
826 ink_buf->x = overall.width + cs->lbearing;
827 ink_buf->y = -(cs->ascent);
828 ink_buf->width = cs->rbearing - cs->lbearing;
829 ink_buf->height = cs->ascent + cs->descent;
832 logical_buf->x = overall.width;
833 logical_buf->y = -(font->ascent);
834 logical_buf->width = cs->width;
835 logical_buf->height = font->ascent + font->descent;
842 overall.ascent = max(overall.ascent, cs->ascent);
843 overall.descent = max(overall.descent, cs->descent);
844 overall.lbearing = min(overall.lbearing, overall.width +
846 overall.rbearing = max(overall.rbearing, overall.width +
848 overall.width += cs->width;
854 overall_ink->x = overall.lbearing;
855 overall_ink->y = -(overall.ascent);
856 overall_ink->width = overall.rbearing - overall.lbearing;
857 overall_ink->height = overall.ascent + overall.descent;
860 if (overall_logical) {
861 overall_logical->x = 0;
862 overall_logical->y = -(font->ascent);
863 overall_logical->width = overall.width;
864 overall_logical->height = font->ascent + font->descent;
871 _XwcDefaultTextPerCharExtents(XOC oc, _Xconst wchar_t *text, int length,
872 XRectangle *ink_buf, XRectangle *logical_buf,
873 int buf_size, int *num_chars,
874 XRectangle *overall_ink,
875 XRectangle *overall_logical)
878 char *buf = AllocLocalBuf(length);
884 if (wcs_to_mbs(oc, buf, text, length) == False)
887 ret = _XmbDefaultTextPerCharExtents(oc, buf, length, ink_buf, logical_buf,
888 buf_size, num_chars, overall_ink,
898 _XmbDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
899 _Xconst char *text, int length)
901 XFontStruct *font = *oc->core.font_info.font_struct_list;
903 XSetFont(dpy, gc, font->fid);
904 XDrawString(dpy, d, gc, x, y, text, length);
906 return XTextWidth(font, text, length);
910 _XwcDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
911 _Xconst wchar_t *text, int length)
914 char *buf = AllocLocalBuf(length);
920 if (wcs_to_mbs(oc, buf, text, length) == False)
923 ret = _XmbDefaultDrawString(dpy, d, oc, gc, x, y, buf, length);
932 _XmbDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
933 int y, _Xconst char *text, int length)
935 XSetFont(dpy, gc, (*oc->core.font_info.font_struct_list)->fid);
936 XDrawImageString(dpy, d, gc, x, y, text, length);
940 _XwcDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
941 int y, _Xconst wchar_t *text, int length)
944 char *buf = AllocLocalBuf(length);
949 if (wcs_to_mbs(oc, buf, text, length) == False)
952 _XmbDefaultDrawImageString(dpy, d, oc, gc, x, y, buf, length);
958 static _Xconst XOCMethodsRec oc_default_methods = {
962 _XmbDefaultTextEscapement,
963 _XmbDefaultTextExtents,
964 _XmbDefaultTextPerCharExtents,
965 _XmbDefaultDrawString,
966 _XmbDefaultDrawImageString,
967 _XwcDefaultTextEscapement,
968 _XwcDefaultTextExtents,
969 _XwcDefaultTextPerCharExtents,
970 _XwcDefaultDrawString,
971 _XwcDefaultDrawImageString
974 static XlcResource oc_resources[] = {
975 { XNBaseFontName, NULLQUARK, sizeof(char *),
976 XOffsetOf(XOCRec, core.base_name_list), XlcCreateMask | XlcGetMask },
977 { XNOMAutomatic, NULLQUARK, sizeof(Bool),
978 XOffsetOf(XOCRec, core.om_automatic), XlcGetMask },
979 { XNMissingCharSet, NULLQUARK, sizeof(XOMCharSetList),
980 XOffsetOf(XOCRec, core.missing_list), XlcGetMask },
981 { XNDefaultString, NULLQUARK, sizeof(char *),
982 XOffsetOf(XOCRec, core.default_string), XlcGetMask },
983 { XNOrientation, NULLQUARK, sizeof(XOrientation),
984 XOffsetOf(XOCRec, core.orientation), XlcSetMask | XlcGetMask },
985 { XNResourceName, NULLQUARK, sizeof(char *),
986 XOffsetOf(XOCRec, core.res_name), XlcSetMask | XlcGetMask },
987 { XNResourceClass, NULLQUARK, sizeof(char *),
988 XOffsetOf(XOCRec, core.res_class), XlcSetMask | XlcGetMask },
989 { XNFontInfo, NULLQUARK, sizeof(XOMFontInfo),
990 XOffsetOf(XOCRec, core.font_info), XlcGetMask }
1001 oc = Xcalloc(1, sizeof(XOCGenericRec));
1007 if (oc_resources[0].xrm_name == NULLQUARK)
1008 _XlcCompileResourceList(oc_resources, XlcNumber(oc_resources));
1010 if (_XlcSetValues((XPointer) oc, oc_resources, XlcNumber(oc_resources),
1011 args, num_args, XlcCreateMask | XlcDefaultMask))
1014 if (oc->core.base_name_list == NULL)
1017 oc->core.resources = oc_resources;
1018 oc->core.num_resources = XlcNumber(oc_resources);
1020 if (create_fontset(oc) == False)
1023 oc->methods = (XOCMethods)&oc_default_methods;
1037 XOMGenericPart *gen = XOM_GENERIC(om);
1042 if ((data = gen->data)) {
1043 if (data->font_data) {
1044 for (font_data = data->font_data, count = data->font_data_count;
1045 count-- > 0 ; font_data++) {
1046 if (font_data->name)
1047 Xfree(font_data->name);
1049 Xfree(data->font_data);
1054 if (om->core.res_name)
1055 Xfree(om->core.res_name);
1056 if (om->core.res_class)
1057 Xfree(om->core.res_class);
1058 if (om->core.required_charset.charset_list)
1059 XFreeStringList(om->core.required_charset.charset_list);
1061 Xfree((char*)om->core.required_charset.charset_list);
1062 if (om->core.orientation_list.orientation)
1063 Xfree(om->core.orientation_list.orientation);
1076 if (om->core.resources == NULL)
1079 return _XlcSetValues((XPointer) om, om->core.resources,
1080 om->core.num_resources, args, num_args, XlcSetMask);
1089 if (om->core.resources == NULL)
1092 return _XlcGetValues((XPointer) om, om->core.resources,
1093 om->core.num_resources, args, num_args, XlcGetMask);
1096 static _Xconst XOMMethodsRec methods = {
1103 static XlcResource om_resources[] = {
1104 { XNRequiredCharSet, NULLQUARK, sizeof(XOMCharSetList),
1105 XOffsetOf(XOMRec, core.required_charset), XlcGetMask },
1106 { XNQueryOrientation, NULLQUARK, sizeof(XOMOrientation),
1107 XOffsetOf(XOMRec, core.orientation_list), XlcGetMask },
1108 { XNDirectionalDependentDrawing, NULLQUARK, sizeof(Bool),
1109 XOffsetOf(XOMRec, core.directional_dependent), XlcGetMask },
1110 { XNContextualDrawing, NULLQUARK, sizeof(Bool),
1111 XOffsetOf(XOMRec, core.contextual_drawing), XlcGetMask }
1118 XOMGenericPart *gen = XOM_GENERIC(om);
1121 new = Xcalloc(1, sizeof(OMDataRec));
1131 static _Xconst char *supported_charset_list[] = {
1133 /* fix for bug4332979 */
1134 "adobe-fontspecific",
1135 /* fix for bug4237353: "JISX0201.1976-0" entry should be removed from
1136 supported_charset_list because it is not a supported_charset for C locale
1137 "JISX0201.1976-0", */
1146 XOMGenericPart *gen = XOM_GENERIC(om);
1149 char **required_list;
1150 XOrientation *orientation;
1152 int i, count, length = 0;
1154 count = XlcNumber(supported_charset_list);
1156 data = add_data(om);
1160 font_data = Xcalloc(count, sizeof(FontDataRec));
1161 if (font_data == NULL)
1163 data->font_data = font_data;
1164 data->font_data_count = count;
1166 for (i = 0; i < count; i++, font_data++) {
1167 font_data->name = strdup(supported_charset_list[i]);
1168 if (font_data->name == NULL)
1172 length += strlen(data->font_data->name) + 1;
1174 /* required charset list */
1175 required_list = Xmalloc(sizeof(char *));
1176 if (required_list == NULL)
1179 bufptr = Xmalloc(length);
1180 if (bufptr == NULL) {
1181 Xfree(required_list);
1185 om->core.required_charset.charset_list = required_list;
1186 om->core.required_charset.charset_count = 1; /* always 1 */
1190 strcpy(bufptr, data->font_data->name);
1191 *required_list++ = bufptr;
1192 bufptr += strlen(bufptr) + 1;
1194 /* orientation list */
1195 orientation = Xmalloc(sizeof(XOrientation));
1196 if (orientation == NULL)
1199 *orientation = XOMOrientation_LTR_TTB;
1200 om->core.orientation_list.orientation = orientation;
1201 om->core.orientation_list.num_orientation = 1;
1203 /* directional dependent drawing */
1204 om->core.directional_dependent = False;
1206 /* contexual drawing */
1207 om->core.contextual_drawing = False;
1209 /* context dependent */
1210 om->core.context_dependent = False;
1216 _XDefaultOpenOM(XLCd lcd, Display *dpy, XrmDatabase rdb,
1217 _Xconst char *res_name, _Xconst char *res_class)
1221 om = Xcalloc(1, sizeof(XOMGenericRec));
1225 om->methods = (XOMMethods)&methods;
1227 om->core.display = dpy;
1230 om->core.res_name = strdup(res_name);
1231 if (om->core.res_name == NULL)
1235 om->core.res_class = strdup(res_class);
1236 if (om->core.res_class == NULL)
1240 if (om_resources[0].xrm_name == NULLQUARK)
1241 _XlcCompileResourceList(om_resources, XlcNumber(om_resources));
1243 om->core.resources = om_resources;
1244 om->core.num_resources = XlcNumber(om_resources);
1246 if (init_om(om) == False)