add getmetrics to add descent heigh to PSBT Maths and FormattedAddress

This commit is contained in:
Nick Klockenga
2024-07-19 00:54:20 -04:00
parent 0f329f6fb5
commit 5a510e5aef
2 changed files with 6 additions and 3 deletions
+3 -1
View File
@@ -22,6 +22,7 @@ class GUIConstants:
EDGE_PADDING = 8
COMPONENT_PADDING = 8
LIST_ITEM_PADDING = 4
FIXED_FONT_HEIGHT_PADDING = 6
BACKGROUND_COLOR = "black"
WARNING_COLOR = "#FFD60A"
@@ -616,7 +617,8 @@ class FormattedAddress(BaseComponent):
# Fixed width font means we only have to measure one max-height character
left, top, right, bottom = self.font.getbbox("Q")
char_width, char_height = right - left, bottom - top
ascent, descent = self.font.getmetrics()
char_width, char_height = right - left, bottom - top + descent
n = 7
display_str = f"{self.address[:n]} {self.address[n:-1*n]} {self.address[-1*n:]}"
+3 -2
View File
@@ -511,8 +511,9 @@ class PSBTMathScreen(ButtonListScreen):
body_font = Fonts.get_font(GUIConstants.BODY_FONT_NAME, (GUIConstants.BODY_FONT_SIZE)*ssf)
fixed_width_font = Fonts.get_font(GUIConstants.FIXED_WIDTH_FONT_NAME, (GUIConstants.BODY_FONT_SIZE + 6)*ssf)
left, top, right, bottom = fixed_width_font.getbbox(self.input_amount + "+")
digits_width, digits_height = right - left, bottom - top
left, top, right, bottom = fixed_width_font.getbbox(self.input_amount + "Q")
ascent, descent = fixed_width_font.getmetrics()
digits_width, digits_height = right - left, bottom - top + descent
# Draw each line of the equation
cur_y = 0