Where goest my True Type fonts?

Автор: Richard K. Goran

Дата: December, 1995

Источник: EDM/2

WIN-ATM Object Setting

Many OS/2 users have found that they can no longer use their True Type fonts under OS/2. The remedy is very simple - just change the WIN_ATM setting in the Settings notebook for the WIN-OS/2 object in question. The OS/2 Warp default is to have WIN_ATM set to off as shown in [#Figure 1 Figure 1]. If there are just one or two objects that require this setting to be changed, it is not a very time consuming nor difficult task to make these changes. However, if you have vary many of these WIN-OS/2 program objects, it could be a laborious task to change each of these objects manually. This is the tie-in between these object's settings and this column which is primarily devoted to REXX. This column may get a little more technical than many of you would like; however, the end result will provide you with the knowledge and the capability to create your own REXX program to enable the WIN_ATM setting for all of your WIN-OS/2 program objects. If the details bore you, you can simply download the finished product ([../pub/winatmon.zip winatmon.zip]) and run it on your system.

9512fg01.jpg
Figure 1

REXXUTIL, the function package that is part of the standard OS/2 REXX package and contains all of the commonly known functions that begin with Sys provides the capability to create and modify Workplace Shell (WPS) objects but has no ability to query objects about their settings or other properties. This shortcoming was overcome by the DeskMan/2 commercial product but DeskMan/2 was not intended as a user Application Program Interface (API) to allow the user to interrogate WPS objects from within his own REXX programs. Fortunately, there is an API written by Henk Kelder of the Netherlands and available free of charge which provides that capability. Kelder's package is available on most OS/2 repositories, including [../pub/welcome.htm#wptool this site], as file wptool19.zip.

One other capability that is needed is the ability to reference WPS objects by their handle (a persistent object identity whose explanation goes beyond the scope of this column). This function is provided in the REXXLIB API from Quercus Systems.

The REXXUTIL functions require that all object manipulation be done with reference to an object ID or the full file system name for file system objects (directories and files). An object ID is a string of characters bounded by less than (<) and greater than (>) characters respectively and normally assigned to a WPS object when that object is created. If a non-file system object - an abstract object - is created without an object ID, the standard REXXUTIL functions cannot be used to reference that object. However, all objects have a persistent identity known as the object's handle. The REXXLIB extensions provide the capability to alter an object's settings by referencing the object by its handle - even to the point of allowing an object ID to be assigned to any object previously created without one. Most of the WPS objects for WIN-OS/2 programs fall into this category - they were created with an object ID.

Overall steps

The APIs that are required are included in the files rexxutil.dll, rexxlib.dll, and wptools.dll. They are registered using the built-in REXX RxFuncAdd() function (Fragment 1). These DLLs must be in a directory that is named in LIBPATH statement in config.sys, reside in a directory named in a BeginLibPath or EndLibPath environment variable, or reside in the same directory of the calling program (presuming that ".;" is included in the LIBPATH statement).

An output file is defined so that a record can be made of all of the WIN-OS/2 objects that are changed. The output file name is built from the path and file name of the calling program with a file extension of TXT - winatmon.txt.

All WIN-OS/2 objects will have a program type selected from one of the following types: PROG_31_ENH, PROG_31_ENHSEAMLESSCOMMON, PROG_31_ENHSEAMLESSVDM, SEPARATEWIN, WIN, WINDOWEDWIN. By interrogating all of the WPS program objects that are included in the PM_Abstract:Objects section of the os2.ini file, ignoring those that do not have a PROGTYPE= value included in the above list, we are left with all of the WIN-OS/2 program objects ([#Fragment 2 Fragment 2]).

Ignoring those objects that already have a setting of WIN_ATM=1;, we are left with only those objects that are to be modified. Since we have the object's handle from the data retrieved from the os2.ini file, and REXXLIB has been extended to allow an object's setup string to be altered simply by using the file's object handle as its identifier, we simply have to supply a setup string of WIN_ATM=1; to effect the desired change ([#Fragment 3 Fragment 3]).

Fragment 1

if RxFuncQuery( 'SysLoadFuncs' ) \= 0 then
   do
      call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
      call SysLoadFuncs
   end

if RxFuncQuery( 'rexxlibregister' ) \= 0 then
   do
      call RxFuncAdd 'REXXLibRegister', 'REXXLIB', 'rexxlibregister'
      call REXXLibRegister
   end

if RxFuncQuery( 'WPToolsLoadFuncs' ) \= 0 then
   do
      call RxFuncAdd 'WPToolsLoadFuncs', 'WPTOOLS', 'WPToolsLoadFuncs'
      call WPToolsLoadFuncs
   end

Fragment 2

 /*----------------------------------*\
 |  Output file is program name .TXT  |
 \*----------------------------------*/
 GBL.output_file =,
    GBL.program_path ||,
    GBL.program_fn || '.TXT'
 call SysFileDelete GBL.output_file
 
 /*--------------------------*\
 |  Windows PROGTYPE= values  |
 \*--------------------------*/
 windows_progtype_list =,
    'PROG_31_ENH',
    'PROG_31_ENHSEAMLESSCOMMON',
    'PROG_31_ENHSEAMLESSVDM',
    'SEPARATEWIN',
    'WIN',
    'WINDOWEDWIN',
    ''
 

Fragment 3

 /*-----------------------------------------*\
 |  Get list of object handles from OS2.INI  |
 \*-----------------------------------------*/
 app = 'PM_Abstract:Objects'
 call SysIni 'USER', app, 'ALL:', 'handle_stem'
 if handle_stem.0 = 0 then
    do
       say '   Unable to locate ' ||,
           app                    ||,
           ' in '                 ||,
           VALUE( 'USER_INI',, 'OS2ENVIRONMENT' )
       call EOJ
    end
 
 /*---------------------------------------*\
 |  Process each PM_Abstract:Object entry  |
 \*---------------------------------------*/
 do h = 1 to handle_stem.0
    hex_handle = handle_stem.h
    dec_handle = X2D( '2' || RIGHT( hex_handle, 4, '0' ) )
 
    /*-----------------------------*\
    |  Process each program object  |
    \*-----------------------------*/
    hex_handle_string = '#2' || RIGHT( hex_handle, 4, '0' )
    call WPToolsQueryObject hex_handle_string,,
                            'class',,
                            'title',,
                            'setup_string',,
                            'location'
    if RESULT = 0 then
       do
          say '   WPToolsQueryObject was unsuccessful for object ' ||,
              hex_handle_string                                    ||,
              ' object ignored.'
          iterate h                  /* ignore this object */
       end
 
    /*-----------------------------------------------------*\
    |  Identify Windows or WIN-OS/2 programs via PROGTYPE=  |
    \*-----------------------------------------------------*/
    parse value setup_string with,
       'PROGTYPE=',
       object_progtype,
       ';'
    if object_progtype = '' then
       do
          iterate h                  /* ignore this object */
       end
 
    /* See if PROGTYPE value is in table */
    if WORDPOS( object_progtype, windows_progtype_list ) = 0 then
       do
          iterate h                  /* ignore this object */
       end
 
    /*----------------------------------------*\
    |  Ignore object if WIN_ATM=1 already set  |
    \*----------------------------------------*/
    win_atm_search_arg = 'WIN_ATM='
    win_atm_ptr        = POS( win_atm_search_arg, setup_string )
    if win_atm_ptr > 0 then
       do
          win_atm_value =,
              SUBSTR( setup_string,,
                      win_atm_ptr + LENGTH(win_atm_search_arg),,
                      1 )
          if win_atm_value = 1 then
             do
                iterate h            /* ignore this object */
             end
       end
       call UPDATE_SETUP_STRING
 
 end
 call STREAM GBL.output_file, 'C', 'CLOSE'
 
 call EOJ 0
 
 /*------------------------------------------------------------------------*\
 |                                                                          |
 |                Subroutine to update object's setup string                |
 |                                                                          |
 \*------------------------------------------------------------------------*/
 UPDATE_SETUP_STRING:
 
 output_line =,
    LEFT( title,    18 ),
    LEFT( location, 25 ),
    setup_string
 call LINEOUT GBL.output_file, output_line
 call WPSSetObjectData dec_handle, 'SET WIN_ATM=1;'
 if RESULT �= 1 then
    do
       say '   Unable to update setup string for ' ||,
           title                                   ||,
           ' (' || hex_handle_string || ')'
    end
 return