Don't click here unless you want to be banned.

LSL Wiki : LibraryXyTextFonts

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are ia360925.us.archive.org
The following script-fu script can be used with The Gimp to create textures for use with single texture versions of "XyText".

(define (script-fu-xytext-font inText inFont inFontSize inTextColor inImageSize inAdjust inMaxWidth)
	(let*
		(
			; define our local variables
			; create a new image:
			(theImageWidth  1)
			(theImageHeight 1)
			(theMaxWidth)
			(theImageWidthModTen)
			(theImageHeightModTen)
			(theXPos 0)
			(theYPos 0)
			(theImage)
			(theLayer)
			(theBackground)
			(theTextWidth)
			(theTextHeight)
			(theChar)
			(theText)     ;a declaration for the text
			              ;we create later
		)
		(while (> inImageSize 0) (set! inImageSize (- inImageSize 1))
			(set! theImageWidth (* theImageWidth 2))
			(set! theImageHeight (* theImageHeight 2))
		)
		(set! theImageWidthModTen (- theImageWidth (* (/ theImageWidth 10) 10)))
		(set! theImageHeightModTen (- theImageHeight (* (/ theImageHeight 10) 10)))
		(set! inFontSize (/ (* theImageHeight inFontSize) 100))
		(set! theMaxWidth (/ (* theImageHeight inMaxWidth) 100))
              
		(gimp-context-set-foreground inTextColor)
		(gimp-context-set-background inTextColor)

		(set! theImage (car
			(gimp-image-new
				theImageWidth
				theImageHeight
				RGB
			)
		))
		(set! theBackground (car
			(gimp-layer-new
				theImage
				theImageWidth
				theImageHeight
				RGBA-IMAGE
				"Background"
				0.5
				NORMAL
			)
		))
		(gimp-image-add-layer theImage theBackground 0)
		(gimp-drawable-fill theBackground BACKGROUND-FILL)
		(set! theLayer (car
			(gimp-layer-new
				theImage
				theImageWidth
				theImageHeight
				RGBA-IMAGE
				"layer 1"
				100
				NORMAL
			)
		))
		(gimp-image-add-layer theImage theLayer -1)
		(gimp-selection-none theImage)
		(gimp-edit-clear theLayer)
		(while (and (< theYPos 10) (> (string-length inText) 0))
			(set! theChar (substring inText 0 1))
			(set! theText (car (gimp-text-fontname
				theImage -1
				0 0
				theChar
				0
				TRUE
				inFontSize PIXELS
				inFont
			)))
			(if (>= theText 0) (begin
				(gimp-layer-translate theText
					(- (/ theImageWidth 2) (/ (car (gimp-drawable-width theText)) 2))
					(- (/ theImageHeight 2) (/ (car (gimp-drawable-height theText)) 2))
				)
				(if (> (car (gimp-drawable-width theText)) theMaxWidth)
					(gimp-layer-scale theText
						theMaxWidth
						(car (gimp-drawable-height theText))
						1
					)
				)
				(gimp-layer-translate theText
					0
					(/ (* theImageHeight inAdjust) 100)
				)
				(gimp-layer-resize-to-image-size theText)
				(gimp-layer-resize theText
					(- theImageWidth theImageWidthModTen) 
					(- theImageWidth theImageHeightModTen) 
					(/ theImageWidthModTen 2)
					(/ theImageHeightModTen 2)
				)
				
				(gimp-layer-scale theText
					(/ theImageWidth 10)
					(/ theImageHeight 10)
					0
				)
				(gimp-layer-translate theText
					(- (/ (* theImageWidth theXPos) 10) (/ theImageWidthModTen 2))
					(- (/ (* theImageHeight theYPos) 10) (/ theImageHeightModTen 2))
				)
				(gimp-image-merge-down theImage theText CLIP-TO-BOTTOM-LAYER)
			))
			(set! inText (substring inText 1 (string-length inText)))
			(set! theXPos (+ theXPos 1))
			(if (>= theXPos 10) (begin
				(set! theXPos 0)
				(set! theYPos (+ theYPos 1))
			))
		)
		
	(gimp-image-merge-visible-layers theImage CLIP-TO-BOTTOM-LAYER)
	(gimp-display-new theImage)
))

        (script-fu-register
          "script-fu-xytext-font"                        ;func name
          "XYText Font"                                  ;menu label
          "Creates a texture for single letter\
            XYText font scripts."                     ;description
          "Cadell DeCuir"                             ;author
          "Copyright 2007 Cadell DeCuir"             ;copyright notice
          "June 14, 2007"                          ;date created
          ""                     ;image type that the script works on
          SF-STRING      "Char Map"         " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"   ;a string variable
          SF-FONT        "Font"         "Courier"    ;a font variable
          SF-ADJUSTMENT  "Font size (Percent)"     '(80 50 200 1 10 0 0)
                                                      ;a spin-button
          SF-COLOR       "Color"        '(255 255 255)     ;color variable
		  SF-ADJUSTMENT  "Image Size (Powers of 2)" '(9 6 10 1 1 0 0)
		  SF-ADJUSTMENT  "Font Shift Vertical (Percent)"	'(-10 -50 50 1 10 0 0)
		  SF-ADJUSTMENT  "Font Max Width (Percent)" '(50 10 100 1 10 0 0)
        )
        (script-fu-menu-register "script-fu-xytext-font" "<Toolbox>/Xtns/Script-Fu/Second Life")
There is no comment on this page. [Display comments/form]