Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting the system fonts
03-21-2017, 07:03 AM (This post was last modified: 03-21-2017 07:04 AM by bbjimmy.)
Post: #1
Getting the system fonts
yab did not include a way to determine the currently set system font. this library file should do the trick!

https://github.com/bbjimmy/yab-lib/tree/...ystemfonts

Code:
//export sub getfont_family$(fonttype$)
//returns the string needed by draw set to set this font -- less the point size.

//export sub getfont_size$(fonttype$)
// returns the piont size of the font

//fonttype$ can be "bold", "book", or "mono"




////////////////////////////////////

sub getsystemfonts()
local a$,num,x
dim font$(1)
a$=system$("message /boot/home/config/settings/system/app_server/fonts")
num=split(a$,font$(),"\n")
for x=2 to 10
    a$=gststring$(font$(x))
    if a$<>"" font$(x)=a$
next
font$(4)=getsize$(font$(4))
font$(7)=getsize$(font$(7))
font$(10)=getsize$(font$(10))

end sub

////////////////////////////////////

sub gststring$(a$)
local x
x=instr(a$,chr$(34))
a$=right$(a$,len(a$)-x)
x=instr(a$,chr$(34))
a$=left$(a$,x-1)
return a$
end sub

////////////////////////////////////

sub getsize$(a$)
x=instr(a$,"(")
a$=right$(a$,len(a$)-x)
x=instr(a$,".")
a$=left$(a$,x-1)
return a$
end sub

////////////////////////////////////


export sub getfont_family$(fonttype$)
dim font$(1)
x=arraysize(font$(),1)
if x=1 getsystemfonts()
fonttype$=lower$(fonttype$)
if fonttype$="book" return font$(2)+", "+font$(3)+", "
if fonttype$="bold" return font$(5)+", "+font$(6)+", "
if fonttype$="mono" return font$(8)+", "+font$(9)+", "
end sub

////////////////////////////////////


export sub getfont_size$(fonttype$)
dim font$(1)
x=arraysize(font$(),1)
if x=1 getsystemfonts()
fonttype$=lower$(fonttype$)
if fonttype$="book" return font$(4)
if fonttype$="bold" return font$(7)
if fonttype$="mono" return font$(10)
end sub

Fat Elk Sortware
Visit this user's website Find all posts by this user
Quote this message in a reply
04-23-2017, 01:26 AM (This post was last modified: 04-23-2017 01:26 AM by bbjimmy.)
Post: #2
RE: Getting the system fonts
I added a fallback, in case there is no font settings file. The file is now hosted on github:

https://github.com/bbjimmy/yab-lib

Fat Elk Sortware
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

Free Web Hosting