mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
can someone show me how to make a preview font thing, where i can select a font on my system, and it will show the font in a preview?

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
The best method of doing that would be to use the DCX DLL. Set up a richedit window and display the text there with the specified font.

Of course, you could just make it display in a custom window and clear the window each time you preview so you only see the specific preview. But I would personally use DCX for that.


Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
Thanks, yeah i use dcx and will try that!

also, is there an alias anywhere that will get all the fonts on my machine? i want to grab all these fonts, basically click the font name in the listbox, and the preview shoud come up in the richedit as you say.

Last edited by pouncer; 28/05/07 07:05 PM.
Joined: May 2007
Posts: 23
C
Ameglian cow
Offline
Ameglian cow
C
Joined: May 2007
Posts: 23
been a while since i made a dialog so..
Code:
dialog fontlist {
  ...
  list 25 1 1 1 1
}

alias grabfonts { $findfile(c:\,*.ttf,0,did -a fontlist 25 $1-) }


i believe that should print the full path to each .ttf font file in the listbox.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
*** Don't use that alias! As it is written, it will search your entire computer for fonts and if you have a lot of files and large hard drive(s), this can take a very long time.

Use this instead:
Code:
alias grabfonts { $findfile(c:\windows\fonts\,*.ttf,0,0,did -a fontlist 25 $1-) }



If you happen to be on a Windows version that uses a different path for fonts (not sure what Vista uses), you can adjust the path. If necessary, you can check $os and have the path change automatically based on the user's OS.


Invision Support
#Invision on irc.irchighway.net
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
That won't list all fonts, only truetype ones. This should get all of them:

Code:
alias grabfonts { noop $findfile(c:\windows\fonts\,*.fon;*.ttf,0,did -a fontlist 25 $1-) }


You should also not start a line with an $identifier, as mIRC will try to execute the return value as a command. In the case of $findfile, it will try to execute /<number_of_files_found>

Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
Thanks guys. also, isn't there somehow i can save these fonts first time round, and then when the user loads the dialog up, it should put the fonts in the listview

is that a better approach?

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Yeah, you could make a font cache of some sorts..

Code:
alias listfonts { 
  if (!$hget(fontcache)) { noop $findfile(c:\windows\fonts\,*.fon;*.ttf,0,hadd -m fontcache $calc($hget(fontcache,0).item + 1) $1-) }
  var %i = 1
  while ($hget(fontcache,%i)) {
    did -a <dialog> <id> $v1
    inc %i
  }
}


Are you ever going to start having a go at these scripts yourself?

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Oh, yeah. I forgot about the .fon fonts. I've used true type for so long that I just forgot there was another format for them. smile

As for using noop, I should have thought of that. I've had few cases where I've needed it, so I didn't think of it.


Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
well hixxy i'm only asking because someone told me to use filter as its faster loaidng stuff to dialogs like this

Code:
alias listfonts {
  did -r dialog 15
  .filter -k $shortfn(Font.dat) load_font
}

alias load_font {
  if ($1 == [FONTS]) return
  tokenize 61 $1-
  did -a dialog 15 $2
}


where font.dat contains all my system fonts, i'm not sure though

Last edited by pouncer; 29/05/07 11:53 AM.
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
This alias
  • Loads the fonts to the dialog
  • Calls '/listfonts' if needed

To renew the fontlist from "%SystemRoot%\Fonts", delete or empty font.dat.
Code:
alias load_fonts {
  did -r dialog 15
  if !$lines(font.dat) { listfonts }
  loadbuf -o dialog 15 font.dat
}

This alias
  • Finds the path to the "%SystemRoot%\Fonts" directory
  • Then lists the fontfiles in font.dat
  • Sorts the filenames

It lists filenames though, not fontnames.
Code:
alias listfonts {
  var %a = f. $+ $ticks
  .comopen %a WScript.Shell
  if $comerr { return }
  if $com(%a,ExpandEnvironmentStrings,3,bstr*,% $+ SystemRoot%) && $com(%a).result { noop }
  .comclose %a
  if *% iswm $v1 { return }
  %a = $v2 $+ \Fonts
  .fopen -no fontlist font.dat
  noop $findfile(%a,*.fon;*.ttf,0,.fwrite -n fontlist $nopath($1-))
  .fclose fontlist
  filter -ffctn 1 1 font.dat font.dat
}



Link Copied to Clipboard