Title: | DECWINDOWS 26-JAN-89 to 29-NOV-90 |
Notice: | See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit |
Moderator: | STAR::VATNE |
Created: | Mon Oct 30 1989 |
Last Modified: | Mon Dec 31 1990 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 3726 |
Total number of notes: | 19516 |
I'm having trouble putting non-DwtLatin1String fonts into button labels - I'd appreciate some help on what's the sequence of things to do. I have tried variations of the following: 1. DwtFontList font_list; fontlist = XListFonts( display,"*",300, &nfonts ); which returns lots of good names like: "-Adobe-Courier-Medium-R-Normal--8-80-75-75-M-50-ISO8859-1". 2. XFontStruct *pfont; pfont = XLoadQueryFont( display, fontlist[i]); and pfont seems to have meaningfull looking values. ! ext_data: 00000000 ! fid: 00600018 ! direction: 00000000 ! min_char_or_byte2: 00000020 ! max_char_or_byte2: 000000FF ! min_byte1: 00000000 ! max_byte1: 00000000 ! all_chars_exist: 00000000 ! default_char: 00000000 ! n_properties: 00000018 ! properties: 006F9DB8 ! min_bounds ! lbearing: 0FFFF ! rbearing: 0001 ! width: 0005 ! ascent: 0000 ! descent: 0FFFB ! attributes: 0000 ! max_bounds ! lbearing: 0002 ! rbearing: 0006 ! width: 0005 ! ascent: 0007 ! descent: 0002 ! attributes: 0000 ! per_char: 006F9E90 ! ascent: 00000006 ! descent: 00000002 3. DwtFontList font_list; font_list = DwtCreateFontList( pfont, charset ); I surmise from the documentation that this is a way to go. Question, though, is what is charset. I don't see any relationship between the names in fontlist[] and the entries in CDA$DEF.H: In addition I need a smaller font - are there any here which are 8 pt.? /* Character set identification codes (DEC STD 169). */ #define CDA$K_ISO_LATIN1 1 /* ISO Latin 1 (ISO 8859-1) */ #define CDA$K_ISO_LATIN2 2 /* ISO Latin 2 (ISO 8859-2) */ #define CDA$K_ISO_LATIN6 3 /* ISO Latin-Arabic (ISO 8859-6) */ #define CDA$K_ISO_LATIN7 4 /* ISO Latin-Greek (ISO 8859-7) */ #define CDA$K_ISO_LATIN8 6 /* ISO Latin-Hebrew (ISO 8859-8) */ #define CDA$K_JIS_KATAKANA 32 /* JIS Roman, JIS Katakana (JIS X0201) */ #define CDA$K_DEC_TECH 33 /* DEC Special Graphics, DEC Technical */ #define CDA$K_DEC_MATH_ITALIC 34 /* DEC Mathematics Italic */ #define CDA$K_DEC_MATH_SYMBOL 35 /* DEC Mathematics Symbol */ #define CDA$K_DEC_MATH_EXTENSION 36 /* DEC Mathematics Extension */ #define CDA$K_DEC_PUBLISHING 37 /* DEC Publishing */ #define CDA$K_DEC_KANJI 64 /* DEC Kanji (JIS X0208) */ #define CDA$K_DEC_HANZI 65 /* DEC Hanzi (GB 2312) */ 4. Finally what I want to do is: compstring = DwtCSString(string,charset,0,0,0); XtSetArg(arg_list[arg_count], DwtNlabel,compstring); and button = DwtPushButtonCreate( menu, string, arg_list, arg_count ); Thanks, Randy K.
T.R | Title | User | Personal Name | Date | Lines |
---|---|---|---|---|---|
797.1 | RTL::BOLGATZ | Tue May 23 1989 10:25 | 197 | ||
Randy - you're close... First off, you're right - there is no direct relationship between the charset and fonts -- that list is the best you'll get. (I am told that there is a proposal to get the charsets and fonts matched up...) The 1st number is the pixel size, the second is the point size (devide by ten). So the font you mention in #1 is an 8 point font. (For a complete description of the FontName syntax, see section 10.2 in the Font memo in the next reply). I have included a test driver that demonstrates how to set a font... Jay #ifdef VMS #include "decw$include:decwdwtwidgetprog.h" #else #include "/usr/include/X11/DECwDwtWidgetProg.h" #endif #include <decw$include/cda$def.h> XFontStruct *x_font_list; DwtFontList good_font_list; /* Command line options table. Only resources are entered here...there is a pass over the remaining options after XtParseCommand is let loose. */ static XrmOptionDescRec options[] = { {"-label", XtNlabel, XrmoptionSepArg, NULL} }; /* * Report the syntax for calling xlabel */ Syntax(call) char *call; { } static Widget textwid; static Widget toplevel, create_fs_pb, change_fs_pb, exit_fs_pb, work, mainw; static void bye_bye() { exit(1); } static DwtCallback bye_bye_cb[2] = { {(VoidProc) bye_bye, NULL}, {NULL, NULL} }; static void ChangeAttributes() { Arg al[10]; int ac = 0; x_font_list = XLoadQueryFont(XtDisplay(mainw), "-*-Courier-BOLD-R-Normal--*-120-*-*-M-*-*-*"); good_font_list = DwtCreateFontList(x_font_list, CDA$K_ISO_LATIN8); XtSetArg(al[ac], DwtNfont, good_font_list); ac++; XtSetValues(textwid, al, ac); } static DwtCallback change_cb[2] = { {(VoidProc) ChangeAttributes, NULL}, {NULL, NULL} }; static void manage() { XtManageChild(textwid); }; static DwtCallback manage_cb[2] = { {(VoidProc) manage, NULL}, {NULL, NULL} }; static void unmanage() { XtUnmanageChild(textwid); }; static DwtCallback unmanage_cb[2] = { {(VoidProc) unmanage, NULL}, {NULL, NULL} }; int main(argc, argv) unsigned int argc; char **argv; { Arg arglist[20]; int argCount = 0; char *dirmask, *value; int *dpy; { char c[6]; int i; sscanf("1234$","%d",&i); sprintf(c,"%d",12345); } toplevel = XtInitialize( argv[0], "XLabel", options, 1, &argc, argv); DwtSetArg("TRUE",arglist,0,XtNallowShellResize); XtSetValues(toplevel,arglist,1); mainw = DwtMainWindow(toplevel,"main",0,0,300,300); XtManageChild(mainw); work = DwtDialogBoxCreate(mainw,"work",NULL,0); XtManageChild(work); create_fs_pb = DwtPushButton(work, "create fs pb", 20,20, DwtLatin1String("manage fs widget"), manage_cb,NULL); XtManageChild(create_fs_pb); change_fs_pb = DwtPushButton(work, "change fs pb", 20,40, DwtLatin1String("change fs widget"), change_cb,NULL); XtManageChild(change_fs_pb); exit_fs_pb = DwtPushButton(work, "exit fs pb", 20,60, DwtLatin1String("exit"), bye_bye_cb,NULL); XtManageChild(exit_fs_pb); XtSetArg(arglist[argCount], DwtNx, 20); argCount++; XtSetArg(arglist[argCount], DwtNy, 80); argCount++; XtSetArg(arglist[argCount], DwtNrows, 1); argCount++; XtSetArg(arglist[argCount], DwtNcols, 25); argCount++; /* XtSetArg(arglist[argCount], DwtNfont, (fs->dialog.fontlist + 0) ); argCount++; */ textwid = DwtSTextCreate( work, "Test TextWidget", arglist, argCount); XtManageChild(textwid); DwtMainSetAreas (mainw, NULL, work, 0, 0, 0); XtRealizeWidget(toplevel); dpy = DwtGetDisplay(toplevel); XSynchronize(dpy, TRUE); XtMainLoop(); /* UNREACHABLE */ return (0); } | |||||
797.2 | font name syntax... | RTL::BOLGATZ | Tue May 23 1989 10:36 | 10 | |
font name syntax: FOUNDRY, FAMILY_NAME, WEIGHT_NAME, SLANT, SETWIDTH_NAME, ADD_STYLE_NAME, PIXEL_SIZE, POINT_SIZE, RESOLUTION_X, RESOLUTION_Y, SPACING, AVERAGE_WIDTH, CHARSET_REGISTRY, CHARSET_ENCODING, FONT_ASCENT, FONT_DESCENT, CAP_HEIGHT, FACE_NAME, COPYRIGHT, NOTICE | |||||
797.3 | DwtCreateFontList-what IS charset? | DSSDEV::KEZAR | Wed May 24 1989 13:49 | 22 | |
Thanks very much - I really appreciate the help! The following works fine (knowing that dpi = 75) but I'm confused still by what charset is and how it doesn't seem to have any effect in the sequence below. I've patched in charset = 1,2,3,32 and still get what looks like whatever font is named in fontlist[0]. fontlist = XListFonts( display, "-Adobe-Helvetica-Medium-R-Normal--10-100-75-75-P-56-ISO8859-1", 2, &nfonts ); pfont = XLoadQueryFont( display, fontlist[0] ); font_list = DwtCreateFontList( pfont, charset ); >>> ------- XtSetArg( arg_list[arg_count], DwtNfont, font_list ); XtSetValues( menu, arg_list, arg_count ); Randy | |||||
797.4 | 2520::TREGGIARI | Thu May 25 1989 12:52 | 23 | ||
> The following works fine (knowing that dpi = 75) but I'm confused > still by what charset is and how it doesn't seem to have any > effect in the sequence below. I've patched in charset = 1,2,3,32 The "charset" you pass to DwtCreateFontList must be one of the character set constants out of SYS$LIBRARY:CDA$DEF.H. If you look in that file you will also see the relationship between the charset ids and the names at the end of the font names. For example: #define CDA$K_ISO_LATIN1 1 /* ISO Latin 1 (ISO 8859-1) */ ^ ^ ^ name number looks like name at end of font that goes with it. The reason it is working no matter what you put in there, is that if the toolkit can't find a "match" in the fontlist, it uses the first entry in the fontlist (and your fontlist only contains 1 entry...). Leo | |||||
797.5 | charset matching? | 2167::KEZAR | Tue May 30 1989 10:52 | 18 | |
Reply to .4 Thsnks for the info about default selection from fontlist if charset does not have a match. Is that a guaranteed functionality - if so - then is it safe to assume that charset = -1 (say) will *never* match and will force the selection from fontlist. How about in this case an appropriate definition of CDA$K_* which will do this? It's also still not clear to me how the "match" is done (from the point of view of CDA$DEF.H). With the names I get back from XListFonts, and the naming conventions described in note 620.4, it looks as if many fonts can match the typical /* comment font description */. I'm concerned about possible matching changes and an application ending up with a different font. Randy | |||||
797.6 | 2520::TREGGIARI | Tue May 30 1989 11:32 | 22 | ||
> Is that a guaranteed functionality - if so - then is it safe to assume that > charset = -1 (say) will *never* match and will force the selection from > fontlist. How about in this case an appropriate definition of CDA$K_* which > will do this? No, it's not guaranteed. I was merely explaining to you why it was behaving the way it was. > It's also still not clear to me how the "match" is done (from the point of > view of CDA$DEF.H). With the names I get back from XListFonts, and > the naming conventions described in note 620.4, it looks as if many fonts > can match the typical /* comment font description */. I'm concerned about > possible matching changes and an application ending up with a different font. The toolkit is not doing any automatic matching for you. The CDA$K_* constants appear both in the compound string and the font list. That is all the toolkit "matches". It doesn't look at the logical font name at all. It's up to the application to ensure that the right font is in the font list associated with the right CDA$K_* constant. Leo | |||||
797.7 | changing font in unmanaged stext widget | HPSCAD::SMORRISON | Sue Morrison | Thu Nov 02 1989 17:30 | 32 |
Is it true that an SText widget must be managed and realized before its font can be changed? I am getting an error at the XtSetValues call in the code below. If I move the XtManageChild to before the XtSetValues it seems to work. Sue ****************************************************************************** void popup_stext (Widget parent, int x, int y) { XFontStruct *font; DwtFontList font_list; Arg al[20]; int ac=0; popup = DwtSText ( parent, /* parent widget */ "", /* no name */ x, y, /* location */ 15, /* columns */ 1, /* rows */ ""); /* initial string value */ font = XLoadQueryFont (dpy, "-Adobe-Courier-Medium-R-Normal--12-120*"); font_list = DwtCreateFontList (font, CDA$K_ISO_LATIN8); XtSetArg (al[ac], DwtNfont, font_list); ac++; XtSetValues (popup, al, ac); XtManageChild (popup); } |