From ece717cb39f3b4c6a2361ea72f05a2b40477f98a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Mon, 17 Nov 2014 10:33:18 -0500 Subject: [PATCH] lib/tileset: intro `TileSetFont::text_height` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/mnit/tileset.nit | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/mnit/tileset.nit b/lib/mnit/tileset.nit index 41872bd..41d8a47 100644 --- a/lib/mnit/tileset.nit +++ b/lib/mnit/tileset.nit @@ -87,6 +87,15 @@ class TileSetFont # Distance between the beginning of a letter tile and the beginning of the next letter tile fun advance: Numeric do return width.add(hspace) + + # Distance between the top of the first line to the bottom of the last line in `text` + fun text_height(text: Text): Numeric + do + if text.is_empty then return 0 + + var n_lines = text.chars.count('\n') + return (n_lines+1).mul(height.add(vspace)).sub(vspace) + end end redef class Display -- 1.7.9.5