I’ve got a routine that displays the words ‘Green’ & ‘Red’ in a text field in their matching colors, and sets the text to ‘Bold’, but it’s too small. I can’t work out the correct terminology to use the line where I’m setting the Font & Size (myFont), somewhere in the handler, though.
on searchText(itemToSearchFor, stringToSearch, colorToSet)
try
set p to 1
set lenOfSearch to count of itemToSearchFor
set p to 2
# set stringToSearch to MutableStringToSearch as text
set p to 2.1
set foundPositions to my findAll(stringToSearch, itemToSearchFor)
set p to 3
if foundPositions is {} then
set p to 4
return stringToSearch
end if
set p to 5
repeat with i in foundPositions
set p to 7
set attributeRange to {i - 1, lenOfSearch}
set p to 8
set myFont to (current application's NSFont's fontWithName:"Hiragino Kaku Gothic ProN W3" |size|:13)
set p to 8.1
(my (attributedSearchItem's addAttribute:(current application's NSForegroundColorAttributeName) value:colorToSet range:attributeRange))
set p to 8.2
(attributedSearchItem's applyFontTraits:(current application's NSBoldFontMask as integer) range:attributeRange) -- bold
end repeat
set p to 9
return my attributedSearchItem
on error errmsg number errnum
tell application "System Events" to display dialog "searchText " & errmsg & " p = " & p as text
end try
end searchText