Created
December 24, 2020 06:17
-
-
Save lokedhs/50b92d6f9d77fc565a0601dc4ca2ee0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-g-boxed-cstruct pango-rectangle "PangoRectangle" | |
(x :int :initform 0) | |
(y :int :initform 0) | |
(width :int :initform 0) | |
(height :int :initform 0)) | |
(defcfun ("pango_layout_get_pixel_extents" %pango-layout-get-pixel-extents) :void | |
(layout (g-object pango-layout)) | |
(ink-rect (:pointer (:struct pango-rectangle-cstruct))) | |
(logical-rect (:pointer (:struct pango-rectangle-cstruct)))) | |
(defun pango-layout-get-pixel-extents (layout) | |
(with-foreign-objects ((ink-rect '(:struct pango-rectangle-cstruct)) | |
(logical-rect '(:struct pango-rectangle-cstruct))) | |
(%pango-layout-get-pixel-extents layout ink-rect logical-rect) | |
(let ((a (make-pango-rectangle :x (cffi:foreign-slot-value ink-rect '(:struct pango-rectangle-cstruct) 'x) | |
:y (cffi:foreign-slot-value ink-rect '(:struct pango-rectangle-cstruct) 'y) | |
:width (cffi:foreign-slot-value ink-rect '(:struct pango-rectangle-cstruct) 'width) | |
:height (cffi:foreign-slot-value ink-rect '(:struct pango-rectangle-cstruct) 'height))) | |
(b (make-pango-rectangle :x (cffi:foreign-slot-value logical-rect '(:struct pango-rectangle-cstruct) 'x) | |
:y (cffi:foreign-slot-value logical-rect '(:struct pango-rectangle-cstruct) 'y) | |
:width (cffi:foreign-slot-value logical-rect '(:struct pango-rectangle-cstruct) 'width) | |
:height (cffi:foreign-slot-value logical-rect '(:struct pango-rectangle-cstruct) 'height)))) | |
(values a b)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment