Active2 years, 1 month ago
I write a lot of technical emails, and like to use a monospaced font for the code bits. Highlight text, hit apple-T, choose my font from the list of favorites, then close the font window. Is there a way to use a keyboard shortcut to apply a given font to the currently selected text? Ideally this would be OS-wide, but if that's not possible I can use it for just a single app (Mail.app)
Sam BarnumSam Barnum
migrated from stackoverflow.comSep 16 '11 at 10:17
This question came from our site for professional and enthusiast programmers.
4 Answers
Mac keyboard shortcuts By pressing certain key combinations, you can do things that normally need a mouse, trackpad, or other input device. To use a keyboard shortcut, press and hold one or more modifier keys and then press the last key of the shortcut. Mac OS X also has a Text to Speech Option which will read selected text when the user presses a user defined Shortcut Key. The text to speech option also works in the Apple Calculator to make it self voicing. It is a simpler option than VoiceOver to use for reading e. I found that OS X's text-to-speech feature is actually a really nice way to keep reading uninterrupted, and most people probably don't even realize how easy it is. To use this Office keyboard shortcut, you must first turn off the Mac OS X keyboard shortcut for this key. On the Apple menu, click System Preferences. Under Hardware, click Keyboard. With a simple keyboard shortcut you can tell your Mac to read any highlighted text, and in other programs you just tell your app to start reading. Even better: with Mavericks you can download a variety of high-quality voices with a variety of regional accents, from the UK to Australia, and India to South Africa.
I've been looking for doing this for a very long time.
I finally managed to end up with something that really works great for me, with the help of Alfred and Highlight CLI tool.
Here is the Alfred script portion :
Make sure the shortcut trigger adds
__SHORTCUT__
to be recognized and argument is 'Selection in OSX' :Short demo https://youtu.be/y8NJT52APRQ
Yann BizeulYann Bizeul
I don't know of a system-wide way to script the Fonts panel but here's a few ways to get quick access to monospace fonts in Mail.app
Way 1: Plan Text Message
Go to Mail.app's preferences > Fonts & Colors and check the checkbox for 'Use fixed-width font for plain text messages'
Now when you're in a message where you want to use a monospace font you can simply hit: Command-Shift-T and you can toggle between the fixed-width font of your choice and your standard font (plain text message & rich text).
The downside of this method is if the receiver has not set their font to a fixed-width font they may not see the message as intended. Excel for mac select cells with containing specific text.
Way 2: Set the Font with Applescript
The second way to do this would be to create a new message with the correct font chosen using Applescript. You can do that like this:
You do have to set the content to something with this script. It seems Mail doesn't let you set the font for an empty message.
Way 3: Use TextExpander
This way costs money but it might give you what you are after. You could setup a couple of TextExpander ($34.99 USD on the app store) shortcuts for fixed width and normal type so that you can switch back and forth by typing a few characters.
TextExpander will allow you to insert rich text (text with a font, color, style, etc set). Just create a snippet of type Formatted Text, Pictures and set a font for the text you'll be inserting. You will need to include at least a space character for this strategy to work.
You will need your snippits to include at least a space character to ensure that the font will take.
Samuel Mikel BowlesSamuel Mikel Bowles
3,75211 gold badge1313 silver badges2323 bronze badges
What I ended up using was manually specifying monospace in some text, then Format -> Copy Style (Option+Cmd+C) which copies the format but not the text. Then select some other plain text and Format->Paste Style (Option+Cmd+V) which assigns this format to the selection. After restarting, you need to do this again, and it only works for one style, but this meets my needs.
Sam BarnumSam Barnum
Copy a character with a specific style:
echo '<span style='font:14px 'Monaco'> </span>' | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf
pbcopy -Prefer rtf
Can word for mac read text out loud. doesn't include plain text data, so paste will only work in rich text views.Insert a character with a specific style:
Read Highlighted Text Windows 10
Paste style:
LriLri81.9k1212 gold badges175175 silver badges241241 bronze badges