comparison lisp/w3/css.el @ 134:34a5b81f86ba r20-2b1

Import from CVS: tag r20-2b1
author cvs
date Mon, 13 Aug 2007 09:30:11 +0200
parents 7d55a9ba150c
children b980b6286996
comparison
equal deleted inserted replaced
133:b27e67717092 134:34a5b81f86ba
1 ;;; css.el -- Cascading Style Sheet parser 1 ;;; css.el -- Cascading Style Sheet parser
2 ;; Author: wmperry 2 ;; Author: wmperry
3 ;; Created: 1997/04/01 19:21:41 3 ;; Created: 1997/04/17 13:50:34
4 ;; Version: 1.34 4 ;; Version: 1.36
5 ;; Keywords: 5 ;; Keywords:
6 6
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 ;;; Copyright (c) 1996 by William M. Perry (wmperry@cs.indiana.edu) 8 ;;; Copyright (c) 1996 by William M. Perry (wmperry@cs.indiana.edu)
9 ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc. 9 ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc.
141 [page-break-before nil symbol] 141 [page-break-before nil symbol]
142 [page-break-after nil symbol] 142 [page-break-after nil symbol]
143 143
144 ;; These are for specifying speech properties (Raman-style) 144 ;; These are for specifying speech properties (Raman-style)
145 [voice-family t string] 145 [voice-family t string]
146 [gain t integer] 146 [gain t symbol]
147 [left-volume t integer] 147 [left-volume t integer]
148 [right-volume t integer] 148 [right-volume t integer]
149 [pitch t integer] 149 [pitch t integer]
150 [pitch-range t integer] 150 [pitch-range t integer]
151 [stress t integer] 151 [stress t integer]
342 342
343 (defun css-split-font-shorthand (font) 343 (defun css-split-font-shorthand (font)
344 ;; [<font-weight> || <font-style>]? <font-size> [ / <line-height> ]? <font-family> 344 ;; [<font-weight> || <font-style>]? <font-size> [ / <line-height> ]? <font-family>
345 (let (weight size height family retval) 345 (let (weight size height family retval)
346 (if (not (string-match " *\\([0-9.]+[^ /]+\\)" font)) 346 (if (not (string-match " *\\([0-9.]+[^ /]+\\)" font))
347 (error "Malformed font shorthand: %s" font)) 347 (progn
348 (setq weight (if (/= 0 (match-beginning 0)) 348 (message "Malformed font shorthand: %s" font)
349 (substring font 0 (match-beginning 0))) 349 nil)
350 size (match-string 1 font) 350 (setq weight (if (/= 0 (match-beginning 0))
351 font (substring font (match-end 0) nil)) 351 (substring font 0 (match-beginning 0)))
352 (if (string-match " */ *\\([^ ]+\\) *" font) 352 size (match-string 1 font)
353 ;; they specified a line-height as well 353 font (substring font (match-end 0) nil))
354 (setq height (match-string 1 font) 354 (if (string-match " */ *\\([^ ]+\\) *" font)
355 family (substring font (match-end 0) nil)) 355 ;; they specified a line-height as well
356 (if (string-match "^[ \t]+" font) 356 (setq height (match-string 1 font)
357 (setq family (substring font (match-end 0) nil)) 357 family (substring font (match-end 0) nil))
358 (setq family font))) 358 (if (string-match "^[ \t]+" font)
359 (if weight 359 (setq family (substring font (match-end 0) nil))
360 (push (cons 'font-weight (css-expand-value 'weight weight)) retval)) 360 (setq family font)))
361 (if size 361 (if weight
362 (push (cons 'font-size (css-expand-length size)) retval)) 362 (push (cons 'font-weight (css-expand-value 'weight weight)) retval))
363 (if height 363 (if size
364 (push (cons 'line-height (css-expand-length height t)) retval)) 364 (push (cons 'font-size (css-expand-length size)) retval))
365 (if family 365 (if height
366 (push (cons 'font-family (css-expand-value 'string-list family)) retval)) 366 (push (cons 'line-height (css-expand-length height t)) retval))
367 retval)) 367 (if family
368 (push (cons 'font-family (css-expand-value 'string-list family)) retval))
369 retval)))
368 370
369 (if (not (fboundp 'frame-char-height)) 371 (if (not (fboundp 'frame-char-height))
370 (defun frame-char-height (&optional frame) 372 (defun frame-char-height (&optional frame)
371 "Height in pixels of a line in the font in frame FRAME. 373 "Height in pixels of a line in the font in frame FRAME.
372 If FRAME is omitted, the selected frame is used. 374 If FRAME is omitted, the selected frame is used.