 (defn character-idxs
   [char-width characters]
   (let [character-matrix (partition-all (characters-per-line char-width (count characters)) characters)]
-    (log/info "arranging character with" characters-per-line "per line")
+    #_(log/info "arranging character with" characters-per-line "per line")
     (mapcat concat
     (map-indexed (fn [row line]
                    (map-indexed (fn [col c]

      compact-image)
    image))

(defn- hmetrics [^STBTTFontinfo font-info codepoint]
  (let [advance-width (BufferUtils/createIntBuffer 1)
        left-side-bearing (BufferUtils/createIntBuffer 1)]
    (STBTruetype/stbtt_GetCodepointHMetrics font-info (int codepoint) advance-width left-side-bearing)
    [(.get advance-width) (.get left-side-bearing)]))

(defn- codepoint-bitmap-box [^STBTTFontinfo font-info scale codepoint]
  (let [ix0 (BufferUtils/createIntBuffer 1)
        iy0 (BufferUtils/createIntBuffer 1)
        ix1 (BufferUtils/createIntBuffer 1)
        iy1 (BufferUtils/createIntBuffer 1)]
    (STBTruetype/stbtt_GetCodepointBitmapBox
      font-info
      (int codepoint)
      (float scale)
      (float scale)
      ix0

          height     cheight ;(max cwidth cheight)
          antialias  true
          char-idxs   (character-idxs char-width characters)]
      (log/info characters)
      #_(log/info "characters" (count characters) "cwidth" cwidth "cheight" cheight)
      #_(log/info "glyph image width" width "height" height)
      #_(log/info "char-idxs" char-idxs)
      ;(log/info "characters" (vec characters))
      ;(log/info "character-idxs" (vec (character-idxs characters)))
      (let [texture-image (zimg/image width height)]
        ;; Loop through each character, drawing it
        (doseq [[[codepoint glyph-index] col row]  (reverse char-idxs)]
          (try
            (let [x  (* col char-width)
                  y  (* row char-height)
                  chr-img (char-image font-info char-width char-height ascent scale codepoint glyph-index)]
              #_(log/info "drawing" codepoint "@" x y)
              (zimg/draw-image texture-image
                             chr-img
                             x
