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>
* autogen.sh (LIBTOOL_WIN32): changed to 1.5 since win32 libtool

View File

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