ankush-me / SynthText

Code for generating synthetic text images as described in "Synthetic Data for Text Localisation in Natural Images", Ankush Gupta, Andrea Vedaldi, Andrew Zisserman, CVPR 2016.
http://www.robots.ox.ac.uk/~vgg/data/scenetext/
Apache License 2.0
2.03k stars 622 forks source link

Can't add a new (my own) font in the script - PLZ IF SOMEONE KNOWS, IT'S URGENTLY FOR ME, Ty #262

Closed Didier0 closed 2 years ago

Didier0 commented 2 years ago

Hi all and @ankush-me ,

can someone help me, I don't understand how to add my own font into script? I found in code fontlist.txt text source - a file that is used as text source. So there I put my .ttf fonts that I downloaded from here: https://www.1001fonts.com/text-fonts.html?page=1&fbclid=IwAR395plHPNmZemLoKmvpedbqRv0z8pUVU66np7LLWzia14GrAKWcZB1H5o4 and then terminal shows me and error :

'Fabiolo' is the name of font

Capture

When I use the upper one (fontlist1.txt - mine) there shows an error. When I use the bottom one (fontlist.txt - originally from SynthText script) that works fine everytime.

Capture1

Here you can see how I add paths and names into fontlist1.txt I also add the font names like 'Fabiolo', 'Halida Sans', ... into Font Manager but still nothing, shows the same errors.

Capture2

ankush-me commented 2 years ago

You need to give the full (relative) path to the font file (.ttf) as you have also shown in the last screenshot --- but the paths are not given in the second screenshot. Also you probably need to use the same filename (fontlist.txt and not fontlist1.txt) unless you have made the corresponding change in the code.

Didier0 commented 2 years ago

Yes, in the second screenshot I didn't put .ttf fonts into folders, they were out (in the same folder where are fontlist.txt) like halida-sans.normal.ttf in 2nd screenshot, but then I try to put them in folders like you did, that you can see in the 3rd screenshot and also don't work. In code I made a change from fontlist.txt to fontlist1.txt, just load other .txt file.

You can see in the picture:

image

And also says this:

Traceback (most recent call last):
  File "/home/isus/Dokumenti/WET/SynthText-python3/synthgen.py", line 669, in render_text
    regions['homography_inv'][ireg])
  File "/home/isus/Dokumenti/WET/SynthText-python3/synthgen.py", line 506, in place_text
    render_res = self.text_renderer.render_sample(font,collision_mask)
  File "/home/isus/Dokumenti/WET/SynthText-python3/text_utils.py", line 415, in render_sample
    f_h = self.font_state.get_font_size(font, f_h_px)
  File "/home/isus/Dokumenti/WET/SynthText-python3/text_utils.py", line 535, in get_font_size
    m = self.font_model[font.name]
KeyError: 'Fabiolo'

Mabye the script can't read any font?

Do I need to install the fonts on Ubuntu?

ankush-me commented 2 years ago

This last error is different. For adding new fonts you need to update the font model as well. Check here, and use this script.

ankush-me commented 2 years ago

Also I don't think you need to install these fonts -- but can try.

ankush-me commented 2 years ago

The Failed to load font: unknown file format error seems to be originating in Pygame's freestyle font engine. I do not have any good pointers on how to resolve that unfortunately.

Lane689 commented 2 years ago

Ok, thank you, I'll try.

Lane689 commented 2 years ago

I just used fonts that exists here font_px2pt.cp and it works. TY