Browse our Products

Aspose.OCR for Python via .NET 26.7 - Release Notes

What was changed

KeySummaryCategory
OCRNET‑1253Added font detection support for recognized text lines, including font family, style, size, and confidence values.New feature

Public API changes and backwards compatibility

This section lists all public API changes introduced in Aspose.OCR for Python via .NET 26.7 that may affect the code of existing applications.

Added public APIs:

The following public APIs have been introduced in this release:

aspose.ocr.RecognitionSettings.detect_fonts - a new property

Enables font detection for each recognized text line. When enabled, font family, style, and estimated size are returned in RecognitionResult.recognition_lines_result.

aspose.ocr.FontLineResult - a new type

Contains detected font information for a recognized text line.

New Properties

PropertyDescription
line_indexZero-based line index in the processed font batch.
size_pxDetected line height in pixels.
size_pt_estimateEstimated font size in points.
styleDetected font style.
style_confidenceConfidence score for the detected style.
fontDetected font family name.
font_confidenceConfidence score for the detected font family.

aspose.ocr.RecognitionResult.LinesResult.font - a new property

Returns FontLineResult for the recognized text line when font detection is enabled.

Updated public APIs:

No changes.

Removed public APIs:

No changes.

Examples

The code sample below illustrates the changes introduced in this release:

Detect fonts in recognized text lines

import aspose.ocr

api = aspose.ocr.AsposeOcr()

input_data = aspose.ocr.OcrInput(aspose.ocr.InputType.SINGLE_IMAGE)
input_data.add("source.png")

settings = aspose.ocr.RecognitionSettings()
settings.detect_fonts = True
settings.threads_count = 1

result = api.recognize(input_data, settings)[0]

for line in result.recognition_lines_result:
    if not line.text_in_line or not line.text_in_line.strip():
        continue

    font = line.font

    print(line.text_in_line)
    print(f"Font: {font.font} ({font.font_confidence:.0%})")
    print(f"Style: {font.style} ({font.style_confidence:.0%})")
    print(f"Size: {font.size_px}px / {font.size_pt_estimate}pt")