2021-01-17 12:15:53 +01:00
|
|
|
|
;;; guile-fontconfig --- FFI bindings for FontConfig
|
|
|
|
|
;;; Copyright © 2021 Nicolò Balzarotti <nicolo@nixo.xyz>
|
|
|
|
|
;;;
|
|
|
|
|
;;; This file is part of guile-fontconfig.
|
|
|
|
|
;;;
|
|
|
|
|
;;; Guile-fontconfig is free software; you can redistribute it and/or
|
|
|
|
|
;;; modify it under the terms of the GNU Lesser General Public License
|
|
|
|
|
;;; as published by the Free Software Foundation; either version 3 of
|
|
|
|
|
;;; the License, or (at your option) any later version.
|
|
|
|
|
;;;
|
|
|
|
|
;;; Guile-fontconfig is distributed in the hope that it will be
|
|
|
|
|
;;; useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
|
|
|
;;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
;;; See the GNU General Public License for more details.
|
|
|
|
|
;;;
|
|
|
|
|
;;; You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
;;; License along with guile-fontconfig. If not, see
|
|
|
|
|
;;; <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
;;
|
|
|
|
|
;; Low-level FFI bindings.
|
|
|
|
|
;;
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
(define-module (fontconfig bindings)
|
|
|
|
|
#:use-module (fontconfig config)
|
|
|
|
|
#:use-module (system foreign)
|
2021-01-17 20:46:12 +01:00
|
|
|
|
#:export (fontconfig-pattern-create
|
|
|
|
|
fontconfig-pattern-destroy
|
2021-01-17 12:15:53 +01:00
|
|
|
|
fontconfig-object-set-destroy))
|
|
|
|
|
|
|
|
|
|
(define fontconfig-func
|
|
|
|
|
(let ((lib (dynamic-link %libfontconfig)))
|
|
|
|
|
(lambda (return-type function-name arg-types)
|
|
|
|
|
"Return a procedure for the foreign function FUNCTION-NAME in
|
|
|
|
|
the FontConfig shared library. That function must return a value of
|
|
|
|
|
RETURN-TYPE and accept arguments of ARG-TYPES."
|
|
|
|
|
(pointer->procedure return-type
|
|
|
|
|
(dynamic-func function-name lib)
|
|
|
|
|
arg-types))))
|
|
|
|
|
|
|
|
|
|
(define-syntax-rule (define-foreign name return-type func-name arg-types)
|
|
|
|
|
(define-public name
|
|
|
|
|
(fontconfig-func return-type func-name arg-types)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Initialization
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define-foreign fontconfig-init-load-config-and-fonts
|
|
|
|
|
'* "FcInitLoadConfigAndFonts" '())
|
|
|
|
|
|
|
|
|
|
(define-foreign fontconfig-finalize
|
|
|
|
|
void "FcFini" '())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Version
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define-foreign fontconfig-get-version
|
|
|
|
|
int "FcGetVersion" '())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Pattern
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define-foreign fontconfig-pattern-create
|
|
|
|
|
'* "FcPatternCreate" '())
|
|
|
|
|
|
|
|
|
|
(define fontconfig-pattern-destroy
|
|
|
|
|
(dynamic-func "FcPatternDestroy" (dynamic-link %libfontconfig)))
|
|
|
|
|
|
2021-01-18 10:24:39 +01:00
|
|
|
|
;; (define-foreign fontconfig-pattern-destroy
|
|
|
|
|
;; void "FcPatternDestroy" '(*))
|
|
|
|
|
|
2021-01-17 12:15:53 +01:00
|
|
|
|
(define-foreign fontconfig-pattern-add-string
|
|
|
|
|
int "FcPatternAddString" '(* * *))
|
|
|
|
|
|
|
|
|
|
(define-foreign fontconfig-pattern-add-double
|
|
|
|
|
int "FcPatternAddDouble" `(* * ,double))
|
|
|
|
|
|
|
|
|
|
(define-foreign fontconfig-pattern-add-integer
|
|
|
|
|
int "FcPatternAddInteger" `(* * ,int))
|
|
|
|
|
|
|
|
|
|
(define-foreign fontconfig-pattern-add-bool
|
|
|
|
|
int "FcPatternAddBool" `(* * ,int))
|
|
|
|
|
|
|
|
|
|
(define-foreign fontconfig-name-unparse
|
|
|
|
|
'* "FcNameUnparse" '(*))
|
|
|
|
|
|
|
|
|
|
(define-foreign fontconfig-pattern-format
|
|
|
|
|
'* "FcPatternFormat" '(* *))
|
|
|
|
|
|
|
|
|
|
;; FcResult (FcPattern *p, const char *object, int id, FcValue *v);
|
|
|
|
|
(define-foreign fontconfig-pattern-get
|
|
|
|
|
int "FcPatternGet" `(* * ,int *))
|
|
|
|
|
|
2021-01-18 12:15:38 +01:00
|
|
|
|
(define-foreign libc-free void "free" '(*))
|
|
|
|
|
|
2021-01-18 22:05:06 +01:00
|
|
|
|
|
2021-01-17 12:15:53 +01:00
|
|
|
|
;;;
|
|
|
|
|
;;; Object Set
|
|
|
|
|
;;;
|
|
|
|
|
(define-foreign fontconfig-object-set-create
|
|
|
|
|
'* "FcObjectSetCreate" '())
|
|
|
|
|
|
|
|
|
|
(define-foreign fontconfig-object-set-add
|
|
|
|
|
int "FcObjectSetAdd" '(* *))
|
|
|
|
|
|
|
|
|
|
(define-foreign fontconfig-font-list
|
|
|
|
|
'* "FcFontList" '(* * *))
|
|
|
|
|
|
|
|
|
|
(define fontconfig-object-set-destroy
|
|
|
|
|
(dynamic-func "FcObjectSetDestroy" (dynamic-link %libfontconfig)))
|