changeset 182:fefcd73386c2

Workaround to allow empty text lines in labels.
author Mikhail Kryshen <mikhail@kryshen.net>
date Tue, 01 Dec 2015 19:31:17 +0300
parents fc9c674a4d54
children a43e3c9b007e
files src/indyvon/views.clj
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/indyvon/views.clj	Wed Nov 18 19:12:12 2015 +0300
+++ b/src/indyvon/views.clj	Tue Dec 01 19:31:17 2015 +0300
@@ -246,8 +246,11 @@
 
 (defn- get-text-layout
   [^String line ^Font font ^FontRenderContext font-context]
-  (.get text-layout-cache [line font font-context]
-        #(TextLayout. line font font-context)))
+  ;; XXX: TextLayout fails on empty strings, use zero-width space as a
+  ;; workaround.
+  (let [line (if (.isEmpty line) "\u200b" line)]
+    (.get text-layout-cache [line font font-context]
+          #(TextLayout. line font font-context))))
 
 (defn- layout-text
   [lines font font-context]