Releases: DocsaidLab/WordCanvas
Release 2.1.0
Release 2.0.2
Release 2.0.1
Release Note
Dependency Updates
- Replaced
docsaidkit
utilities withcapybara
:- 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 tocustom_aug.py
to better reflect its role in handling custom augmentation functionalities.- Utilities from
base.py
andutils.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
andtext2image.py
were consolidated intomrz_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
andRandomWordCanvas
:- 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.
- Split
-
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
andRandomWordCanvas
functionalities, covering randomization and image alignment.
- Validates
- Introduced new test files:
-
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.
- Utilized
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
.
- Test files:
Full Changelog: [GitHub Compare Link](1.0.4...2.0.1)
Release 1.0.4
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
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:
-
Detailed Glyph Validation with
RecordingPen
:- Introduced
RecordingPen
fromfontTools.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.
- Introduced
-
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, theRecordingPen
is used to verify the presence of actual path data.
- The function now supports both TrueType (
-
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.
- Added the
-
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.
-
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.
- The
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
Release 0.5.1
Release Note
- [C] Update
DEFAULT_FONT_BLOCK_LIST
setting inWordCanvas
. - [A] Add
Code39Generator
&Code128Generator
.- Referring to documents BarcodeGenerator
- [A] Add
MRZGenerator
.- Referring to documents MRZGenerator
Full Changelog: 0.4.6...0.5.1
Release 0.4.6
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
Release Note
- [C] Update
DEFAULT_FONT_BLOCK_LIST
rule. - [C] Update github workflow settings.
Full Changelog: 0.4.0...0.4.2