diff --git a/doc/example/report.md b/doc/example/report.md
index 2f9f313..81d4f34 100644
--- a/doc/example/report.md
+++ b/doc/example/report.md
@@ -1,8 +1,8 @@

|name|origin|size|remaining|collisions
|:-|:-|:-|:-|:-|
-|kernel|0x10|0x50|-0x10|{'rootfs': '0x50'}|
-|uboot|0xD0|0x50|-0x10|{'uboot-scr': '0x110'}|
-|rootfs|0x50|0x30|0x10|{'kernel': '0x50'}|
+|kernel|0x10|0x50|-0x10|{'rootfs': '0x50'}|
+|uboot|0xD0|0x50|-0x10|{'uboot-scr': '0x110'}|
+|rootfs|0x50|0x30|0x10|{'kernel': '0x50'}|
|dtb|0x90|0x30|0x10|{}|
-|uboot-scr|0x110|0x30|0x2a8|{'uboot': '0x110'}|
+|uboot-scr|0x110|0x30|0x2a8|{'uboot': '0x110'}|
diff --git a/doc/example/report.png b/doc/example/report.png
index 3ee0a21..a256ff0 100644
Binary files a/doc/example/report.png and b/doc/example/report.png differ
diff --git a/mm/diagram.py b/mm/diagram.py
index 797b0fe..a3ff0d7 100644
--- a/mm/diagram.py
+++ b/mm/diagram.py
@@ -30,6 +30,7 @@ class MemoryMap:
"""height of the diagram image"""
width = 500
"""width of the diagram image"""
+ bgcolour = "oldlace"
def __init__(self):
self._legend_width = 50
@@ -50,7 +51,7 @@ def __init__(self):
def _create_diagram(self, region_list: List[mm.types.Region]):
# init the main image
- img_main = PIL.Image.new("RGB", (MemoryMap.width, MemoryMap.height), color=(255, 255, 255))
+ img_main = PIL.Image.new("RGB", (MemoryMap.width, MemoryMap.height), color=MemoryMap.bgcolour)
# this is the x-axis drawing offset for each region
# we increment this each time we draw a region to clearly show overlaps
@@ -77,12 +78,31 @@ def _create_diagram(self, region_list: List[mm.types.Region]):
outline="black",
width=1,
)
- name_text_font = PIL.ImageFont.load_default(10)
- name_text_img = PIL.Image.new("RGB", (60, 15), color=(255, 255, 255))
- name_text_canvas = PIL.ImageDraw.Draw(name_text_img)
- name_text_canvas.text((0, 0), region.name, fill="black", font=name_text_font)
- name_text_img = name_text_img.rotate(180)
- region_img.paste(name_text_img, (10, 10))
+
+ # draw name text
+ ntext_img_width = 60
+ ntext_img_height = 7
+ ntext_font = PIL.ImageFont.load_default(ntext_img_height)
+ ntext_img = PIL.Image.new(
+ "RGB",
+ (ntext_img_width, ntext_img_height),
+ color=MemoryMap.bgcolour)
+
+ ntext_canvas = PIL.ImageDraw.Draw(ntext_img)
+
+ _, _, ntext_width, ntext_height = ntext_canvas.textbbox(
+ (0, 0),
+ region.name,
+ font=ntext_font)
+
+ ntext_canvas.text(
+ ((ntext_img_width-ntext_width)/2,
+ (ntext_img_height-ntext_height)/2-1),
+ region.name, fill="black",
+ font=ntext_font)
+
+ ntext_img = ntext_img.rotate(180)
+ region_img.paste(ntext_img, (5, 5))
### Address Text