No matching definitions.

plutovg/font

src/plutovg/font.tur
defn

font-face-load-from-file

(font-face-load-from-file [path :cstr index :int] :ptr<void>)

load a font face from disk.

pathfilesystem path to a TTF / OTF / TTC file
indexface index within a TrueType Collection; 0 for the typical
single-face .ttf/.otf

(ok face-handle) on success; (err 0) if plutovg cannot load the file.

(font-face-load-from-file "/Library/Fonts/Helvetica.ttc" 0)

Since: PV5

defn

font-face-load-from-data

(font-face-load-from-data [data :cstr len :int index :int] :ptr<void>)

load a font face from an in-memory buffer.

datapointer to the raw TTF/OTF bytes (:cstr)
lenlength in bytes
indexface index (0 for single-face data)

(ok face-handle) on success; (err 0) on failure. The buffer is borrowed -- plutovg holds the pointer for the lifetime of the face. Free the buffer only AFTER font-face-destroy.

Since: PV5

defn

font-face-destroy

(font-face-destroy [ff :int] :void)

release a font face.

Since: PV5

defn

font-face-ascent

(font-face-ascent [ff :int size :float] :float)

return the ascender (above baseline) in pixels at

Since: PV5

defn

font-face-descent

(font-face-descent [ff :int size :float] :float)

return the descender (below baseline, typically

Since: PV5

defn

font-face-line-gap

(font-face-line-gap [ff :int size :float] :float)

return the recommended extra spacing between

Since: PV5

defn

font-face-text-extents

(font-face-text-extents [ff :int size :float text :cstr] :ptr<void>)

measure a string at a given font size.

fffont-face handle
sizefont size in pixels
textUTF-8 :cstr (use canvas-text-extents for other encodings)

(ok rect-handle) -- bounding box of the rendered text. Release with rect-destroy (re-exported from plutovg/path).

(let [r (font-face-text-extents ff 24.0 "Hello")]
    (let [box (ok-val r)]
      (println (rect-w box))
      (rect-destroy box)))

Since: PV5

defn

font-cache-create

(font-cache-create :ptr<void>)

allocate a new empty font-face cache.

(ok cache-handle) on success; (err 0) on allocation failure.

Since: PV5

defn

font-cache-destroy

(font-cache-destroy [fc :int] :void)

release a font-face cache and all faces it owns.

Since: PV5

defn

font-cache-add-file

(font-cache-add-file [fc :int path :cstr] :ptr<void>)

load all faces from a font file and register

fccache handle
pathfilesystem path to a TTF/OTF/TTC file

(ok n) where n is the number of faces actually added; (err 0) on load failure.

(font-cache-add-file fc "/System/Library/Fonts/Helvetica.ttc")

Since: PV5

defn

font-cache-load-system

(font-cache-load-system [fc :int] :ptr<void>)

discover and register fonts from the

(ok n) where n is the number of faces registered; (err 0) if no system fonts were found.

Since: PV5

defn

font-cache-get

(font-cache-get [fc :int family :cstr style :cstr size :float] :ptr<void>)

look up a font face by family name and style.

fccache handle
familyCSS-style family name (e.g. "Helvetica", "Arial")
style":regular", ":bold", ":italic", ":bold-italic"
sizerequested font size in pixels. This argument is currently
ignored at lookup time (plutovg caches faces, not sized
instances) but is accepted for forward compatibility and
API symmetry with the plan.

(ok face-handle) on success; (err 0) if no matching face is registered. The face is owned by the cache -- do NOT call font-face-destroy on it.

(font-cache-get fc "Helvetica" ":bold" 24.0)

Since: PV5

defn

canvas-set-font-face

(canvas-set-font-face [c :int ff :int] :void)

set the canvas's current font face without

Since: PV5

defn

canvas-set-font-size

(canvas-set-font-size [c :int size :float] :void)

set the canvas's current font size in pixels.

Since: PV5

defn

canvas-set-font

(canvas-set-font [c :int ff :int size :float] :void)

set face + size in a single call.

Since: PV5

defn

canvas-fill-text

(canvas-fill-text [c :int text :cstr encoding :cstr x :float y :float] :void)

fill `text` at (x, y) using the current paint, font

ccanvas handle
text:cstr text buffer
encoding":utf8" (default), ":utf16", ":utf32", or ":latin1"
xbaseline x in surface space
ybaseline y in surface space

void. (plutovg returns the advance width as a float; we drop it. Use canvas-text-extents if you need the bounding box.)

Since: PV5

defn

canvas-stroke-text

(canvas-stroke-text [c :int text :cstr encoding :cstr x :float y :float] :void)

stroke `text` at (x, y) using the current stroke

Since: PV5

defn

canvas-text-extents

(canvas-text-extents [c :int text :cstr encoding :cstr] :ptr<void>)

measure text using the canvas's current font.

ccanvas handle (must have a font set via canvas-set-font*)
text:cstr text buffer
encoding":utf8" (default), ":utf16", ":utf32", or ":latin1"

(ok rect-handle) -- release with rect-destroy.

Since: PV5

Internal definitions
__ok-- create an ok result wrapping integer value v.
__err-- create an err result wrapping integer error value e.