Modifying Application to use New Font System Introduced in 17.0
by, 9-Jan-2014 at 04:12 PM (1434 Views)
Visual DataFlex 17.0 introduced a change in regards to fonts. Visual DataFlex 17.0 (and higher) allows true Windows fonts to be used in applications. Before 17.0, Sans Serif was the only font used in Visual DatFlex.
That means that applications being migrated to 17.0 or higher may need to be adjusted in order to have the desired screen layout on all platforms and resolutions, but once you make this one-time change, your application should look the same on any platform.
The first thing you should do when moving your application to 17.0 is to set the pbUseWindowsFont property to False and adjust the component sizes to what looks correct. Independently on the platform you are running on, you should do this first.
Next, make the changes we indicate in the online Help (page Migrating Workspaces to DataFlex [new revision]; Font Changes section). It includes a list of the settings to look for and either remove or adjust:NOTE:
You might find that even though pbUseWindowsFont is False, your application does not look the same as it did when running it on 15.1, for example. This happens because of a bug fix in 17.0, where with some sizes the dialog units were creating widths that were too small. It truncated instead of rounding. With some particular sizes, we can really see this. The longer the width, the more dramatic it is. The solution here is to reset the width of those objects like demonstrated below:
This adjustment is needed because of a bug fix and would be required on XP or Windows 7 or any other platform.Code:Object oDbTabDialog1 is a dbTabDialog // Set Size to 207 282 Set Size to 207 265 Set Location to 20 1 Set FontSize to 40 20 Object oDbTabPage1 is a dbTabPage Set Label to 'oDbTabPage1' Object oDbGrid1 is a dbGrid // Set Size to 223 369 Set Size to 223 350
- Get / Set Typeface: if the typeface is MS Sans Serif, you probably want to remove it. Anything else should be marked for testing.
- Get/Set FontSize: You want to get rid of this. First try removing it, as it may be unnecessary. If you need to set a custom height, use FontPointHeight instead.
- Get/Set Physical_FontSize: You want to get rid of this. First try removing it, as it may be unnecessary. If you need to set a custom height, use FontPointHeight instead.
- Get/Set Form_FontSize: see FontSize
- Get/Set Form_Typeface: see Typeface
- Get/Set Form_PhysicalFontSize: PhysicalFontSize
At this point you will need to make a decision. To quote Development,With that in mind, you can either decide to 1. keep pbUseWindowsFont property False (which is not really recommended because it will leave you stuck in the past), 2. do not use different fonts/heights and Windows will take care of scaling it all properly or 3. control all typefaces and font height yourself.Up until now, the same font is used for all versions of VDF. If you start changing some font point sizes you are going to get different results with different fonts. MS Sans Serif [the default in VDF] and Segoe UI [the default on Windows Vista/7] will have different widths and even slightly different point heights. Also, MS Sans Serif only supports a few scaling sizes. Keep in mind that object placement is determined by the parent object and object size is determined by the object. If you start changing the point size of objects and you then change the fontface, you will get inexact results. Containers will have different dialog units which affect their size and affect the location of child objects, and controls will be different sized depending on the font. The default point height and typeface are different in XP and W7.When these differences are combined with custom font settings (because the developer has set explicit Font sizes themselves) you get lots of different results.
You may want a combination of 2 and 3 depending on your system. In that case, you will need to learn what applying option 3 means and see how that will impact your application even before setting pbUseWindowsFont property back to True.
Applying option 3 means that you will need to:
- pick a default font for your views to use the font you pick needs to be part of the platforms you will be running your application on. For example, if the machines where your application will run on are Windows XP, 2003, 2008 and 7, you will need to pick a font that is installed on Windows XP, 2003, 2008 and 7. You can check the fonts available on your system from Control Panel | Fonts
- Once you picked a Font, you will need to change every object in those views to specify the typeface and fontpointheight they will be using. IOW, every object must have a Set TypeFace to "" and a FontPointHeight set as a default. Note that every object means every object - controls and containers
- After that, set pbUseWindowsFont property to True and test-run your application
Keep in mind that you will have to test-run your application while adjusting the heights so you can find the ideal height for all objects, but this is the only way you will get this right. So play with those settings and change the font and heights one at a time to see how they affect your views.
This is going to be really hard work since you have to run things to see the results and do trial and error corrections, but keep in mind that once you go through this process once, you will be done -- Windows will take care of scaling fonts and objects from that point on -- so happy testing and migrating!