[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

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

2853.0. "mixed fonts example, what is a character set?" by BEAGLE::LAFORGUE (It works better if you plug it!) Fri Jun 01 1990 12:00

Here is an example of label and pushbutton widget displaying a compound
string witha different font for each segment of the compound string.

I had to use a different character set for each segment and this bring
us the the question:
What is exactly a character set?
Is there internally any difference between all the character sets of
8 bits writing from left to right.
For exemple what is the difference between ISO-LATIN1, ISO-LATIN2 and
ISO-LATIN_GREEK?

Where can I find the description of ISO standard 8859-1 8859-2 or 8859-7

These questions are very important for a big business with the EEC in
Europe.

Bernard


/* hellocshigh.c  1.4  90/06/01 */
/* derived from hellohigh v1.3 */
/* this exemple shows how compound string can mix two different fonts
  by associating them to different character sets
  The first exemple is a mix of latin and greek alphabet, using the
  LATIN-GREEK character set,
  the second example "Bye WORLD" mixes normal and bold by using
  LATIN-2 charcter set, which was probablibly not the original purpose
*/
#include <stdio.h>
#include <X11/DECwDwtApplProg.h>
static void helloworld_button_activate();
static DwtCallback callback_arg[2];
Widget label;
static unsigned long charset1 = 1; /* LATIN-1 (see include file cda_def.h) */
static unsigned long charset2 = 4; /* LATIN-GREEK */
static unsigned long charset3 = 2; /* LATIN-2 */

int main(argc, argv)
unsigned int argc;
char **argv;
{
    Widget toplevel, helloworldmain, button;
    DwtCompString cs1, cs2;
    DwtFontList  font_list;
    Arg arglist[2];
    /******** Set up the User Interface **********/
    toplevel = XtInitialize("hellocshigh","Helloclass", NULL, 0, &argc, argv);
    XtSetArg (arglist[0], XtNallowShellResize, TRUE) ;
    XtSetValues (toplevel, arglist, 1) ;
    helloworldmain = DwtDialogBox( toplevel, "mainwin", TRUE, 0, 0,
    DwtLatin1String("Hi v1.4"), DwtWorkarea, 0, 0);

    /* create the font list */
    font_list = DwtCreateFontList(XLoadQueryFont(XtDisplay(toplevel),
      "-*-Times-Medium-R-Normal--*-140-*-*-P-*-*-*"), charset1);
    font_list = DwtAddFontList(font_list, XLoadQueryFont(XtDisplay(toplevel),
      "-*-Symbol-Medium-R-Normal--*-140-*-*-P-*-*-*"), charset2);
    font_list = DwtAddFontList(font_list, XLoadQueryFont(XtDisplay(toplevel),
      "-*-Helvetica-Bold-R-Normal--*-180-*-*-P-*-*-*"), charset3);
    XtSetArg(arglist[0], DwtNfont,	font_list);

    /* create the compound strings */
    cs1 = DwtCStrcat(DwtLatin1String("Press button once\nto change label;\n"),
		       DwtCSString("twice to exit", charset2, False));
    cs2 = DwtCStrcat(DwtCSString("Hello ", charset1, False),
		       DwtCSString("World", charset2, False));
    label = DwtLabel( helloworldmain, "label", 0, 0, cs1, 0);
    XtSetValues (label, arglist, 1) ;
    XtManageChild(label);
    callback_arg[0].proc = helloworld_button_activate;
    callback_arg[0].tag = 0;
    callback_arg[1].proc = NULL;
    button = DwtPushButton( helloworldmain, "button", 15, 40, cs2,
		 callback_arg, 0);
    XtSetValues (button, arglist, 1) ;
    XtManageChild( button);
    XtManageChild( helloworldmain);
    XtRealizeWidget( toplevel);
    XtMainLoop();
    return
    (0);
}
static void helloworld_button_activate( widget, tag, callback_data)
Widget widget;
char *tag;
DwtAnyCallbackStruct *callback_data;
{
Arg arglist[2];
static int call_count = 0;
call_count += 1 ;
switch ( call_count)
    {
    case 1:
        XtSetArg( arglist[0], DwtNlabel,
	    DwtCStrcat(DwtCSString("Bye ", charset1, False),
		       DwtCSString("World", charset3, False)));
        XtSetValues( widget, arglist, 1);
        XtSetArg( arglist[0], DwtNlabel,
            DwtLatin1String("Press button to exit."));
        XtSetValues( label, arglist, 1);
        break ;
    case 2:
        exit(1);
        break ;
    }
}
T.RTitleUserPersonal
Name
DateLines
2853.1Where to find out about character setsSTAR::VATNEPeter Vatne, VMS DevelopmentFri Jun 01 1990 12:3325
You can find out tons of information about character sets in the
conference LEVEL::DEC_STD_169 (hit KP7 to add).

To answer your direct question, yes, there is quite a bit of difference
internally between the different character sets.  The basic problem is
that our standard character size of 8 bits is enough to represent 256
different characters, but if you want to treat the Latin, Greek, Cyrillic,
Hebrew, Arabic, etc., characters as different characters, then you need to
represent far more than 256 characters.  There are two possible solutions:
either you expand the size of your characters, or you re-use the
character values and have some way to decide which character is meant.

Expanding the size of characters is in some respects the ideal solution,
and work is being done to define a universal character set.  However,
it should be obvious that without some sort of compression scheme, such
"wide characters" will chew up lots of memory and disk space.

Re-use of character values is what is most often done.  The mapping of
characters from a language (or set of languages) onto the 256 values
is called a character set.  The application must always be aware of
which mapping is intended.  All normal text files on VMS and Ultrix
use the Latin-1 character set mapping by default.  To use other character
sets, I believe it is best to use DDIF, as that format includes all the
necessary meta-data for applications to know which character set is
supposed to be used with each character string.
2853.2Character sets in compound strings?LEOVAX::TREGGIARISat Jun 02 1990 09:2114
    If your question is what does a character set mean to compound strings,
    the answer is absolutely nothing.  The character set identifiers are
    mearly a means of matching compound string text segments to fonts in
    the font list; nothing else.  So, you can "cheat" and use the same
    mechanism to display a compound string in different size fonts.
    The *real* constraint is that the byte values in the text match the
    glyphs in the font that is gets matched to.  If the text if ISOLATIN1
    and the font is ISOLATIN1, you're all set.  Motif makes it a little
    easier to "cheat" since character set identifiers are strings rather
    than a set of hard-coded integers.  But there is still no *straight-
    forward* way to display text of the same character set in different
    size fonts in one compound string.
    
    Leo
2853.3Please use things legally!MARKB::BRAMHALLMark Bramhall, CDA architecture, E PLURIBUS UNUMMon Jun 04 1990 10:5621
    While the current implementation of compound strings in the DECwindows
    toolkit may not ascribe any real character set meaning to the character
    set field of each segment, it is a very bad idea indeed to cheat and
    not put the real character set in that field! It will certainly come
    back and bite you sometime later.
    
    Fonts and character sets are very different concepts -- and confused by
    many people and applications. Extremely briefly, a font is a collection
    of character shapes all in the same style (like Helvetica, Times,
    etc.). A character set (or, more properly, a coded character set) is
    the relationship between a set of values (usually 32-127, 160-255) and
    a set of characters. For example, 65 is A in ASCII. Assuming that
    you've named all characters (there is official ISO work in progress to
    do this) then you can map a value to a character name via some coded
    character set and then map a character name to a shape (glyph) via some
    font.
    
    Compound strings are intended to be data-only strings. So,
    appearance-only things like fonts are not usually stored in them. But,
    content information like the coded character set for the character
    values is always needed.
2853.4use compound string power is illegal: what a pity!BEAGLE::LAFORGUEIt works better if you plug it!Tue Jun 05 1990 07:0016
    Thanks a lot to Peter, Leo and Mark for the very clear explanations.
    
    I agree with Mark who wants to use the things legally, but as the
    compound string implementation is able to mix different fonts, it
    is a pity not being able to use it legally.
       Think to complexity of the problem to display a text with two
    fonts having not the same size. Try to do yourself: you will have
    to compute the size of the first text to set the position of the
    second, therefore you must do queries about the geometry of each
    characters and so on... 
       All this work is done and well done in the DECwindows widget
    and you are not allowed to use it without cheating.
      
    Thanks,
    Bernard
    
2853.5The *real* solution is just a SMOPMARKB::BRAMHALLMark Bramhall, CDA architecture, E PLURIBUS UNUMTue Jun 05 1990 20:399
    I would be more likely to say cheating was OK if I thought that there
    was a roadblock in the way of a real solution. But, in this case, it is
    a "small matter of programming" to keep the use of compound strings
    compeltely legal *and* have multiple fonts!
    
    It would be done not by misusing the coded character set field, but by
    adding the code to enable the font field of compound strings! There are
    many defined fields of compound strings that are not yet enabled by the
    code. For example: bold, italic, underline, etc.
2853.6How about 3 readable fonts in same string?CSC32::JJONESJeff JonesTue Sep 18 1990 14:5015
    Ok, .0 has shown me how to have 2 different "English-readable" fonts in
    the same string.
    
    2 questions:
    
    	Is this the way to do it?
    
    	And what if I want more than 2 different fonts in the same string?
    	How do I do that? Because in looking at it, only ISOLATINT1 & 2
    	produce "English-readable" text. Sure, I can have 3 fonts by .0's 
    	example, but I can only read 2; and only 2 ISOLATIN fonts are
    	defined.
    
    Help please,
    jjjones
2853.7VToolKit is the way...CSC32::JJONESJeff JonesWed Sep 19 1990 20:007
    Geez... make me answer my own questions! ;^)
    
    Steve Klein's VToolKit has excellent examples on how to do just this.
    
    	DW_EXAMPLES TOPIC 404
    
    jjjones