; NFont Renderer by Jonny D (GrimFang4@hotmail.com) ; Edition of Mike Oliphant's SFont Renderer ; ; Use this script-fu script in 'The Gimp 2.4' to create a bitmap for use as ; a font image for NFont (or SFont). NFont is a C++ font class ; that provides great bitmap font functionality under ; SDL (Simple DirectMedia Layer). ; ;; ;; SFont Renderer ;; ;; Render a font to be used with the SFont library ;; ;; Written by Mike Oliphant (http://nostatic.org) ;; Based on other logo examples that came with the gimp ;; ; Subroutine of the Gimp call (define (apply-create-nfont-effect img logo-layer top-color bottom-color background-color do-shadow do-bumpmap do-ext-ascii) (let* ((width (car (gimp-drawable-width logo-layer))) (height (car (gimp-drawable-height logo-layer))) (shadow-layer (car (gimp-layer-new img width height RGBA-IMAGE "Shadow" 100 MULTIPLY))) (bottom-layer (car (gimp-layer-new img width height RGBA-IMAGE "Bottom" 0 MULTIPLY))) (old-fg (car (gimp-palette-get-foreground))) (old-bg (car (gimp-palette-get-background)))) (gimp-selection-none img) ;(script-fu-util-image-resize-from-layer img logo-layer) (gimp-image-resize img width height 0 0) (gimp-image-add-layer img bottom-layer 2) (gimp-palette-set-foreground background-color) (gimp-edit-fill bottom-layer FOREGROUND-FILL) (if (equal? do-shadow TRUE) (begin (gimp-image-add-layer img shadow-layer 1) (gimp-palette-set-foreground '(0 0 0)) (gimp-layer-set-preserve-trans logo-layer 100) (gimp-edit-fill logo-layer FOREGROUND-FILL) (gimp-edit-clear shadow-layer) (gimp-selection-layer-alpha logo-layer) (gimp-context-set-background '(0 0 0)) (gimp-selection-grow img 1) (gimp-edit-fill shadow-layer BACKGROUND-FILL)) (begin (gimp-palette-set-foreground '(0 0 0)) (gimp-layer-set-preserve-trans logo-layer 100) (gimp-edit-fill logo-layer FOREGROUND-FILL) (gimp-selection-layer-alpha logo-layer) (gimp-context-set-background '(0 0 0)) (gimp-selection-grow img 1))) (gimp-selection-none img) (gimp-context-set-foreground top-color) (gimp-context-set-background bottom-color) (gimp-edit-blend logo-layer FG-BG-RGB-MODE NORMAL-MODE GRADIENT-LINEAR 100 20 REPEAT-NONE FALSE FALSE 0 0 FALSE (/ width 2) 0 (/ width 2) height) (gimp-layer-set-preserve-trans logo-layer 0) (if (= do-bumpmap TRUE) (plug-in-bump-map 1 img logo-layer logo-layer 115 40 1 0 0 0 15 TRUE FALSE 0)) (gimp-context-set-background old-bg) (gimp-context-set-foreground old-fg))) ; The function called by the Gimp (define (script-fu-render-nfont size font top-color bottom-color background-color do-shadow do-bumpmap do-ext-ascii) (let* ((text (if (equal? do-ext-ascii FALSE) "! \" \# $ % & ' \( \) * + , - \. / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \\ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~" "! \" \# $ % & ' \( \) * + , - \. / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \\ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯ ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ")) (img (car (gimp-image-new 256 256 RGB))) (extents (gimp-text-get-extents-fontname text size PIXELS font)) (descent (cadr (cddr extents))) (text-layer (car (gimp-text-fontname img -1 0 0 text 2 TRUE size PIXELS font))) (width (car (gimp-drawable-width text-layer))) (height (car (gimp-drawable-height text-layer)))) ; Now do stuff (gimp-image-undo-disable img) (gimp-layer-set-name text-layer "font") (gimp-layer-resize text-layer width (+ height descent) 0 descent) (gimp-layer-set-offsets text-layer 0 0) ; Call our function above (apply-create-nfont-effect img text-layer top-color bottom-color background-color do-shadow do-bumpmap do-ext-ascii) (gimp-image-undo-enable img) (gimp-display-new img))) ; Menu item/GUI info (script-fu-register "script-fu-render-nfont" _"/Xtns/Script-Fu/NFont/Create NFont" "Creates font for use with the NFont library" "Jonny D, orig. by Mike Oliphant" "Jonny D, orig. by Mike Oliphant" "4-29-2008" "" SF-ADJUSTMENT _"Font Size (pixels)" '(28 2 1000 1 10 0 1) SF-FONT _"Font" "Sans" SF-COLOR _"Top Color" '(0 0 0) SF-COLOR _"Bottom Color" '(0 0 0) SF-COLOR _"Background Color" '(255 255 255) SF-TOGGLE _"Shadow/Border" FALSE SF-TOGGLE _"Apply 3D effect" TRUE SF-TOGGLE _"Use extended ASCII" FALSE)