diff lisp/fontconfig.el @ 4408:8bbabcab2c42

Merge.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 20 Jan 2008 13:09:58 +0100
parents f5693b5f7f2d
children 517f6887fbc0
line wrap: on
line diff
--- a/lisp/fontconfig.el	Wed Dec 26 17:30:16 2007 +0100
+++ b/lisp/fontconfig.el	Sun Jan 20 13:09:58 2008 +0100
@@ -350,6 +350,21 @@
   (let ((pair (assoc str fc-font-name-weight-mapping-string-reverse)))
     (if pair (cdr pair))))
 
+(defun fc-pattern-get-or-compute-size (pattern id)
+  "Get the size from `pattern' associated with `id' or try to compute it.
+Returns 'fc-result-no-match if unsucessful."
+  ;;  Many font patterns don't have a "size" property, but do have a
+  ;;  "dpi" and a "pixelsize" property".
+  (let ((maybe (fc-pattern-get-size pattern id)))
+    (if (not (eq maybe 'fc-result-no-match))
+	maybe
+      (let ((dpi (fc-pattern-get-dpi pattern id))
+	    (pixelsize (fc-pattern-get-pixelsize pattern id)))
+	(if (and (numberp dpi)
+		 (numberp pixelsize))
+	    (* pixelsize (/ 72 dpi))
+	  'fc-result-no-match)))))
+
 (defun fc-copy-pattern-partial (pattern attribute-list)
   "Return a copy of PATTERN restricted to ATTRIBUTE-LIST.