Generating ClearType subpixel positioned and all other Glyphs

polcott 20 Reputation points
2023-07-10T19:51:09.75+00:00

I just provided a purely hypothetical guess of an answer to show exactly what an answer looks like.

I need to be able to generate and capture all of the rasterised images of individual font instances such as: {Times New Roman, Bold, Italic, 8-Point @96 dpi} That any Microsoft desktop application would generate I need this to train my DFA OCR.

Microsoft has several different ways that it can generate bitmap images of glyphs. The following example was captured from a browser window seems to use the latest ClearType that has subpixel positioning. four_glyphs

I need to be able to generate and capture all of the different bitmap images of glyphs all of the ways that Microsoft can do this for every Microsoft application on a single desktop computer. WordPad only has one glyph bitmap per character.

WFP can generate the latest ClearType glyphs. DirectX can also do this, yet I do not know that the resulting bitmaps are identical. I don't know how TrueType and OpenType fit into this picture.

I also need to capture the bitmaps of these glyphs from the Window. I am unsure of which Microsoft technologies are best for this. WPF is my current starting point.

Can I generate all of the bitmaps of all of the font instances for a every application used on a specific machine using WPF, or do I need separate programs that also use GDI, GDI+, and DirectX?

Developer technologies | .NET | Other
Developer technologies | C#
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 78,006 Reputation points Volunteer Moderator
    2023-07-10T22:13:39.3133333+00:00

    a Glyph in ClearType is a single font character. It is not a raster image but a small TrueType program. TrueType defines glyphs as a series of quadratic Bézier splines and hints. it's a small push/pop machine language.

    https://learn.microsoft.com/en-us/typography/truetype/fixing-rasterization-issues
    https://learn.microsoft.com/en-us/typography/truetype/hinting-tutorial/hinting-and-truetype-instructions

    ClearType calls TrueType to produce a raster image that ClearType then performs a filter on. This is done at runtime to produce a raster image based on the font size and screen resolution.

    you can use the TrueType tool to produce a raster image of a font character in varies font sizes and screen resolutions.

    https://learn.microsoft.com/en-us/typography/tools/vtt/

    note: with modern hi-res displays, ClearType is fairly obsolete and been replaced with OpenType (an extended truetype format) which supports larger font families.


  2. polcott 20 Reputation points
    2023-07-12T15:11:40.3833333+00:00

    I am providing this hypothetical answer to show exactly what kind of an answer I am looking for. It is not fact based it is merely a guess of what the facts could be.

    Windows Presentation Foundation (WPF) can generate the exact same glyph bitmap images that every other Windows technology {GDI, GDI+, DiredtX} can generate. This will work consistently for TrueType, OpenType and any version of ClearType.

    This will allow generating and capturing the bitmaps of 900,000 lines of text that will exactly match the bitmaps generated by every Microsoft application by any of the Microsoft technologies and any font technology when done on the same desktop computer/monitor configuration. In some of these cases the rasterising parameters may need to be adjusted.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.