CVP Fórum Címkép
  >Corel     >Corel itthon   
 
 

Temporary installation of fonts

An interesting side effect of the font preview window on Windows XP and earlier was that, in order to display a preview of the font, it installed it temporarily for all applications to see and use. While the preview window was open, you could use the font in any other application (including DTP ones). This was a nice solution for those cases where you quickly needed to create some ad or client work requiring a specific font but you didn't want to install it permanently. However, this side effect of the preview window was removed in Windows 7.

Because this feature (even if it was considered an unintended side effect in earlier Windows versions) was quite comfortable for many who learned to rely upon it, we wrote a small and simple utility to reproduce its behavior on Windows 7. The utility can be downloaded in a .zip archive. Just start the executable inside (you can copy it into any folder you prefer or add a desktop shortcut to it). You can either supply a full path to a font file on the command line (which makes it possible to assign it to a particular font file extension) or, if started without a font file specified, it will allow you to browse for one using the usual file open dialog.

The program requires the .NET Framework 2.0 but as it is supposed to be useful on Windows 7 where this framework is part of the system by default, you won't notice anything.

Notebook Power Display

I got fed up with the small battery icon in the system tray of my notebook. I used a borrowed Mac PowerBook for a few days and I immediately started to envy the battery status indicator of its OS X.

With this battery display on the Mac, you don't have to hover over an icon to learn the percentage, hidden in a tray that might not even visible on the screen all the time (I prefer to set the task bar to Auto hide myself). The Windows display usually only shows the battery percentage, not the time remaining and when is does show time, I've already seen the most amusing values there: both 8 minutes and more than 10 hours remaining estimated for a 50% charged battery. Besides, it never even tries to estimate the remaining time until full when charging the battery.

So, I decided to write my own utility. Instead of being hidden as an icon, it can display the measure and estimated data anywhere on the screen. It works best on Windows 2000 and XP because these support user interface transparency. On Windows 98, a background will always be seen behind the display area. Due to lack of support for the low level hardware interface to the battery, the program will not run on NT 4.0 or Windows 95. And, of course, it will not run on desktop computers where there is no battery in the first place...

Running from battery Instead of displaying the percentage and remaining time in digits, the program uses color and size. The colors are obvious: 100% (full) is green, 50% is yellow, 0% (empty) is red. The display is divided into small sections, each one representing 30 minutes (so, this picture represents the battery still charged to about 50%, with a projected estimate of 1.5 hours of remaining time). You can change the number of sections, or in other words, the total displayable time in Settings (click on the icon in the taskbar). You can move the display around the screen, if it is on the right, it will be mirrored, it's always the outer edge that it is moving towards. When the program starts (also after sleeping or hibernating), it gives a very rough time estimate that will start adjusting itself after only as little as 0.2% change in battery capacity (this will usually take 20-30 seconds at most), and will become more precise as time goes by.

Charging the battery During charging, the display changes from red to green, the length representing the remaining charging time to full (this picture shows the previous notebook just connected to the mains, battery charged to 50%, estimated time remaining to full charge is about 40 minutes). When it is fully charged and runs on mains, the display disappears completely. When Windows reports a bad battery, the whole display is red. If there are more than one batteries in the system, the program estimates combined times for all batteries.

On 98 and NT, there is no transparency support comparable to 2000 or XP. On these systems, the part of the display not actually used in any given moment is drawn in the background color specified in the .INI file. Change that, if necessary, to make the display background blend into your desktop colors. The display will obscure the icons or other windows beneath it, there is no cure for that on those operating systems. If you find the display too obtrusive, just reduce its height in the .INI file.

The time estimate calculations are based on finer hardware input than those used by the built-in Windows battery icon (namely, perthousands instead of percents). This approach allows the program to be much more responsive, to start displaying acceptable time estimates faster. On notebooks where the hardware doesn't provide data with this granularity, this can lead to fluctuating display: the display bar will constantly rise (the hardware input remains constant while time elapses, fooling the program into thinking that the battery reserve will be sufficient for a longer total time), then drop suddenly as the battery capacity level changes abruptly, then start rising again. In those cases, the refresh frequency of the display should be decreased in the INI file.

The program is customizable but not everything is available in the Settings dialog. It leaves a PowerDisplay.ini in the Windows directory, you can change the vertical size of the display or the background color there (start the program once and exit it, this will create the .ini file with default values; then you can change those).

You can also specify the usual time it takes for the battery to be charged and discharged (defaulting to 1.5 and 3 hours, respectively). This value is only used to make the rough estimate shown during the initial 0.2% period a little bit more realistic, it is ignored otherwise.

The entries in the .INI file are as follows:

[Settings]

Horizontal
X co-ordinate of the display rectangle (in pixels; defaults to 0)
Vertical
Y co-ordinate of the display rectangle (in pixels; defaults to 0)
Width
width of the display rectangle (in pixels)
Height
height of the display rectangle (in pixels; defaults to one third of the height of the small window caption)
Sections
number of 30-minute sections in the display

[Background]

R, G, B
RGB color components of the background (0-255 each; only used on Win98 and NT 4, ignored on 2000 and XP)

[UsualTime]

Charge
usual time required to charge the battery fully (in seconds; defaults to 1.5 hours)
Discharge
usual time required to discharge the battery fully (in seconds; defaults to 3 hours)

[Display]

RefreshPeriod
period between display refreshes (in seconds; defaults to 5 sec)

The utility can be downloaded in a .zip archive (10,527 bytes). Just start the executable inside (23,072 bytes), or copy it into your Startup folder if you want to have it started automatically with your system. It does put an icon into the system tray but this doesn't serve as a display any more, just a place where you can click to bring up a small menu with only two choices: a Settings dialog and a way to shut down the program.

In the Settings dialog, you can decide where the display will appear on the screen (look out for a moving selection rectangle as you move the horizontal or vertical slider).

Reorganize the characters in fonts

Both traditional TrueType and newer OpenType fonts of both flavors (TTF or OTF) can have Unicode characters, out of the reach for non-Unicode compliant applications, including Ventura. Windows offers so-called virtual fonts where Unicode characters are mapped to the lower ANSI range but they require manual settings in the registry. In addition, you can only select from predefined mappings, corresponding to the well established codepages. Besides, Ventura 10 doesn't seem to like these virtual fonts at all.

A much more reliable solution is to actually create new fonts from the existing ones, with the internal character mapping modified actually rather than virtually. The small utility you can download from here was modified from a freely available utility written by Charles Hedrick, distributed on the net. My addition was to make it accept an external file describing the required mapping instead of using a couple of hardwired ones.

These external files are plain text files of a very simple format. The first item on a line is the ANSI character position you want to move a character to, the second is the Unicode character code (so-called codepoint) of the character to be moved. For instance, to move the Cyrillic capital De into the ANSI position 125, simply write

125 0x0414

you can use both decimal and hexadecimal numbers in both positions, the hexadecimal ones should start with 0x. You can look up the Unicode codepoints in the Character Map application in Windows, looking for the U+ values in the bottom of the display.

You can use a third value on the line when you want to map consecutive Unicode characters.

161 1025 12

is equal to

161 1025
162 1026
163 1027
...
171 1035
172 1036

The new font has to have a different name so that both the original and the new one can co-exist at the same time. You have to specify the typeface name suffix of the newly create font in the first line of the file.

To give a complete example, the mapping file for the ISO 8859-5 Cyrillic font will be as follows:

Cyrillic
161 1025 12
174 1038 66
240 8470
241 1105 12
253 167
254 1118 2

The utility can be downloaded in a .zip archive. To convert a font, issue the command

chcmap original-font new-font mapping-file

Supposing you have a Palatino font in a font file named palatino.ttf, the

chcmap palatino.ttf palatinocyr.ttf 8859-5.txt

will create a new Palatino Cyrillic font in a font file called palatinocyr.ttf that you can install and use just like any other font.

Error Messages

There are various error messages the program can display but the one giving most problems is "Couldn't find character 128 (080) to copy to -- aborting". To understand this, you have to know that ChCMAP is unable to create new characters, it can only copy already existing characters to the place of other, already existing characters. So, if you get this message, you have to modify the .txt file you use to not include character positions absent from the original font. Make a copy of the .txt file you use and remove the line referring to the character position the program is complaining about. And repeat this procedure until the program runs without errors.


The usual disclaimers apply: use these programs at your own risk. If you happen to have any comment or question, feel free to drop us a message.



A Corel Ventura 8™ a Corel Corp. bejegyzett védjegye.