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

120 lines
3.4 KiB
Scheme
Raw Normal View History

1997-11-24 14:05:25 -08:00
;; font-select
;; Spencer Kimball
(define (max-font-width text use-name font-list font-size)
(let* ((list font-list)
(width 0)
1997-11-24 14:05:25 -08:00
(maxwidth 0)
(font "")
(extents '()))
1997-11-24 14:05:25 -08:00
(while list
(set! font (car list))
(set! list (cdr list))
(if (= use-name TRUE)
(set! text font))
(set! extents (gimp-text-get-extents-fontname text
font-size PIXELS
font))
1997-11-24 14:05:25 -08:00
(set! width (nth 0 extents))
(if (> width maxwidth)
(set! maxwidth width)))
1997-11-24 14:05:25 -08:00
maxwidth))
(define (max-font-height text use-name font-list font-size)
(let* ((list font-list)
(height 0)
1997-11-24 14:05:25 -08:00
(maxheight 0)
(font "")
(extents '()))
1997-11-24 14:05:25 -08:00
(while list
(set! font (car list))
(set! list (cdr list))
(if (= use-name TRUE)
(set! text font))
(set! extents (gimp-text-get-extents-fontname text
font-size PIXELS
font))
1997-11-24 14:05:25 -08:00
(set! height (nth 1 extents))
(if (> height maxheight)
(set! maxheight height)))
1997-11-24 14:05:25 -08:00
maxheight))
(define (script-fu-font-map text use-name labels font-filter font-size border)
(let* ((font "")
(count 0)
(font-list (cadr (gimp-fonts-get-list font-filter)))
(num-fonts (length font-list))
(label-size (/ font-size 2))
(border (+ border (* labels (/ label-size 2))))
(y border)
(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))
(* labels (* label-size num-fonts))))
(img (car (gimp-image-new width height GRAY)))
(drawable (car (gimp-layer-new img width height GRAY-IMAGE
"Background" 100 NORMAL-MODE))))
1999-10-16 17:07:55 -07:00
(gimp-image-undo-disable img)
(gimp-edit-clear drawable)
1997-11-24 14:05:25 -08:00
(gimp-image-add-layer img drawable 0)
(if (= labels TRUE)
(begin
(set! drawable (car (gimp-layer-new img width height GRAYA-IMAGE
"Labels" 100 NORMAL-MODE)))
(gimp-edit-clear drawable)
(gimp-image-add-layer img drawable -1)))
1997-11-24 14:05:25 -08:00
(while font-list
(set! font (car font-list))
(set! font-list (cdr font-list))
(if (= use-name TRUE)
(set! text font))
(gimp-text-fontname img -1
border
y
text
0 TRUE font-size PIXELS
font)
(set! y (+ y maxheight))
(if (= labels TRUE)
(begin
(gimp-floating-sel-anchor (car (gimp-text-fontname img drawable
(- border
(/ label-size 2))
(- y
(/ label-size 2))
font
0 TRUE
label-size PIXELS
"Sans")))
(set! y (+ y label-size))))
(set! count (+ count 1)))
1997-11-24 14:05:25 -08:00
(gimp-image-set-active-layer img drawable)
1999-10-16 17:07:55 -07:00
(gimp-image-undo-enable img)
1997-11-24 14:05:25 -08:00
(gimp-display-new img)))
(script-fu-register "script-fu-font-map"
removed function gimp_menu_path_strip_uline() ... 2003-08-09 Henrik Brix Andersen <brix@gimp.org> * gimp/app/widgets/gimpwidgets-utils.[ch]: removed function gimp_menu_path_strip_uline() ... * gimp/libgimpbase/gimputils.[ch]: ... and added it here under the name gimp_strip_uline() * gimp/devel-docs/libgimpbase/libgimpbase-sections.txt: added gimp_strip_uline to gimputils section * gimp/app/plug-in/plug-in.c * gimp/app/widgets/gimpitemfactory.c * gimp/app/widgets/gimptoolbox. * gimp/app/gui/plug-in-menus.c: changed accordingly * gimp/plug-ins/script-fu/script-fu-scripts.c (script_fu_interface): use gimp_strip_uline() to strip mnemonics from script-fu menu paths * gimp/app/gui/vectors-menu.c * gimp/app/gui/templates-menu.c * gimp/app/gui/qmask-menu.c * gimp/app/gui/palettes-menu.c * gimp/app/gui/palette-editor-menu.c * gimp/app/gui/images-menu.c * gimp/app/gui/gradients-menu.c * gimp/app/gui/gradient-editor-menu.c * gimp/app/gui/documents-menu.c * gimp/app/gui/dialogs-menu.c * gimp/app/gui/colormap-editor-menu.c * gimp/app/gui/channels-menu.c * gimp/app/gui/buffers-menu.c * gimp/app/gui/brushes-menu.c * gimp/app/gui/layers-menu.c * gimp/plug-ins/pygimp/plug-ins/clothify.py * gimp/plug-ins/pygimp/plug-ins/shadow_bevel.py * gimp/plug-ins/pygimp/plug-ins/whirlpinch.py * gimp/plug-ins/pygimp/plug-ins/foggify.py * gimp/plug-ins/script-fu/scripts/*.scm * gimp/plug-ins/script-fu/script-fu.c: added mnemonics fixing more of bug #106991 * gimp/app/gui/error-console-menu.c (error_console_menu_update): updated menu item names, added mnemonics * gimp/plug-ins/common/animoptimize.c * gimp/plug-ins/common/animationplay.c: don't prepend every menu entry with "Animation"
2003-08-11 10:14:32 -07:00
_"<Toolbox>/Xtns/Script-Fu/Utils/_Font Map..."
"Generate a listing of fonts matching a filter"
1997-11-24 14:05:25 -08:00
"Spencer Kimball"
"Spencer Kimball"
"1997"
""
SF-STRING _"Text" "How quickly daft jumping zebras vex."
SF-TOGGLE _"Use Font Name as Text" FALSE
SF-TOGGLE _"Labels" 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))