MMCC MASTHEAD


INDEX
ALSO SEE:


v1.10
Mid-Michigan Computer Consultants, Inc.
509 Center
Bay City, Michigan

Sales (989) 892-9242             Support (989) 686-8860

ANSI Standard PL/B Language
FONTS
NOTE TO OUR READERS
This web resource is written for our own use. But we feel strongly that the PL/B language should be shared with the software community. So feel free to use this at will! BUT PLEASE... if you find errors or omissions or have a better way to do something. TELL US! Dialog helps us all. Send e-mail to: support@mmcctech.com

FONTS
Fonts present some interesting challenges. They can be frustrating at times. You can't just get all the information you might want in one place. Secondly, the instructions to create a font and those to use a font in another object use different forms.

CREATING FONTS
For the most point, fonts can be created in the forms designer and forgotten. But there are times when you need to create them in the program and use them there.
     [label]    CREATE   {font},{name}[,{property list}...]

     MY_FONT    FONT
                CREATE   MY_FONT,"Arial",SIZE=12,BOLD
USING FONTS
Once the font has been created, you can use it for printing, for screen objects, etc.
                CREATE   STEXT1=10:11:20:60,"text",FONT1  

                CREATE   BUTTON1=16:17:35:42,"Click Me",FONT=FONT1

                PRTPAGE  PRINTER_FILE;*FONT=FONT1
SHORTCUT FONT PROPERTY
You can use a font directly as a property for an object. This does not require you to create the font in advance. The font DOES have to exist on the computer:
                CREATE   BUTTON1=16:17:35:42,"Click Me":
                           FONT="'>MS Sans Serif'(8,BOLD)"
Note YOU CANNOT use the short cut to create the font itself. The following will not work. You'll get an object error:
               .... this will get an object error:
                CREATE   MY_FONT,"'>MS Sans Serif'(8,BOLD)"
GETTING FONT INFORMATION
Here's where some of the frustration comes in.

Let's say that you create an array of fonts. Now you need to get the information about the third font in that array so that you can do something else with it. The only properties you can get about that font are:
        BOLD
        ITALIC
        SIZE
What you NEED for creating another font object is the NAME of the font. That's not directly available.

There is a trick for getting the font name, however. What you can do is apply that font to some object, like an edit text, then get the font name from THAT object. So, to get the information about a font do this:
     MY_FONT    FONT
                CREATE   FONT1,"Arial",SIZE=12,BOLD
     ..... the above is done somewhere in the program ....
     ..... now to get the information about that font do this:

     TEMP_ET    EDITTEXT
                CREATE  TEMP_ET=10:10:10:10
                SETPROP TEMP_ET,FONT=MY_FONT
                GETPROP TEMP_ET,FONT={string}       Gets the font name
                GETPROP TEMP_ET,FONT={font object}  Gets font information
                     	

COPY A FONT
Suppose you want to get the font from one object and apply it to another object. Say, in the designer you set up a font on an EditText then at run time you want to apply that font to a StatText. That's fairly simple:
     MY_FONT    FONT
                GETPROP FIRST_EditText, FONT=MY_FONT
                SETPROP SECOND_StatText,FONT=MY_FONT


DUPLICATE A FONT
Now suppose you have created a font and you want to make another font just like it for some reason. This takes a few steps:
   MY_FONT     FONT
   2ND_FONT    FONT
               CREATE  MY_FONT,"Arial",SIZE=12,BOLD  ;original font is created

   TEMP_ET     EDITTEXT
   FONT_NAME   DIM     100
   FONT_SIZE   FORM      3
   FONT_BOLD   FORM      1
   FONT_ITALIC FORM     1
               CREATE  TEMP_ET=10:10:10:10           ;temp EditText (not activated)
               SETPROP TEMP_ET,FONT=MY_FONT          ;give it MY_FONT

.              Get the NAME of the font from the edit text 
               GETPROP TEMP_ET,FONT=FONT_NAME        ;string gets the font name

.              Get the FONT itself from the edit text
               GETPROP TEMP_ET,FONT=MY_FONT          ;font object gets font itself

.              Now using the FONT, get it's properties
               GETPROP MY_FONT,SIZE=FONT_SIZE:       ;get the size
                               BOLD=FONT_BOLD:       ;get the bold property
                               ITALIC=FONT_ITALIC    ;gets italic property

.              We're done with the temp edit text.  Destroy it.
               DESTROY TEMP_ET

.              Now we can create the second font to match the first one:
               CREATE   2ND_FONT,  FONT_NAME:
                                   SIZE=FONT_SIZE:
                                   BOLD=FONT_BOLD12:
                                   ITALIC=FONT_ITALIC

ALSO SEE:

CONTENTS

v1.10
Send e-mail to MMCC.

Write to MMCC Technical Support at:
MMCC, Inc.
600 W. Midland
Bay City, MI 48708
(989) 686-8860
| Home   |

© 1997 MMCC, Inc. All Rights Reserved.

Report problems or suggestions to support@mmcctech.com