gimp/plug-ins/script-fu/scripts/font-map.scm

74 lines
2.2 KiB
Scheme
Raw Normal View History

1997-11-24 22:05:25 +00:00
;; font-select
;; Spencer Kimball
(define (max-font-width font-list font-size)
(let* ((list font-list)
(width 0)
(maxwidth 0)
(font "")
(extents '()))
(while list
(set! font (car list))
(set! list (cdr list))
(set! extents (gimp-text-get-extents font font-size PIXELS
"*" font "*" "*" "*" "*" "*" "*"))
1997-11-24 22:05:25 +00:00
(set! width (nth 0 extents))
(if (> width maxwidth) (set! maxwidth width)))
maxwidth))
(define (max-font-height font-list font-size)
(let* ((list font-list)
(height 0)
(maxheight 0)
(font "")
(extents '()))
(while list
(set! font (car list))
(set! list (cdr list))
(set! extents (gimp-text-get-extents font font-size PIXELS
"*" font "*" "*" "*" "*" "*" "*"))
1997-11-24 22:05:25 +00:00
(set! height (nth 1 extents))
(if (> height maxheight) (set! maxheight height)))
maxheight))
(define (script-fu-font-map font-list font-size border)
(let* ((font "")
(count 0)
(text-fs 0)
(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))))
1999-10-17 00:07:55 +00:00
(gimp-image-undo-disable img)
1997-11-24 22:05:25 +00:00
(gimp-image-add-layer img drawable 0)
(gimp-edit-fill drawable BG-IMAGE-FILL)
1997-11-24 22:05:25 +00:00
(while font-list
(set! font (car font-list))
(set! font-list (cdr font-list))
(set! text-fs (car (gimp-text img drawable border (+ border (* count maxheight))
font 0 TRUE font-size PIXELS "*" font "*" "*" "*" "*" "*" "*")))
1997-11-24 22:05:25 +00:00
(set! count (+ count 1))
(gimp-floating-sel-anchor text-fs))
1999-10-17 00:07:55 +00:00
(gimp-image-undo-enable img)
1997-11-24 22:05:25 +00:00
(gimp-display-new img)))
(script-fu-register "script-fu-font-map"
_"<Toolbox>/Xtns/Script-Fu/Utils/Font Map..."
1997-11-24 22:05:25 +00:00
"Generate a listing of the specified fonts"
"Spencer Kimball"
"Spencer Kimball"
"1997"
""
SF-VALUE _"Fonts" "'(\"Agate\" \"AlfredDrake\" \"Becker\" \"Blippo\" \"Bodoni\" \"Dragonwick\" \"Engraver\" \"Futura_Poster\" \"RoostHeavy\")"
SF-ADJUSTMENT _"Font Size (pixels)" '(32 2 1000 1 10 0 1)
SF-ADJUSTMENT _"Border" '(10 0 150 1 10 0 1)
)