├── .gitignore ├── Vagrantfile ├── README.md └── generate_CodeM.pe /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant/ 2 | *.zip 3 | *.ttf 4 | *.log 5 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.vm.box = "codem" 6 | 7 | config.vm.provision "shell", inline: <<-SHELL 8 | apt-get update 9 | apt-get upgrade 10 | apt-get install -y language-pack-ja-base 11 | apt-get install -y language-pack-ja 12 | update-locale LANGUAGE=ja_JP.UTF-8 LC_ALL=ja_JP.UTF-8 LANG=ja_JP.UTF-8 13 | apt-get install -y fontforge 14 | cd /vagrant 15 | apt-get install -y unzip 16 | unzip 1.050R-it.zip 17 | unzip migu-1m-20150712.zip 18 | cp source-code-pro-2.030R-ro-1.050R-it/TTF/*.ttf . 19 | cp migu-1m-20150712/*.ttf . 20 | fontforge -script generate_CodeM.pe 21 | git clone https://github.com/Lokaltog/powerline-fontpatcher 22 | fontforge -lang=py -script ./powerline-fontpatcher/scripts/powerline-fontpatcher CodeM-Regular.ttf 23 | fontforge -lang=py -script ./powerline-fontpatcher/scripts/powerline-fontpatcher CodeM-Regular-Wide.ttf 24 | fontforge -lang=py -script ./powerline-fontpatcher/scripts/powerline-fontpatcher CodeM-Regular-Expanded.ttf 25 | fontforge -lang=py -script ./powerline-fontpatcher/scripts/powerline-fontpatcher CodeM-Bold.ttf 26 | fontforge -lang=py -script ./powerline-fontpatcher/scripts/powerline-fontpatcher CodeM-Bold-Wide.ttf 27 | fontforge -lang=py -script ./powerline-fontpatcher/scripts/powerline-fontpatcher CodeM-Bold-Expanded.ttf 28 | mkdir CodeM 29 | mv CodeM*ttf CodeM 30 | rm *.ttf 31 | SHELL 32 | end 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CodeM Font Generator 2 | ================================================================================ 3 | 4 | * はじめに 5 | * 生成手順 6 | * 生成手順(仮想マシンを使う方法) 7 | * 【重要】利用に関して 8 | * 変更履歴 9 | 10 | はじめに 11 | -------------------------------------------------------------------------------- 12 | 13 | 本生成スクリプトはプログラミングやコンソール上で 14 | 使いやすいフォントを用意することを目的として作成しています。 15 | フォントの合成元として「Source Code Pro」と「Migu 1M」を使用していますが 16 | 後々は汎用的なフォント合成スクリプトを目指すのも面白いかと思っています。 17 | ※現状では生成物のフォントに特に不満が無い為、未定です。 18 | 19 | スクリプトの動作としては 20 | 21 | 1. ASCII文字用のフォント(本スクリプトでは「Source Code Pro」)からASCII文字以外を除去 22 | 2. 日本語用フォント(本スクリプトでは「Migu 1M」)からASCII文字を除去 23 | 3. 日本語用フォントから抜けたASCII文字を埋める形でフォントを合成 24 | 25 | となっているため、文字のサイズを調整することでその他のフォント合成にも利用 26 | 出来ると思います。 27 | 28 | 生成手順 29 | -------------------------------------------------------------------------------- 30 | 本生成スクリプトは合成元となるttfフォントと、合成ソフトとしてFontForgeを 31 | 使用しています。 32 | 生成されたフォントは配布物として含めませんので各自で生成してください。 33 | 34 | * 生成スクリプト(配布物) 35 | - generate_CodeM.pe\* 36 | 37 | * TrueTypeFont ファイル 38 | - SourceCodePro-Bold.ttf 39 | - SourceCodePro-Regular.ttf 40 | - migu-1m-bold.ttf 41 | - migu-1m-regular.ttf 42 | 43 | >合成元となるフォントは下記の場所から入手することが出来ます。 44 | > Source Code Pro 45 | > http://sourceforge.net/projects/sourcecodepro.adobe/ 46 | > M+ Font 47 | > http://mix-mplus-ipa.sourceforge.jp/ 48 | 49 | 1. 各種 ttfファイル を生成スクリプトと同じディレクトリに置きます。 50 | 2. コンソール上から生成スクリプトを実行します。 51 | 例) `fontforge -script generate_CodeM.pe` 52 | 3. 下記のフォントが生成されます。 53 | 文字の太さは2種類(通常、太字)、行の間隔は3種類(通常、やや広め、広め)です。 54 | 内容に関してはファイル名を参考にしてください。 55 | CodeM-Bold-Expanded.ttf 56 | CodeM-Bold-Wide.ttf 57 | CodeM-Bold.ttf 58 | CodeM-Regular-Expanded.ttf 59 | CodeM-Regular-Wide.ttf 60 | CodeM-Regular.ttf 61 | 62 | 生成手順(仮想マシンを使う方法) 63 | -------------------------------------------------------------------------------- 64 | 65 | Windowsマシン上で生成する場合などにおいて、仮想マシンで生成することも可能です。 66 | 仮想マシン環境の構築方法は割愛しますが、こちらの方が便利という人はご活用ください。 67 | 68 | 1. `VirtualBox` と `Vagrant` をインストール 69 | 2. `Ubuntu` の BOX イメージを `codem` という名前で登録 70 | 3. 各フォントのzipファイルを取得してこのリポジトリと同じディレクトリに配置する 71 | - Source Code Pro 72 | - 1.050R-it.zip 73 | - Migu 1M 74 | - migu-1m-20150712.zip 75 | - zipのファイル名が上記と違う場合は `Vagrantfile` の該当ファイル名を修正 76 | 4. `vagrant up` で仮想マシンを起動 77 | - 仮想マシンのプロビジョニングにより `CodeM` ディレクトリにフォントが生成されます。 78 | 79 | 【重要】利用に関して 80 | -------------------------------------------------------------------------------- 81 | 82 | 生成元のフォントに関するライセンスは各種著作物のライセンスに従うものとします。 83 | 本スクリプトで生成されたフォントは個人利用の範囲に留め、ネットワークその他による配布は禁止とします。 84 | また、本生成スクリプトの改変や使用は個人の責任において行なってください。 85 | 86 | 変更履歴 87 | -------------------------------------------------------------------------------- 88 | * [2016/12/19] 89 | - Visual Studio Code で表示が変だったので調整 90 | 91 | * [2014/06/03] 92 | - 句読点の位置を調整 [thanks [hibara](https://github.com/hibara)さん] 93 | 94 | * [2013/05/12] 95 | - 全角空白可視化 96 | - 一部記号の変更(|) ※真ん中に隙間が出来るように。 97 | - 一部半角記号(-<=>@[]^~_{})の位置調整 98 | - 一部半角記号(.,:;!_)の強調表示 99 | 100 | * [2013/04/10] 101 | - 文字間隔を調整 102 | 103 | * [2013/04/09] 104 | - レギュラー書体のAscent,Descentを調整 105 | 106 | * [2013/04/06] 107 | - 初回登録 108 | 109 | vim:ts=4:sw=4 110 | -------------------------------------------------------------------------------- /generate_CodeM.pe: -------------------------------------------------------------------------------- 1 | #!/usr/bin/fontforge 2 | # vim:ts=2:sw=2:tw=0 3 | 4 | Print('--------------------------------------------------') 5 | 6 | # -------------------------------------------------- 7 | # Source Code Pro 8 | # 750 x 250 = 1000(Em) 9 | # Win(Ascent, Descent)=(-16, -127) 10 | # hhea(height, width)=(-16, 127) 11 | # -------------------------------------------------- 12 | # SourceCodePro Regular 書体の変更 13 | Print('Source Code Pro Regular の編集') 14 | Open('SourceCodePro-Regular.ttf') 15 | # 0x20(半角スペース)?0x007e(チルダ)以外を削除 16 | Select(0x0000,0x001f) 17 | Clear() 18 | Select(0x0080,0x010000) 19 | Clear() 20 | # ---------- 21 | SelectNone() 22 | SelectAll() 23 | ClearInstrs() 24 | #ClearHints() 25 | UnlinkReference() 26 | CenterInWidth() 27 | Generate('tmp_scp_reg.ttf') 28 | Close() 29 | # -------------------------------------------------- 30 | # SourceCodePro Bold 書体の変更 31 | Print('Source Code Pro Bold の編集') 32 | Open('SourceCodePro-Bold.ttf') 33 | # 0x20(半角スペース)?0x007e(チルダ)以外を削除 34 | Select(0x0000,0x001f) 35 | Clear() 36 | Select(0x0080,0x010000) 37 | Clear() 38 | # ---------- 39 | SelectNone() 40 | SelectAll() 41 | ClearInstrs() 42 | #ClearHints() 43 | UnlinkReference() 44 | CenterInWidth() 45 | Generate('tmp_scp_bold.ttf') 46 | Close() 47 | 48 | # -------------------------------------------------- 49 | # Migu 1M 50 | # 750 x 140 = 1000(Em) 51 | # Win(Ascent, Descent)=(-195, -90) 52 | # hhea(height, width)=(-195, 90) 53 | # -------------------------------------------------- 54 | # Migu-1m Regular 書体の変更 55 | Print('Migu 1M Regular の編集') 56 | Open('migu-1m-regular.ttf') 57 | # 0x20(半角スペース)?0x007e(チルダ)を削除 58 | Select(0x0020,0x007e) 59 | Clear() 60 | # ---------- 61 | SelectNone() 62 | SelectAll() 63 | ClearInstrs() 64 | #ClearHints() 65 | UnlinkReference() 66 | ScaleToEm(800,400); 67 | CenterInWidth() 68 | Generate('tmp_mig_1m_r.ttf') 69 | Close() 70 | # -------------------------------------------------- 71 | # Migu-1m Bold 書体の変更 72 | Print('Migu 1M Bold の編集') 73 | Open('migu-1m-bold.ttf') 74 | # 0x20(半角スペース)?0x007e(チルダ)を削除 75 | Select(0x0020,0x007e) 76 | Clear() 77 | # ---------- 78 | SelectNone() 79 | SelectAll() 80 | ClearInstrs() 81 | #ClearHints() 82 | UnlinkReference() 83 | ScaleToEm(800,400); 84 | CenterInWidth() 85 | Generate('tmp_mig_1m_b.ttf') 86 | Close() 87 | 88 | 89 | 90 | 91 | # -------------------------------------------------- 92 | # CodeM 93 | # 750 x 250 = 1110(Em) 94 | # Win(Ascent, Descent)=(-195, -90) 95 | # hhea(height, width)=(-195, 90) 96 | # -------------------------------------------------- 97 | # CodeM Regular の生成 98 | Open('tmp_mig_1m_r.ttf') 99 | MergeFonts('tmp_scp_reg.ttf') 100 | 101 | copyright = 'CodeM Generator Author: Masayuki Fukada\n' \ 102 | + 'Copyright (c) 2013 ' 103 | version = '1.0.0' 104 | 105 | # Regular 106 | Print('CodeM-Regular の生成') 107 | SetFontNames('CodeM-Regular', 'CodeM', 'CodeM Regular', 'Regular', copyright, version) 108 | SetTTFName(0x411, 1, 'CodeM') 109 | SetUniqueID(0) 110 | SetOS2Value('VendorID', 'MfFt') 111 | SetOS2Value('TypoLineGap', 0) 112 | # ------------------------------ 113 | # フォント改造 114 | Select(0u0021) # ! 115 | ExpandStroke(20,0,0,0,1) 116 | Select(0u002c) # , 117 | ExpandStroke(20,0,0,0,1) 118 | Select(0u002d); Move(0,-80); # - 119 | Select(0u002e) # . 120 | ExpandStroke(20,0,0,0,1) 121 | Select(0u003a) # : 122 | ExpandStroke(20,0,0,0,1) 123 | Select(0u003b) # ; 124 | ExpandStroke(20,0,0,0,1) 125 | Select(0u003c); Move(0,-80); # < 126 | Select(0u003d); Move(0,-80); # = 127 | Select(0u003e); Move(0,-80); # > 128 | Select(0u0040); Move(0, 80); # @ 129 | Select(0u005b); Move(0, 40); # [ 130 | Select(0u005d); Move(0, 40); # ] 131 | Select(0u005e); Move(0,180); # ^ 132 | Select(0u005f); Move(0,-60); # _ 133 | ExpandStroke(40,0,0,0,1) 134 | Select(0u007b); Move(0, 40); # { 135 | Select(0u007c); Move(0, 70); # | 136 | Select(0u002d); Copy(); Select(0u009c); Paste(); 137 | Rotate(90); Move(0,340); Copy(); Select(0u007c); Paste(); 138 | Select(0u002d); Copy(); Select(0u009c); Paste(); 139 | Rotate(90); Move(0,-140); Copy(); Select(0u007c); PasteInto(); 140 | Select(0u007d); Move(0, 40); # } 141 | Select(0u007e); Move(0,260); # ~ 142 | #句読点の位置調整 143 | Select(0u3001); Move(-140,0); # 、(読点) 144 | SetWidth(140,1) 145 | Select(0u3002); Move(-140,0); # 。(句点) 146 | SetWidth(140,1) 147 | #全角空白 148 | Select(0u2610); Copy(); Select(0u3000); Paste() 149 | Select(0u271a); Copy(); Select(0u3000); PasteInto() 150 | OverlapIntersect() 151 | # ------------------------------ 152 | defAscent = GetOS2Value('WinAscent') 153 | defDescent = GetOS2Value('WinDescent') 154 | addAscent = defAscent + 64 155 | addDescent = defDescent + 16 156 | SetOS2Value('WinAscent', addAscent) 157 | SetOS2Value('WinDescent', addDescent) 158 | SetOS2Value('HHeadAscent', addAscent) 159 | SetOS2Value('HHeadDescent', -addDescent) 160 | Generate('CodeM-Regular.ttf') 161 | # Wide 162 | Print('CodeM-Regular-Wide の生成') 163 | SetFontNames('CodeMWide-Regular', 'CodeM Wide', 'CodeM Wide Regular', 'Wide', copyright, version) 164 | SetTTFName(0x411, 1, 'CodeM Wide') 165 | addAscent = defAscent + 128 166 | addDescent = defDescent + 32 167 | SetOS2Value('WinAscent', addAscent) 168 | SetOS2Value('WinDescent', addDescent) 169 | SetOS2Value('HHeadAscent', addAscent) 170 | SetOS2Value('HHeadDescent', -addDescent) 171 | Generate('CodeM-Regular-Wide.ttf') 172 | # Expanded 173 | Print('CodeM-Regular-Expanded の生成') 174 | SetFontNames('CodeMExpanded-Regular', 'CodeM Expanded', 'CodeM Expanded Regular', 'Expanded', copyright, version) 175 | SetTTFName(0x411, 1, 'CodeM Expanded') 176 | addAscent = defAscent + 192 177 | addDescent = defDescent + 48 178 | SetOS2Value('WinAscent', addAscent) 179 | SetOS2Value('WinDescent', addDescent) 180 | SetOS2Value('HHeadAscent', addAscent) 181 | SetOS2Value('HHeadDescent', -addDescent) 182 | Generate('CodeM-Regular-Expanded.ttf') 183 | Close() 184 | 185 | # CodeM Bold の生成 186 | Open('tmp_mig_1m_b.ttf') 187 | MergeFonts('tmp_scp_bold.ttf') 188 | 189 | copyright = 'CodeM Generator Author: Masayuki Fukada\n' \ 190 | + 'Copyright (c) 2013 ' 191 | version = '1.0.0' 192 | 193 | # Bold 194 | Print('CodeM-Bold の生成') 195 | SetFontNames('CodeM-Bold', 'CodeM', 'CodeM Bold', 'Bold', copyright, version) 196 | SetTTFName(0x411, 1, 'CodeM') 197 | SetUniqueID(0) 198 | SetOS2Value('VendorID', 'MfFt') 199 | SetOS2Value('TypoLineGap', 0) 200 | # ------------------------------ 201 | # フォント改造  202 | Select(0u0021) # ! 203 | ExpandStroke(20,0,0,0,1) 204 | Select(0u002c) # , 205 | ExpandStroke(20,0,0,0,1) 206 | Select(0u002d); Move(0,-80); # - 207 | Select(0u002e) # . 208 | ExpandStroke(20,0,0,0,1) 209 | Select(0u003a) # : 210 | ExpandStroke(20,0,0,0,1) 211 | Select(0u003b) # ; 212 | ExpandStroke(20,0,0,0,1) 213 | Select(0u003c); Move(0,-80); # < 214 | Select(0u003d); Move(0,-80); # = 215 | Select(0u003e); Move(0,-80); # > 216 | Select(0u0040); Move(0, 80); # @ 217 | Select(0u005b); Move(0, 40); # [ 218 | Select(0u005d); Move(0, 40); # ] 219 | Select(0u005e); Move(0,180); # ^ 220 | Select(0u005f); Move(0,-60); # _ 221 | ExpandStroke(40,0,0,0,1) 222 | Select(0u007b); Move(0, 40); # { 223 | Select(0u007c); Move(0, 70); # | 224 | Select(0u002d); Copy(); Select(0u009c); Paste(); 225 | Rotate(90); Move(0,340); Copy(); Select(0u007c); Paste(); 226 | Select(0u002d); Copy(); Select(0u009c); Paste(); 227 | Rotate(90); Move(0,-140); Copy(); Select(0u007c); PasteInto(); 228 | Select(0u007d); Move(0, 40); # } 229 | Select(0u007e); Move(0,260); # ~ 230 | #句読点の位置調整 231 | Select(0u3001); Move(-140,0); # 、(読点) 232 | SetWidth(140,1) 233 | Select(0u3002); Move(-140,0); # 。(句点) 234 | SetWidth(140,1) 235 | #全角空白 236 | Select(0u2610); Copy(); Select(0u3000); Paste() 237 | Select(0u271a); Copy(); Select(0u3000); PasteInto() 238 | OverlapIntersect() 239 | # ------------------------------ 240 | defAscent = GetOS2Value('WinAscent') 241 | defDescent = GetOS2Value('WinDescent') 242 | addAscent = defAscent + 64 243 | addDescent = defDescent + 16 244 | SetOS2Value('WinAscent', addAscent) 245 | SetOS2Value('WinDescent', addDescent) 246 | SetOS2Value('HHeadAscent', addAscent) 247 | SetOS2Value('HHeadDescent', -addDescent) 248 | Generate('CodeM-Bold.ttf') 249 | # Wide 250 | Print('CodeM-Bold-Wide の生成') 251 | SetFontNames('CodeMWide-Bold', 'CodeM Wide', 'CodeM Wide Bold', 'Wide', copyright, version) 252 | SetTTFName(0x411, 1, 'CodeM Wide') 253 | addAscent = defAscent + 128 254 | addDescent = defDescent + 32 255 | SetOS2Value('WinAscent', addAscent) 256 | SetOS2Value('WinDescent', addDescent) 257 | SetOS2Value('HHeadAscent', addAscent) 258 | SetOS2Value('HHeadDescent', -addDescent) 259 | Generate('CodeM-Bold-Wide.ttf') 260 | # Expanded 261 | Print('CodeM-Bold-Expanded の生成') 262 | SetFontNames('CodeMExpanded-Bold', 'CodeM Expanded', 'CodeM Expanded Bold', 'Expanded', copyright, version) 263 | SetTTFName(0x411, 1, 'CodeM Expanded') 264 | addAscent = defAscent + 192 265 | addDescent = defDescent + 48 266 | SetOS2Value('WinAscent', addAscent) 267 | SetOS2Value('WinDescent', addDescent) 268 | SetOS2Value('HHeadAscent', addAscent) 269 | SetOS2Value('HHeadDescent', -addDescent) 270 | Generate('CodeM-Bold-Expanded.ttf') 271 | Close() 272 | --------------------------------------------------------------------------------