Fonts

[python3]フォントのグリフIDを取得する

202411280200421_533x319

yugothb.ttc.html


こんな感じで
フォントの文字情報を取得してHTML表示します

ダウンロード - dumpgid.zip




サンプルコード

サンプルソース(参考)
行番号ソース
001#!/usr/bin/env python3
002# coding: utf-8
003import sys
004import os
005from fontTools.ttLib import TTFont
006from fontTools.ttLib import TTCollection
007import unicodedata
008
009 
010ARG_QUERY = sys.argv
011STR_FONT_FILE_PATH = str(ARG_QUERY[1])
012ARG_INPUT_STRING = str(ARG_QUERY[2])
013NORMALIZED_STRING = unicodedata.normalize("NFC", ARG_INPUT_STRING)
014
015#テスト用
016#STR_FONT_FILE_PATH = "/path/to/some/font.otf"
017#ARG_INPUT_STRING="美しい日本語"
018
019PATH_DESKTOP = os.path.join(os.path.expanduser("~"), "Desktop")
020PATH_FILENAME = os.path.basename(STR_FONT_FILE_PATH)
021PATH_BASE_FILENAME = os.path.splitext(PATH_FILENAME)[0]
022STR_SAVE_TEXT_FILENAME = f"{PATH_BASE_FILENAME}.txt"
023PATH_OUTPUT_FILE = os.path.join(PATH_DESKTOP,STR_SAVE_TEXT_FILENAME)
024
025def FUNC_TTF(STR_FONT_FILE_PATH):
026    READ_FONT = TTFont(STR_FONT_FILE_PATH)
027    with open(PATH_OUTPUT_FILE, 'w', encoding='utf-8') as file:
028        print(f"COLLECTION:1")
029        print(f"パス: {STR_FONT_FILE_PATH}")
030        file.write(f"パス: {STR_FONT_FILE_PATH}\n")
031        STR_FILENAME = os.path.basename(STR_FONT_FILE_PATH)
032        print(f"ファイル名: {STR_FILENAME}\n")
033        file.write(f"ファイル名: {STR_FILENAME}\n\n")
034        
035        FONT_DICT = READ_FONT["name"].names
036        for item in FONT_DICT:
037            if item.nameID == 1:
038                FONTFAMILY_NAME = item.toUnicode()
039                break
040
041        print(f"FontFamily名: {FONTFAMILY_NAME}")
042        file.write(f"FontFamily名: {FONTFAMILY_NAME}\n")
043    
044        for item in FONT_DICT:
045            if item.nameID == 6:
046                POSTSCRIPT_NAME = item.toUnicode()
047                break
048
049        print(f"PostScript名: {POSTSCRIPT_NAME}")
050        file.write(f"PostScript名: {POSTSCRIPT_NAME}\n")
051        
052        GLYPH_SET = READ_FONT.getGlyphSet()
053        print(f"収録文字数: {len(GLYPH_SET)}")
054        file.write(f"収録文字数: {len(GLYPH_SET)}\n\n")
055
056        STR_HEADER="NO\t文字\tユニコード\tグリフ名\tグリフID\tUTF8\t文字幅"
057        print(f"{STR_HEADER}")
058        file.write(f"{STR_HEADER}\n")
059
060        for INDEXNO, ITEMCHAR in enumerate(NORMALIZED_STRING):
061            DEC_CODEPOINT = ord(ITEMCHAR)
062            BYTE_UTF8 = ITEMCHAR.encode('utf-8')
063            HEX_UTF8 = BYTE_UTF8.hex().upper()
064            HEX_CODEPOINT = hex(DEC_CODEPOINT)
065            HEX_CODE = HEX_CODEPOINT[2:].upper()
066            STR_GLYPHNAME = READ_FONT.getBestCmap().get(DEC_CODEPOINT, "missing value")
067            NUM_GLYPHID = READ_FONT.getGlyphID(STR_GLYPHNAME)if STR_GLYPHNAME != "missing value" else -1
068            ITEM_GLYPH = READ_FONT.getGlyphSet()[STR_GLYPHNAME]
069            NUM_GLYPH_WIDTH = ITEM_GLYPH.width
070            print(f"{INDEXNO}\t{ITEMCHAR}\t{HEX_CODE}\t{STR_GLYPHNAME}\t{NUM_GLYPHID}\t{HEX_UTF8}\t{NUM_GLYPH_WIDTH}")
071            file.write(f"{INDEXNO}\t{ITEMCHAR}\t{HEX_CODE}\t{STR_GLYPHNAME}\t{NUM_GLYPHID}\t{HEX_UTF8}\t{NUM_GLYPH_WIDTH}\n")
072            
073
074        print(f"\n\n")
075        file.write(f"\n\n")
076        
077def FUNC_TTC(STR_FONT_FILE_PATH):
078
079    with open(PATH_OUTPUT_FILE, 'w', encoding='utf-8') as file:
080        FONT_COLLECTION = TTCollection(STR_FONT_FILE_PATH)
081        NUM_CNT_ONT_COLLECTION = len(FONT_COLLECTION.fonts)
082        print(f"COLLECTION:{NUM_CNT_ONT_COLLECTION}")
083        print(f"パス: {STR_FONT_FILE_PATH}")
084        file.write(f"パス: {STR_FONT_FILE_PATH}\n")
085        STR_FILENAME = os.path.basename(STR_FONT_FILE_PATH)
086        print(f"ファイル名: {STR_FILENAME}")
087        file.write(f"ファイル名: {STR_FILENAME}\n\n")
088        
089        for ITEM_FONT in FONT_COLLECTION.fonts:
090
091            FONT_DICT = ITEM_FONT["name"].names
092            for item in FONT_DICT:
093                if item.nameID == 1:
094                    FONTFAMILY_NAME = item.toUnicode()
095                    break
096
097            print(f"FontFamily名: {FONTFAMILY_NAME}")
098            file.write(f"FontFamily名: {FONTFAMILY_NAME}\n")
099            
100            for item in FONT_DICT:
101                if item.nameID == 6:
102                    POSTSCRIPT_NAME = item.toUnicode()
103                    break
104
105            print(f"PostScript名: {POSTSCRIPT_NAME}")
106            file.write(f"PostScript名: {POSTSCRIPT_NAME}\n")
107                
108            GLYPH_SET = ITEM_FONT.getGlyphSet()
109            print(f"収録文字数: {len(GLYPH_SET)}")
110            file.write(f"収録文字数: {len(GLYPH_SET)}\n\n")
111            
112            STR_HEADER="NO\t文字\tユニコード\tグリフ名\tグリフID\tUTF8\t文字幅"
113            print(f"{STR_HEADER}")
114            file.write(f"{STR_HEADER}\n")
115            
116            for INDEXNO, ITEMCHAR in enumerate(NORMALIZED_STRING):
117                DEC_CODEPOINT = ord(ITEMCHAR)
118                BYTE_UTF8 = ITEMCHAR.encode('utf-8')
119                HEX_UTF8 = BYTE_UTF8.hex().upper()
120                HEX_CODEPOINT = hex(DEC_CODEPOINT)
121                HEX_CODE = HEX_CODEPOINT[2:].upper()
122                STR_GLYPHNAME = ITEM_FONT.getBestCmap().get(DEC_CODEPOINT, "missing value")
123                NUM_GLYPHID = ITEM_FONT.getGlyphID(STR_GLYPHNAME)if STR_GLYPHNAME != "missing value" else -1
124                ITEM_GLYPH = ITEM_FONT.getGlyphSet()[STR_GLYPHNAME]
125                NUM_GLYPH_WIDTH = ITEM_GLYPH.width
126                print(f"{INDEXNO}\t{ITEMCHAR}\t{HEX_CODE}\t{STR_GLYPHNAME}\t{NUM_GLYPHID}\t{HEX_UTF8}\t{NUM_GLYPH_WIDTH}")
127                file.write(f"{INDEXNO}\t{ITEMCHAR}\t{HEX_CODE}\t{STR_GLYPHNAME}\t{NUM_GLYPHID}\t{HEX_UTF8}\t{NUM_GLYPH_WIDTH}\n")
128                
129
130            #print(f"")
131            file.write(f"\n\n")
132        
133
134_, extension = os.path.splitext(STR_FONT_FILE_PATH)
135EXTENSION_LOWER = extension.lower()
136if EXTENSION_LOWER == ".ttc":
137    FUNC_TTC(STR_FONT_FILE_PATH)
138elif EXTENSION_LOWER == ".otc":
139    FUNC_TTC(STR_FONT_FILE_PATH)
140elif EXTENSION_LOWER == ".otf":
141    FUNC_TTF(STR_FONT_FILE_PATH)
142elif EXTENSION_LOWER == ".ttf":
143    FUNC_TTF(STR_FONT_FILE_PATH)
144
AppleScriptで生成しました

|

[reportlab]フォントのダンプ(失敗作)

オープンタイプのアウトラインフォント未対応を後から知る…

ダウンロード - fontdumppyttf.zip




サンプルコード

サンプルソース(参考)
行番号ソース
001#!/usr/bin/env python3
002# coding: utf-8
003import sys
004from fontTools.ttLib import TTFont
005from reportlab.pdfgen import canvas
006from reportlab.lib.pagesizes import A4
007from reportlab.pdfbase import pdfmetrics
008from reportlab.pdfbase.ttfonts import TTFont as ReportlabTTFont
009
010def dump_font_to_pdf(font_path, output_pdf):
011    # フォントファイルを読み込み
012    font = TTFont(font_path)
013    # cmapを取得
014    cmap = font["cmap"].getBestCmap()
015    # フォント名を取得
016    font_name = None
017    try:
018        font_name = font["name"].getName(1, 3, 1, 1033).toUnicode()
019    except AttributeError:
020        pass
021    
022    if not font_name:
023        try:
024            font_name = font["name"].getName(6, 1, 0, 0).toUnicode()
025        except AttributeError:
026            raise ValueError("フォント名を取得できませんでした。")
027    
028    print(f"Using font: {font_name}")
029    # フォントをreportlabに登録
030    reportlab_font_name = "ReadFont"
031    pdfmetrics.registerFont(ReportlabTTFont(reportlab_font_name, font_path))
032    
033    # PDF作成
034    pdf_canvas = canvas.Canvas(output_pdf, pagesize=A4)
035    width, height = A4
036    pdf_canvas.setFont("Helvetica", 12)
037
038    # フォント名を描画
039    pdf_canvas.drawString(50, height - 50, f"Font Dump: {font_name}")
040
041    y = height - 80
042    for  index,(codepoint, glyph_name) in enumerate(sorted(cmap.items())):
043        char = chr(codepoint)
044
045        pdf_canvas.setFont("Courier", 12)
046        pdf_canvas.drawString(50, y, f"U+{codepoint:04X} INDEX: {index}")
047        pdf_canvas.setFont("Courier", 12)
048        pdf_canvas.drawString(200, y, f" CID: {glyph_name}")
049        pdf_canvas.setFont(reportlab_font_name, 12)
050        pdf_canvas.drawString(420, y, f"{char}")
051        y -= 15
052
053        if y < 50:
054            pdf_canvas.showPage()
055            pdf_canvas.setFont("Courier", 12)
056            y = height - 50
057
058    pdf_canvas.save()
059    print(f"PDF saved as {output_pdf}")
060
061#
062argGetData = sys.argv
063font_path = str(argGetData[1])
064output_pdf = str(argGetData[2])
065#テスト用
066#   font_path = "/path/to/font/file.ttf"
067#   output_pdf = "/Path/to/save/pfg/file.pdf"
068dump_font_to_pdf(font_path, output_pdf)
069
AppleScriptで生成しました

|

[Font] SkypeAssets 絵文字フォント Skype専用

Skypeassetslight1tiff
Skypeassetslight2tiff

|

Adobe Fonts 同期のリセット(同期不具合発生時用) 少し手直し


AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004# Adobeフォントリストファイル 拡張子lstもゴミ箱に入れるようにした
005#
006#
007# com.cocolog-nifty.quicktimer.icefloe
008----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
009use AppleScript version "2.8"
010use framework "Foundation"
011use framework "AppKit"
012use scripting additions
013
014property refMe : a reference to current application
015
016set appFileManager to refMe's NSFileManager's defaultManager()
017
018###################################
019#まずは処理するアプリケーションを終了させる
020###################################
021set strKeyWord to ("adobe") as text
022log "アプリケーション終了開始"
023set numCntApp to 1
024repeat until numCntApp = 0
025  ##対象プロセスが無くなるまで繰り返し
026  set numCntApp to doAppQuit(strKeyWord)
027  delay 1
028end repeat
029log "アプリケーション終了"
030###################################
031#プロセス終了を確認する
032###################################
033log "プロセス終了開始"
034log doKillProcess()
035
036log "プロセス終了"
037###################################
038#フォントのキャッシュを ゴミ箱に入れる
039###################################
040
041log doMoveToTrash("~/Library/Application Support/Adobe/CoreSync/plugins/livetype")
042
043###################################
044#フォントのキャッシュを ゴミ箱に入れる
045###################################
046set appFileManager to refMe's NSFileManager's defaultManager()
047set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSUserDomainMask))
048set ocidApplicatioocidupportDirPathURL to ocidURLsArray's firstObject()
049#
050set ocidTargetDirPathURL to ocidApplicatioocidupportDirPathURL's URLByAppendingPathComponent:("Adobe") isDirectory:(true)
051#コンテンツの収集
052set ocidPropertiesArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
053ocidPropertiesArray's addObject:(refMe's NSURLIsDirectoryKey)
054ocidPropertiesArray's addObject:(refMe's NSURLNameKey)
055ocidPropertiesArray's addObject:(refMe's NSURLPathKey)
056set ocidOption to (refMe's NSDirectoryEnumerationSkipsHiddenFiles)
057#収集
058set ocidEmuDict to appFileManager's enumeratorAtURL:(ocidTargetDirPathURL) includingPropertiesForKeys:(ocidPropertiesArray) options:(ocidOption) errorHandler:(reference)
059#全部のパスを順番に調べる
060repeat
061  #次へ
062  set ocidItemURL to ocidEmuDict's nextObject()
063  #空になったらループ終了
064  if ocidItemURL = (missing value) then
065    exit repeat
066  else
067    #ファイルか?それ以外か?
068    set listResponse to (ocidItemURL's getResourceValue:(reference) forKey:(refMe's NSURLIsRegularFileKey) |error| :(reference))
069    set boolFile to (item 2 of listResponse) as boolean
070    if boolFile is true then
071      #ファイルなら
072      set strExtensionName to ocidItemURL's pathExtension() as text
073      if strExtensionName is "lst" then
074        #拡張子がlstなら
075        set strFileName to ocidItemURL's lastPathComponent() as text
076        if strFileName contains "Fnt" then
077          #ファイル名にFNTが含まれているなら
078          #ゴミ箱に入れる
079          set listDone to (appFileManager's trashItemAtURL:(ocidItemURL) resultingItemURL:(ocidItemURL) |error| :(reference))
080          if (item 2 of listDone) ≠ (missing value) then
081            set strErrorNO to (item 2 of listDone)'s code() as text
082            set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
083            refMe's NSLog("■:" & strErrorNO & strErrorMes)
084            return "エラーしました" & strErrorNO & strErrorMes
085          end if
086        end if
087      end if
088    end if
089  end if
090  
091end repeat
092
093
094###################################
095#処理 ゴミ箱に入れる
096###################################
097
098to doMoveToTrash(argFilePath)
099  ###ファイルマネジャー初期化
100  set appFileManager to refMe's NSFileManager's defaultManager()
101  #########################################
102  ###渡された値のClassを調べてとりあえずNSURLにする
103  set refClass to class of argFilePath
104  if refClass is list then
105    return "エラー:リストは処理しません"
106  else if refClass is text then
107    log "テキストパスです"
108    set ocidArgFilePathStr to (refMe's NSString's stringWithString:argFilePath)
109    set ocidArgFilePath to ocidArgFilePathStr's stringByStandardizingPath
110    set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
111  else if refClass is alias then
112    log "エイリアスパスです"
113    set strArgFilePath to (POSIX path of argFilePath) as text
114    set ocidArgFilePathStr to (refMe's NSString's stringWithString:strArgFilePath)
115    set ocidArgFilePath to ocidArgFilePathStr's stringByStandardizingPath
116    set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
117  else
118    set refClass to (className() of argFilePath) as text
119    if refClass contains "NSPathStore2" then
120      log "NSPathStore2です"
121      set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:argFilePath)
122    else if refClass contains "NSCFString" then
123      log "NSCFStringです"
124      set ocidArgFilePath to argFilePath's stringByStandardizingPath
125      set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
126    else if refClass contains "NSURL" then
127      set ocidArgFilePathURL to argFilePath
128      log "NSURLです"
129    end if
130  end if
131  #########################################
132  ###
133  -->false
134  set ocidFalse to (refMe's NSNumber's numberWithBool:false)'s boolValue
135  -->true
136  set ocidTrue to (refMe's NSNumber's numberWithBool:true)'s boolValue
137  #########################################
138  ###NSURLがエイリアス実在するか
139  set ocidArgFilePath to ocidArgFilePathURL's |path|()
140  set boolFileAlias to appFileManager's fileExistsAtPath:(ocidArgFilePath)
141  ###パス先が実在しないなら処理はここまで
142  if boolFileAlias = false then
143    log ocidArgFilePath as text
144    log "処理中止 パス先が実在しない"
145    return false
146  end if
147  #########################################
148  ###NSURLがディレクトリなのか?ファイルなのか?
149  set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsDirectoryKey) |error| :(reference)
150  #   log (item 1 of listBoolDir)
151  #   log (item 2 of listBoolDir)
152  #   log (item 3 of listBoolDir)
153  if (item 2 of listBoolDir) = ocidTrue then
154    #########################################
155    log "ディレクトリです"
156    log ocidArgFilePathURL's |path| as text
157    ##内包リスト
158    set listResult to appFileManager's contentsOfDirectoryAtURL:ocidArgFilePathURL includingPropertiesForKeys:{refMe's NSURLPathKey} options:0  |error| :(reference)
159    ###結果
160    set ocidContentsPathURLArray to item 1 of listResult
161    ###リストの数だけ繰り返し
162    repeat with itemContentsPathURL in ocidContentsPathURLArray
163      ###ゴミ箱に入れる
164      set listResult to (appFileManager's trashItemAtURL:itemContentsPathURL resultingItemURL:(missing value) |error| :(reference))
165    end repeat
166  else
167    #########################################
168    log "ファイルです"
169    set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsAliasFileKey) |error| :(reference)
170    if (item 2 of listBoolDir) = ocidTrue then
171      log "エイリアスは処理しません"
172      return false
173    end if
174    set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsSymbolicLinkKey) |error| :(reference)
175    if (item 2 of listBoolDir) = ocidTrue then
176      log "シンボリックリンクは処理しません"
177      return false
178    end if
179    set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsSystemImmutableKey) |error| :(reference)
180    if (item 2 of listBoolDir) = ocidTrue then
181      log "システムファイルは処理しません"
182      return false
183    end if
184    ###ファイルをゴミ箱に入れる
185    set listResult to (appFileManager's trashItemAtURL:ocidArgFilePathURL resultingItemURL:(missing value) |error| :(reference))
186  end if
187  return true
188end doMoveToTrash
189
190
191
192
193#############################
194#アプリケーション終了簡易版
195#############################
196to doAppQuit(argKeyWord)
197  #全プロセス取得して
198  tell application "System Events"
199    #バンドルIDリストにします
200    set listBundleID to bundle identifier of (every application process)
201  end tell
202  #全プロセスで
203  repeat with itemBundleID in listBundleID
204    #対象のドメイン名を含むなら
205    if itemBundleID contains argKeyWord then
206      #バンドルIDでアプリケーションを取得して
207      set ocidResultsArray to (refMe's NSRunningApplication's runningApplicationsWithBundleIdentifier:(itemBundleID))
208      set numCntArray to ocidResultsArray's |count|()
209      repeat with itemNo from 0 to (numCntArray - 1) by 1
210        set ocidRunApp to (ocidResultsArray's objectAtIndex:(itemNo))
211        #通常終了を試みます
212        set boolDone to ocidRunApp's terminate()
213        if (boolDone) is true then
214          log itemBundleID & ":正常終了"
215          #失敗したら
216        else if (boolDone) is false then
217          #強制終了を試みます
218          set boolDone to ocidRunApp's forceTerminate()
219          if (boolDone) is true then
220            log itemBundleID & ":強制終了"
221          else if (boolDone) is false then
222            log itemBundleID & ":終了出来ませんでした"
223          end if
224        end if
225      end repeat
226    end if
227  end repeat
228  #実行後のプロセス数で
229  tell application "System Events"
230    set listBundleID to bundle identifier of (every application process)
231  end tell
232  set numDoneCnt to 0 as integer
233  repeat with itemBundleID in listBundleID
234    #対象のドメイン名を含む数を
235    if itemBundleID contains "adobe" then
236      set numDoneCnt to numDoneCnt + 1
237    end if
238  end repeat
239  #戻す
240  return numDoneCnt
241end doAppQuit
242
243###################################
244#プロセス終了を確認する
245###################################
246to doKillProcess()
247  set listAppName to {"ACCFinderSync", "AGMService", "AcroCEF", "AcroCEF Helper", "AcroCEF Helper (GPU)", "AcroCEF Helper (Renderer)", "Acrobat", "Acrobat CEF", "Acrobat CEF Helper", "Acrobat CEF Helper (GPU)", "Acrobat CEF Helper (Renderer)", "Adobe Acrobat Synchronizer", "Adobe CEF", "Adobe CEF Helper", "Adobe CEF Helper (GPU)", "Adobe CEF Helper (Renderer)", "Adobe Content Synchronizer", "Adobe Crash Handler", "Adobe Crash Processor", "Adobe Crash Reporter", "Adobe Desktop Service", "Adobe FormsCentral", "Adobe Installer", "AdobeCEF", "AdobeCEF Helper", "AdobeCEF Helper (GPU)", "AdobeCEF Helper (Renderer)", "AdobeCRDaemon", "AdobeExtensionsService", "AdobeGCClient", "AdobeIPCBroker", "AdobeReader", "AdobeResourceSynchronizer", "CCLibrary", "CCXProcess", "Core Sync", "Core Sync Helper", "Creative Cloud", "Creative Cloud Content Manager.node", "Creative Cloud Helper", "LogTransport", "RdrCEF", "RdrCEF Helper", "RdrCEF Helper (GPU)", "RdrCEF Helper (Renderer)", "Reader CEF", "Reader CEF Helper", "Reader CEF Helper (GPU)", "Reader CEF Helper (Renderer)", "armsvc", "com.adobe.ARMDC.Communicator", "com.adobe.ARMDC.SMJobBlessHelper", "com.adobe.acc.installer.v2"} as list
248  
249  
250  repeat with itemAppName in listAppName
251    set strAppName to itemAppName as text
252    set strCommandText to "/bin/ps  -alxe | grep \"" & strAppName & "\" | grep -v \"grep\" | awk '{ print $2 }'" as text
253    set strResponce to (do shell script strCommandText) as text
254    log strResponce
255    set AppleScript's text item delimiters to "\r"
256    set listPID to every text item of strResponce
257    set AppleScript's text item delimiters to ""
258    
259    if (count of listPID) = 0 then
260      log "対象プロセス無し"
261    else
262      repeat with itemPID in listPID
263        ###プロセスを終了させる
264        doQuitApp2PID(itemPID)
265      end repeat
266    end if
267  end repeat
268  
269end doKillProcess
270
271
272
273
274###################################
275#アプリケーションを終了させる
276###################################
277to doQuitApp2PID(argPID)
278  set strPID to argPID as text
279  #### killallを使う場合
280  set strCommandText to ("/bin/kill -15  " & strPID & "") as text
281  set ocidCommandText to refMe's NSString's stringWithString:strCommandText
282  set ocidTermTask to refMe's NSTask's alloc()'s init()
283  ocidTermTask's setLaunchPath:"/bin/zsh"
284  ocidTermTask's setArguments:({"-c", ocidCommandText})
285  set listResults to ocidTermTask's launchAndReturnError:(reference)
286  log listResults
287  if item 1 of listResults is true then
288    log "正常終了"
289  else
290    try
291      set strCommandText to ("/bin/kill -9  " & strPID & "") as text
292      set strResponse to (do shell script strCommandText) as text
293    end try
294  end if
295end doQuitApp2PID
296
AppleScriptで生成しました

|

文字関連メモ まとめ用

基本的には
モリサワの資料が読みやすい



1:文字コード
2:文字セット
3:文字コレクション
4:その他


1:文字コード
ユニコードだっりUTF8だったり
『文字』としての共通の背番号的な意味合い
001_20241114142301

第一水準や第二水準といった文字コレクションは
文字コード(JISコード)と紐づいているので文字コードとしての意味も含む場合があるので文脈によって意味が変わる場合があります



2:文字セット
旧jIS字形 新JIS字形 学参字形 PRESS字形といった字形のセット
文字のスタイルや見た目を統一する目的で
文字のスタイル=字形を定義しているのであって
CIDや文字コードとは『直接的には』関係無い

001_20241114142601



3:文字コレクション
見た目の文字の形とCID(フォント内部のGID(グリフインデックス番号)と『ほぼ』同義)を紐づけているだけ
001_20241114144101

3−1:文字コレクション
文字のキャラクター(見た目としての字形)とCID(キャラクターID)番号の組み合わせを定義
字形とCIDの組み合わせなので、文字コードとは『直接的には』関係無い

旧JIS字形の一点しんにょうの辻
202411140237221_1002x282

新jiS字形の二点しんにょうの辻
202411140239101_1026x236

3−2:フォントとしての文字コレクション
Std Pro Pro6といったフォントの収録文字数
対象のフォントがCIDフォント(文字コレクションで指定したCIDに文字が入っている)の場合は
これも『一種の』文字コレクションと言って良い
Std=AdobeJapan1-3
Pro=AdobeJapan1-4

一般的には非CIDフォント(CID番号と違う番号のフォント内のGIDに文字が入っている)の方が多い

Std Pro Pro6が付かないフォントは基本的には非CIDフォントで
文字コレクション=収録文字数やGIDは独自である事が多い


第一水準や第二水準といった文字コレクションは
文字コード(JISコード)と紐づいているので文字コードとしての意味も含む場合があるので
文脈によって意味が変わる場合があります



4:その他
異体字
フォント内の異体字は、オープンタイプの機能によって制御されている
001_20241114145201

また
絵文字に代表される
Unicodeによる異体字やサロゲートペアにバリエーションは
文字コードの仕組みで、フォントの異体字の仕組みとは別物

|

[ログイン項目]フォントブック用 ログイン時に起動して隠しておく


AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004(*
005ログイン項目登録用
006起動時に起動後『隠す』処理
007ファイル>書き出す…からアプリケーションに書き出し
008ログイン項目に登録する
009設定項目のバンドルIDは
010https://github.com/force4u/AppleScript/blob/main/Script%20Menu/Developer/Get/getAppBundleID.applescript
011を使って取得できます
012*)
013#com.cocolog-nifty.quicktimer.icefloe
014----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
015use AppleScript version "2.8"
016use framework "Foundation"
017use framework "AppKit"
018use scripting additions
019property refMe : a reference to current application
020
021set strBundleID to ("com.apple.FontBook") as text
022
023#起動 launchだとWindowが開かない
024tell application id strBundleID to launch
025#前面へ これだとWindowが開く
026#tell application id strBundleID to activate
027
028#起動待ち 最大60回
029repeat 120 times
030  tell application id strBundleID
031    activate
032    set boolFrontMost to frontmost as boolean
033  end tell
034  if boolFrontMost is true then
035    exit repeat
036  else
037    delay 0.5
038    tell application id strBundleID to activate
039  end if
040end repeat
041
042#ランニングアプリケーションでフォントブック
043set appRunAppArray to refMe's NSRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID)
044set appRunApp to appRunAppArray's firstObject()
045##起動確認
046repeat 120 times
047  set boolFrontMost to appRunApp's isActive() as boolean
048  if boolFrontMost is true then
049    exit repeat
050  else
051    delay 0.5
052    appRunApp's active()
053  end if
054end repeat
055##起動終了確認
056repeat 120 times
057  set boolFrontMost to appRunApp's isFinishedLaunching() as boolean
058  if boolFrontMost is true then
059    exit repeat
060  else
061    delay 0.5
062    appRunApp's active()
063  end if
064end repeat
065#隠れていないか?の確認
066repeat 120 times
067  set boolFrontMost to appRunApp's isHidden() as boolean
068  if boolFrontMost is false then
069    exit repeat
070  else
071    delay 0.5
072    appRunApp's active()
073  end if
074end repeat
075###名前の取得
076tell application id strBundleID
077  set strAppName to name as text
078end tell
079###隠す処理
080tell application "System Events"
081  tell application process strAppName
082    set visible to false
083  end tell
084end tell
085#隠す処理
086repeat 120 times
087  set boolFrontMost to appRunApp's isHidden() as boolean
088  if boolFrontMost is false then
089    delay 0.5
090    appRunApp's hide()
091  else
092    exit repeat
093  end if
094end repeat
095
096return
AppleScriptで生成しました

|

フォントのバージョンを取得してHTMLリスト表示する

202410310412291_836x343


ダウンロード - getfontversionlist.zip




AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003# com.cocolog-nifty.quicktimer.icefloe
004#  ファイル毎にコマンド打ちますのでそれなりに時間かかります
005#  選択したフォントバージョンを取得してHTML表示します
006#  python3のセットアップが必要です
007#
008----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
009use AppleScript version "2.8"
010use framework "Foundation"
011use framework "AppKit"
012use framework "UniformTypeIdentifiers"
013use scripting additions
014
015property refMe : a reference to current application
016
017
018################
019#python3のパスチェック
020if (doChkPython3()) is false then
021  return "python3が見つかりませんでした終了します"
022end if
023
024################
025#pythonスクリプトパス
026set aliasPathToMe to (path to me) as alias
027set strPathToMe to (POSIX path of aliasPathToMe) as text
028set ocidPathToMeStr to refMe's NSString's stringWithString:(strPathToMe)
029set ocidPathToMe to ocidPathToMeStr's stringByStandardizingPath()
030set ocidPathToMeURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidPathToMe) isDirectory:(false)
031set ocidContainerDirPathURL to ocidPathToMeURL's URLByDeletingLastPathComponent()
032set ocidBinDirPathURL to ocidContainerDirPathURL's URLByAppendingPathComponent:("bin") isDirectory:(true)
033set ocidPyFilePathURL to ocidBinDirPathURL's URLByAppendingPathComponent:("getNameIdDict.py") isDirectory:(true)
034set strPyFilePathURL to (ocidPyFilePathURL's |path|) as text
035################
036#パス
037set strName to (name of current application) as text
038if strName is "osascript" then
039  tell application "Finder" to activate
040else
041  tell current application to activate
042end if
043############ デフォルトロケーション
044set appFileManager to refMe's NSFileManager's defaultManager()
045set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
046set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
047set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias
048
049set listUTI to {"public.opentype-font", "public.truetype-ttf-font", "public.truetype-collection-font", "public.opentype-collection-font", "public.font"} as list
050set strMes to ("ファイルを選んでください") as text
051set strPrompt to ("ファイルを選んでください") as text
052try
053  ### ファイル選択時
054  set listAliasFilePath to (choose file strMes with prompt strPrompt default location aliasDefaultLocation of type listUTI with invisibles, multiple selections allowed and showing package contents) as list
055  
056on error
057  log "エラーしました"
058  return "エラーしました"
059end try
060if listAliasFilePath is {} then
061  return "選んでください"
062end if
063
064################
065# URLDICT作成
066set ocidFilePathNameDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
067
068repeat with itemAliasFilePath in listAliasFilePath
069  set aliasFilePath to itemAliasFilePath as alias
070  set strFilePath to (POSIX path of aliasFilePath) as text
071  set ocidFilePathStr to (refMe's NSString's stringWithString:(strFilePath))
072  set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
073  set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
074  #
075  set strFileName to ocidFilePathURL's lastPathComponent() as text
076  (ocidFilePathNameDict's setObject:(ocidFilePathURL) forKey:(strFileName))
077end repeat
078
079
080################
081#
082set ocidAllKeys to ocidFilePathNameDict's allKeys()
083set ocidSortedAllKey to ocidAllKeys's sortedArrayUsingSelector:("localizedStandardCompare:")
084#
085set ocidOutPutDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
086#
087repeat with itemKye in ocidSortedAllKey
088  set itemFileURL to (ocidFilePathNameDict's objectForKey:(itemKye))
089  
090  #修正日
091  set listResponse to (itemFileURL's getResourceValue:(reference) forKey:(refMe's NSURLContentModificationDateKey) |error| :(reference))
092  set ocidModDay to (item 2 of listResponse)
093  #ファイルサイズ
094  set listResponse to (itemFileURL's getResourceValue:(reference) forKey:(refMe's NSURLFileSizeKey) |error| :(reference))
095  set ocidFileSize to (item 2 of listResponse)
096  #コマンド実行
097  set ocidFilePath to (itemFileURL's |path|)
098  set ocidFilePathM to ocidFilePath's mutableCopy()
099  set ocidFilePathM to (ocidFilePathM's stringByReplacingOccurrencesOfString:("\\") withString:("\\\\\\\\"))
100  set ocidFilePathM to (ocidFilePathM's stringByReplacingOccurrencesOfString:("'") withString:("\\'"))
101  set ocidFilePathM to (ocidFilePathM's stringByReplacingOccurrencesOfString:("\"") withString:("\\\\\\\""))
102  set strFilePathM to ocidFilePathM as text
103  set strCommandText to ("\"" & strPyFilePathURL & "\"  \"" & strFilePathM & "\"") as text
104  log "\n" & strCommandText & "\n"
105  set strExecCommand to ("/bin/zsh -c '" & strCommandText & "'") as text
106  try
107    set strResponse to (do shell script strExecCommand) as text
108  on error
109    set strResponse to ("") as text
110  end try
111  set ocidResponse to (refMe's NSString's stringWithString:(strResponse))
112  set ocidResponeArray to (ocidResponse's componentsSeparatedByString:("\t"))
113  set ocidFontFamily to ocidResponeArray's firstObject()
114  set ocidFontVersion to ocidResponeArray's lastObject()
115  
116  #リストにして次工程用のDICTに渡す
117  set listValue to {(ocidFilePath), (ocidFileSize), (ocidModDay), (ocidFontFamily), (ocidFontVersion)} as list
118  (ocidOutPutDict's setObject:(listValue) forKey:(itemKye))
119end repeat
120
121###############
122##
123set ocidSaveString to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
124(ocidSaveString's appendString:("ファイル名\tファミリ名\tサイズ\t修正日\tバージョン\t備考"))
125(ocidSaveString's appendString:("\n"))
126#
127set ocidAllKeys to ocidOutPutDict's allKeys()
128set ocidSortedAllKey to ocidAllKeys's sortedArrayUsingSelector:("localizedStandardCompare:")
129#
130set appDateFormatter to refMe's NSDateFormatter's alloc()'s init()
131(appDateFormatter's setDateFormat:("yyyyMMdd"))
132
133##############################
134# XML 生成開始
135##############################
136set ocidXMLDoc to refMe's NSXMLDocument's alloc()'s init()
137(ocidXMLDoc's setDocumentContentKind:(refMe's NSXMLDocumentHTMLKind))
138# DTD付与
139set ocidDTD to refMe's NSXMLDTD's alloc()'s init()
140(ocidDTD's setName:("html"))
141(ocidXMLDoc's setDTD:(ocidDTD))
142# XML主要部分を生成
143set ocidRootElement to doMakeRootElement()
144#ボディエレメント
145set ocidBodyElement to (refMe's NSXMLElement's elementWithName:("body"))
146#ヘッダー
147set ocidHeaderElement to (refMe's NSXMLElement's elementWithName:("header"))
148set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("id") stringValue:("header"))
149(ocidHeaderElement's addAttribute:(ocidAddNode))
150set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("class") stringValue:("body_header"))
151(ocidHeaderElement's addAttribute:(ocidAddNode))
152(ocidBodyElement's addChild:(ocidHeaderElement))
153#アーティクル
154set ocidArticleElement to (refMe's NSXMLElement's elementWithName:("article"))
155set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("id") stringValue:("article"))
156(ocidArticleElement's addAttribute:(ocidAddNode))
157set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("class") stringValue:("body_article"))
158(ocidArticleElement's addAttribute:(ocidAddNode))
159(ocidBodyElement's addChild:(ocidArticleElement))
160#フッター
161set ocidFooterElement to (refMe's NSXMLElement's elementWithName:("footer"))
162set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("id") stringValue:("footer"))
163(ocidFooterElement's addAttribute:(ocidAddNode))
164set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("class") stringValue:("body_footer"))
165(ocidFooterElement's addAttribute:(ocidAddNode))
166#リンク付与(不要なら削除可)
167set ocidAElement to (refMe's NSXMLElement's elementWithName:("a"))
168set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("href") stringValue:("https://quicktimer.cocolog-nifty.com/"))
169(ocidAElement's addAttribute:(ocidAddNode))
170set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("target") stringValue:("_blank"))
171(ocidAElement's addAttribute:(ocidAddNode))
172set strContents to ("AppleScriptで生成しました") as text
173(ocidAElement's setStringValue:(strContents))
174(ocidFooterElement's addChild:(ocidAElement))
175(ocidBodyElement's addChild:(ocidFooterElement))
176##############################
177# TABLE コンテンツ部分生成開始
178##############################
179#テーブル部生成開始
180set ocidTableElement to (refMe's NSXMLElement's elementWithName:("table"))
181set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("summary") stringValue:("フォントのバージョン一覧 フォントの各項目の値が一覧になっています"))
182(ocidTableElement's addAttribute:(ocidAddNode))
183
184#【caption】
185set ocidCaptionElement to (refMe's NSXMLElement's elementWithName:("caption"))
186(ocidCaptionElement's setStringValue:("【ファイルリスト】: フォントリスト"))
187(ocidTableElement's addChild:(ocidCaptionElement))
188#【colgroup】
189set ocidColgroupElement to (refMe's NSXMLElement's elementWithName:("colgroup"))
190#テーブルのタイトル部
191set listColName to {"行番号", "ファイル名", "ファミリー名", "サイズ", "修正日", "バージョン", "備考"} as list
192set listColID to {"liineNO", "FileName", "FontFamilyName", "FileSize", "ModDay", "Version", "Note"} as list
193#項目数を取得して
194set numCntCol to (count of listColName) as integer
195#タイトル部の数だけ繰り返し
196repeat with itemNo from 1 to numCntCol by 1
197  set strItemName to (item itemNo of listColName) as text
198  #【col】col生成
199  set ocidAddElement to (refMe's NSXMLElement's elementWithName:("col"))
200  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(strItemName))
201  (ocidAddElement's addAttribute:(ocidAddNode))
202  (ocidColgroupElement's addChild:(ocidAddElement))
203end repeat
204#テーブルエレメントに追加
205(ocidTableElement's addChild:(ocidColgroupElement))
206#【thead】
207set ocidTheadElement to (refMe's NSXMLElement's elementWithName:("thead"))
208#TR
209set ocidTrElement to (refMe's NSXMLElement's elementWithName:("tr"))
210#タイトル部の数だけ繰り返し
211repeat with itemNo from 1 to numCntCol by 1
212  set strItemName to (item itemNo of listColName) as text
213  set strItemID to (item itemNo of listColID) as text
214  #ここはTDではなくてTHを利用
215  set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th"))
216  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(strItemName))
217  (ocidAddElement's addAttribute:(ocidAddNode))
218  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("id") stringValue:(strItemID))
219  (ocidAddElement's addAttribute:(ocidAddNode))
220  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("col"))
221  (ocidAddElement's addAttribute:(ocidAddNode))
222  #値を入れる
223  (ocidAddElement's setStringValue:(strItemName))
224  #TH→TRにセット
225  (ocidTrElement's addChild:(ocidAddElement))
226end repeat
227#TRをTHEADにセット
228(ocidTheadElement's addChild:(ocidTrElement))
229#THEADをテーブルにセット
230(ocidTableElement's addChild:(ocidTheadElement))
231
232############
233#【tbody】
234set ocidTbodyElement to refMe's NSXMLElement's elementWithName:("tbody")
235set numCntLineNo to 1 as integer
236repeat with itemKey in ocidSortedAllKey
237  set ocidItemArray to (ocidOutPutDict's objectForKey:(itemKey))
238  set strFileName to itemKey as text
239  #URL サイズ 修正日 バージョン  
240  set ocidUrl to (ocidItemArray's objectAtIndex:(0))
241  set ocidSize to (ocidItemArray's objectAtIndex:(1))
242  set ocidMod to (ocidItemArray's objectAtIndex:(2))
243  set ocidFamily to (ocidItemArray's objectAtIndex:(3))
244  set ocidVer to (ocidItemArray's objectAtIndex:(4))
245  #
246  set strColName1 to (item 1 of listColName) as text
247  set strColName2 to (item 2 of listColName) as text
248  set strColName3 to (item 3 of listColName) as text
249  set strColName4 to (item 4 of listColName) as text
250  set strColName5 to (item 5 of listColName) as text
251  set strColName6 to (item 6 of listColName) as text
252  set strColName7 to (item 7 of listColName) as text
253  #
254  set strItemID1 to (item 1 of listColID) as text
255  set strItemID2 to (item 2 of listColID) as text
256  set strItemID3 to (item 3 of listColID) as text
257  set strItemID4 to (item 4 of listColID) as text
258  set strItemID5 to (item 5 of listColID) as text
259  set strItemID6 to (item 6 of listColID) as text
260  set strItemID7 to (item 7 of listColID) as text
261  #
262  set ocidUrlStr to (refMe's NSString's stringWithString:(ocidUrl))
263  set ocidUrlPath to ocidUrlStr's stringByStandardizingPath()
264  set ocidLinkURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidUrlPath) isDirectory:false)
265  set strAbsoluteString to ocidLinkURL's absoluteString() as text
266  set strModDateStr to (appDateFormatter's stringFromDate:(ocidMod)) as text
267  
268  set ocidVer to (ocidVer's stringByReplacingOccurrencesOfString:("Version ") withString:(""))
269  set ocidVer to (ocidVer's stringByReplacingOccurrencesOfString:("version ") withString:(""))
270  set ocidVer to (ocidVer's stringByReplacingOccurrencesOfString:("Version") withString:(""))
271  set ocidVer to (ocidVer's stringByReplacingOccurrencesOfString:("version") withString:(""))
272  ########
273  #TRの開始
274  set ocidTrElement to (refMe's NSXMLElement's elementWithName:("tr"))
275  #【行番号】をTHでセット
276  set strZeroSupp to ("00") as text
277  set strZeroSupp to ("00" & numCntLineNo) as text
278  set strLineNO to (text -3 through -1 of strZeroSupp) as text
279  set ocidThElement to (refMe's NSXMLElement's elementWithName:("th"))
280  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(strColName1))
281  (ocidThElement's addAttribute:(ocidAddNode))
282  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("row"))
283  (ocidThElement's addAttribute:(ocidAddNode))
284  set strSetValue to ("LineNO" & strLineNO) as text
285  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("id") stringValue:(strSetValue))
286  (ocidThElement's addAttribute:(ocidAddNode))
287  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("headers") stringValue:(strItemID1))
288  (ocidThElement's addAttribute:(ocidAddNode))
289  (ocidThElement's setStringValue:(strLineNO))
290  (ocidTrElement's addChild:(ocidThElement))
291  ########
292  #【ファイル名】をTDでセット
293  set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td"))
294  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(strColName2))
295  (ocidTdElement's addAttribute:(ocidAddNode))
296  set strSetValue to (strFileName & " " & strItemID2) as text
297  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("headers") stringValue:(strSetValue))
298  (ocidTdElement's addAttribute:(ocidAddNode))
299  #
300  set ocidAElement to (refMe's NSXMLElement's elementWithName:("a"))
301  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("alt") stringValue:(strFileName))
302  (ocidAElement's addAttribute:(ocidAddNode))
303  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("href") stringValue:(strAbsoluteString))
304  (ocidAElement's addAttribute:(ocidAddNode))
305  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("target") stringValue:("_blank"))
306  (ocidAElement's addAttribute:(ocidAddNode))
307  (ocidAElement's setStringValue:(strFileName))
308  #リンクをTDにセット
309  (ocidTdElement's addChild:(ocidAElement))
310  #TDをTRにセット
311  (ocidTrElement's addChild:(ocidTdElement))
312  ############
313  #【見本】をTDでセット
314  set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td"))
315  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(strColName3))
316  (ocidTdElement's addAttribute:(ocidAddNode))
317  set strSetValue to (strFileName & " " & strItemID3) as text
318  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("headers") stringValue:(strItemID3))
319  (ocidTdElement's addAttribute:(ocidAddNode))
320  #
321  set ocidSpanElement to (refMe's NSXMLElement's elementWithName:("span"))
322  set strSetValue to ("font-family: '" & ocidFamily & "', sans-serif;") as text
323  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("style") stringValue:(strSetValue))
324  (ocidSpanElement's addAttribute:(ocidAddNode))
325  set strSetValue to (ocidFamily) as text
326  (ocidSpanElement's setStringValue:(strSetValue))
327  (ocidTdElement's addChild:(ocidSpanElement))
328  (ocidTrElement's addChild:(ocidTdElement))
329  ############
330  #【ファイルサイズ】TD
331  set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td"))
332  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(strColName4))
333  (ocidTdElement's addAttribute:(ocidAddNode))
334  set strSetValue to (strFileName & " " & strItemID4) as text
335  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("headers") stringValue:(strSetValue))
336  (ocidTdElement's addAttribute:(ocidAddNode))
337  #単位による分岐
338  set strValue to ocidSize as text
339  set numFileSize to strValue as integer
340  #
341  set numByteUnits to 1000 as integer
342  # バイト単位 10.5以前やWindowsターゲットの場合は1024に
343  if (numFileSize) < numByteUnits then
344    log "b:バイト単位"
345    set strFileSize to doRound2Dec(numFileSize)
346    set strValue to (strFileSize & " b") as text
347  else if numFileSize < (numByteUnits * numByteUnits) then
348    log "kb:キロバイト単位"
349    set strFileSize to doRound2Dec(numFileSize / numByteUnits)
350    set strValue to (strFileSize & " kb") as text
351  else if numFileSize < (numByteUnits * numByteUnits * numByteUnits) then
352    log "mb:メガバイト単位"
353    set strFileSize to doRound2Dec(numFileSize / (numByteUnits * numByteUnits))
354    set strValue to (strFileSize & " mb") as text
355  else
356    log "gb:ギガバイト単位"
357    set strFileSize to doRound2Dec(numFileSize / (numByteUnits * numByteUnits * numByteUnits))
358    set strValue to (strFileSize & " gb") as text
359  end if
360  (ocidTdElement's setStringValue:(strValue))
361  (ocidTrElement's addChild:(ocidTdElement))
362  ########
363  #【修正日】をTDでセット
364  set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td"))
365  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(strColName5))
366  (ocidTdElement's addAttribute:(ocidAddNode))
367  set strSetValue to (strFileName & " " & strItemID5) as text
368  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("headers") stringValue:(strSetValue))
369  (ocidTdElement's addAttribute:(ocidAddNode))
370  (ocidTdElement's setStringValue:(strModDateStr))
371  #TDをTRにセット
372  (ocidTrElement's addChild:(ocidTdElement))
373  ########
374  #【バージョン】をTDでセット
375  set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td"))
376  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(strColName6))
377  (ocidTdElement's addAttribute:(ocidAddNode))
378  set strSetValue to (strFileName & " " & strItemID6) as text
379  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("headers") stringValue:(strSetValue))
380  (ocidTdElement's addAttribute:(ocidAddNode))
381  (ocidTdElement's setStringValue:(ocidVer))
382  #TDをTRにセット
383  (ocidTrElement's addChild:(ocidTdElement))
384  ########
385  #【備考】をTDでセット
386  set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td"))
387  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(strColName7))
388  (ocidTdElement's addAttribute:(ocidAddNode))
389  set strSetValue to (strFileName & " " & strItemID7) as text
390  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("headers") stringValue:(strSetValue))
391  (ocidTdElement's addAttribute:(ocidAddNode))
392  (ocidTdElement's setStringValue:(""))
393  #TDをTRにセット
394  (ocidTrElement's addChild:(ocidTdElement))
395  #出来上がったTRをTBODYにセット
396  (ocidTbodyElement's addChild:(ocidTrElement))
397  #
398  set numCntLineNo to (numCntLineNo + 1) as integer
399end repeat
400########
401#TBODYをテーブルにセット
402(ocidTableElement's addChild:(ocidTbodyElement))
403############
404#【tfoot】 TRで
405set ocidTfootElement to (refMe's NSXMLElement's elementWithName:("tfoot"))
406set ocidTrElement to (refMe's NSXMLElement's elementWithName:("tr"))
407#colspan指定して1行でセット
408set ocidThElement to (refMe's NSXMLElement's elementWithName:("th"))
409set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:("テーブルの終わり"))
410(ocidThElement's addAttribute:(ocidAddNode))
411set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("colspan") stringValue:(numCntCol as text))
412(ocidThElement's addAttribute:(ocidAddNode))
413set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("row"))
414(ocidThElement's addAttribute:(ocidAddNode))
415(ocidThElement's setStringValue:("TTC等のコレクションフォントは代表で1つのみ表示しています"))
416#THをTRにセットして
417(ocidTrElement's addChild:(ocidThElement))
418#TRをTFOOTにセット
419(ocidTfootElement's addChild:(ocidTrElement))
420#TFOOTをテーブルにセット
421(ocidTableElement's addChild:(ocidTfootElement))
422##############################
423# ROOT
424##############################
425# 出来上がったテーブルをArticleエレメントにセット
426(ocidArticleElement's addChild:(ocidTableElement))
427#
428(ocidRootElement's addChild:(ocidBodyElement))
429#ROOTエレメントをXMLにセット
430ocidXMLDoc's setRootElement:(ocidRootElement)
431#読み取りやすい表示
432set ocidXMLdata to ocidXMLDoc's XMLDataWithOptions:(refMe's NSXMLNodePrettyPrint)
433
434
435
436####################
437##
438set appFileManager to refMe's NSFileManager's defaultManager()
439set ocidHomeDirURL to appFileManager's homeDirectoryForCurrentUser()
440set ocidSaveDirPathURL to ocidHomeDirURL's URLByAppendingPathComponent:("Sites/FontList") isDirectory:(true)
441#
442set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
443ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions)
444set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference)
445#
446set strDateNo to doGetNextDateNo({"yyyyMMdd-hhmm", 1})
447
448set strFileName to ("FontList." & strDateNo & ".html") as text
449set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strFileName) isDirectory:false
450#保存
451set listDone to ocidXMLdata's writeToURL:(ocidSaveFilePathURL) options:(refMe's NSDataWritingAtomic) |error| :(reference)
452if (item 1 of listDone) is true then
453  log "正常終了"
454else if (item 1 of listDone) is false then
455  log (item 2 of listDone)'s localizedDescription() as text
456  return "保存に失敗しました"
457end if
458set ocidSaveFilePath to ocidSaveFilePathURL's |path|
459set ocidContainerDirPath to ocidSaveDirPathURL's |path|
460set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
461set boolDone to appSharedWorkspace's selectFile:(ocidSaveFilePath) inFileViewerRootedAtPath:(ocidContainerDirPath)
462set boolDone to appSharedWorkspace's openURL:(ocidSaveFilePathURL)
463if (boolDone as boolean) is false then
464  #ファイルを開く
465  set aliasSaveFilePath to (ocidSaveFilePathURL's absoluteURL()) as alias
466  tell application "Finder"
467    open file aliasSaveFilePath
468  end tell
469end if
470
471
472
473
474##############################
475## python3のパスチェック
476##############################
477to doChkPython3()
478  try
479    set strCmdText to ("/usr/bin/which python3") as text
480    set strBinPath to (do shell script strCmdText) as text
481    return true
482  on error
483    return false
484  end try
485end doChkPython3
486
487##############################
488# 基本的なHTMLの構造
489##############################
490to doMakeRootElement()
491  #
492  set ocidRootElement to refMe's NSXMLElement's elementWithName:("html")
493  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("lang") stringValue:("ja")
494  ocidRootElement's addAttribute:(ocidAddNode)
495  #
496  set ocidHeadElement to refMe's NSXMLElement's elementWithName:("head")
497  #
498  set ocidAddElement to refMe's NSXMLElement's elementWithName:("title")
499  ocidAddElement's setStringValue:("フォント一覧")
500  ocidHeadElement's addChild:(ocidAddElement)
501  # http-equiv
502  set ocidAddElement to refMe's NSXMLElement's elementWithName:("meta")
503  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("http-equiv") stringValue:("Content-Type")
504  ocidAddElement's addAttribute:(ocidAddNode)
505  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("content") stringValue:("text/html; charset=UTF-8")
506  ocidAddElement's addAttribute:(ocidAddNode)
507  ocidHeadElement's addChild:(ocidAddElement)
508  #
509  set ocidAddElement to refMe's NSXMLElement's elementWithName:("meta")
510  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("http-equiv") stringValue:("Content-Style-Type")
511  ocidAddElement's addAttribute:(ocidAddNode)
512  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("content") stringValue:("text/css")
513  ocidAddElement's addAttribute:(ocidAddNode)
514  ocidHeadElement's addChild:(ocidAddElement)
515  #
516  set ocidAddElement to refMe's NSXMLElement's elementWithName:("meta")
517  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("http-equiv") stringValue:("Content-Script-Type")
518  ocidAddElement's addAttribute:(ocidAddNode)
519  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("content") stringValue:("text/javascript")
520  ocidAddElement's addAttribute:(ocidAddNode)
521  ocidHeadElement's addChild:(ocidAddElement)
522  #
523  set ocidAddElement to refMe's NSXMLElement's elementWithName:("meta")
524  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("name") stringValue:("viewport")
525  ocidAddElement's addAttribute:(ocidAddNode)
526  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("content") stringValue:("width=720")
527  ocidAddElement's addAttribute:(ocidAddNode)
528  ocidHeadElement's addChild:(ocidAddElement)
529  #
530  set ocidAddElement to refMe's NSXMLElement's elementWithName:("style")
531  ocidAddElement's setStringValue:("body { margin: 10px; background-color: #FFFFFF; } table { border-spacing: 0; caption-side: top; font-family: system-ui; } thead th { border: solid 1px #666666; padding: .5ch 1ch; border-block-width: 1px 0; border-inline-width: 1px 0; &:first-of-type { border-start-start-radius: .5em } &:last-of-type { border-start-end-radius: .5em; border-inline-end-width: 1px } } tbody td { word-wrap: break-word;max-width: 360px;border-spacing: 0; border: solid 1px #666666; padding: .5ch 1ch; border-block-width: 1px 0; border-inline-width: 1px 0; &:last-of-type { border-inline-end-width: 1px } } tbody p { margin-block-end: 2px; margin-block-start: 2px;} tbody th { border-spacing: 0; border: solid 1px #666666; padding: .5ch 1ch; border-block-width: 1px 0; border-inline-width: 1px 0; } tbody tr:nth-of-type(odd) { background: #F2F2F2; } .kind_string { font-size: 0.75em; } .date_string { font-size: 0.5em; } tfoot th { border: solid 1px #666666; padding: .5ch 1ch; &:first-of-type { border-end-start-radius: .5em } &:last-of-type { border-end-end-radius: .5em; border-inline-end-width: 1px } }")
532  ocidHeadElement's addChild:(ocidAddElement)
533  #
534  ocidRootElement's addChild:(ocidHeadElement)
535  #
536  return ocidRootElement
537end doMakeRootElement
538
539##############################
540# 小数点以下2桁処理
541##############################
542
543to doRound2Dec(argNumber)
544  set strDecNo to ((round (argNumber * 100)) / 100) as text
545  return strDecNo
546end doRound2Dec
547
548################################
549# 明日の日付 doGetDateNo(argDateFormat,argCalendarNO)
550# argCalendarNO 1 NSCalendarIdentifierGregorian 西暦
551# argCalendarNO 2 NSCalendarIdentifierJapanese 和暦
552################################
553to doGetNextDateNo({argDateFormat, argCalendarNO})
554  ##渡された値をテキストで確定させて
555  set strDateFormat to argDateFormat as text
556  set intCalendarNO to argCalendarNO as integer
557  ###日付情報の取得
558  set ocidDate to current application's NSDate's |date|()
559  set ocidIntervalt to current application's NSDate's dateWithTimeIntervalSinceNow:(86400)
560  ###日付のフォーマットを定義(日本語)
561  set ocidFormatterJP to current application's NSDateFormatter's alloc()'s init()
562  ###和暦 西暦 カレンダー分岐
563  if intCalendarNO = 1 then
564    set ocidCalendarID to (current application's NSCalendarIdentifierGregorian)
565  else if intCalendarNO = 2 then
566    set ocidCalendarID to (current application's NSCalendarIdentifierJapanese)
567  else
568    set ocidCalendarID to (current application's NSCalendarIdentifierISO8601)
569  end if
570  set ocidCalendarJP to current application's NSCalendar's alloc()'s initWithCalendarIdentifier:(ocidCalendarID)
571  set ocidTimezoneJP to current application's NSTimeZone's alloc()'s initWithName:("Asia/Tokyo")
572  set ocidLocaleJP to current application's NSLocale's alloc()'s initWithLocaleIdentifier:("ja_JP_POSIX")
573  ###設定
574  ocidFormatterJP's setTimeZone:(ocidTimezoneJP)
575  ocidFormatterJP's setLocale:(ocidLocaleJP)
576  ocidFormatterJP's setCalendar:(ocidCalendarJP)
577  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterNoStyle)
578  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterShortStyle)
579  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterMediumStyle)
580  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterLongStyle)
581  ocidFormatterJP's setDateStyle:(current application's NSDateFormatterFullStyle)
582  ###渡された値でフォーマット定義
583  ocidFormatterJP's setDateFormat:(strDateFormat)
584  ###フォーマット適応
585  set ocidDateAndTime to ocidFormatterJP's stringFromDate:(ocidIntervalt)
586  ###テキストで戻す
587  set strDateAndTime to ocidDateAndTime as text
588  return strDateAndTime
589end doGetNextDateNo
AppleScriptで生成しました

|

絵文字

20241027125835_1544x1160



Adobe Pi Std
https://fonts.adobe.com/fonts/adobe-pi-std

EmojiOne
https://github.com/adobe-fonts/emojione-color

Noto Color Emoji
Noto Emoji

https://github.com/googlefonts/noto-emoji

Segoe UI Emoji
Segoe UI Symbol
Bookshelf Symbol 7

/Applications/Microsoft\ オフィスアプリ各種.app/Contents/Resources/DFonts

Apple Color Emoji
/System/Library/Fonts/Apple Color Emoji.ttc

Apple Symbols
/System/Library/Fonts/Apple Symbols.ttf

Symbol
/System/Library/Fonts/Symbol.ttf

Zapf Dingbats
/System/Library/Fonts/ZapfDingbats.ttf

|

[tool] robofont

robofont
https://robofont.com/
お試しあり €400
Speed Punk LINK対応

Windowmodes_single

|

FontValidatorを使ってフォントのポストスクリプト名を取得する


AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#
005#
006#com.cocolog-nifty.quicktimer.icefloe
007----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
008use AppleScript version "2.8"
009use framework "Foundation"
010use framework "AppKit"
011use scripting additions
012
013property refMe : a reference to current application
014property strBinPath : ("/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Support/FontValidator") as text
015
016##################
017#ログ保存先ディレクトリ
018set appFileManager to refMe's NSFileManager's defaultManager()
019set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
020set ocidDocumentDirPathURL to ocidURLsArray's firstObject()
021set ocidLogDirPathURL to ocidDocumentDirPathURL's URLByAppendingPathComponent:("Apple/Fonts") isDirectory:(true)
022#フォルダ生成
023set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
024ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
025set listDone to appFileManager's createDirectoryAtURL:(ocidLogDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference)
026#ログファイルパス
027set strDateNo to doGetNextDateNo({"yyyyMMdd_hhmm", 1})
028set strLogFileName to (strDateNo & ".json") as text
029set ocidLogFilePathURL to ocidLogDirPathURL's URLByAppendingPathComponent:(strLogFileName) isDirectory:(false)
030set strLogPath to (ocidLogFilePathURL's |path|) as text
031
032
033##################
034#ダイアログ
035tell current application
036  set strName to name as text
037end tell
038if strName is "osascript" then
039  tell application "Finder" to activate
040else
041  tell current application to activate
042end if
043set ocidDirPathURLArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
044set ocidDirPathURL to ocidDirPathURLArray's firstObject()
045set ocidFontsDirPathURL to ocidDirPathURL's URLByAppendingPathComponent:("Fonts")
046set aliasFontsDirPath to (ocidFontsDirPathURL's absoluteURL()) as alias
047set listChooseFileUTI to {"public.font"}
048set strPromptText to "fontファイルを選んでください" as text
049set listAliasFilePath to (choose file with prompt strPromptText default location (aliasFontsDirPath) of type listChooseFileUTI with invisibles and multiple selections allowed without showing package contents) as list
050
051##################
052#本処理
053repeat with itemAliasFilePath in listAliasFilePath
054  #入力ファイルパス
055  set aliasFilePath to itemAliasFilePath as alias
056  set strFilePath to (POSIX path of aliasFilePath) as text
057  set ocidFilePathStr to (refMe's NSString's stringWithString:(strFilePath))
058  set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
059  set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
060  set ocidFileName to ocidFilePathURL's lastPathComponent()
061  #テンポラリーフォルダを生成
062  set listDone to doMakeTempDirURL()
063  if listDone is false then
064    return "テンポラリーフォルダの生成に失敗しました"
065  else
066    set ocidTempDirPathURL to listDone
067  end if
068  #保存用のファイルのURL
069  set ocidBaseTempFilePathURL to (ocidTempDirPathURL's URLByAppendingPathComponent:(ocidFileName) isDirectory:(false))
070  set ocidTextFilePathURL to (ocidBaseTempFilePathURL's URLByAppendingPathExtension:("txt"))
071  set ocidPlistFilePathURL to (ocidBaseTempFilePathURL's URLByAppendingPathExtension:("plist"))
072  set strTextPath to (ocidTextFilePathURL's |path|) as text
073  set strPlistPath to (ocidPlistFilePathURL's |path|) as text
074  
075  set strCommandText to ("/bin/zsh -c '\"" & strBinPath & "\" -report  \"" & strFilePath & "\"'") as text
076  log strCommandText
077  try
078    set strResponseJson to (do shell script strCommandText) as text
079  on error
080    return "コマンドエラーになりました"
081  end try
082  #テキスト出力用
083  
084  set ocidOutPutString to (refMe's NSMutableString's alloc()'s initWithCapacity:(0))
085  (ocidOutPutString's appendString:("\n"))
086  (ocidOutPutString's appendString:(ocidFileName as text))
087  #NSSTRING
088  set ocidResponseStr to (refMe's NSString's alloc()'s initWithString:(strResponseJson))
089  #NSData
090  set ocidResponseData to (ocidResponseStr's dataUsingEncoding:(refMe's NSUTF8StringEncoding))
091  #NSJSONSerialization
092  set ocidOption to (refMe's NSJSONReadingMutableContainers)
093  set listJSONSerialization to (refMe's NSJSONSerialization's JSONObjectWithData:(ocidResponseData) options:(ocidOption) |error| :(reference))
094  set ocidPlistDict to item 1 of listJSONSerialization
095  #NSPropertyListSerialization
096  set ocidXmlPlist to refMe's NSPropertyListXMLFormat_v1_0
097  set ocidPlistSerial to refMe's NSPropertyListSerialization
098  set ocidOption to refMe's NSPropertyListMutableContainersAndLeaves
099  set listPlistData to (ocidPlistSerial's dataWithPropertyList:(ocidPlistDict) format:(ocidXmlPlist) options:(ocidOption) |error| :(reference))
100  set ocidPlistData to item 1 of listPlistData
101  #保存
102  set ocidOption to (refMe's NSDataWritingAtomic)
103  set listDone to (ocidPlistData's writeToURL:(ocidPlistFilePathURL) options:(ocidOption) |error| :(reference))
104  #テキストにしていく
105  (ocidOutPutString's appendString:("\n"))
106  set ocidSetStrValue to (ocidPlistDict's valueForKey:("Failures"))
107  (ocidOutPutString's appendString:("不良数: " & ocidSetStrValue & "\n"))
108  #
109  set ocidDetailsDict to (ocidPlistDict's objectForKey:("Details"))'s firstObject()
110  set ocidSetStrValue to (ocidDetailsDict's valueForKey:("path"))
111  (ocidOutPutString's appendString:("パス: " & ocidSetStrValue & "\n"))
112  set ocidSetStrValue to (ocidDetailsDict's valueForKey:("error"))
113  (ocidOutPutString's appendString:("エラー数: " & ocidSetStrValue & "\n"))
114  set ocidSetStrValue to (ocidDetailsDict's valueForKey:("error_desc"))
115  (ocidOutPutString's appendString:("エラーメッセージ: " & ocidSetStrValue & "\n"))
116  #
117  set ocidFontsArray to ((ocidDetailsDict's objectForKey:("validation"))'s objectForKey:("fonts"))
118  #
119  set numCntFontArray to ocidFontsArray's |count|()
120  (ocidOutPutString's appendString:("内包フォント数: " & (numCntFontArray as text) & "\n"))
121  (ocidOutPutString's appendString:("---------------------------\n"))
122  repeat with itemDict in ocidFontsArray
123    set ocidPsName to (itemDict's valueForKey:("fontname"))
124    (ocidOutPutString's appendString:("PostScriptフォント名: " & ocidPsName & "\n"))
125    set ocidCntErr to (itemDict's objectForKey:("failures"))'s |count|()
126    (ocidOutPutString's appendString:("エラー数: " & (ocidCntErr as text) & "\n"))
127  end repeat
128  #テキスト保存
129  set listDone to (ocidOutPutString's writeToURL:(ocidTextFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference))
130  #保存したテキストを開く
131set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
132set boolDone to appSharedWorkspace's openURL:(ocidTextFilePathURL)
133  
134end repeat
135
136
137
138
139return
140
141
142##コマンド例
143#フォルダに内包されるフォント全部
144set strCommandText to ("/bin/zsh -c '\"" & strBinPath & "\" -report -report_output \"" & strLogPath & "\" \"" & strTargetDirPath & "\"'") as text
145log strCommandText
146do shell script strCommandText
147
148
149
150
151
152##################
153#表示用 起動時に削除される項目
154to doMakeTempDirURL()
155  set appFileManager to refMe's NSFileManager's defaultManager()
156  set ocidTempDirURL to appFileManager's temporaryDirectory()
157  set ocidUUID to refMe's NSUUID's alloc()'s init()
158  set ocidUUIDString to ocidUUID's UUIDString
159  set ocidSaveDirPathURL to ocidTempDirURL's URLByAppendingPathComponent:(ocidUUIDString) isDirectory:true
160  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
161  ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions)
162  set listDone to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference)
163  if (item 1 of listDone) is true then
164    return ocidSaveDirPathURL
165  else if (item 1 of listDone) is false then
166    set strErrorNO to (item 2 of listDone)'s code() as text
167    set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
168    refMe's NSLog("■:" & strErrorNO & strErrorMes)
169    return false
170  end if
171end doMakeTempDirURL
172
173################################
174# 明日の日付 doGetDateNo(argDateFormat,argCalendarNO)
175# argCalendarNO 1 NSCalendarIdentifierGregorian 西暦
176# argCalendarNO 2 NSCalendarIdentifierJapanese 和暦
177################################
178to doGetNextDateNo({argDateFormat, argCalendarNO})
179  ##渡された値をテキストで確定させて
180  set strDateFormat to argDateFormat as text
181  set intCalendarNO to argCalendarNO as integer
182  ###日付情報の取得
183  set ocidDate to current application's NSDate's |date|()
184  set ocidIntervalt to current application's NSDate's dateWithTimeIntervalSinceNow:(86400)
185  ###日付のフォーマットを定義(日本語)
186  set ocidFormatterJP to current application's NSDateFormatter's alloc()'s init()
187  ###和暦 西暦 カレンダー分岐
188  if intCalendarNO = 1 then
189    set ocidCalendarID to (current application's NSCalendarIdentifierGregorian)
190  else if intCalendarNO = 2 then
191    set ocidCalendarID to (current application's NSCalendarIdentifierJapanese)
192  else
193    set ocidCalendarID to (current application's NSCalendarIdentifierISO8601)
194  end if
195  set ocidCalendarJP to current application's NSCalendar's alloc()'s initWithCalendarIdentifier:(ocidCalendarID)
196  set ocidTimezoneJP to current application's NSTimeZone's alloc()'s initWithName:("Asia/Tokyo")
197  set ocidLocaleJP to current application's NSLocale's alloc()'s initWithLocaleIdentifier:("ja_JP_POSIX")
198  ###設定
199  ocidFormatterJP's setTimeZone:(ocidTimezoneJP)
200  ocidFormatterJP's setLocale:(ocidLocaleJP)
201  ocidFormatterJP's setCalendar:(ocidCalendarJP)
202  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterNoStyle)
203  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterShortStyle)
204  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterMediumStyle)
205  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterLongStyle)
206  ocidFormatterJP's setDateStyle:(current application's NSDateFormatterFullStyle)
207  ###渡された値でフォーマット定義
208  ocidFormatterJP's setDateFormat:(strDateFormat)
209  ###フォーマット適応
210  set ocidDateAndTime to ocidFormatterJP's stringFromDate:(ocidIntervalt)
211  ###テキストで戻す
212  set strDateAndTime to ocidDateAndTime as text
213  return strDateAndTime
214end doGetNextDateNo
215return
AppleScriptで生成しました

|

より以前の記事一覧

その他のカテゴリー

Accessibility Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Manifest Acrobat Menu Acrobat Open Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat python Acrobat Reader Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin Support Admin System Information Admin Tools Admin Users Admin Volumes Adobe Adobe FDKO Adobe RemoteUpdateManager AppKit Apple AppleScript AppleScript do shell script AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript System Events AppleScript System Events Plist AppleScript Video Applications AppStore Archive Attributes Automator BackUp Barcode Barcode QR Barcode QR Decode Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome CIImage CityCode CloudStorage Color com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Device Diff Disk Dock DropBox Droplet eMail Encode % Encode Decode Encode UTF8 Error EXIFData ffmpeg File Finder Firefox Folder FolderAction Fonts GIF github Guide HTML HTML Entity Icon Illustrator Image Events Image2PDF ImageOptim iPhone iWork Javascript Jedit Json Label Leading Zero List locationd LRC lsappinfo LSSharedFileList m3u8 Mail MakePDF Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Mouse Music NetWork Notes NSArray NSArray Sort NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSColor NSColorList NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSPrintOperation NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth OneDrive PDF PDFAnnotation PDFAnnotationWidget PDFContext PDFDisplayBox PDFDocumentPermissions PDFImageRep PDFKit PDFnUP PDFOutline perl Photoshop PlistBuddy pluginkit postalcode PostScript prefPane Preview Python QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver SF Symbols character id SF Symbols Entity sips Skype Slack Sound Spotlight sqlite SRT StandardAdditions Swift System Settings TCC TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code VMware Fusion Wacom webarchive webp Wifi Windows XML XML EPUB XML OPML XML Plist XML RSS XML savedSearch XML SVG XML TTML XML webloc XML XMP YouTube zoom