Skip to content

Releases: DocsaidLab/WordCanvas

Release 2.1.0

17 Jan 05:52
Compare
Choose a tag to compare

Release Note

  • [A] Add random multilines supporting.

Full Changelog: 2.0.2...2.1.0

Release 2.0.2

15 Jan 08:29
Compare
Choose a tag to compare

Release Note

  • [F] Fixed string format in py310.

Full Changelog: 2.0.1...2.0.2

Release 2.0.1

13 Jan 02:07
Compare
Choose a tag to compare

Release Note

Dependency Updates

  • Replaced docsaidkit utilities with capybara:
    • For image resizing and file-handling functionalities.
    • Introduced at the start to emphasize its importance in enhancing functionality and performance.

Key Changes and Code Refactoring

Module Renaming and Restructuring

  • Renamed and Refactored Modules:

    • imgaug.py was renamed to custom_aug.py to better reflect its role in handling custom augmentation functionalities.
    • Utilities from base.py and utils.py were restructured into more specialized modules for improved code clarity and maintainability:
      • font_utils.py: Dedicated to font management, including loading, validating fonts, and introducing new functions for Unicode character validation and filtering.
      • text_image_renderer.py: Handles text-to-image rendering with extensive customization options, including multi-line text support and text stroke features.
    • Machine Readable Zone (MRZ) related functions from mrz.py and text2image.py were consolidated into mrz_generator.py for streamlined MRZ generation.
  • Introduced New Modules:

    • font_utils.py:
      • Implements font-related operations like loading, filtering, and validating characters against Unicode ranges.
      • Added multiple new functions to enhance font validation and improve robustness in character checks.
    • text_image_renderer.py:
      • Enables rendering of text into images with configurable direction, alignment, stroke, and spacing.
      • Introduced multi-line text rendering and enhanced text stroke options.
    • mrz_generator.py:
      • Focused exclusively on generating MRZ images with validation for text formatting and spacing.

Functional Enhancements

  • WordCanvas and RandomWordCanvas:

    • Split WordCanvas into two dedicated classes:
      • WordCanvas focuses on static, predictable text rendering.
      • RandomWordCanvas specializes in dynamic, randomized text and style generation.
    • Expanded randomization options for font, color, direction, and spacing.
    • Refined logic for image dimension adjustments and text alignment.
  • MRZGenerator:

    • Improved flexibility for generating MRZ text, supporting customizable lines, spacing, and randomization.
    • Enhanced character placement accuracy within MRZ images.
  • text2image:

    • Added features to control text stroke width and fill color.
    • Introduced support for multi-line text rendering.
    • Improved text alignment and spacing calculations for better visual rendering.
    • Returns metadata such as font path, actual font size, and text direction for enhanced traceability.

Testing Enhancements

  • Comprehensive Test Coverage:

    • Introduced new test files:
      • test_custom_aug.py:
        • Validates Shear augmentation under various probabilities and parameter combinations.
      • test_font_utils.py:
        • Ensures font-loading mechanisms and character filtering work as expected.
        • Tests new font validation functions thoroughly.
      • test_mrz_generator.py:
        • Tests MRZ generation for types TD1, TD2, and TD3 with text validation.
      • test_text_image_renderer.py:
        • Checks rendering accuracy, including alignment, direction, and text clamping.
        • Verifies new multi-line text and text stroke rendering.
      • test_word_canvas.py:
        • Validates WordCanvas and RandomWordCanvas functionalities, covering randomization and image alignment.
  • Advanced Testing Strategies:

    • Utilized pytest.mark.parametrize for efficient multi-case testing.
    • Simulated edge cases, including invalid font paths and incorrect text directions.
    • Integrated testing for combined functionalities (e.g., Shear and ExampleAug).
    • Enhanced error handling to strengthen validation for unsupported characters and corrupted fonts.

Deprecated and Removed Files

  • Removed the following obsolete or redundant files:
    • Test files: test_generator.py, test_imgaug.py, test_utils.py.
    • Modules: mrz.py, base.py, utils.py, text2image.py.

Full Changelog: [GitHub Compare Link](1.0.4...2.0.1)

Release 1.0.4

23 Oct 23:23
Compare
Choose a tag to compare

Release Note

  • [F] Fixed block_list setting error.
  • [F] Fixed unable print error.
  • [F] Fixed ttb setting error in scatter image.
  • [F] Fixed use_cache setting error.

Full Changelog: 1.0.3...1.0.4

Release 1.0.0

14 Oct 23:41
Compare
Choose a tag to compare

Release Note

Update get_supported_characters for Enhanced Glyph Validation in Fonts

In this release, we have significantly improved the functionality of the get_supported_characters function to provide more accurate and detailed checks for glyph availability in both TrueType and OpenType fonts. The enhancements ensure that the module can now more effectively determine whether characters are supported by the font, even considering cases where glyphs may be empty or missing.

Key Changes:

  1. Detailed Glyph Validation with RecordingPen:

    • Introduced RecordingPen from fontTools.pens.recordingPen to accurately validate glyphs in fonts, especially when dealing with complex fonts such as CFF-based OpenType fonts.
    • The RecordingPen ensures that glyphs are not just present but also contain actual drawing commands. This prevents empty or undefined glyphs from being falsely reported as valid.
  2. Enhanced TrueType and OpenType Font Support:

    • The function now supports both TrueType (glyf table) and CFF-based OpenType (CFF table) fonts.
    • For TrueType fonts, glyphs are validated by checking the numberOfContours attribute to ensure they contain outlines, while for OpenType fonts, the RecordingPen is used to verify the presence of actual path data.
  3. Optional Glyph Empty Check:

    • Added the check_glyph_empty argument, which when enabled, checks for empty glyphs to ensure that only characters with valid visual representations are returned.
    • This feature can be toggled off for performance optimization when empty glyphs are not a concern.
  4. Cache Mechanism for Supported Characters:

    • A caching mechanism is introduced for storing and retrieving previously computed supported character sets. This optimizes repeated font checks by saving the results in a JSON cache file.
    • The cache is located in a directory relative to the script path, ensuring easy management and quick access to previously validated fonts.
  5. Verbose Output for Debugging:

    • The verbose option has been enhanced to provide more granular feedback when errors occur, or when certain glyphs are missing or empty.
    • If a glyph is not found or contains no drawing commands, detailed messages are printed, helping developers identify potential font issues more easily.

This release is recommended for all users who require precise font validation in their applications, especially in environments dealing with complex fonts or high-performance requirements.

Full Changelog: 0.5.2...1.0.0

Release 0.5.2

30 Aug 02:36
Compare
Choose a tag to compare

Release Note

  • [C] Add random_text_color supporting for MRZGenerator.

Full Changelog: 0.5.1...0.5.2

Release 0.5.1

07 Aug 15:53
Compare
Choose a tag to compare

Release Note

  • [C] Update DEFAULT_FONT_BLOCK_LIST setting in WordCanvas.
  • [A] Add Code39Generator & Code128Generator.
  • [A] Add MRZGenerator.

Full Changelog: 0.4.6...0.5.1

Release 0.4.6

24 May 04:32
Compare
Choose a tag to compare

Release Note

  • [F] Fixed comma missing error.
  • [F] Fixed return error in split_text

Full Changelog: 0.4.5...0.4.6

Release 0.4.2

20 May 04:27
Compare
Choose a tag to compare

Release Note

  • [C] Update DEFAULT_FONT_BLOCK_LIST rule.
  • [C] Update github workflow settings.

Full Changelog: 0.4.0...0.4.2

Release 0.4.0

19 May 02:50
Compare
Choose a tag to compare

Release Note

  • [A] Add DEFAULT_FONT_BLOCK_LIST for skip error fonts.

Full Changelog: 0.3.1...0.4.0