cl-freetype2

2022-07-08

Wrapper for the Freetype2 library

Upstream URL

github.com/rpav/cl-freetype2

Author

Ryan Pavlik <rpavlik@gmail.com>

License

New BSD, LLGPL
README

cl-freetype2

This is a general Freetype 2 wrapper for Common Lisp using CFFI. It's geared toward both using Freetype directly by providing a simplified API, as well as providing access to the underlying C structures and functions for use with other libraries which may also use Freetype.

Platform

Confirmed working:

  • SBCL
  • Clozure
  • CLISP (with CVS libffcall only, otherwise callbacks don't work)

Confirmed not working:

  • ECL (CFFI doesn't load)
  • ABCL (CFFI loads, but can't grovel?)

Documentation

See doc/cl-freetype2.html for complete documentation.

Example

An example using the toy interface:

(defparameter *face* (new-face "/usr/share/fonts/corefonts/times.ttf"))

;; Set the size to 24 points and 72 DPI
(set-char-size *face* (* 24 64) 0 72 72)

;; Trivial output:
(print-with-face *face* "Hello")

;; Output (if this doesn't display, make sure your encoding is
;; set to UTF-8):
                                                        ▒▒▓▓██      ▒▒▓▓██                            
████████████      ████████████                        ████████    ████████                            
  ▒▒████░░          ▒▒████░░                              ████        ████                            
    ████              ████                                ████        ████                            
    ████              ████                                ████        ████                            
    ████              ████                                ████        ████                            
    ████              ████            ░░██████▓▓          ████        ████          ░░▓▓████▓▓░░      
    ████              ████          ▒▒██░░  ░░████        ████        ████        ░░██░░    ▓▓██▒▒    
    ██████████████████████        ░░██▒▒      ░░██▒▒      ████        ████        ██▒▒        ████░░  
    ████              ████        ▓▓██          ████      ████        ████      ▒▒██          ▒▒██▓▓  
    ████              ████        ██████████████████      ████        ████      ████            ████  
    ████              ████        ████                    ████        ████      ████            ████  
    ████              ████        ████░░          ░░      ████        ████      ████░░          ████  
    ████              ████        ▓▓██▓▓        ░░▓▓      ████        ████      ▓▓██▒▒          ██▒▒  
    ████              ████        ░░████▓▓    ░░██░░      ████        ████      ░░████        ░░██    
  ░░████░░          ░░████░░        ▓▓██████████▒▒      ▒▒████▒▒    ▒▒████▒▒      ▒▒████    ░░██░░    
████████████      ████████████        ▒▒██████░░      ████████████████████████      ░░▓▓████▓▓░░      


;; Trivial output:
(print-with-face *face* "Hello" :right-left)
                                                                                                   
                                                                                                   
                                                                                                       
                         ▒▒▓▓██      ▒▒▓▓██                                                            
                       ████████    ████████                            ████████████      ████████████  
                           ████        ████                              ▒▒████░░          ▒▒████░░    
                           ████        ████                                ████              ████      
                           ████        ████                                ████              ████      
                           ████        ████                                ████              ████      
     ░░▓▓████▓▓░░          ████        ████          ░░██████▓▓            ████              ████      
   ░░██░░    ▓▓██▒▒        ████        ████        ▒▒██░░  ░░████          ████              ████      
   ██▒▒        ████░░      ████        ████      ░░██▒▒      ░░██▒▒        ██████████████████████      
 ▒▒██          ▒▒██▓▓      ████        ████      ▓▓██          ████        ████              ████      
 ████            ████      ████        ████      ██████████████████        ████              ████      
 ████            ████      ████        ████      ████                      ████              ████      
 ████░░          ████      ████        ████      ████░░          ░░        ████              ████      
 ▓▓██▒▒          ██▒▒      ████        ████      ▓▓██▓▓        ░░▓▓        ████              ████      
 ░░████        ░░██        ████        ████      ░░████▓▓    ░░██░░        ████              ████      
   ▒▒████    ░░██░░      ▒▒████▒▒    ▒▒████▒▒      ▓▓██████████▒▒        ░░████░░          ░░████░░    
     ░░▓▓████▓▓░░      ████████████████████████      ▒▒██████░░        ████████████      ████████████  


;; Trivial output:
(print-with-face *face* "XY" :up-down)


░░████████████▓▓      ▓▓████████▓▓              
    ▒▒██████░░          ░░████░░                
      ░░████▒▒          ▒▒██                    
        ░░████        ░░██                      
          ▓▓████      ██░░                      
            ████▒▒  ▓▓▒▒                        
            ░░████▒▒▓▓                          
              ▒▒████                            
                ████▒▒                          
              ▒▒▒▒████                          
            ░░▓▓  ▒▒████                        
            ██      ▓▓██▒▒                      
          ▓▓░░        ████░░                    
        ▓▓▒▒          ░░████                    
    ░░████              ██████░░                
  ██████████░░      ▓▓████████████              
                                                
                                                
                                                
                                                
                                                
                                                
  ████████████▒▒      ▒▒██████████              
    ▒▒████▓▓              ████░░                
      ░░████              ██                    
        ▒▒██▓▓          ▓▓░░                    
          ████░░      ░░▓▓                      
          ░░████      ██                        
            ▓▓██▒▒  ▒▒▒▒                        
              ████░░██                          
              ▒▒████░░                          
                ████                            
                ████                            
                ████                            
                ████                            
                ████                            
              ░░████░░                          
            ████████████

Dependencies (6)

  • alexandria
  • cffi
  • cl-markdown
  • cl-who
  • fiveam
  • trivial-garbage

Dependents (3)

  • GitHub
  • Quicklisp