Page 1 of 1

FontProg

Posted: Tue Feb 10, 2015 2:22 pm
by mmtuk

Code: Select all

/* program under development - work in progress!
See suggestions area of forum for problems in taking forward.
*/

'g'
GRAPHICS

OPTION BASE 1
DIM A$(1000)
LIST FONTS TO A$,N
fs=40 'default font size
f=100 'default font
Slidval=.1
Change=0 'user input monitor

/* program requires the the user provide a text file (can be anything) in order for typefaces to display something. It needs to be called demotext.txt or change next prog line to suit yourself.
*/

FILE "demotext.txt" READLINE Demotext$ 

GOSUB CheckScreenOrientation
GOSUB CreateButtons
GOSUB CreatePointSizeSlider

'b'

Main:

GRAPHICS CLEAR 0,0,0
GOSUB CheckScreenOrientation
Screen$=Orient$
GOSUB CreateButtons
GOSUB CreatePointSizeSlider

IF Orient$= "landscape" THEN SPRITE "screen" BEGIN 1024,560
IF Orient$= "portrait" THEN SPRITE "screen" BEGIN 768,810
GRAPHICS CLEAR .2,.2,.2
DRAW COLOR 0,.7,2
DRAW FONT SIZE fs
DRAW FONT NAME A$(f)
'Uncomment next line to display your text file, then comment out the following line.
'DRAW TEXT Demotext$ at 8,60 
/*Next line just displays font name in its own typeface. Comment out if demotext$ used otherwise display corrupted. */
DRAW TEXT A$(f) AT 8,60 
SPRITE "screen" END
SPRITE "screen" SHOW
SPRITE "screen" AT 0,60

Loop:
GOSUB CheckScreenOrientation
IF change=1 THEN GOTO Main
GOSUB CheckButtons
IF change=1 THEN GOTO Main
gosub CheckPointSizeSlider
IF change=1 THEN GOTO Main
GOTO Loop

GOTO Main

'r'

CheckScreenOrientation:
Change=0
IF SCREEN_WIDTH() < SCREEN_HEIGHT() THEN
Orient$="portrait"
hwo=O 'horizontal width offset
vho=255 'vertical height offset
ENDIF
IF SCREEN_WIDTH() > SCREEN_HEIGHT() THEN
Orient$="landscape"
hwo=253
vho=0
ENDIF
IF Orient$<>Screen$ THEN Change=1
RETURN

CreateButtons:
b$=A$(f)
c$="#"&f&" of "&N&" - "&fs&" point"
BUTTON 0 TITLE b$ AT 8,10
BUTTON 1 TITLE c$ AT 8,685+vho
BUTTON 23 TITLE "-10" AT 415+hwo,10
BUTTON 24 TITLE "-5" AT 474+hwo,10
BUTTON 25 TITLE "Prev." AT 522+hwo,10
BUTTON 26 TITLE "Next" AT 592+hwo,10
BUTTON 27 TITLE "+5" AT 660+hwo,10
BUTTON 28 TITLE "+10" AT 710+hwo,10
RETURN

CreatePointSizeSlider:
GOSUB CheckScreenOrientation
SLIDER 0 VALUE slidval AT 230,(685+(vho)) SIZE (530+(hwo))
Slidval=SLIDER_VALUE ("0")
RETURN

CheckButtons:
Change=0
IF BUTTON_PRESSED("23") THEN
f=f-10
Change=1
IF f<1 THEN f=N
ENDIF
IF BUTTON_PRESSED("24") THEN
f=f-5
Change=1
IF f<1 THEN f=N
ENDIF
IF BUTTON_PRESSED("25") THEN
f=f-1
Change=1
IF f<1 THEN f=N
ENDIF
IF BUTTON_PRESSED("26") THEN
f=f+1
Change=1
IF f>N THEN f=1
ENDIF
IF BUTTON_PRESSED("27") THEN
f=f+5
Change=1
IF f>N THEN f=1
ENDIF
IF BUTTON_PRESSED("28") THEN
f=f+10
Change=1
IF f>N THEN f=1
ENDIF
RETURN

CheckPointSizeSlider: 'modified as suggested by Mr K.
IF SLIDER_CHANGED("0")=1 THEN
Change=1
Slidval=SLIDER_VALUE ("0")
sv=Slidval*1000
sfs=(sv/100)*50
fs=int(sfs)
ENDIF
RETURN

Re: FontProg

Posted: Tue Feb 10, 2015 2:48 pm
by Mr. Kibernetik
There is SLIDER_CHANGED() function to detect if slider value was changed.

Re: FontProg

Posted: Tue Feb 10, 2015 5:51 pm
by mmtuk
Mr. Kibernetik wrote:There is SLIDER_CHANGED() function to detect if slider value was changed.
There are a great many things I need to get to grips with in SmartBASIC, I've only been at it for the odd hour or so over the past couple of weeks. However, all comments are greatfully received - including those that highlight my lack of knowledge!
One thing that did occur to me today was that the text functions I'm aiming for are not too dissimilar to the SmartBASIC editor - it scales the typeface using a slider, and has word (or letter) wrap built in. Now if only I could code that in SmartBASIC and add a few enhancements!

Re: FontProg

Posted: Tue Feb 10, 2015 5:56 pm
by Mr. Kibernetik
mmtuk wrote:One thing that did occur to me today was that the text functions I'm aiming for are not too dissimilar to the SmartBASIC editor - it scales the typeface using a slider, and has word (or letter) wrap built in. Now if only I could code that in SmartBASIC and add a few enhancements!
This functionality will be available in version 4.8.

Re: FontProg

Posted: Wed Feb 11, 2015 12:00 am
by mmtuk
Mr. Kibernetik wrote: This functionality will be available in version 4.8.
What more can I say - Mr.K you're a star!