Class OcrResult.OcrFont
Detailed font information returned when using Tesseract OEM engine modes.
Inheritance
Namespace: IronOcr
Assembly: IronOcr.dll
Syntax
public class OcrFont : Object
OcrResult.OcrFont reports the typeface IronOCR believes a recognized character was set in, so you can preserve or analyze styling rather than capturing plain text alone. Reach for it when a downstream step needs to know whether a glyph was bold, italic, serif, or fixed-width, for example when rebuilding a styled document or filtering by emphasis.
You do not construct this object. You read it from the Font property of an OcrResult.Character, which you reach by walking an OcrResult returned from IronTesseract.Read. Font detail is populated mainly under the Tesseract OEM engine modes, so it is most reliable when the engine is configured for the legacy Tesseract path rather than the LSTM-only modes; expect best-guess values, since the figures are estimated from the recognized shapes.
The members fall into two groups. FontName gives the closest known typeface name and FontSize the estimated height in points. The remaining members are boolean style flags: IsBold, IsItalic, and IsUnderlined for the common emphases, IsSerif and IsFixedWidth for the family classification (serif like Times, monospaced like Courier), and IsSmallCaps and IsCaligraphic for the less common small-caps and Fraktur-style cases. Read the flags directly on the character's font to branch on styling, and treat each value as advisory rather than exact, since the engine infers them from the recognized glyph shapes. A practical pattern is to read FontName and FontSize to approximate a typeface, then use the flags to apply emphasis when you rebuild the text in a styled output, falling back to a plain rendering whenever the flags conflict or the font detail was not populated for that character.
using IronOcr;
var ocr = new IronTesseract();
using var input = new OcrInput("scan.png");
OcrResult result = ocr.Read(input);
OcrResult.OcrFont font = result.Pages[0].Words[0].Characters[0].Font;
Console.WriteLine($"{font.FontName} {font.FontSize}pt bold={font.IsBold}");The working with OCR results how-to covers reading character detail, the IronTesseract how-to explains the engine modes that populate font data, and the results objects example shows accessing per-character properties.
Properties
FontName
Best guess at the closest known typeface name.
Declaration
public string FontName { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
FontSize
Best guess at the font height in points.
Declaration
public double FontSize { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
IsBold
Is the text Bold.
Declaration
public bool IsBold { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsCaligraphic
Is the text in a calligraphic or "Fruktur" style.
Declaration
public bool IsCaligraphic { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsFixedWidth
Is the text FixedWidth (monospaced like Courier).
Declaration
public bool IsFixedWidth { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsItalic
Is the text Italic.
Declaration
public bool IsItalic { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsSerif
Is the text Serif (like Times-New Roman).
Declaration
public bool IsSerif { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsSmallCaps
Is the text in "Small Caps" (half height capital letters).
Declaration
public bool IsSmallCaps { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsUnderlined
Is the text Underlined.
Declaration
public bool IsUnderlined { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |