ASCII-generator icon indicating copy to clipboard operation
ASCII-generator copied to clipboard

The FreeTypeFont object from the PIL library no longer has the getsize() method

Open ace-shang opened this issue 1 year ago • 1 comments

The FreeTypeFont object from the PIL library no longer has the getsize() method, use the getbbox() method instead.

ace-shang avatar Nov 25 '24 01:11 ace-shang

To anyone facing this issue the best way is to use getbox instead of getsize

  • getsize would return a tuple (23,1)
  • getbox return a tuple of 4 values (0,0,23,1)

it is therefore best to use the code from @ace-shang Branch with updates changes

or you can copy this code and paste this code and remove the getbox line

    bbox = font.getbbox(sample_character)
    char_width = bbox[2] - bbox[0]
    char_height = bbox[3] - bbox[1]

credit : @ace-shang

the-dezeray avatar Jan 17 '25 00:01 the-dezeray