wanted: program to process Windows Font files
#11
WARNING: a better program is provided in a later post in this topic.
Code: (Select All)
dim as long ff, i, l, x, y, siz
dim as _byte goon
redim sf$(1 to 100)

chr255$ = chr$(255)

afile$ = "/tmp/fontlist.txt"
adir$ = "/usr/share/fonts/TTF"
zomd$ = "ls -1 " + adir$ + " > " + afile$
shell zomd$
adir$ = adir$ + "/"

l = 0
ff = freefile
open afile$ for input as ff
do until eof(ff)
    line input #ff, a$
    a$ = adir$ + a$
    if _fileexists(a$) then
        l = l + 1
        sf$(l) = a$
    else
        print a$; " NOT FOUND! Something is wrong."
    end if
    if l >= 100 then exit do
loop
close ff

screen _newimage(800, 600, 32)
_TITLE "Check font..."
redim _preserve sf$(1 to l)
do
    for i = 1 to l
        for siz = 8 to 72 step 4
            if _keydown(27) then exit do
            m$ = "M"
            han = _loadfont(sf$(i), siz)
            if han > 0 then
ON ERROR GOTO ancienterrmusic
                if _fontwidth(han) = 0 then m$ = ""
                'if _printwidth("W") <> _printwidth("l") then m$ = ""
                goon = 1
                _font han
                if goon = 0 then _continue
                x = int(rnd * 700 + 1)
                y = int(rnd * 500 + 1)
                a$ = chr$(int(rnd * 95 + 33))
                _printstring(x, y), a$
                _font 14
                _freefont han
                entr$ = entr$ + sf$(i) + str$(siz) + m$ + chr255$
ON ERROR GOTO 0
            end if
        next
    next
loop while 0
if _keydown(27) then system
$CONSOLE
_DEST _CONSOLE
for i = 1 to len(entr$)
    a$ = mid$(entr$, i, 1)
    if a$ = chr255$ then print else print a$;
next
print
system

ancienterrmusic:
goon = 0
resume next

Quick and dirty on Linux, tested on Manjaro MATE.

Sadly, it doesn't report accurately which is "MONOSPACE". Either it says all of them or none of them. The commented line with "_printwidth()" should have substituted for "_fontwidth()", otherwise the latter requires "MONOSPACE" parameter passed to "_loadfont()".

This only checks "TTF" directory because it has more fonts than any other place within "/usr/share/fonts".
Reply


Messages In This Thread
RE: wanted: program to process Windows Font files - by mnrvovrfc - 10-26-2022, 12:12 AM



Users browsing this thread: 12 Guest(s)