ObjecTips

Swift & Objective-C で iOS とか macOS とか

縦書き対応した iWorks アプリの新レイアウトエンジン

縦書き対応した iWorks についてMacお宝鑑定団にて
http://www.macotakara.jp/blog/category-60/entry-37209.html

今回の縦書き表示は、Core Textではなく、iWorks専用レイアウトエンジンが搭載されていて、

との事で気になったので調べてみる。

otool -L /Applications/Pages.app/Contents/MacOS/Pages

上記コマンドでアプリにリンクされているライブラリを確認。
そしてアプリをアップデートしてから再度確認。
アップデート前後のバージョン 7.3 と 8.0 の otool の結果は以下

https://gist.github.com/727c02194f2d9402dd80de7a1620e69b

これを diff ツールで確認した追加ライブラリと削除ライブラリのリストは以下

https://gist.github.com/24ea90e725b6c8a03e6c7fde2994a014

ざっとみて分かるのは

  • ClassKit 対応
  • AddressBook, AudioToolbox, CFNetwork などの古くからの Framework は不使用に
  • CloudKit, Contacts などは使われなくなった訳ではなくアプリ同梱版に完全置き換え。前はアプリ同梱版とシステム版の両方にリンクされていた。
  • EquationKit の追加。Equation の訳は「方程式」なので LaTeX と MathML 関連のコードが切り出されたのではないかと予想される。

そして特筆すべきは Prefix TS から始まる TSKit などのフレームワーク群。いずれもアプリ内に同梱されている。

 @rpath/TSKit.framework/Versions/A/TSKit (compatibility version 1.0.0, current version 1.0.0)
    @rpath/TSStyles.framework/Versions/A/TSStyles (compatibility version 1.0.0, current version 1.0.0)
    @rpath/TSUtility.framework/Versions/A/TSUtility (compatibility version 1.0.0, current version 1.0.0)
    @rpath/TSCoreSOS.framework/Versions/A/TSCoreSOS (compatibility version 1.0.0, current version 1.0.0)
    @rpath/TSPersistence.framework/Versions/A/TSPersistence (compatibility version 1.0.0, current version 1.0.0)
    @rpath/TSTables.framework/Versions/A/TSTables (compatibility version 1.0.0, current version 1.0.0)
    @rpath/TSApplication.framework/Versions/A/TSApplication (compatibility version 1.0.0, current version 1.0.0)
    @rpath/TSAccessibility.framework/Versions/A/TSAccessibility (compatibility version 1.0.0, current version 1.0.0)
    @rpath/TSCalculationEngine.framework/Versions/A/TSCalculationEngine (compatibility version 1.0.0, current version 1.0.0)
    @rpath/TSCharts.framework/Versions/A/TSCharts (compatibility version 1.0.0, current version 1.0.0)
    @rpath/TSDrawables.framework/Versions/A/TSDrawables (compatibility version 1.0.0, current version 1.0.0)
    @rpath/TSText.framework/Versions/A/TSText (compatibility version 1.0.0, current version 1.0.0)

いくつか class-dump してみたところ、TSText の中に以下のプロトコルを発見。これがテキストボックス単位の縦書き横書きの切り替えかと思われる。

@protocol TSWPVerticalTextCommand <NSObject>
- (BOOL)addsOrRemovesVerticalText;
@end

またいくつかのクラスには以下のメソッドが存在しており、こちらはテキスト内の部分的な縦書きに関するメソッドかなと。

- (BOOL)textIsVerticalAtCharIndex:(unsigned long long)arg1;

とりあえず調査はここまでで深くは追わないけど、TS系の Framework が大量に追加されており新たなテキストレイアウトエンジン、テキスト描画エンジンが搭載されているというのは間違いなさそう。