TextRecognitionDataGenerator icon indicating copy to clipboard operation
TextRecognitionDataGenerator copied to clipboard

How to specify the font to be used?

Open 2catycm opened this issue 2 years ago • 4 comments

My need is really simple, given a text and a ttf font file, output the images augmented. However, the example in README.md does not work as I expected.

After I read your doc, I think the following code should be correct,

from trdg.generators import (
    GeneratorFromDict,
    GeneratorFromRandom,
    GeneratorFromStrings,
    GeneratorFromWikipedia,
)

# The generators use the same arguments as the CLI, only as parameters
generator = GeneratorFromStrings(
    ['Test1', 'Test2', 'Test3'],
    blur=2,
    random_blur=True, 
    fonts = load_fonts('my_font_folder')
    language = 'my_font_folder'
)

However, the trdg just ignore 'my_font_folder', it just uses the fonts in 'en' folder and use en language

2catycm avatar Mar 21 '23 08:03 2catycm

ttf files are in the 'my_font_folder'

2catycm avatar Mar 21 '23 08:03 2catycm

Did you ever resolve this issue? I am looking at the same problem.

rdavis22 avatar May 14 '23 02:05 rdavis22

Try mentioning the .ttf file in the font parameter and the path to the font folder in the font directory parameter

Deeksha-5 avatar May 20 '23 19:05 Deeksha-5