Keep text layers instead of merging them down. Allow to specify a text to

2003-09-04  Sven Neumann  <sven@gimp.org>

	* plug-ins/script-fu/scripts/font-map.scm (script-fu-font-map):
	Keep text layers instead of merging them down. Allow to specify a
	text to render in place of the font names.
This commit is contained in:
Sven Neumann 2003-09-04 19:44:26 +00:00 committed by Sven Neumann
parent 203d86291e
commit 501f84b11f
2 changed files with 49 additions and 35 deletions

View File

@ -1,3 +1,9 @@
2003-09-04 Sven Neumann <sven@gimp.org>
* plug-ins/script-fu/scripts/font-map.scm (script-fu-font-map):
Keep text layers instead of merging them down. Allow to specify a
text to render in place of the font names.
2003-09-04 Sven Neumann <sven@gimp.org> 2003-09-04 Sven Neumann <sven@gimp.org>
* autogen.sh (LIBTOOL_WIN32): changed to 1.5 since win32 libtool * autogen.sh (LIBTOOL_WIN32): changed to 1.5 since win32 libtool

View File

@ -1,53 +1,58 @@
;; font-select ;; font-select
;; Spencer Kimball ;; Spencer Kimball
(define (max-font-width font-list font-size) (define (max-font-width text use-name font-list font-size)
(let* ((list font-list) (let* ((list font-list)
(width 0) (width 0)
(maxwidth 0) (maxwidth 0)
(font "") (font "")
(extents '())) (extents '()))
(while list (while list
(set! font (car list)) (set! font (car list))
(set! list (cdr list)) (set! list (cdr list))
(set! extents (gimp-text-get-extents-fontname font (if (= use-name TRUE)
(set! text font))
(set! extents (gimp-text-get-extents-fontname text
font-size PIXELS font-size PIXELS
font)) font))
(set! width (nth 0 extents)) (set! width (nth 0 extents))
(if (> width maxwidth) (set! maxwidth width))) (if (> width maxwidth)
(set! maxwidth width)))
maxwidth)) maxwidth))
(define (max-font-height font-list font-size) (define (max-font-height text use-name font-list font-size)
(let* ((list font-list) (let* ((list font-list)
(height 0) (height 0)
(maxheight 0) (maxheight 0)
(font "") (font "")
(extents '())) (extents '()))
(while list (while list
(set! font (car list)) (set! font (car list))
(set! list (cdr list)) (set! list (cdr list))
(set! extents (gimp-text-get-extents-fontname font (if (= use-name TRUE)
(set! text font))
(set! extents (gimp-text-get-extents-fontname text
font-size PIXELS font-size PIXELS
font)) font))
(set! height (nth 1 extents)) (set! height (nth 1 extents))
(if (> height maxheight) (set! maxheight height))) (if (> height maxheight)
(set! maxheight height)))
maxheight)) maxheight))
(define (script-fu-font-map font-filter font-size border) (define (script-fu-font-map text use-name font-filter font-size border)
(let* ((font "") (let* ((font "")
(count 0) (count 0)
(text-fs 0)
(font-list (cadr (gimp-fonts-get-list font-filter))) (font-list (cadr (gimp-fonts-get-list font-filter)))
(num-fonts (length font-list)) (num-fonts (length font-list))
(maxheight (max-font-height font-list font-size)) (maxheight (max-font-height text use-name font-list font-size))
(maxwidth (max-font-width font-list font-size)) (maxwidth (max-font-width text use-name font-list font-size))
(width (+ maxwidth (* 2 border))) (width (+ maxwidth (* 2 border)))
(height (+ (* maxheight num-fonts) (* 2 border))) (height (+ (* maxheight num-fonts) (* 2 border)))
(img (car (gimp-image-new width height GRAY))) (img (car (gimp-image-new width height GRAY)))
(drawable (car (gimp-layer-new img width height GRAY_IMAGE (drawable (car (gimp-layer-new img width height GRAY_IMAGE
"Font List" 100 NORMAL)))) "Background" 100 NORMAL))))
(gimp-image-undo-disable img) (gimp-image-undo-disable img)
(gimp-image-add-layer img drawable 0) (gimp-image-add-layer img drawable 0)
(gimp-edit-fill drawable BG-IMAGE-FILL) (gimp-edit-fill drawable BG-IMAGE-FILL)
@ -55,15 +60,17 @@
(while font-list (while font-list
(set! font (car font-list)) (set! font (car font-list))
(set! font-list (cdr font-list)) (set! font-list (cdr font-list))
(set! text-fs (car (gimp-text-fontname img drawable (if (= use-name TRUE)
border (set! text font))
(+ border (* count maxheight)) (gimp-text-fontname img -1
font border
0 TRUE font-size PIXELS (+ border (* count maxheight))
font))) text
(set! count (+ count 1)) 0 TRUE font-size PIXELS
(gimp-floating-sel-anchor text-fs)) font)
(set! count (+ count 1)))
(gimp-image-set-active-layer img drawable)
(gimp-image-undo-enable img) (gimp-image-undo-enable img)
(gimp-display-new img))) (gimp-display-new img)))
@ -74,7 +81,8 @@
"Spencer Kimball" "Spencer Kimball"
"1997" "1997"
"" ""
SF-STRING _"Filter (regexp)" "Sans" SF-STRING _"Text" "How quickly daft jumping zebras vex."
SF-ADJUSTMENT _"Font Size (pixels)" '(32 2 1000 1 10 0 1) SF-TOGGLE _"Use Font Name as Text" TRUE
SF-ADJUSTMENT _"Border" '(10 0 150 1 10 0 1) SF-STRING _"Filter (regexp)" "Sans"
) SF-ADJUSTMENT _"Font Size (pixels)" '(32 2 1000 1 10 0 1)
SF-ADJUSTMENT _"Border (pixels)" '(10 0 200 1 10 0 1))