mIRC Home    About    Download    Register    News    Help

Print Thread
previewing a font in a textbox #177595 28/05/07 02:30 PM
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?

Re: previewing a font in a textbox [Re: pouncer] #177601 28/05/07 03:00 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
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
Re: previewing a font in a textbox [Re: Riamus2] #177613 28/05/07 06:43 PM
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.
Re: previewing a font in a textbox [Re: pouncer] #177637 29/05/07 01:31 AM
Joined: May 2007
Posts: 23
C
chiram Offline
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.

Re: previewing a font in a textbox [Re: chiram] #177640 29/05/07 02:24 AM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
*** 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
Re: previewing a font in a textbox [Re: Riamus2] #177653 29/05/07 08:21 AM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
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>

Re: previewing a font in a textbox [Re: hixxy] #177658 29/05/07 09:19 AM
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?

Re: previewing a font in a textbox [Re: pouncer] #177664 29/05/07 11:00 AM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
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?

Re: previewing a font in a textbox [Re: hixxy] #177665 29/05/07 11:33 AM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
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
Re: previewing a font in a textbox [Re: Riamus2] #177668 29/05/07 11:52 AM
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.
Re: previewing a font in a textbox [Re: pouncer] #177677 29/05/07 04:13 PM
Joined: Jun 2006
Posts: 508
D
deegee Offline
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
}