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