          :character-height char-height
          :character->col-row (character->col-row char-idxs)
          :character->transparent (zipmap characters (repeat transparent))}))))
-
 
 (defrecord CompositeFont [fonts]
   GlyphGraphics

  GlyphGraphics
  (glyph-graphics [this]
    ;; Adjust canvas to fit character atlas size
    (let [^STBTTFontinfo font-info   (make-font name-or-path)
          scale                      (STBTruetype/stbtt_ScaleForPixelHeight
                                       font-info
                                       size)
          [advance
           left-side-bearing]        (map (partial * scale)
                                       (hmetrics font-info
                                                 (STBTruetype/stbtt_FindGlyphIndex
                                                   font-info
                                                   (int \M))))

      compact-image)
    image))

(defn-ms hmetrics [^MemoryStack ms ^STBTTFontinfo font-info glyph-index]
  (let [advance-width     (.mallocInt ms 1)
        left-side-bearing (.mallocInt ms 1)]
    (log-call "STBTruetype/stbtt_GetGlyphHMetrics" font-info (int glyph-index) advance-width left-side-bearing)
    (STBTruetype/stbtt_GetGlyphHMetrics font-info (int glyph-index) advance-width left-side-bearing)
    [(.get advance-width) (.get left-side-bearing)]))

(defn-ms vmetrics [^MemoryStack ms ^STBTTFontinfo font-info]
  (let [ascent   (.mallocInt ms 1)
        descent  (.mallocInt ms 1)
        line-gap (.mallocInt ms 1)]
    (log-call "STBTruetype/stbtt_GetFontVMetrics" font-info ascent descent line-gap)
    (STBTruetype/stbtt_GetFontVMetrics font-info ascent descent line-gap)
    [(.get ascent) (.get descent) (.get line-gap)]))

(defn-ms glyph-bitmap-box [^MemoryStack ms ^STBTTFontinfo font-info scale glyph-index]
  (let [ix0 (.mallocInt ms 1)
        iy0 (.mallocInt ms 1)
        ix1 (.mallocInt ms 1)
        iy1 (.mallocInt ms 1)]
    (log-call "STBTruetype/stbtt_GetGlyphBitmapBox"
      font-info
      (int glyph-index)
