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

喜夏-厌秋 提交于 2019-12-24 11:27:57

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/31778041/osx-how-can-an-application-running-in-terminal-app-change-the-font-size-of-its

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!