简体   繁体   中英

OSX: How can an application running in Terminal.app change the font size of its window?

How can an application running in a Terminal.app window change its window's font size? No solution (such as a system call to applescript, etc) too odd!

It's relatively simple to do this; the only real caveat is that you might need to adjust the window size if you want it to remain consistent with it's proportions, since the font size seems to affect it.

Applescript called from Bash :

#!/bin/bash

osascript <<EOF
tell application "System Events"
    tell process "Terminal"
        set frontmost to true
    end tell
end tell

tell application "Terminal"
    set font size of first window to "11"
    delay 1.0
    set font size of first window to "14"
end tell
EOF

This shows about the most basic example which should work for anything currently active within a Terminal window. Applescript is ideal for this type of thing, however, if the font sizing requires a lot of typographic manipulation then you might need to consider something different.

If you're interested in additional Terminal window adjustments I've listed some others here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM