Font Sampler AppleScriptでの日本語フォントの指定時の問題

こんにちは


下記のFont Sampler AppleScriptでの日本語フォント指定について、特に"MS ゴシック"、"MS 明朝" 、"MS Pゴシック"、 "MS P明朝"を指定した場合、正しい結果が得られていないようで困っております。

この原因と対策につきましてご指導いただければ幸いです。よろしくお願いいたします。

【FontSampler】

set the font_list to {"Osaka", "Times", "Helvetica", "MS ゴシック", "MS 明朝", "MS Pゴシック", "MS P明朝"}

set the sample_string to "謹賀新年。ありがとう。The quick brown fox jumps over the lazy dog."


display dialog "Font Sampler" & return & return & ¬

"This script will use the TextEdit application to create a document containing a sample of each installed typeface." buttons {"Cancel", "Continue"} default button 2

tell application "TextEdit"

activate

try

-- close every document saving no

make new document at the beginning of documents

set the name of window 1 to "Font Sampler"

set zoomed of the front window to true

set the font_count to the count of the font_list

set this_text to ""

repeat with i from 1 to the font_count

set this_font to item i of the font_list

if i is 1 then

set this_text to this_text & this_font & ": " & the sample_string

else

set this_text to this_text & return & this_font & ": " & the sample_string

end if

end repeat

set the text of the front document to this_text

repeat with i from 1 to the font_count

set this_font to item i of the font_list

tell paragraph i of the text of the front document

set the font to this_font

set the size to 14

end tell

end repeat

display dialog "Font Sampler is complete." buttons {"OK"} default button 1 giving up after 2

on error error_message

beep

display dialog error_message buttons {"Cancel"} default button 1

end try

end tell

【結果(写真)】

ユーザがアップロードしたファイル

動作環境:

-Mac OSX 10.6.8 Snow Leopard

-AppleScriptエディタ 2.3 (118) / AppleScript 2.1.2

-TextEdit 1.6 (264)

iMac, Mac OS X (10.6.8)

投稿日 2012/11/01 10:51

返信
返信: 2

2012/11/01 18:53 kimukazu への返信

"MS ゴシック" 等々は QuickDraw 用の指定方法なので上手く行かないのかと。英語名か PostScript 名で指定すると期待どおりの結果になると思います。


=> MS Gothic か MS-Gothic

=> MS Mincho か MS-Mincho

=> MS PGothic か MS-PGothic

=> MS PMincho か MS-PMincho


フォント名を調べるのはこんな感じ (PostScript 名が返ってくるようです)

tell application "TextEdit"

get font of paragraphs of documents

end tell

2012/11/02 04:16 Hiro__S への返信

コメント、ありがとうございます。

ご指摘の通り、英語名で指定しましたところ、期待とおりの結果が得られました。

【結果】

ユーザがアップロードしたファイル

また、ご呈示いただきましたAppleScriptで指定可能なフォント名を確認できる点、大変参考になりました。

重ねて感謝申し上げます。

このスレッドはシステム、またはAppleコミュニティチームによってロックされました。 問題解決の参考になる情報であれば、どの投稿にでも投票いただけます。またコミュニティで他の回答を検索することもできます。

Font Sampler AppleScriptでの日本語フォントの指定時の問題

Apple サポートコミュニティへようこそ
Apple ユーザ同士でお使いの製品について助け合うフォーラムです。Apple Account を使ってご参加ください。