Jump to: navigation, search

ClearType fonts take advantage of sub-pixel resolution on displays. The software in ctToolBox simulates displays, predicts how fonts are rendered on these displays, and evaluates the visibility of artifacts (color, blurring, super-resolution) for different rendering algorithms.

We have performed psychophysical evaluations of fonts as well.

Programmers Manual

ClearType Technology is used and developed by Microsoft. The work described here has been supported by Microsoft, and we gratefully acknowledge their support and intellectual contributions to this work.

Michael Bennett is carrying out Ongoing_ClearType_Experiments.


Running the ctToolBox GUI

Invoking the script


brings up a general interface window. ctToolBox requires Windows to run, as it uses a number of Windows specific functions and dlls.

ctMain Window

From the main control window you can bring up three other windows that provide a graphic interface enabling you to

  • Select and edit certain parameters of a display
  • Choose a letter and design the clearType filters
  • Visualize the rendered fonts.


The data management in ctToolBox differs from ISET. In ctToolBox the data are stored in the guidata attached to the windows, not in a global variable. This seemed clever at the time. There are many examples of how the data are accessed through the code. The basic lines are

dispGD = ctGetObject('display')
vd = displayGet(dispGD,'vDisplay')
vd = vDisplayGet(vd,'propertyName');
set vd
dispGD = displaySet(dispGD,'vDisplay',vd)


vDisplayCreate and in particular the part that runs through psfGroupCreate() needs to be adjusted so we can model more complex displays. The idea of a block and a pixel needs to be written with more care and clarified in the code (and here).

The rendering with filtOverApply() needs to be simplified and clarified.

Display Window

ctDisplay Window

There are theoretical displays with perfect little pixels. You can load them by going to Display -> Theoretical display, and choose from the options there.

We have some files with calibrated displays data. You can load one of these files to the Display Window by going to Display -> Calibrated displays. A window will open from which you can browse and find a file. In your ctToolbox directory, go to ctData->Display Models->Calibrated Display Models, and choose one of the files "DellChevron" or "DellStripes".

You can get some information and plots about the display properties under the menus "Plot" and "Analyze".

Filter Design Window

In this window you can load a stimuli, and analyze its performance when render by different filters.

In order to load a stimuli go to Stimulus -> Add letter. A window will open where you can choose the letter, and then another window with some more stimulus properties for your choice.

Now you can perform a grid-search of the ab filter parameter space (see ClearType Experiments for more information). You can first determine the search grid, in terms of boundaries and sampling rate, by going to Analyze -> Set analysis options... .

Now you're ready to begin your search. You can evaluate filter performance using a variety of metrics for the calculation. Go to Analyze and choose the metric you want to use for the evaluation. Most metrics there are full-reference metrics, that differ by the reference display and error type they measure. There are some reference-free metrics as well.

At the end of the search two figures will show up -

  • a contour map of the chosen metric results on the ab parameter space. You can always restore your last search's contour map by going to Plot -> Error grid (Contour).
  • a window with some results for the optimal filter found in the grid search - the rendered image on the chosen display, a rendered image on the reference display (for full-reference metrics), the error image and its histogram. You can restore thsi window by going to Plot -> Error image (at min).

You can also get a window with the above collection of figures for any a and b filter coefficients. Edit the current filter coefficients in Edit -> Filter Coefficients, and then get the plots in Plot -> Error image (cur filt).

To see an output of the chosen character rendered by the different filters across the ab space, go to Plot -> CT Array (-.6:.1:.6) or CT Array (specify) for a different grid.

Note: For the Analyze->referenceFree - all option in the menu, you will get an analysis that compares the reference free chrominance metric results and the reference free blur metric results. This plot shows all the filters whose error is under 20% of the maximum error in the grid search range of chrominance and blur metric filters.

Render Window

Links to the Display and Design windows.

Visualizes the output of applying the ClearType process.

Conversion to ISET

The display radiance can be converted to an ISET scene. That toolbox can be used to understand how the image is encoded by the human visual system.

Scripts and Tutorials

See the directory ctScripts for some tutorials and practical scripts.

The script s_ExamineDisplay includes explanations of how to retrieve key variables from the windows, modify them, and then replace them. In particular, it explains how to use ctGetObject(), vDisplayGet/Set(), and ctSetObject().

Adding a new simulated display

In this section I'll provide details on how to simulate a new display in ctToolBox.

Once you've added a display you'll probably want to be able to select the display via the ctToolbox menu, e.g. Design Display -> Display -> Theoretical Display. Do add a menu option under display edit the ctDisplay/ctDisplay.fig file with guide.

Add a Callback for creating the display when the menu item is clicked, e.g. for a RGB Delta Triad display you can add a function called menuDisplayRGBGQuad_Callback() in ctDisplay.m which creates the display when called.

Then edit vDisplayCreate.m and add a new entry for the new display. For example, search for "case{'rgbgquad'}" in vDisplayCreate.m. vDisplayCreate is called from the Callback functions mentioned above. It is the workhorse for display creation, as it sets up the sub-pixel layouts, the primaries, etc.

You'll need to add another setup function in vDisplayCreate.m, which is called from the vDisplayCreate.m entry code. In this case we add a function called displayRGBGQuad(), this sets up the subpixels and the point spread functions.

psfGroupCreate is called by displayRGBGQuad(), and the purpose of it is to setup the position and structure of the subpixels in a tile. A tile is a group of subpixels which is repeated over and over to create a display. We add "case{'2x2RGBG'}" to psfGroupCreate.m to setup a new subpixel layout for the RGBG Quad subpixel display. You'll have to setup the subPixelHalfHeight and HalfWidth correctly, along with the order of the primaries, etc.

Coordinates for centers in psfGroupCreate are X then Y, where X goes left to right -1 to +1 (may be other value than 1), and Y goes from top to bottom -1 to +1 (so its a mismash coordinate system, where 0,0 is kind of equivalent to upper left of the screen). When assigning a primary to a subpixel, you set spps.primaries to the primaries values, e.g. [1 2 3] = subpixel 1 has spectrum primary 1, subpixel 2 has spectrum primary 2, subpixel 3 has spectrum primary 3. Subpixel assignment goes from upper left to lower right.

THIS IS IMPORTANT: When entering the subpixel coordinates, start from the supper left subpixel, going from left to right downwards. Otherwise fonts rendered on the subpixel won't appear correctly (the subpixel ordering is an assumption of the underlying code).

This should be tidied up, as its legacy and strange - making it somewhat awkward to setup new subpixel layouts. Functions subPixPositions.m (param set to subpixelpositions) both check what the subpixel rgb order is before returning a correct count of subpixels. So, when adding a new subpixel layout you also need to extend those functions to check for the new subpixel params, e.g. check for rgbg as well as rgbw, etc. MTODO: Remove subPixPositions, I don't think its needed anymore.

Solving Mex Problems: RI.mexw32 & GDII.mexw32

Depending on the versions of Matlab and Windows you're using you may have issues with the font rendering. In order to solve this problem try replacing RI / GDII mexw32 files with alternative versions included in the ctToolBox/msRaster folder.

There are two GDII.mexw32.* files, and two RI.meww32.* files. The GDII/RI.mexw32.Windows.Unknown.MatlabUnknow.VSUnknown were provided by Microsoft. Sometimes they are incompatible with various Windows / Matlab combinations and won't work. First try renaming GDII.mexw32.Windows.Unknown.MatlabUnknow.VSUnknown to GDII.mexw32, and RI.mexw32.Windows.Unknown.MatlabUnknow.VSUnknown to RI.mexw32. Make sure to rename them GDII and RI files in pairs, i.e. both files should end with the same description (*.Windows.Unknown.MatlabUnknown.VSUnknown). Restart Matlab between reloads.

If that doesn't work, you can rebuild the RI / GDII mexw32 files (source code in ctToolBox\ctFont\Source\msRasterizer\msRasterizer). To do so see Making Matlab & Microsoft Visual Studio 2010 work together: Compiling Mex files and use mex to compile RI.cpp and GDII.cpp

When compiling RI.cpp, you have to link it with truetype.lib. To do so build RI.cpp with the following Matlab command mex RI.cpp -L. -ltruetype while making sure you're in the ctToolBox\ctFont\Source\msRasterizer\msRasterizer folder.


1. Cannot generate an ISET scene from a 2x2 display in the new ctToolbox

2. Cannot read in calibrated display (e.g. Chevron)

Personal tools