2013年10月23日星期三

Mac版OpenOffice介面字體修正及使用Automator模擬全螢幕


OpenOffice介面字體修正

話說半年前我一直打算換筆電,可是老是物色不到合意的,經過數月的評估和Scouting後,決定捨棄萬惡的微軟視窗,投向Mac的懷抱。我上一次用Mac,已是大學時用大學電腦室的機器,那大概是Macintosh Classic或Color Classic,所以我認為自己跟Mac新手沒有分別。從萬年Win用家變成Mac友,一開始不習慣是早料到的,但因為自己目前的工作都只依賴瀏覽器(Google Chrome)和文書工具(OpenOffice.org),所以猜想影響不會太大。結果反而叫我意外,Mac OS X相當易上手,縱使有些在Win系統是理所當然必備的東西而Mac竟然沒有,整體上Mac感覺還是比Win好用。

然而,當我安裝了Mac版的OpenOffice.org 3.4.1後,一打開,不禁皺一下眉。天啊,為什麼介面的中文字型毫不統一?這是模仿綁架信風格嗎?


因為沒影響功能,所以我便沒理會,可以一兩個星期後,總是覺得礙眼。我上網找解決方法,可是沒有明確說明情況的網頁,正打算放棄時,偶然從一些描述其他問題的網頁找到端倪。仔細研究一下,再試了幾個方法,找到最簡單修理的途徑。我在這兒說說,留個記錄,希望能幫到跟我一樣有相同問題的人。

首先,打開OpenOffice的「喜好設定」,在左側「OpenOffice.org」的欄目中,選「字型」。


點選「使用取代清單」,再在正下方的「字型」選單中,鍵入「方正明體」。別嘗試在選單裡找,要直接用鍵盤輸入這四個字,因為如果你能在選單中找到「方正明體」,介面便不會如此一塌糊塗了。之後在「取代成」的選單中選出你想要的介面字型(我建議使用Apple LiGothic/蘋果儷中黑),然後按右面的剔號,再選取選單中的「自動」。之後按確定。


介面便修好了。


如果我沒理解錯誤的話,OOo內部設定了中文介面字型為「方正明體」,但由於我的Mac(和你的Mac)沒有這字型,所以程式便亂選一氣,變成如此古怪的情況。上述的做法,其實是指示程式一旦遇到要求「方正明體」的字型,便自動以你選的另一種字型(例如儷中黑)代替。嚴格來說,直接修改OOo的內部設定檔比較好,但上述的方法較簡單。(你喜歡的話,用娃娃體當介面字型也可以)(爆)



模擬全螢幕

再來是全螢幕的問題。我的Mac是Air 11吋,Mountain Lion,使用Mission Control製造多個桌面、將一些軟體打開成全螢幕十分方便。我習慣了「Dashboard、桌面1、全螢幕Chrome、桌面2、全螢幕行事曆」的配置,OpenOffice便在桌面2打開。然而,我沒想到,OpenOffice居然沒有加入Mac全螢幕功能。OpenOffice有「內置全螢幕」,但一使用,菜單和工具列都會消失。我只會在讀稿時使用那個內置功能,平時打字一定用普通的環境。問題是,非全螢幕的Mac軟體,全部都要讓路給下方的Dock。


要拿走那個Dock,讓OOo的編輯空間增大,有兩個選擇,一是將Dock搬到左方或右方變成直立式,一是使用Dock的「隱藏功能」,在滑鼠指標移到畫面下方時Dock才冒出來。我覺得後者較好,可是,一般Mac的全螢幕軟體都很聰明,我移到全螢幕的程式,Dock會自動隱藏,而我跳到旁邊的桌面,Dock又會自動升回原位。為什麼OOo沒有啊……

我希望OOo有這樣的功能:
1.打開時會替我自動隱藏Dock,並放到最大
2.切換至其他程式時,Dock會自動冒出
3.再切換回OOo時,Dock會再次自動隱藏
4.關掉OOo後,Dock會自動關掉隱藏功能

在學習Mac的操作時,我發現了Automator這個偉大的工具。原來Mac內置了「自動化機器」的軟體,容許用家編寫指令,為任何程式添加功能。我審視了好一陣子,瀏覽過好些網頁,發覺Automator配合Applescript(蘋果的Script語言)或者可以做到我上述的要求。求人不如求己,我便寫了一個App,讓OOo模擬全畫面運作。我以下會說明做法,不過先聲明一點,我只用了一個月Mac,對Applescript理解不深,以下做法我不保證在所有機器上都能正常運作,如果在你的Mac上沒成功,別問我解決方法。(我也不知道升級至Maverick後是否繼續正常運作,但至少在我的山獅上,這方法OK)

首先要確認一下「允許使用輔助設備」的選項有沒有打開。這選項在左上角蘋果圖示裡,「系統偏好設定」、「輔助使用」,再在左下角找到。其實我不肯定是否一定要打開,但如果要用Automator自動按一些介面按鈕,這選項一定要選。(我以下的Script改過幾次,最新版本好像不用也可以,不過還是打開這選項較好吧,我懶得測試這細節了)

先打開Launchpad,在「其他」的程式組合裡找出「Automator」,打開。你會看到以下畫面:


在中間的七個文件類型中,選「應用程式」,按選擇。在左面的欄目中,選「工具程式」,再將第二欄中的「執行AppleScript」拖到右面那一大片空間上。


將「on run……end run」的文字全刪去,把以下的Script貼上:

----------------------------------------------------
--Toggle Dock Autohide function
----------------------------------------------------
on toggleDock(toggleOn)
tell application "System Events" to set autohide of dock preferences to toggleOn
tell application "System Events" to set translucent menu bar of current desktop to not toggleOn
end toggleDock

----------------------------------------------------
--Main program starts
----------------------------------------------------
on run {input, parameters}

----------------------------------------------------
--START hiding the annoying gear animation icon in menu bar
----------------------------------------------------

tell application "System Events"
set isAutomator to exists process "Automator Launcher"
end tell
if isAutomator then tell application "Automator Launcher" to quit

----------------------------------------------------
--END hiding the annoying gear animation icon in menu bar
----------------------------------------------------

----------------------------------------------------
--START Data you can change
----------------------------------------------------
set appName to "OpenOffice.org"
-- The Application you want to make fullscreen

set waitTime to 2
-- Wait Time, in second. Smaller value for faster response, but uses up more system resources.

set mainWindowThreadHold to 0.8
-- Threadhold, used to identify the main window.
-- Default is 0.8, which means all windows of target application with 80% screen size would be maximized.

----------------------------------------------------
--END Data you can change
----------------------------------------------------

set debugMode to false

tell application "Finder"
set screenSize to bounds of window of desktop
set screenWidth to (item 3 of screenSize)
set screenHeight to (item 4 of screenSize)
set scrWidthT to (item 3 of screenSize) * mainWindowThreadHold
set scrHeightT to (item 4 of screenSize) * mainWindowThreadHold
end tell


toggleDock(true)
set inputFile to input as string
tell application appName
activate
if inputFile is not equal to "" then
repeat with i from 1 to count of input
open item i of input as string
end repeat
end if
end tell
delay 3 -- wait 3 seconds. Some apps need time to start.

tell application "System Events"
if exists process appName then set frontmost of process appName to true
try
if inputFile is equal to "" then
tell process appName
set position of window 1 to {0, 0}
set size of window 1 to {screenWidth, screenHeight}
end tell
end if
on error
if debugMode is true then display dialog "Error in initializing window(s)"
end try
end tell


repeat
if application appName is not running then exit repeat

tell application "System Events"
if exists process appName then
if frontmost of process appName then
if translucent menu bar of current desktop is true then
set translucent menu bar of current desktop to false
end if
if autohide of dock preferences is false then
set autohide of dock preferences to true
delay 0.5
try
tell process appName
repeat with myWin in windows
set mySize to size of myWin
set myWidth to item 1 of mySize
set myHeight to item 2 of mySize
if myWidth > scrWidthT and myHeight > scrHeightT then
--click button 2 of myWin
set position of myWin to {0, 0}
set size of myWin to {screenWidth, screenHeight}
end if
end repeat
end tell
on error
if debugMode is true then display dialog "Error in resizing window(s)"
end try
end if
else
if translucent menu bar of current desktop is false then
set translucent menu bar of current desktop to true
end if
if autohide of dock preferences is true then
set autohide of dock preferences to false
end if
end if
end if
end tell
delay waitTime
end repeat

toggleDock(false)

return input
end run

按Command-S儲存。app的名字你可以隨意改,例如「我的OOo.app」,位置也可以隨便放(放桌面也可,不過我建議放在其他資料夾,再為這個app建一個替身放桌面)。結束Automator,它功成身退了。以後,你便可以打開這個新建的App代替OpenOffice,它會替你隱藏Dock、打開OOo、放到最大,並且在切換至其他程式時,自動升降Dock。這App支援拖放文件到圖示來打開,你也可以像我一樣把圖示換成OOo,將替身放桌面。以下是運作時的樣子:



其實這段Script不單能應用到OOo,也可以改成LibreOffice或其他軟體,只要改掉Script中部分關鍵字便可以(我已將可以改的變數集中放在開頭)。各位有興趣可以隨意複製修改發佈使用,但如果你想改但不懂編程,請先找些入門網站看看再試。這個小工具本來只是我為了自用而編寫的,所以我懶得逐行說明,而且流程滿簡單的,我想懂一點AppleScript的朋友也能看懂。

3 則留言:

  1. 介紹一個軟件比你: iA Writer ,對,是收費的,但是有他的價值。

    回覆刪除
  2. Thanks電鋸兄!我研究一下~! :)

    回覆刪除
  3. 多謝分享~
    等我找我家的飯糰研究下~~

    回覆刪除