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:
Sun, 13 Feb 2011 11:08:26 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (51 lines)
Er... hello again... 

On 2011-02-13 [+0900 JST], at 2:43 AM, Kino wrote:

> For substituted default fonts, it shows something like '<default font> [substituted by Times]'

Silly me, I did not notice that the original font name of a substituted font can be got by $sel.displayTypingAttributes.fontFamilyName. That's easy and simeple. So everything works properly in this new version, I hope.

<http://www2.odn.ne.jp/alt-quinon/files/NWPro/convert/RemapFonts_20110213_nwm.zip> 'rev. 1.5' in the title
<http://www2.odn.ne.jp/alt-quinon/files/NWPro/select/SelectByFont_20110213_nwm.zip> 'rev. 2.5' in the title

The code below is the one used in those macros for identifying the original font of a substituted or missing font.


Kino
--

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

$text = $sel.text
$i = $sel.location
$displayAttr = $text.displayAttributesAtIndex $i
$properties = Array.new 'characterStyle', 'paragraphStyle'
$displayFont = $displayAttr.fontFamilyName

if $displayAttr.isFontSubstituted
	$font = $sel.displayTypingAttributes.fontFamilyName.textByAppending ' [substituted by ',  $displayFont, ']'
elsif $displayAttr.isFontMissing
	$attr = $text.attributesAtIndex $i
	$originalFont = $attr.fontFamilyName
	if $originalFont == undefined
		foreach $property in $properties
			$style = $attr.getProperty $property
			if Defined $style
				$originalFont = $style.attributes.fontFamilyName
				if Defined $originalFont
					break
				end
			end
		end
	end
	$font = $originalFont.textByAppending ' [missing and displayed by ',  $displayFont, ']'
else
	$font = $displayFont
end

exit $font

ATOM RSS1 RSS2