Fixed GpuMemDumpVis.py to not use deprecated Pillow function textsize

See https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/issues/375 Thanks @alecazam
This commit is contained in:
Adam Sawicki 2023-11-03 13:18:46 +01:00
parent 5cb534cf9b
commit 1ab8aaec7e

View File

@ -25,7 +25,7 @@ import json
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont
PROGRAM_VERSION = 'Vulkan/D3D12 Memory Allocator Dump Visualization 3.0.2' PROGRAM_VERSION = 'Vulkan/D3D12 Memory Allocator Dump Visualization 3.0.3'
IMG_WIDTH = 1200 IMG_WIDTH = 1200
IMG_MARGIN = 8 IMG_MARGIN = 8
TEXT_MARGIN = 4 TEXT_MARGIN = 4
@ -277,8 +277,8 @@ if __name__ == '__main__':
draw.text((x + IMG_MARGIN + TEXT_MARGIN, y), "0", fill=COLOR_TEXT_H2, font=font) draw.text((x + IMG_MARGIN + TEXT_MARGIN, y), "0", fill=COLOR_TEXT_H2, font=font)
else: else:
text = BytesToStr(byte) text = BytesToStr(byte)
textSize = draw.textsize(text, font=font) textLength = draw.textlength(text, font=font)
draw.text((x + IMG_MARGIN - textSize[0] - TEXT_MARGIN, y), text, fill=COLOR_TEXT_H2, font=font) draw.text((x + IMG_MARGIN - textLength - TEXT_MARGIN, y), text, fill=COLOR_TEXT_H2, font=font)
byte += bytesBetweenGridLines byte += bytesBetweenGridLines
y += FONT_SIZE + IMG_MARGIN y += FONT_SIZE + IMG_MARGIN