OpenTypeフォントの軽量化と自動カーニング

OpenTypeフォントの機能を残しつつ、サブセット化するための手順です。

目次

筆者の環境

  • OSX 10.11.6 ( El Capitan )
  • Python 2.7.10

やりたいこと

  • 日本語フォントをWebフォントとして使うために軽量化したい
  • CSSの font-feature-settings: 'palt'; で文字詰めしたい

つかうもの

FontTools

武蔵システムさんのサブセットフォントメーカーでは、カーニング情報が削除されてしまうため、こちらのツールを使います。

フォントファイル

軽量化したい OpenTypeフォントを用意します。

今回は Noto Sans Japanese を軽量化してみます。
ファイルは Noto Sans CJK JP よりも軽い、源ノ角ゴシック( Source Han Sans ) を利用します。

フォントに格納する文字のテキストファイル

Webフォントとして表示するための文字を選びます。

今回は、第一水準漢字 + 記号 + ローマ字 + カタカナ + ひらがなで試します。
下の文字をコピペして chars.txt という名前で保存してください。

唖娃阿哀愛挨姶逢葵茜穐悪握渥旭葦芦鯵梓圧斡扱宛姐虻飴絢綾鮎或粟袷安庵按暗案闇鞍杏以伊位依偉囲夷委威尉惟意慰易椅為畏異移維緯胃萎衣謂違遺医井亥域育郁磯一壱溢逸稲茨芋鰯允印咽員因姻引飲淫胤蔭院陰隠韻吋右宇烏羽迂雨卯鵜窺丑碓臼渦嘘唄欝蔚鰻姥厩浦瓜閏噂云運雲荏餌叡営嬰影映曳栄永泳洩瑛盈穎頴英衛詠鋭液疫益駅悦謁越閲榎厭円園堰奄宴延怨掩援沿演炎焔煙燕猿縁艶苑薗遠鉛鴛塩於汚甥凹央奥往応押旺横欧殴王翁襖鴬鴎黄岡沖荻億屋憶臆桶牡乙俺卸恩温穏音下化仮何伽価佳加可嘉夏嫁家寡科暇果架歌河火珂禍禾稼箇花苛茄荷華菓蝦課嘩貨迦過霞蚊俄峨我牙画臥芽蛾賀雅餓駕介会解回塊壊廻快怪悔恢懐戒拐改魁晦械海灰界皆絵芥蟹開階貝凱劾外咳害崖慨概涯碍蓋街該鎧骸浬馨蛙垣柿蛎鈎劃嚇各廓拡撹格核殻獲確穫覚角赫較郭閣隔革学岳楽額顎掛笠樫橿梶鰍潟割喝恰括活渇滑葛褐轄且鰹叶椛樺鞄株兜竃蒲釜鎌噛鴨栢茅萱粥刈苅瓦乾侃冠寒刊勘勧巻喚堪姦完官寛干幹患感慣憾換敢柑桓棺款歓汗漢澗潅環甘監看竿管簡緩缶翰肝艦莞観諌貫還鑑間閑関陥韓館舘丸含岸巌玩癌眼岩翫贋雁頑顔願企伎危喜器基奇嬉寄岐希幾忌揮机旗既期棋棄機帰毅気汽畿祈季稀紀徽規記貴起軌輝飢騎鬼亀偽儀妓宜戯技擬欺犠疑祇義蟻誼議掬菊鞠吉吃喫桔橘詰砧杵黍却客脚虐逆丘久仇休及吸宮弓急救朽求汲泣灸球究窮笈級糾給旧牛去居巨拒拠挙渠虚許距鋸漁禦魚亨享京供侠僑兇競共凶協匡卿叫喬境峡強彊怯恐恭挟教橋況狂狭矯胸脅興蕎郷鏡響饗驚仰凝尭暁業局曲極玉桐粁僅勤均巾錦斤欣欽琴禁禽筋緊芹菌衿襟謹近金吟銀九倶句区狗玖矩苦躯駆駈駒具愚虞喰空偶寓遇隅串櫛釧屑屈掘窟沓靴轡窪熊隈粂栗繰桑鍬勲君薫訓群軍郡卦袈祁係傾刑兄啓圭珪型契形径恵慶慧憩掲携敬景桂渓畦稽系経継繋罫茎荊蛍計詣警軽頚鶏芸迎鯨劇戟撃激隙桁傑欠決潔穴結血訣月件倹倦健兼券剣喧圏堅嫌建憲懸拳捲検権牽犬献研硯絹県肩見謙賢軒遣鍵険顕験鹸元原厳幻弦減源玄現絃舷言諺限乎個古呼固姑孤己庫弧戸故枯湖狐糊袴股胡菰虎誇跨鈷雇顧鼓五互伍午呉吾娯後御悟梧檎瑚碁語誤護醐乞鯉交佼侯候倖光公功効勾厚口向后喉坑垢好孔孝宏工巧巷幸広庚康弘恒慌抗拘控攻昂晃更杭校梗構江洪浩港溝甲皇硬稿糠紅紘絞綱耕考肯肱腔膏航荒行衡講貢購郊酵鉱砿鋼閤降項香高鴻剛劫号合壕拷濠豪轟麹克刻告国穀酷鵠黒獄漉腰甑忽惚骨狛込此頃今困坤墾婚恨懇昏昆根梱混痕紺艮魂些佐叉唆嵯左差査沙瑳砂詐鎖裟坐座挫債催再最哉塞妻宰彩才採栽歳済災采犀砕砦祭斎細菜裁載際剤在材罪財冴坂阪堺榊肴咲崎埼碕鷺作削咋搾昨朔柵窄策索錯桜鮭笹匙冊刷察拶撮擦札殺薩雑皐鯖捌錆鮫皿晒三傘参山惨撒散桟燦珊産算纂蚕讃賛酸餐斬暫残仕仔伺使刺司史嗣四士始姉姿子屍市師志思指支孜斯施旨枝止死氏獅祉私糸紙紫肢脂至視詞詩試誌諮資賜雌飼歯事似侍児字寺慈持時次滋治爾璽痔磁示而耳自蒔辞汐鹿式識鴫竺軸宍雫七叱執失嫉室悉湿漆疾質実蔀篠偲柴芝屡蕊縞舎写射捨赦斜煮社紗者謝車遮蛇邪借勺尺杓灼爵酌釈錫若寂弱惹主取守手朱殊狩珠種腫趣酒首儒受呪寿授樹綬需囚収周宗就州修愁拾洲秀秋終繍習臭舟蒐衆襲讐蹴輯週酋酬集醜什住充十従戎柔汁渋獣縦重銃叔夙宿淑祝縮粛塾熟出術述俊峻春瞬竣舜駿准循旬楯殉淳準潤盾純巡遵醇順処初所暑曙渚庶緒署書薯藷諸助叙女序徐恕鋤除傷償勝匠升召哨商唱嘗奨妾娼宵将小少尚庄床廠彰承抄招掌捷昇昌昭晶松梢樟樵沼消渉湘焼焦照症省硝礁祥称章笑粧紹肖菖蒋蕉衝裳訟証詔詳象賞醤鉦鍾鐘障鞘上丈丞乗冗剰城場壌嬢常情擾条杖浄状畳穣蒸譲醸錠嘱埴飾拭植殖燭織職色触食蝕辱尻伸信侵唇娠寝審心慎振新晋森榛浸深申疹真神秦紳臣芯薪親診身辛進針震人仁刃塵壬尋甚尽腎訊迅陣靭笥諏須酢図厨逗吹垂帥推水炊睡粋翠衰遂酔錐錘随瑞髄崇嵩数枢趨雛据杉椙菅頗雀裾澄摺寸世瀬畝是凄制勢姓征性成政整星晴棲栖正清牲生盛精聖声製西誠誓請逝醒青静斉税脆隻席惜戚斥昔析石積籍績脊責赤跡蹟碩切拙接摂折設窃節説雪絶舌蝉仙先千占宣専尖川戦扇撰栓栴泉浅洗染潜煎煽旋穿箭線繊羨腺舛船薦詮賎践選遷銭銑閃鮮前善漸然全禅繕膳糎噌塑岨措曾曽楚狙疏疎礎祖租粗素組蘇訴阻遡鼠僧創双叢倉喪壮奏爽宋層匝惣想捜掃挿掻操早曹巣槍槽漕燥争痩相窓糟総綜聡草荘葬蒼藻装走送遭鎗霜騒像増憎臓蔵贈造促側則即息捉束測足速俗属賊族続卒袖其揃存孫尊損村遜他多太汰詑唾堕妥惰打柁舵楕陀駄騨体堆対耐岱帯待怠態戴替泰滞胎腿苔袋貸退逮隊黛鯛代台大第醍題鷹滝瀧卓啄宅托択拓沢濯琢託鐸濁諾茸凧蛸只叩但達辰奪脱巽竪辿棚谷狸鱈樽誰丹単嘆坦担探旦歎淡湛炭短端箪綻耽胆蛋誕鍛団壇弾断暖檀段男談値知地弛恥智池痴稚置致蜘遅馳築畜竹筑蓄逐秩窒茶嫡着中仲宙忠抽昼柱注虫衷註酎鋳駐樗瀦猪苧著貯丁兆凋喋寵帖帳庁弔張彫徴懲挑暢朝潮牒町眺聴脹腸蝶調諜超跳銚長頂鳥勅捗直朕沈珍賃鎮陳津墜椎槌追鎚痛通塚栂掴槻佃漬柘辻蔦綴鍔椿潰坪壷嬬紬爪吊釣鶴亭低停偵剃貞呈堤定帝底庭廷弟悌抵挺提梯汀碇禎程締艇訂諦蹄逓邸鄭釘鼎泥摘擢敵滴的笛適鏑溺哲徹撤轍迭鉄典填天展店添纏甜貼転顛点伝殿澱田電兎吐堵塗妬屠徒斗杜渡登菟賭途都鍍砥砺努度土奴怒倒党冬凍刀唐塔塘套宕島嶋悼投搭東桃梼棟盗淘湯涛灯燈当痘祷等答筒糖統到董蕩藤討謄豆踏逃透鐙陶頭騰闘働動同堂導憧撞洞瞳童胴萄道銅峠鴇匿得徳涜特督禿篤毒独読栃橡凸突椴届鳶苫寅酉瀞噸屯惇敦沌豚遁頓呑曇鈍奈那内乍凪薙謎灘捺鍋楢馴縄畷南楠軟難汝二尼弐迩匂賑肉虹廿日乳入如尿韮任妊忍認濡禰祢寧葱猫熱年念捻撚燃粘乃廼之埜嚢悩濃納能脳膿農覗蚤巴把播覇杷波派琶破婆罵芭馬俳廃拝排敗杯盃牌背肺輩配倍培媒梅楳煤狽買売賠陪這蝿秤矧萩伯剥博拍柏泊白箔粕舶薄迫曝漠爆縛莫駁麦函箱硲箸肇筈櫨幡肌畑畠八鉢溌発醗髪伐罰抜筏閥鳩噺塙蛤隼伴判半反叛帆搬斑板氾汎版犯班畔繁般藩販範釆煩頒飯挽晩番盤磐蕃蛮匪卑否妃庇彼悲扉批披斐比泌疲皮碑秘緋罷肥被誹費避非飛樋簸備尾微枇毘琵眉美鼻柊稗匹疋髭彦膝菱肘弼必畢筆逼桧姫媛紐百謬俵彪標氷漂瓢票表評豹廟描病秒苗錨鋲蒜蛭鰭品彬斌浜瀕貧賓頻敏瓶不付埠夫婦富冨布府怖扶敷斧普浮父符腐膚芙譜負賦赴阜附侮撫武舞葡蕪部封楓風葺蕗伏副復幅服福腹複覆淵弗払沸仏物鮒分吻噴墳憤扮焚奮粉糞紛雰文聞丙併兵塀幣平弊柄並蔽閉陛米頁僻壁癖碧別瞥蔑箆偏変片篇編辺返遍便勉娩弁鞭保舗鋪圃捕歩甫補輔穂募墓慕戊暮母簿菩倣俸包呆報奉宝峰峯崩庖抱捧放方朋法泡烹砲縫胞芳萌蓬蜂褒訪豊邦鋒飽鳳鵬乏亡傍剖坊妨帽忘忙房暴望某棒冒紡肪膨謀貌貿鉾防吠頬北僕卜墨撲朴牧睦穆釦勃没殆堀幌奔本翻凡盆摩磨魔麻埋妹昧枚毎哩槙幕膜枕鮪柾鱒桝亦俣又抹末沫迄侭繭麿万慢満漫蔓味未魅巳箕岬密蜜湊蓑稔脈妙粍民眠務夢無牟矛霧鵡椋婿娘冥名命明盟迷銘鳴姪牝滅免棉綿緬面麺摸模茂妄孟毛猛盲網耗蒙儲木黙目杢勿餅尤戻籾貰問悶紋門匁也冶夜爺耶野弥矢厄役約薬訳躍靖柳薮鑓愉愈油癒諭輸唯佑優勇友宥幽悠憂揖有柚湧涌猶猷由祐裕誘遊邑郵雄融夕予余与誉輿預傭幼妖容庸揚揺擁曜楊様洋溶熔用窯羊耀葉蓉要謡踊遥陽養慾抑欲沃浴翌翼淀羅螺裸来莱頼雷洛絡落酪乱卵嵐欄濫藍蘭覧利吏履李梨理璃痢裏裡里離陸律率立葎掠略劉流溜琉留硫粒隆竜龍侶慮旅虜了亮僚両凌寮料梁涼猟療瞭稜糧良諒遼量陵領力緑倫厘林淋燐琳臨輪隣鱗麟瑠塁涙累類令伶例冷励嶺怜玲礼苓鈴隷零霊麗齢暦歴列劣烈裂廉恋憐漣煉簾練聯蓮連錬呂魯櫓炉賂路露労婁廊弄朗楼榔浪漏牢狼篭老聾蝋郎六麓禄肋録論倭和話歪賄脇惑枠鷲亙亘鰐詫藁蕨椀湾碗腕、。,.:;?!゛゜´`¨^ ̄_ヽヾゝゞ〃仝々〆〇ー―‐/\~∥|…‥‘’“”()〔〕[]{}〈〉《》「」『』【】+-±×÷=≠<>≦≧°′″℃¥$¢£%#&*@☆★○●◎◇◆□■△▲▽▼※〒→←↑↓〓⇒⇔∽123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶ─!"#$`"'①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ〝〟√0@P`p!1AQaq"2BRbr#3CScs$4DTdt%5EUeu&6FVfv'7GWgw(8HXhx)9IYiy*:JZgz+;K[k{,<L\l|-=M]m}.>N^n~/?O_o

インストール

FontTools をインストールします。 今回は README の通りにすすめます。

Python の virtualenv というパッケージを使って仮想環境を作り、
その中で FontTools を動かす流れになります。

ソースコードをダウンロード

$ git clone https://github.com/fonttools/fonttools.git

fonttools ディレクトリに移動

$ cd fonttools

仮想環境を作る

$ python -m virtualenv fonttools-venv

“fonttools-venv” の部分は好きな名前にできます。

仮想環境を有効化

$ . fonttools-venv/bin/activate

インストール

(fonttools-venv) $ pip install -e .

-e オプションをつけてローカルでインストールします。
これをつけないと、 PyPI(Pythonのパッケージ管理サービス)からインストールされるみたいです。

ついでに brotli もインストール

フォントを woff, woff2 形式に変換するためのライブラリです。

(fonttools-venv) $ pip install brotli

つかいかた

fonttools ディレクトリに移動

$ cd fonttools

仮想環境を有効化

無効にしたいときは deactivate

$ . fonttools-venv/bin/activate

フォントファイルとテキストファイルの場所を指定して pyftsubset

(fonttools-venv) $ pyftsubset ./_src/SourceHanSansJP-Bold.otf --text-file=./_src/chars.txt --layout-features='*' --flavor=woff2 --output-file=./_dist/SourceHanSansJP-Bold.min.woff2

結果

Before:

total 61600
-rwxr-xr-x@ 1 test  test   4.4M  2  5  2016 SourceHanSansJP-Bold.otf
-rwxr-xr-x@ 1 test  test   4.0M  2  5  2016 SourceHanSansJP-ExtraLight.otf
-rwxr-xr-x@ 1 test  test   4.6M  2  5  2016 SourceHanSansJP-Heavy.otf
-rwxr-xr-x@ 1 test  test   4.2M  2  5  2016 SourceHanSansJP-Light.otf
-rwxr-xr-x@ 1 test  test   4.3M  2  5  2016 SourceHanSansJP-Medium.otf
-rwxr-xr-x@ 1 test  test   4.3M  2  5  2016 SourceHanSansJP-Normal.otf
-rwxr-xr-x@ 1 test  test   4.3M  2  5  2016 SourceHanSansJP-Regular.otf

After:

total 12232
-rw-r--r--  1 test  test   906K  2 16 18:38 SourceHanSansJP-Bold.min.woff2
-rw-r--r--  1 test  test   808K  2 16 18:38 SourceHanSansJP-ExtraLight.min.woff2
-rw-r--r--  1 test  test   906K  2 16 18:38 SourceHanSansJP-Heavy.min.woff2
-rw-r--r--  1 test  test   859K  2 16 18:38 SourceHanSansJP-Light.min.woff2
-rw-r--r--  1 test  test   882K  2 16 18:38 SourceHanSansJP-Medium.min.woff2
-rw-r--r--  1 test  test   868K  2 16 18:38 SourceHanSansJP-Normal.min.woff2
-rw-r--r--  1 test  test   874K  2 16 18:38 SourceHanSansJP-Regular.min.woff2

なんということでしょう

格納する文字を絞れば、もっと軽くなりそうです。

もっといろいろしたい

ヘルプに詳しく書いてあります。

$ pyftsubset --help

pyftsubset – OpenType font subsetter and optimizer

pyftsubset is an OpenType font subsetter and optimizer, based on fontTools. It accepts any TT- or CFF-flavored OpenType (.otf or .ttf) or WOFF (.woff) font file. The subsetted glyph set is based on the specified glyphs or characters, and specified OpenType layout features.

The tool also performs some size-reducing optimizations, aimed for using subset fonts as webfonts. Individual optimizations can be enabled or disabled, and are enabled by default when they are safe.

Usage:

  pyftsubset font-file [glyph...] [--option=value]...

  At least one glyph or one of --gids, --gids-file, --glyphs, --glyphs-file,
  --text, --text-file, --unicodes, or --unicodes-file, must be specified.

Arguments:

  font-file
      The input font file.

  glyph
      Specify one or more glyph identifiers to include in the subset. Must be
      PS glyph names, or the special string '*' to keep the entire glyph set.

Initial glyph set specification:

  These options populate the initial glyph set. Same option can appear
  multiple times, and the results are accummulated.
  --gids=<NNN>[,<NNN>...]
          Specify comma/whitespace-separated list of glyph IDs or ranges as
          decimal numbers.  For example, --gids=10-12,14 adds glyphs with
          numbers 10, 11, 12, and 14.
  --gids-file=<path>
          Like --gids but reads from a file. Anything after a '#' on any line
          is ignored as comments.
  --glyphs=<glyphname>[,<glyphname>...]
          Specify comma/whitespace-separated PS glyph names to add to the subset.
          Note that only PS glyph names are accepted, not gidNNN, U+XXXX, etc
          that are accepted on the command line.  The special string '*' wil keep
          the entire glyph set.
  --glyphs-file=<path>
          Like --glyphs but reads from a file. Anything after a '#' on any line
          is ignored as comments.
  --text=<text>
          Specify characters to include in the subset, as UTF-8 string.
  --text-file=<path>
          Like --text but reads from a file. Newline character are not added to
          the subset.
  --unicodes=<XXXX>[,<XXXX>...]
          Specify comma/whitespace-separated list of Unicode codepoints or
          ranges as hex numbers, optionally prefixed with 'U+', 'u', etc.
          For example, --unicodes=41-5a,61-7a adds ASCII letters, so does
          the more verbose --unicodes=U+0041-005A,U+0061-007A.
          The special strings '*' will choose all Unicode characters mapped
          by the font.
  --unicodes-file=<path>
          Like --unicodes, but reads from a file. Anything after a '#' on any
          line in the file is ignored as comments.
  --ignore-missing-glyphs
          Do not fail if some requested glyphs or gids are not available in
          the font.
  --no-ignore-missing-glyphs
          Stop and fail if some requested glyphs or gids are not available
          in the font. [default]
  --ignore-missing-unicodes [default]
          Do not fail if some requested Unicode characters (including those
          indirectly specified using --text or --text-file) are not available
          in the font.
  --no-ignore-missing-unicodes
          Stop and fail if some requested Unicode characters are not available
          in the font.
          Note the default discrepancy between ignoring missing glyphs versus
          unicodes.  This is for historical reasons and in the future
          --no-ignore-missing-unicodes might become default.

Other options:

  For the other options listed below, to see the current value of the option,
  pass a value of '?' to it, with or without a '='.

  Examples:

      $ pyftsubset --glyph-names?
      Current setting for 'glyph-names' is: False

      $ ./pyftsubset --name-IDs=?
      Current setting for 'name-IDs' is: [1, 2]

      $ ./pyftsubset --hinting? --no-hinting --hinting?
      Current setting for 'hinting' is: True
      Current setting for 'hinting' is: False

Output options:

  --output-file=<path>
          The output font file. If not specified, the subsetted font
          will be saved in as font-file.subset.

  --flavor=<type>
          Specify flavor of output font file. May be 'woff' or 'woff2'.
          Note that WOFF2 requires the Brotli Python extension, available
          at https://github.com/google/brotli

  --with-zopfli
          Use the Google Zopfli algorithm to compress WOFF. The output is 3-8 %
          smaller than pure zlib, but the compression speed is much slower.
          The Zopfli Python bindings are available at:
          https://github.com/anthrotype/py-zopfli

Glyph set expansion:

  These options control how additional glyphs are added to the subset.

  --notdef-glyph
          Add the '.notdef' glyph to the subset (ie, keep it). [default]

  --no-notdef-glyph
          Drop the '.notdef' glyph unless specified in the glyph set. This
          saves a few bytes, but is not possible for Postscript-flavored
          fonts, as those require '.notdef'. For TrueType-flavored fonts,
          this works fine as long as no unsupported glyphs are requested
          from the font.

  --notdef-outline
          Keep the outline of '.notdef' glyph. The '.notdef' glyph outline is
          used when glyphs not supported by the font are to be shown. It is not
          needed otherwise.

  --no-notdef-outline
          When including a '.notdef' glyph, remove its outline. This saves
          a few bytes. [default]

  --recommended-glyphs
          Add glyphs 0, 1, 2, and 3 to the subset, as recommended for
          TrueType-flavored fonts: '.notdef', 'NULL' or '.null', 'CR', 'space'.
          Some legacy software might require this, but no modern system does.

  --no-recommended-glyphs
          Do not add glyphs 0, 1, 2, and 3 to the subset, unless specified in
          glyph set. [default]

  --layout-features[+|-]=<feature>[,<feature>...]
          Specify (=), add to (+=) or exclude from (-=) the comma-separated
          set of OpenType layout feature tags that will be preserved.
          Glyph variants used by the preserved features are added to the
          specified subset glyph set. By default, 'calt', 'ccmp', 'clig', 'curs',
          'kern', 'liga', 'locl', 'mark', 'mkmk', 'rclt', 'rlig' and all features
          required for script shaping are preserved. To see the full list, try
          '--layout-features=?'. Use '*' to keep all features.
          Multiple --layout-features options can be provided if necessary.

          Examples:
              --layout-features+=onum,pnum,ss01
                      * Keep the default set of features and 'onum', 'pnum', 'ss01'.
              --layout-features-='mark','mkmk'
                      * Keep the default set of features but drop 'mark' and 'mkmk'.
              --layout-features='kern'
                      * Only keep the 'kern' feature, drop all others.
              --layout-features=''
                      * Drop all features.
              --layout-features='*'
                      * Keep all features.
              --layout-features+=aalt --layout-features-=vrt2
                      * Keep default set of features plus 'aalt', but drop 'vrt2'.

Hinting options:

  --hinting
          Keep hinting [default]

  --no-hinting
          Drop glyph-specific hinting and font-wide hinting tables, as well
          as remove hinting-related bits and pieces from other tables (eg. GPOS).
          See --hinting-tables for list of tables that are dropped by default.
          Instructions and hints are stripped from 'glyf' and 'CFF ' tables
          respectively. This produces (sometimes up to 30%) smaller fonts that
          are suitable for extremely high-resolution systems, like high-end
          mobile devices and retina displays.
          XXX Note: Currently there is a known bug in 'CFF ' hint stripping that
          might make the font unusable as a webfont as they will be rejected by
          OpenType Sanitizer used in common browsers. For more information see:
          https://github.com/behdad/fonttools/issues/144
          The --desubroutinize options works around that bug.

Optimization options:

  --desubroutinize
          Remove CFF use of subroutinizes.  Subroutinization is a way to make CFF
          fonts smaller.  For small subsets however, desubroutinizing might make
          the font smaller.  It has even been reported that desubroutinized CFF
          fonts compress better (produce smaller output) WOFF and WOFF2 fonts.
          Also see note under --no-hinting.

  --no-desubroutinize [default]
          Leave CFF subroutinizes as is, only throw away unused subroutinizes.

Font table options:

  --drop-tables[+|-]=<table>[,<table>...]
          Specify (=), add to (+=) or exclude from (-=) the comma-separated
          set of tables that will be be dropped.
          By default, the following tables are dropped:
          'BASE', 'JSTF', 'DSIG', 'EBDT', 'EBLC', 'EBSC', 'SVG ', 'PCLT', 'LTSH'
          and Graphite tables: 'Feat', 'Glat', 'Gloc', 'Silf', 'Sill'
          and color tables: 'CBLC', 'CBDT', 'sbix'.
          The tool will attempt to subset the remaining tables.

          Examples:
              --drop-tables-='SVG '
                      * Drop the default set of tables but keep 'SVG '.
              --drop-tables+=GSUB
                      * Drop the default set of tables and 'GSUB'.
              --drop-tables=DSIG
                      * Only drop the 'DSIG' table, keep all others.
              --drop-tables=
                      * Keep all tables.

  --no-subset-tables+=<table>[,<table>...]
          Add to the set of tables that will not be subsetted.
          By default, the following tables are included in this list, as
          they do not need subsetting (ignore the fact that 'loca' is listed
          here): 'gasp', 'head', 'hhea', 'maxp', 'vhea', 'OS/2', 'loca',
          'name', 'cvt ', 'fpgm', 'prep', 'VMDX', 'DSIG' and 'CPAL'.
          By default, tables that the tool does not know how to subset and are not
          specified here will be dropped from the font, unless --passthrough-tables
          option is passed.
          Example:
               --no-subset-tables+=FFTM
                      * Keep 'FFTM' table in the font by preventing subsetting.
  --passthrough-tables
          Do not drop tables that the tool does not know how to subset.
  --no-passthrough-tables
          Tables that the tool does not know how to subset and are not specified
          in --no-subset-tables will be dropped from the font. [default]
  --hinting-tables[-]=<table>[,<table>...]
          Specify (=), add to (+=) or exclude from (-=) the list of font-wide
          hinting tables that will be dropped if --no-hinting is specified,
          Examples:
              --hinting-tables-='VDMX'
                      * Drop font-wide hinting tables except 'VDMX'.
              --hinting-tables=''
                      * Keep all font-wide hinting tables (but strip hints from glyphs).
  --legacy-kern
          Keep TrueType 'kern' table even when OpenType 'GPOS' is available.
  --no-legacy-kern
          Drop TrueType 'kern' table if OpenType 'GPOS' is available. [default]

Font naming options:

  These options control what is retained in the 'name' table. For numerical
  codes, see: //www.microsoft.com/typography/otspec/name.htm
  --name-IDs[+|-]=<nameID>[,<nameID>...]
          Specify (=), add to (+=) or exclude from (-=) the set of 'name' table
          entry nameIDs that will be preserved. By default only nameID 1 (Family)
          and nameID 2 (Style) are preserved. Use '*' to keep all entries.

          Examples:
              --name-IDs+=0,4,6
                      * Also keep Copyright, Full name and PostScript name entry.
              --name-IDs=''
                      * Drop all 'name' table entries.
              --name-IDs='*'
                      * keep all 'name' table entries

  --name-legacy
          Keep legacy (non-Unicode) 'name' table entries (0.x, 1.x etc.).
          XXX Note: This might be needed for some fonts that have no Unicode name
          entires for English. See: https://github.com/behdad/fonttools/issues/146

  --no-name-legacy
          Drop legacy (non-Unicode) 'name' table entries [default]

  --name-languages[+|-]=<langID>[,<langID>]
          Specify (=), add to (+=) or exclude from (-=) the set of 'name' table
          langIDs that will be preserved. By default only records with langID
          0x0409 (English) are preserved. Use '*' to keep all langIDs.

  --obfuscate-names
          Make the font unusable as a system font by replacing name IDs 1, 2, 3, 4,
          and 6 with dummy strings (it is still fully functional as webfont).

Glyph naming and encoding options:

  --glyph-names
          Keep PS glyph names in TT-flavored fonts. In general glyph names are
          not needed for correct use of the font. However, some PDF generators
          and PDF viewers might rely on glyph names to extract Unicode text
          from PDF documents.

  --no-glyph-names
          Drop PS glyph names in TT-flavored fonts, by using 'post' table
          version 3.0. [default]

  --legacy-cmap
          Keep the legacy 'cmap' subtables (0.x, 1.x, 4.x etc.).

  --no-legacy-cmap
          Drop the legacy 'cmap' subtables. [default]

  --symbol-cmap
          Keep the 3.0 symbol 'cmap'.

  --no-symbol-cmap
          Drop the 3.0 symbol 'cmap'. [default]

Other font-specific options:

  --recalc-bounds
          Recalculate font bounding boxes.

  --no-recalc-bounds
          Keep original font bounding boxes. This is faster and still safe
          for all practical purposes. [default]

  --recalc-timestamp
          Set font 'modified' timestamp to current time.

  --no-recalc-timestamp
          Do not modify font 'modified' timestamp. [default]

  --canonical-order
          Order tables as recommended in the OpenType standard. This is not
          required by the standard, nor by any known implementation.

  --no-canonical-order
          Keep original order of font tables. This is faster. [default]

  --prune-unicode-ranges
          Update the 'OS/2 ulUnicodeRange*' bits after subsetting. The Unicode
          ranges defined in the OpenType specification v1.7 are intersected with
          the Unicode codepoints specified in the font's Unicode 'cmap' subtables:
          when no overlap is found, the bit will be switched off. However, it will
          *not* be switched on if an intersection is found.  [default]

  --no-prune-unicode-ranges
          Don't change the 'OS/2 ulUnicodeRange*' bits.

  --recalc-average-width
          Update the 'OS/2 xAvgCharWidth' field after subsetting.

  --no-recalc-average-width
          Don't change the 'OS/2 xAvgCharWidth' field. [default]

Application options:

  --verbose
          Display verbose information of the subsetting process.

  --timing
          Display detailed timing information of the subsetting process.

  --xml
          Display the TTX XML representation of subsetted font.

Example: Produce a subset containing the characters ‘ !“#$%’ without performing size-reducing optimizations:

  $ pyftsubset font.ttf --unicodes="U+0020-0025" \
      --layout-features='*' --glyph-names --symbol-cmap --legacy-cmap \
      --notdef-glyph --notdef-outline --recommended-glyphs \
      --name-IDs='*' --name-legacy --name-languages='*'

参考にしたサイト