[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] fonts, netstat,etc.



>Is there a way to:
>
>1) Get a list of all currently active fonts
>2) Get an ID # for those fonts?

use Mac::Fonts;

$fontName = "Geneva";
$fontNum = GetFNum $fontName;

print "$fontName = $fontNum\n";

__EXIT__

>
>Is there a hash or something with them?  Thanks!

Here's how I do it...


#!perl

use Mac::Menus;
use Mac::Fonts;

$fontmenu = NewMenu (200, "xyz");
AppendResMenu ($fontmenu,'FONT');
$items = CountMItems ($fontmenu);

for $i (1..$items) {
	$fontName = GetMenuItemText ($fontmenu, $i);
	$fontNum  = GetFNum $fontName;
	for ($f=1; length($fontNum)<6; $f++) { $fontNum = " " . $fontNum }
	$fonts[$i] = "$fontNum = $fontName\n";
}
DisposeMenu ($fontmenu);

@fontNums = sort(@fonts);
$holdNum = $holdName = "-1";
for $f (1..@fontNums) {
	($fontNum,$fontName) = split(/ = /,$fontNums[$f]);
	if($fontNum == $holdNum) {
		$report .= "DUPLICATE: FONT ID $fontNum = $fontName and
$holdName\n";
		$duplicates++;
	}
	$holdNum = $fontNum;
	$holdName = $fontName;
}

print "@fontNums\n\n\n";
if($duplicates > 0) { print "$report\n" }
else { print "No duplicate font ids found.\n" }

__END__


David Seay
http://www.mastercall.com/g-s/




# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org