NISUS Archives

February 2011

NISUS@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Reply To:
Date:
Sat, 12 Feb 2011 21:04:12 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (47 lines)
On 2011-02-12 [+0900 JST], at 5:46 PM, Kino wrote:

> So I wrote a macro for replacing a set of fonts with another set.

Sorry, the macro was buggy. It did not treat missing or substituted fonts properly. The bug affected my older macro 'Select by Font' too. Here are the download links of the new macro files.
<http://www2.odn.ne.jp/alt-quinon/files/NWPro/convert/RemapFonts_20110212_nwm.zip> 'rev. 1' in the title
<http://www2.odn.ne.jp/alt-quinon/files/NWPro/select/SelectByFont_20110212_nwm.zip> 'rev. 2' in the title

Now, the font names *should* be treated in the same way as NWP's Character palette but I may still miss something important.

Instead of quoting the whole text of those macros, I paste below the code of a small macro used for testing the routine added to the revised version of those macros.


Kino
--

$sel = TextSelection.active
if $sel == undefined
	exit
end

$i = $sel.location
$text = $sel.text
$styleCategories = Array.new 'characterStyle', 'paragraphStyle'
$attr = $text.displayAttributesAtIndex $i

if $attr.isFontMissing || $attr.isFontSubstituted
	if Defined $text.attributesAtIndex($i).fontFamilyName  # manually applied
		$fontFamilyName = $text.attributesAtIndex($i).fontFamilyName
	else  # applied via a character/paragraph style
		foreach $styleCategory in $styleCategories
			$style = $text.displayAttributesAtIndex($i).getProperty $styleCategory
			if Defined $style
				$styleAttr = $style.attributes
				if Defined $styleAttr.fontFamilyName
					$fontFamilyName = $styleAttr.fontFamilyName
					break
				end
			end
		end
	end
else
	$fontFamilyName = $attr.fontFamilyName
end

exit $fontFamilyName

ATOM RSS1 RSS2