Core Textは、Mac OS X v10.4で初めて導入され、Mac OS X v10.5で公開されたmacOSのCore Foundation風のAPIで、古くからmacOSにあり非推奨となったQuickDrawやATSUIに代わってテキストレンダリングの機能を担うものである。Appleによると、Core Textは高いパフォーマンスと利用の容易さを意識して設計され、このレイアウトAPIはシンプルで安定しており、Core FoundationやCore Graphics、Cocoaと密接に関連している。[1] Core Textは次のような不透過型を提供している。 次のコードは与えられたグラフィックコンテクストに「Hello, World!」と表示する。// フォントの準備CTFontRef font = CTFontCreateWithName(CFSTR("Times"), 48, NULL);// 属性付き文字列の生成CFStringRef keys[] = { kCTFontAttributeName };CFTypeRef values[] = { font };CFDictionaryRef attr = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values, sizeof(keys) / sizeof(keys[0]), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);CFAttributedStringRef attrString = CFAttributedStringCreate(NULL, CFSTR("Hello, World!"), attr);CFRelease(attr);// 文字列の描画CTLineRef line = CTLineCreateWithAttributedString(attrString);CGContextSetTextMatrix(context, CGAffineTransformIdentity);CGContextSetTextPosition(context, 10, 20);CTLineDraw(line, context);// 後片付けCFRelease(line);CFRelease(attrString);CFRelease(font);
特徴
CTFramesetter - CTTypesetterを使って、与えられた属性付き文字列とCGPathからCTFrameオブジェクトを生成する。
CTTypesetter - 改行などの行のレイアウトを行う。
CTFrame - 行(CTLineオブジェクト)の配列を表す。
CTLine - 同じ属性を持つグリフの並びの配列を表す。
CTFont - フォントを表す。
使用例
参照[脚注の使い方]^ ⇒Core Text Programming Guide: Core Text Overview
外部リンク
⇒Overview at Apple's Developer Connection
歴
macOS
バージョン
Public Beta
10.0
10.1
10.2
10.3
10.4
10.5
10.6
10.7
10.8
10.9
10.10
10.11
10.12
10.13
10.14
10.15
11
12
13
14
アプリケーション
Automator
DVD プレーヤー
FaceTime
Finder
Font Book
Launchpad
Mac App Store
News
Audio MIDI 設定
AirMacユーティリティ
Bluetoothファイル交換
ColorSyncユーティリティ
Digital Color Meter
Grapher
Mission Control
Time Machine
VoiceOverユーティリティ
アーカイブユーティリティ
アクティビティモニタ
移行アシスタント
イメージキャプチャ
画面共有
キーチェーンアクセス
コンソール
システム情報
スクリプトエディタ
スクリーンショット
ターミナル
ディスクユーティリティ
ディレクトリユーティリティ
フィードバックアシスタント
プリントセンター
ワイヤレス診断
廃止
グラブ
ネットワークユーティリティ
テクノロジーおよび
インタフェース
AirDrop
AirPlay
Apple Pay
Apple File System
Apple Remote Desktop
AppleScript
Apple Type Services for Unicode Imaging
Aqua
Audio Units
AVFoundation
Bonjour
Boot Camp
Cocoa (API)
ColorSync
Core Animation
Core Audio
Core Data
Core Foundation
Core Text
Core Image
CUPS
Darwin
Dock
FileVault
Game Center
Gatekeeper
Grand Central Dispatch(英語版)
Inkwell
Keychain
launchd
Mach-O
Metal
Mission Control