« FontBookからコピーした値からパスやPostscript名を取得する | トップページ | Microsoft OfficeのフォントをFontBookに登録する »

FontBookからコピーした値からフォントサンプル画像を生成する(縦型用)


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "UniformTypeIdentifiers"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application

###################################
#####設定項目
###################################
###画像に印字するテキスト
set strInputText3 to "美しい日本語" as text
set strInputText4 to "ABCDEFGHIJKLMNOPQRSTUVWXYZ" as text
set strInputText5 to "abcdefghijklmnopqrstuvwxyz" as text
set strInputText6 to "*0123456789=*%&#¥@{}" as text

set strInputText7 to "090-1234-5678" as text

########################
## クリップボードの中身取り出し
########################
###初期化
set ocidPasteboard to refMe's NSPasteboard's generalPasteboard()
##中身の要素
set ocidPastBoardTypeArray to ocidPasteboard's types
#
set boolContain to ocidPastBoardTypeArray's containsObject:("NSStringPboardType")
if boolContain is true then
  set ocidClassesArrayM to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
ocidClassesArrayM's addObject:(refMe's NSString)
  set ocidReadArray to ocidPasteboard's readObjectsForClasses:(ocidClassesArrayM) options:(missing value)
end if
set ocidReadStrings to ocidReadArray's firstObject()

########################
## 改行区切りでリスト化
########################
set ocidLFChar to refMe's NSString's stringWithString:("\n")
set ocidLineArray to (ocidReadStrings's componentsSeparatedByString:(ocidLFChar))
###############################
## テキスト形式のURLをNSURLに
###############################
#URLとポストスクリプト名を格納するDICT
set ocidFilePathDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
#URLだけを格納するARRAY
set ocidFileURLArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
#PostScriptNameの保存用
set ocidPostScriptNameArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
#コピーしたファイルの数だけ繰り返し
repeat with itemArray in ocidLineArray
  ##URLに
  set ocidURL to (refMe's NSURL's alloc()'s initWithString:(itemArray))
  #fragmentを取得して
  set ocidFragment to ocidURL's fragment()
  if ocidFragment = (missing value) then
return "FontBooKで選んでください"
  end if
  #fragmentからPostScriptNameの取得
  set ocidSepChar to (refMe's NSString's stringWithString:("="))
  set ocidFragmentArray to (ocidFragment's componentsSeparatedByString:(ocidSepChar))
  set ocidPostScriptName to (ocidFragmentArray's objectAtIndex:(1))
  #PostScript名用のリストに追加していく
(ocidPostScriptNameArray's addObject:(ocidPostScriptName))
  #NSURLComponentsに分割して
  set ocidURLomponents to (refMe's NSURLComponents's componentsWithURL:(ocidURL) resolvingAgainstBaseURL:(false))
  #fragmentを削除してNSURLにする
(ocidURLomponents's setFragment:(missing value))
  set ocidFilePathURL to ocidURLomponents's |URL|
  #ファイル名
  set ocidFileName to ocidFilePathURL's lastPathComponent()
  #リストに追加していく
(ocidFileURLArray's addObject:(ocidFilePathURL))
  #DICTに追加していく
(ocidFilePathDict's setObject:(ocidFilePathURL) forKey:(ocidPostScriptName))
end repeat

###############################
## 保存先
###############################
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
tell application "Finder"
  set aliasDefaultLocation to path to desktop folder from user domain as alias
end tell
try
  set aliasFolderPath to (choose folder "出来あがり画像の保存先フォルダを選んでください" with prompt "出来あがり画像の保存先フォルダを選択してください" default location aliasDefaultLocation without multiple selections allowed, invisibles and showing package contents) as alias
on error
log "エラーしました"
return
end try
###保存先フォルダパス
set strSaveDirPath to (POSIX path of aliasFolderPath) as text
set ocidSaveDirPathStr to refMe's NSString's stringWithString:(strSaveDirPath)
set ocidSaveDirPath to ocidSaveDirPathStr's stringByStandardizingPath()
set ocidSaveDirPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidSaveDirPath) isDirectory:true)
###############################
## 背景色
###############################
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
set the listRGB16bitColor to (choose color default color {65535, 55535, 0, 0}) as list
set numRcolor16Bit to (item 1 of listRGB16bitColor) as integer
set numGcolor16Bit to (item 2 of listRGB16bitColor) as integer
set numBcolor16Bit to (item 3 of listRGB16bitColor) as integer
#
set numRcolorFloat to (numRcolor16Bit / 65535) as number
set numGcolorFloat to (numGcolor16Bit / 65535) as number
set numBcolorFloat to (numBcolor16Bit / 65535) as number
###############################
## 文字色
###############################
set the listRGB16bitColor to (choose color default color {0, 0, 0, 0}) as list
set numRcolor16Bit to (item 1 of listRGB16bitColor) as integer
set numGcolor16Bit to (item 2 of listRGB16bitColor) as integer
set numBcolor16Bit to (item 3 of listRGB16bitColor) as integer
#
set numRcolorFloatText to (numRcolor16Bit / 65535) as number
set numGcolorFloatText to (numGcolor16Bit / 65535) as number
set numBcolorFloatText to (numBcolor16Bit / 65535) as number

###############################
## PostScriptNameArrayの処理
###############################
###画像サイズ
set intWidthPx to 1214 as integer
set intHightPx to 2160 as integer
###余白 px
set numPadding to 10 as integer

###カーニング値 詰めたい場合は -1.7 等マイナス値
set numKern to 0 as number
### テキスト色の透過   透過あり 0.0 - 1.0 透過なし
set numAlpha to 1.0 as number
###ドロップシャドウの有無 true or false
set boolDropShadow to false as boolean


repeat with itemArray in ocidPostScriptNameArray
  set strPostScriptName to itemArray as text
  #
  set intWidth to intWidthPx as integer
  set intHight to intHightPx as integer
  ###################################################
  ##画像生成開始
  set ocidBitmapFormat to refMe's NSBitmapFormatAlphaFirst
  set ocidColorSpaceName to refMe's NSDeviceRGBColorSpace
  set ocidNSBitmapImageFileType to refMe's NSBitmapImageFileTypePNG
  set ocidArtBoardRep to (refMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:(intWidth) pixelsHigh:(intHight) bitsPerSample:8 samplesPerPixel:4 hasAlpha:true isPlanar:false colorSpaceName:(ocidColorSpaceName) bitmapFormat:(ocidBitmapFormat) bytesPerRow:0 bitsPerPixel:32)
  ###################################################
  ###初期化
refMe's NSGraphicsContext's saveGraphicsState()
  ###Context
  set ocidContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
  ###生成された画像でNSGraphicsContext初期化
(refMe's NSGraphicsContext's setCurrentContext:(ocidContext))
  ###塗り色
  set ocidSetColor to (refMe's NSColor's colorWithDeviceRed:(numRcolorFloat) green:(numGcolorFloat) blue:(numBcolorFloat) alpha:1)
ocidSetColor's |set|()
  ##画像にする
refMe's NSRectFill({origin:{x:0, y:0}, |size|:{width:intWidth, height:intHight}})
  ####画像作成終了
refMe's NSGraphicsContext's restoreGraphicsState()
  
  ###################################
  #####テキスト生成
  ###################################
  ###フォント初期化
  set appFontManager to refMe's NSFontManager
  set appSharedMaanager to appFontManager's sharedFontManager()
  
  ###設定用のレコード
  set ocidTextAttr to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
  ###################
  ###文字色
  set ocidTextColor to (refMe's NSColor's colorWithSRGBRed:(numRcolorFloatText) green:(numGcolorFloatText) blue:(numBcolorFloatText) alpha:(numAlpha))
  #
(ocidTextAttr's setObject:(ocidTextColor) forKey:(refMe's NSForegroundColorAttributeName))
  
  ###################
  ##行間
  set ocidStyle to refMe's NSParagraphStyle's defaultParagraphStyle
(ocidTextAttr's setObject:(ocidStyle) forKey:(refMe's NSParagraphStyleAttributeName))
  ###################
  ##カーニング
  set ocidKern to numKern
(ocidTextAttr's setObject:(ocidKern) forKey:(refMe's NSKernAttributeName))
  ###################
  if boolDropShadow is true then
    ##ドロップシャドウ
    set ocidShadow to refMe's NSShadow's alloc()'s init()
    ###テキスト色と同色にする場合
    set ocidShadowColor to (ocidTextColor's colorWithAlphaComponent:0.8)
    ###色指定する場合
    set ocidShadowColor to (refMe's NSColor's colorWithDeviceRed:0 green:0 blue:0 alpha:0.5)
(ocidShadow's setShadowColor:(ocidShadowColor))
(ocidShadow's setShadowOffset:(refMe's NSMakeSize(1, -1)))
(ocidShadow's setShadowBlurRadius:4)
(ocidTextAttr's setObject:(ocidShadow) forKey:(refMe's NSShadowAttributeName))
  end if
  ###################
  set ocidTempFont to (refMe's NSFont's fontWithName:(strPostScriptName) matrix:(missing value))
  set strDisplayName to ocidTempFont's displayName as text
  ##描画する文字列
  set ocidText1 to (refMe's NSString's stringWithString:(strDisplayName))
  set ocidText2 to (refMe's NSString's stringWithString:(strPostScriptName))
  set ocidText3 to (refMe's NSString's stringWithString:(strInputText3))
  set ocidText4 to (refMe's NSString's stringWithString:(strInputText4))
  set ocidText5 to (refMe's NSString's stringWithString:(strInputText5))
  set ocidText6 to (refMe's NSString's stringWithString:(strInputText6))
  #
  set ocidText7 to (refMe's NSString's stringWithString:(strInputText7))
  ###################
  ####モバイル端末用の位置調整
  set intHight to (intHight - 140) as integer
  set numHightPost to intHight
  ####描画されるテキストボックスのサイズ
  ##【52】フォント サイズ
  ###フォントサイズ
  set numFontSize to 52 as integer
  set ocidFont to (refMe's NSFont's fontWithName:(strPostScriptName) |size|:numFontSize)
(ocidTextAttr's setObject:(ocidFont) forKey:(refMe's NSFontAttributeName))
  #
  set ocidTextSize1 to (ocidText1's sizeWithAttributes:(ocidTextAttr))
  set numTextwidth to ((intWidth - (ocidTextSize1's width)) / 2) as integer
  set numTextHigh to (intHight - (ocidTextSize1's height)) as integer
  set numTextHigh1 to ((numTextHigh - (numFontSize / 3))) as integer
  set ocidTextOrigin1 to refMe's NSMakePoint(numTextwidth, numTextHigh1)
  #
  set ocidTextSize2 to (ocidText2's sizeWithAttributes:(ocidTextAttr))
  set numTextwidth to ((intWidth - (ocidTextSize2's width)) / 2) as integer
  set numTextHigh to (numTextHigh1 - (ocidTextSize2's height)) as integer
  set numTextHigh2 to ((numTextHigh - (numFontSize / 3))) as integer
  set ocidTextOrigin2 to refMe's NSMakePoint(numTextwidth, numTextHigh2)
  #
  set ocidTextSize3 to (ocidText3's sizeWithAttributes:(ocidTextAttr))
  set numTextwidth to ((intWidth - (ocidTextSize3's width)) / 2) as integer
  set numTextHigh to (numTextHigh2 - (ocidTextSize3's height)) as integer
  set numTextHigh3 to ((numTextHigh - (numFontSize / 3))) as integer
  set ocidTextOrigin3 to refMe's NSMakePoint(numTextwidth, numTextHigh3)
  #
  set ocidTextSize4 to (ocidText4's sizeWithAttributes:(ocidTextAttr))
  set numTextwidth to ((intWidth - (ocidTextSize4's width)) / 2) as integer
  set numTextHigh to (numTextHigh3 - (ocidTextSize4's height)) as integer
  set numTextHigh4 to ((numTextHigh - (numFontSize / 3))) as integer
  set ocidTextOrigin4 to refMe's NSMakePoint(numTextwidth, numTextHigh4)
  #
  set ocidTextSize5 to (ocidText5's sizeWithAttributes:(ocidTextAttr))
  set numTextwidth to ((intWidth - (ocidTextSize5's width)) / 2) as integer
  set numTextHigh to (numTextHigh4 - (ocidTextSize5's height)) as integer
  set numTextHigh5 to ((numTextHigh - (numFontSize / 3))) as integer
  set ocidTextOrigin5 to refMe's NSMakePoint(numTextwidth, numTextHigh5)
  #
  set ocidTextSize6 to (ocidText6's sizeWithAttributes:(ocidTextAttr))
  set numTextwidth to ((intWidth - (ocidTextSize6's width)) / 2) as integer
  set numTextHigh to (numTextHigh5 - (ocidTextSize6's height)) as integer
  set numTextHigh6 to ((numTextHigh - (numFontSize / 3))) as integer
  set ocidTextOrigin6 to refMe's NSMakePoint(numTextwidth, numTextHigh6)
  #############################
  ##【36】フォント サイズ
  set numFontSize to 36 as integer
  set ocidFont to (refMe's NSFont's fontWithName:(strPostScriptName) |size|:(numFontSize))
(ocidTextAttr's setObject:(ocidFont) forKey:(refMe's NSFontAttributeName))
  #余白分
  set numTextHigh6 to (numTextHigh6 - numFontSize) as integer
  #
  set ocidTextSize7 to (ocidText3's sizeWithAttributes:(ocidTextAttr))
  set numTextwidth to ((intWidth - (ocidTextSize7's width)) / 2) as integer
  set numTextHigh to (numTextHigh6 - (ocidTextSize7's height)) as integer
  set numTextHigh7 to ((numTextHigh - (numFontSize / 3))) as integer
  set ocidTextOrigin7 to refMe's NSMakePoint(numTextwidth, numTextHigh7)
  #
  set ocidTextSize8 to (ocidText4's sizeWithAttributes:(ocidTextAttr))
  set numTextwidth to ((intWidth - (ocidTextSize8's width)) / 2) as integer
  set numTextHigh to (numTextHigh7 - (ocidTextSize8's height)) as integer
  set numTextHigh8 to ((numTextHigh - (numFontSize / 3))) as integer
  set ocidTextOrigin8 to refMe's NSMakePoint(numTextwidth, numTextHigh8)
  #
  set ocidTextSize9 to (ocidText5's sizeWithAttributes:(ocidTextAttr))
  set numTextwidth to ((intWidth - (ocidTextSize9's width)) / 2) as integer
  set numTextHigh to (numTextHigh8 - (ocidTextSize9's height)) as integer
  set numTextHigh9 to ((numTextHigh - (numFontSize / 3))) as integer
  set ocidTextOrigin9 to refMe's NSMakePoint(numTextwidth, numTextHigh9)
  #
  set ocidTextSize10 to (ocidText6's sizeWithAttributes:(ocidTextAttr))
  set numTextwidth to ((intWidth - (ocidTextSize10's width)) / 2) as integer
  set numTextHigh to (numTextHigh9 - (ocidTextSize10's height)) as integer
  set numTextHigh10 to ((numTextHigh - (numFontSize / 3))) as integer
  set ocidTextOrigin10 to refMe's NSMakePoint(numTextwidth, numTextHigh10)
  #############################
  ##【72】フォント サイズ
  set numFontSize to 72 as integer
  set ocidFont to (refMe's NSFont's fontWithName:(strPostScriptName) |size|:numFontSize)
(ocidTextAttr's setObject:(ocidFont) forKey:(refMe's NSFontAttributeName))
  #余白分
  set numTextHigh10 to (numTextHigh10 - numFontSize) as integer
  #
  set ocidTextSize11 to (ocidText3's sizeWithAttributes:(ocidTextAttr))
  set numTextwidth to ((intWidth - (ocidTextSize11's width)) / 2) as integer
  set numTextHigh to (numTextHigh10 - (ocidTextSize11's height)) as integer
  set numTextHigh11 to ((numTextHigh - (numFontSize / 3))) as integer
  set ocidTextOrigin11 to refMe's NSMakePoint(numTextwidth, numTextHigh11)
  #
  set ocidTextSize12 to (ocidText4's sizeWithAttributes:(ocidTextAttr))
  set numTextwidth to ((intWidth - (ocidTextSize12's width)) / 2) as integer
  set numTextHigh to (numTextHigh11 - (ocidTextSize12's height)) as integer
  set numTextHigh12 to ((numTextHigh - (numFontSize / 3))) as integer
  set ocidTextOrigin12 to refMe's NSMakePoint(numTextwidth, numTextHigh12)
  #
  set ocidTextSize13 to (ocidText5's sizeWithAttributes:(ocidTextAttr))
  set numTextwidth to ((intWidth - (ocidTextSize13's width)) / 2) as integer
  set numTextHigh to (numTextHigh12 - (ocidTextSize13's height)) as integer
  set numTextHigh13 to ((numTextHigh - (numFontSize / 3))) as integer
  set ocidTextOrigin13 to refMe's NSMakePoint(numTextwidth, numTextHigh13)
  #
  set ocidTextSize14 to (ocidText6's sizeWithAttributes:(ocidTextAttr))
  set numTextwidth to ((intWidth - (ocidTextSize14's width)) / 2) as integer
  set numTextHigh to (numTextHigh13 - (ocidTextSize14's height)) as integer
  set numTextHigh14 to ((numTextHigh - (numFontSize / 3))) as integer
  set ocidTextOrigin14 to refMe's NSMakePoint(numTextwidth, numTextHigh14)
  #############################
  ##【96】フォント サイズ
  set numFontSize to 96 as integer
  set ocidFont to (refMe's NSFont's fontWithName:(strPostScriptName) |size|:numFontSize)
(ocidTextAttr's setObject:(ocidFont) forKey:(refMe's NSFontAttributeName))
  #余白分
  set numTextHigh14 to (numTextHigh14 - numFontSize) as integer
  #
  # set ocidTextSize15 to (ocidText3's sizeWithAttributes:(ocidTextAttr))
  set ocidTextSize15 to (ocidText7's sizeWithAttributes:(ocidTextAttr))
  set numTextwidth to ((intWidth - (ocidTextSize15's width)) / 2) as integer
  set numTextHigh to (numTextHigh14 - (ocidTextSize15's height)) as integer
  set numTextHigh15 to ((numTextHigh - (numFontSize / 3))) as integer
  set ocidTextOrigin15 to refMe's NSMakePoint(numTextwidth, numTextHigh15)
  #
  set ocidTextSize16 to (ocidText4's sizeWithAttributes:(ocidTextAttr))
  set numTextwidth to ((intWidth - (ocidTextSize16's width)) / 2) as integer
  set numTextHigh to (numTextHigh15 - (ocidTextSize16's height)) as integer
  set numTextHigh16 to ((numTextHigh - (numFontSize / 3))) as integer
  set ocidTextOrigin16 to refMe's NSMakePoint(numTextwidth, numTextHigh16)
  #
  set ocidTextSize17 to (ocidText5's sizeWithAttributes:(ocidTextAttr))
  set numTextwidth to ((intWidth - (ocidTextSize17's width)) / 2) as integer
  set numTextHigh to (numTextHigh16 - (ocidTextSize17's height)) as integer
  set numTextHigh17 to ((numTextHigh - (numFontSize / 3))) as integer
  set ocidTextOrigin17 to refMe's NSMakePoint(numTextwidth, numTextHigh17)
  #
  set ocidTextSize18 to (ocidText6's sizeWithAttributes:(ocidTextAttr))
  set numTextwidth to ((intWidth - (ocidTextSize18's width)) / 2) as integer
  set numTextHigh to (numTextHigh17 - (ocidTextSize18's height)) as integer
  set numTextHigh18 to ((numTextHigh - (numFontSize / 3))) as integer
  set ocidTextOrigin18 to refMe's NSMakePoint(numTextwidth, numTextHigh18)
  
  
  #############################
  ##【48】フォント サイズ
  set numFontSize to 48 as integer
  set ocidFont to (refMe's NSFont's fontWithName:(strPostScriptName) |size|:numFontSize)
(ocidTextAttr's setObject:(ocidFont) forKey:(refMe's NSFontAttributeName))
  #余白分
  set numTextHigh18 to (numTextHigh18 - numFontSize) as integer
  #
  set ocidTextSize19 to (ocidText1's sizeWithAttributes:(ocidTextAttr))
  set numTextwidth to ((intWidth - (ocidTextSize19's width)) / 2) as integer
  set numTextHigh to ((ocidTextSize19's height)) as integer
  set numTextHigh19 to (((numTextHigh * 2) + (numFontSize / 3))) as integer
  set ocidTextOrigin19 to refMe's NSMakePoint(numTextwidth, numTextHigh19)
  #
  set ocidTextSize20 to (ocidText2's sizeWithAttributes:(ocidTextAttr))
  set numTextwidth to ((intWidth - (ocidTextSize20's width)) / 2) as integer
  set numTextHigh to ((ocidTextSize20's height)) as integer
  set numTextHigh20 to ((numTextHigh - (numFontSize / 3))) as integer
  set ocidTextOrigin20 to refMe's NSMakePoint(numTextwidth, numTextHigh20)
  
  ###################################
  #####テキスト描画 本処理
  ###################################
  ####NSGraphicsContextは透明アートボード
  set ocidContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
  ###初期化
refMe's NSGraphicsContext's saveGraphicsState()
  ###透明アートボードでNSGraphicsContext初期化
(refMe's NSGraphicsContext's setCurrentContext:(ocidContext))
  
  ###テキスト描画する
  set numFontSize to 52 as integer
  set ocidFont to (refMe's NSFont's fontWithName:(strPostScriptName) |size|:numFontSize)
(ocidTextAttr's setObject:(ocidFont) forKey:(refMe's NSFontAttributeName))
(ocidText1's drawAtPoint:(ocidTextOrigin1) withAttributes:(ocidTextAttr))
(ocidText2's drawAtPoint:(ocidTextOrigin2) withAttributes:(ocidTextAttr))
(ocidText3's drawAtPoint:(ocidTextOrigin3) withAttributes:(ocidTextAttr))
(ocidText4's drawAtPoint:(ocidTextOrigin4) withAttributes:(ocidTextAttr))
(ocidText5's drawAtPoint:(ocidTextOrigin5) withAttributes:(ocidTextAttr))
(ocidText6's drawAtPoint:(ocidTextOrigin6) withAttributes:(ocidTextAttr))
  #
  set numFontSize to 36 as integer
  set ocidFont to (refMe's NSFont's fontWithName:(strPostScriptName) |size|:numFontSize)
(ocidTextAttr's setObject:(ocidFont) forKey:(refMe's NSFontAttributeName))
(ocidText3's drawAtPoint:(ocidTextOrigin7) withAttributes:(ocidTextAttr))
(ocidText4's drawAtPoint:(ocidTextOrigin8) withAttributes:(ocidTextAttr))
(ocidText5's drawAtPoint:(ocidTextOrigin9) withAttributes:(ocidTextAttr))
(ocidText6's drawAtPoint:(ocidTextOrigin10) withAttributes:(ocidTextAttr))
  #
  set numFontSize to 72 as integer
  set ocidFont to (refMe's NSFont's fontWithName:(strPostScriptName) |size|:numFontSize)
(ocidTextAttr's setObject:(ocidFont) forKey:(refMe's NSFontAttributeName))
(ocidText3's drawAtPoint:(ocidTextOrigin11) withAttributes:(ocidTextAttr))
(ocidText4's drawAtPoint:(ocidTextOrigin12) withAttributes:(ocidTextAttr))
(ocidText5's drawAtPoint:(ocidTextOrigin13) withAttributes:(ocidTextAttr))
(ocidText6's drawAtPoint:(ocidTextOrigin14) withAttributes:(ocidTextAttr))
  #
  set numFontSize to 96 as integer
  set ocidFont to (refMe's NSFont's fontWithName:(strPostScriptName) |size|:numFontSize)
(ocidTextAttr's setObject:(ocidFont) forKey:(refMe's NSFontAttributeName))
  # (ocidText3's drawAtPoint:(ocidTextOrigin15) withAttributes:(ocidTextAttr))
(ocidText7's drawAtPoint:(ocidTextOrigin15) withAttributes:(ocidTextAttr))
  # (ocidText4's drawAtPoint:(ocidTextOrigin16) withAttributes:(ocidTextAttr))
  # (ocidText5's drawAtPoint:(ocidTextOrigin17) withAttributes:(ocidTextAttr))
  # (ocidText6's drawAtPoint:(ocidTextOrigin18) withAttributes:(ocidTextAttr))
  
  #
  set numFontSize to 48 as integer
  set ocidFont to (refMe's NSFont's fontWithName:(strPostScriptName) |size|:numFontSize)
(ocidTextAttr's setObject:(ocidFont) forKey:(refMe's NSFontAttributeName))
(ocidText1's drawAtPoint:(ocidTextOrigin19) withAttributes:(ocidTextAttr))
(ocidText2's drawAtPoint:(ocidTextOrigin20) withAttributes:(ocidTextAttr))
  
  
  ####画像作成終了
refMe's NSGraphicsContext's restoreGraphicsState()
  ###################################################
  ###プロパティ
  set ocidProperty to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
  ###
  set ocidColorSpace to refMe's NSColorSpace's displayP3ColorSpace()
  set ocidColorSpaceData to ocidColorSpace's ICCProfileData()
(ocidProperty's setObject:(ocidColorSpaceData) forKey:(refMe's NSImageColorSyncProfileData))
  ###
(ocidProperty's setObject:(false) forKey:(refMe's NSImageInterlaced))
  ###
  set numGamma to (1 / 2.2) as number
(ocidProperty's setObject:(false) forKey:(refMe's NSImageGamma))
  ####DATAに
  set ocidNSInlineData to (ocidArtBoardRep's representationUsingType:(ocidNSBitmapImageFileType) |properties|:(ocidProperty))
  ###################################
  #####保存
  ###################################
  
  ###ファイル名はフォント名
  set ocidSaveFilePathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:(strPostScriptName) isDirectory:false)
  set ocidFilePathURL to (ocidSaveFilePathURL's URLByAppendingPathExtension:"png")
  ###保存
  set boolDone to (ocidNSInlineData's writeToURL:(ocidFilePathURL) atomically:true)
  set ocidNSInlineData to ""
  set ocidContext to ""
  
  
  
end repeat





|

« FontBookからコピーした値からパスやPostscript名を取得する | トップページ | Microsoft OfficeのフォントをFontBookに登録する »

AppleScript Fonts」カテゴリの記事