Quantcast
Channel: itouhiroはてなブログ
Viewing all 107 articles
Browse latest View live

Source Han Sans(源ノ角ゴシック)ver1.001 「かな」字形の変更点

$
0
0

Source Han Sans(源ノ角ゴシック) ver1.001
https://github.com/adobe-fonts/source-han-sans/tree/1.001R
ChangeLogSourceHanSansReadMe.pdfのp18)見たら

Japanese
・A small number of glyphs for kana were tweaked for improved readability
(少数の「かな」字形を微調整したよ。読みやすさを改善するためにね)

具体的にどの文字を調整したのか、もっと詳しく知りたいと思った。 調べてみた。Regularを重ねてみる。

「タ ダ ネ」の3文字が大きな違い。

f:id:itouhiro:20140923170730p:plain


Nasuフォント ver2014.0925 の合成用濁点・半濁点

$
0
0

Nasuフォント http://itouhiro.hatenablog.com/entry/20140917/font ver2014.0925 の合成用濁点・半濁点設定についてメモ。

使用方法

以下からコピーすれば使える。

ほかの使い方は、Google日本語入力であれば、ローマ字入力設定でたとえば a と @ を押すと U+3042 + U+3099 と入力されるように設定できるはず。ATOKはムリなはず。

あ゙い゙ゔえ゙お゙
がぎぐげご
ざじずぜぞ
だぢづでど
な゙に゙ぬ゙ね゙の゙
ばびぶべぼ
ま゙み゙む゙め゙も゙
や゙ゆ゙よ゙
ら゙り゙る゙れ゙ろ゙
わ゙ゐ゙ゑ゙を゙ん゙
っ゙ゃ゙ゅ゙ょ゙
ぁ゙ぃ゙ぅ゙ぇ゙ぉ゙

ア゙イ゙ヴエ゙オ゙
ガギグゲゴ
ザジズゼゾ
ダヂヅデド
ナ゙ニ゙ヌ゙ネ゙ノ゙
バビブベボ
マ゙ミ゙ム゙メ゙モ゙
ヤ゙ユ゙ヨ゙
ラ゙リ゙ル゙レ゙ロ゙
ヷヸヹヺン゙
ッ゙ャ゙ュ゙ョ゙
ァ゙ィ゙ゥ゙ェ゙ォ゙

あ゚い゚う゚え゚お゚
か゚き゚く゚け゚こ゚
さ゚し゚す゚せ゚そ゚
た゚ち゚つ゚て゚と゚
な゚に゚ぬ゚ね゚の゚
ぱぴぷぺぽ
ま゚み゚む゚め゚も゚
や゚ゆ゚よ゚
ら゚り゚る゚れ゚ろ゚
わ゚ゐ゚ゑ゚を゚ん゚
っ゚ゃ゚ゅ゚ょ゚
ぁ゚ぃ゚ぅ゚ぇ゚ぉ゚

ア゚イ゚ウ゚エ゚オ゚
カ゚キ゚ク゚ケ゚コ゚
サ゚シ゚ス゚セ゚ソ゚
タ゚チ゚ツ゚テ゚ト゚
ナ゚ニ゚ヌ゚ネ゚ノ゚
パピプペポ
マ゚ミ゚ム゚メ゚モ゚
ヤ゚ユ゚ヨ゚
ラ゚リ゚ル゚レ゚ロ゚
ワ゚ヰ゚ヱ゚ヲ゚ン゚
ッ゚ャ゚ュ゚ョ゚
ァ゚ィ゚ゥ゚ェ゚ォ゚

「彼が有名なウルトラマン氏だ」
「え゙ぇ゙ーっ!」「人間サイズじゃないですか。ビルより大きいって聞いてたのに……」
「――まあまあ、まずは挨拶からだ」
「ジョ゙ヷッ゙、シ゚ュ゚ワ゚ワ♣」
「日本語でおk」

「彼が有名なウルトラマン氏だ」
「え゙ぇーっ!」「人間サイズじゃないですか。ビルより大きいって聞いてたのに……」
「――まあまあ、まずは挨拶からだ」
「ジョヷッ、シ゚ュワ゚ワ♣」
「日本語でおk」

ア゙パ
あ゛は゜
~〜(FULLWIDTH TILDE U+FF5E・WAVE DASH U+301C)

制限仕様

Adobe Illustrator CS6で調べると、

  • ちいさな文字(っゃゅょぁぃぅぇぉ)と合成濁点・半濁点の組み合わせ
  • 縦書き

のとき、うまく表示できない。フォントの設定が問題なのか、アプリ側の問題なのか不明。縦書きするなら、ちいさな文字に合成濁点を使うのはひかえたほうがよさそうである。

f:id:itouhiro:20140925182941p:plain

f:id:itouhiro:20140925182950p:plain

作成方法

Unicode Private AreaであるU+E100~に、濁点・半濁点合成済み文字を作字した。この文字配置は「GL-アンチック」 http://gutenberg.sourceforge.jp/となるべく同じにしている。

f:id:itouhiro:20140925180816p:plain

・GSUBテーブルの設定で、

「あ」(このフォントでは cid01454 という名前。FontForgeで見ればわかる)
+
「゜」合成用濁点(このフォントでは cid01539 という名前)
=
「あ゛」(このフォントでは uniE100 という名前。上の画像でFontForgeウィンドウ上部に表示されている)

のような設定をそれぞれの文字について設定する。 具体的にはTTXで書き出したGSUBテーブル設定の一部、具体的には 最初から「う cid01463」+「゛ cid01539」=「ゔ cid01536」のような設定は用意されている

<LigatureSet glyph="cid01458">
            <Ligature components="cid01539" glyph="cid01536"/>
          </LigatureSet>

ので、その部分を以下のように書き換えて(「ぁあぃいぅうぇえぉお」などはもちろん削除する)、TTXで書き戻す。TTXの使い方は http://itouhiro.hatenablog.com/entry/20140910/font参照。

以下のテキストは、源真ゴシックがもともと持っているリガチャー設定と、新規作成した設定を両方含む。

ぁあぃいぅうぇえぉお
          <LigatureSet glyph="cid01453">
            <Ligature components="cid01540" glyph="uniE1B0"/>
            <Ligature components="cid01539" glyph="uniE180"/>
          </LigatureSet>
          <LigatureSet glyph="cid01454">
            <Ligature components="cid01540" glyph="uniE120"/>
            <Ligature components="cid01539" glyph="uniE100"/>
          </LigatureSet>
          <LigatureSet glyph="cid01455">
            <Ligature components="cid01540" glyph="uniE1B1"/>
            <Ligature components="cid01539" glyph="uniE181"/>
          </LigatureSet>
          <LigatureSet glyph="cid01456">
            <Ligature components="cid01540" glyph="uniE121"/>
            <Ligature components="cid01539" glyph="uniE101"/>
          </LigatureSet>
          <LigatureSet glyph="cid01457">
            <Ligature components="cid01540" glyph="uniE1B2"/>
            <Ligature components="cid01539" glyph="uniE182"/>
          </LigatureSet>
          <LigatureSet glyph="cid01458">
            <Ligature components="cid01540" glyph="uniE122"/>
            <Ligature components="cid01539" glyph="cid01536"/>
          </LigatureSet>
          <LigatureSet glyph="cid01459">
            <Ligature components="cid01540" glyph="uniE1B3"/>
            <Ligature components="cid01539" glyph="uniE183"/>
          </LigatureSet>
          <LigatureSet glyph="cid01460">
            <Ligature components="cid01540" glyph="uniE123"/>
            <Ligature components="cid01539" glyph="uniE103"/>
          </LigatureSet>
          <LigatureSet glyph="cid01461">
            <Ligature components="cid01540" glyph="uniE1B4"/>
            <Ligature components="cid01539" glyph="uniE184"/>
          </LigatureSet>
          <LigatureSet glyph="cid01462">
            <Ligature components="cid01540" glyph="uniE124"/>
            <Ligature components="cid01539" glyph="uniE104"/>
          </LigatureSet>
かきくけこ
          <LigatureSet glyph="cid01463">
            <Ligature components="cid01540" glyph="uniE125"/>
            <Ligature components="cid01539" glyph="cid01464"/>
          </LigatureSet>
          <LigatureSet glyph="cid01465">
            <Ligature components="cid01540" glyph="uniE126"/>
            <Ligature components="cid01539" glyph="cid01466"/>
          </LigatureSet>
          <LigatureSet glyph="cid01467">
            <Ligature components="cid01540" glyph="uniE127"/>
            <Ligature components="cid01539" glyph="cid01468"/>
          </LigatureSet>
          <LigatureSet glyph="cid01469">
            <Ligature components="cid01540" glyph="uniE128"/>
            <Ligature components="cid01539" glyph="cid01470"/>
          </LigatureSet>
          <LigatureSet glyph="cid01471">
            <Ligature components="cid01540" glyph="uniE129"/>
            <Ligature components="cid01539" glyph="cid01472"/>
          </LigatureSet>
さしすせそ
          <LigatureSet glyph="cid01473">
            <Ligature components="cid01540" glyph="uniE12A"/>
            <Ligature components="cid01539" glyph="cid01474"/>
          </LigatureSet>
          <LigatureSet glyph="cid01475">
            <Ligature components="cid01540" glyph="uniE12B"/>
            <Ligature components="cid01539" glyph="cid01476"/>
          </LigatureSet>
          <LigatureSet glyph="cid01477">
            <Ligature components="cid01540" glyph="uniE12C"/>
            <Ligature components="cid01539" glyph="cid01478"/>
          </LigatureSet>
          <LigatureSet glyph="cid01479">
            <Ligature components="cid01540" glyph="uniE12D"/>
            <Ligature components="cid01539" glyph="cid01480"/>
          </LigatureSet>
          <LigatureSet glyph="cid01481">
            <Ligature components="cid01540" glyph="uniE12E"/>
            <Ligature components="cid01539" glyph="cid01482"/>
          </LigatureSet>
たちっつてと
          <LigatureSet glyph="cid01483">
            <Ligature components="cid01540" glyph="uniE12F"/>
            <Ligature components="cid01539" glyph="cid01484"/>
          </LigatureSet>
          <LigatureSet glyph="cid01485">
            <Ligature components="cid01540" glyph="uniE130"/>
            <Ligature components="cid01539" glyph="cid01486"/>
          </LigatureSet>
          <LigatureSet glyph="cid01487">
            <Ligature components="cid01540" glyph="uniE1C1"/>
            <Ligature components="cid01539" glyph="uniE191"/>
          </LigatureSet>
          <LigatureSet glyph="cid01488">
            <Ligature components="cid01540" glyph="uniE131"/>
            <Ligature components="cid01539" glyph="cid01489"/>
          </LigatureSet>
          <LigatureSet glyph="cid01490">
            <Ligature components="cid01540" glyph="uniE132"/>
            <Ligature components="cid01539" glyph="cid01491"/>
          </LigatureSet>
          <LigatureSet glyph="cid01492">
            <Ligature components="cid01540" glyph="uniE133"/>
            <Ligature components="cid01539" glyph="cid01493"/>
          </LigatureSet>
なにぬねの
          <LigatureSet glyph="cid01494">
            <Ligature components="cid01540" glyph="uniE134"/>
            <Ligature components="cid01539" glyph="uniE105"/>
          </LigatureSet>
          <LigatureSet glyph="cid01495">
            <Ligature components="cid01540" glyph="uniE135"/>
            <Ligature components="cid01539" glyph="uniE106"/>
          </LigatureSet>
          <LigatureSet glyph="cid01496">
            <Ligature components="cid01540" glyph="uniE135"/>
            <Ligature components="cid01539" glyph="uniE107"/>
          </LigatureSet>
          <LigatureSet glyph="cid01497">
            <Ligature components="cid01540" glyph="uniE136"/>
            <Ligature components="cid01539" glyph="uniE108"/>
          </LigatureSet>
          <LigatureSet glyph="cid01498">
            <Ligature components="cid01540" glyph="uniE137"/>
            <Ligature components="cid01539" glyph="uniE109"/>
          </LigatureSet>
はひふへほ
          <LigatureSet glyph="cid01499">
            <Ligature components="cid01540" glyph="cid01501"/>
            <Ligature components="cid01539" glyph="cid01500"/>
          </LigatureSet>
          <LigatureSet glyph="cid01502">
            <Ligature components="cid01540" glyph="cid01504"/>
            <Ligature components="cid01539" glyph="cid01503"/>
          </LigatureSet>
          <LigatureSet glyph="cid01505">
            <Ligature components="cid01540" glyph="cid01507"/>
            <Ligature components="cid01539" glyph="cid01506"/>
          </LigatureSet>
          <LigatureSet glyph="cid01508">
            <Ligature components="cid01540" glyph="cid01510"/>
            <Ligature components="cid01539" glyph="cid01509"/>
          </LigatureSet>
          <LigatureSet glyph="cid01511">
            <Ligature components="cid01540" glyph="cid01513"/>
            <Ligature components="cid01539" glyph="cid01512"/>
          </LigatureSet>
まみむめも
          <LigatureSet glyph="cid01514">
            <Ligature components="cid01540" glyph="uniE139"/>
            <Ligature components="cid01539" glyph="uniE10A"/>
          </LigatureSet>
          <LigatureSet glyph="cid01515">
            <Ligature components="cid01540" glyph="uniE13A"/>
            <Ligature components="cid01539" glyph="uniE10B"/>
          </LigatureSet>
          <LigatureSet glyph="cid01516">
            <Ligature components="cid01540" glyph="uniE13B"/>
            <Ligature components="cid01539" glyph="uniE10C"/>
          </LigatureSet>
          <LigatureSet glyph="cid01517">
            <Ligature components="cid01540" glyph="uniE13C"/>
            <Ligature components="cid01539" glyph="uniE10D"/>
          </LigatureSet>
          <LigatureSet glyph="cid01518">
            <Ligature components="cid01540" glyph="uniE13D"/>
            <Ligature components="cid01539" glyph="uniE10E"/>
          </LigatureSet>
ゃやゅゆょよ
          <LigatureSet glyph="cid01519">
            <Ligature components="cid01540" glyph="uniE1D3"/>
            <Ligature components="cid01539" glyph="uniE1A3"/>
          </LigatureSet>
          <LigatureSet glyph="cid01520">
            <Ligature components="cid01540" glyph="uniE13E"/>
            <Ligature components="cid01539" glyph="uniE10F"/>
          </LigatureSet>
          <LigatureSet glyph="cid01521">
            <Ligature components="cid01540" glyph="uniE1D4"/>
            <Ligature components="cid01539" glyph="uniE1A4"/>
          </LigatureSet>
          <LigatureSet glyph="cid01522">
            <Ligature components="cid01540" glyph="uniE13F"/>
            <Ligature components="cid01539" glyph="uniE110"/>
          </LigatureSet>
          <LigatureSet glyph="cid01523">
            <Ligature components="cid01540" glyph="uniE1D5"/>
            <Ligature components="cid01539" glyph="uniE1A5"/>
          </LigatureSet>
          <LigatureSet glyph="cid01524">
            <Ligature components="cid01540" glyph="uniE140"/>
            <Ligature components="cid01539" glyph="uniE111"/>
          </LigatureSet>
らりるれろ
          <LigatureSet glyph="cid01525">
            <Ligature components="cid01540" glyph="uniE141"/>
            <Ligature components="cid01539" glyph="uniE112"/>
          </LigatureSet>
          <LigatureSet glyph="cid01526">
            <Ligature components="cid01540" glyph="uniE142"/>
            <Ligature components="cid01539" glyph="uniE113"/>
          </LigatureSet>
          <LigatureSet glyph="cid01527">
            <Ligature components="cid01540" glyph="uniE143"/>
            <Ligature components="cid01539" glyph="uniE114"/>
          </LigatureSet>
          <LigatureSet glyph="cid01528">
            <Ligature components="cid01540" glyph="uniE144"/>
            <Ligature components="cid01539" glyph="uniE115"/>
          </LigatureSet>
          <LigatureSet glyph="cid01529">
            <Ligature components="cid01540" glyph="uniE145"/>
            <Ligature components="cid01539" glyph="uniE116"/>
          </LigatureSet>
わゐゑをん
          <LigatureSet glyph="cid01531">
            <Ligature components="cid01540" glyph="uniE146"/>
            <Ligature components="cid01539" glyph="uniE117"/>
          </LigatureSet>
          <LigatureSet glyph="cid01532">
            <Ligature components="cid01540" glyph="uniE147"/>
            <Ligature components="cid01539" glyph="uniE118"/>
          </LigatureSet>
          <LigatureSet glyph="cid01533">
            <Ligature components="cid01540" glyph="uniE148"/>
            <Ligature components="cid01539" glyph="uniE119"/>
          </LigatureSet>
          <LigatureSet glyph="cid01534">
            <Ligature components="cid01540" glyph="uniE149"/>
            <Ligature components="cid01539" glyph="uniE11A"/>
          </LigatureSet>
          <LigatureSet glyph="cid01535">
            <Ligature components="cid01540" glyph="uniE14A"/>
            <Ligature components="cid01539" glyph="uniE11B"/>
          </LigatureSet>
ゝ
          <LigatureSet glyph="cid01543">
            <Ligature components="cid01539" glyph="cid01544"/>
          </LigatureSet>
ァアィイゥウェエォオ
          <LigatureSet glyph="cid01547">
            <Ligature components="cid01540" glyph="uniE280"/>
            <Ligature components="cid01539" glyph="uniE250"/>
          </LigatureSet>
          <LigatureSet glyph="cid01548">
            <Ligature components="cid01540" glyph="uniE200"/>
            <Ligature components="cid01539" glyph="uniE1E0"/>
          </LigatureSet>
          <LigatureSet glyph="cid01549">
            <Ligature components="cid01540" glyph="uniE281"/>
            <Ligature components="cid01539" glyph="uniE251"/>
          </LigatureSet>
          <LigatureSet glyph="cid01550">
            <Ligature components="cid01540" glyph="uniE201"/>
            <Ligature components="cid01539" glyph="uniE1E1"/>
          </LigatureSet>
          <LigatureSet glyph="cid01551">
            <Ligature components="cid01540" glyph="uniE282"/>
            <Ligature components="cid01539" glyph="uniE252"/>
          </LigatureSet>
          <LigatureSet glyph="cid01552">
            <Ligature components="cid01540" glyph="uniE202"/>
            <Ligature components="cid01539" glyph="cid01630"/>
          </LigatureSet>
          <LigatureSet glyph="cid01553">
            <Ligature components="cid01540" glyph="uniE283"/>
            <Ligature components="cid01539" glyph="uniE253"/>
          </LigatureSet>
          <LigatureSet glyph="cid01554">
            <Ligature components="cid01540" glyph="uniE203"/>
            <Ligature components="cid01539" glyph="uniE1E3"/>
          </LigatureSet>
          <LigatureSet glyph="cid01555">
            <Ligature components="cid01540" glyph="uniE284"/>
            <Ligature components="cid01539" glyph="uniE254"/>
          </LigatureSet>
          <LigatureSet glyph="cid01556">
            <Ligature components="cid01540" glyph="uniE204"/>
            <Ligature components="cid01539" glyph="uniE1E4"/>
          </LigatureSet>
カキクケコ
          <LigatureSet glyph="cid01557">
            <Ligature components="cid01540" glyph="uniE205"/>
            <Ligature components="cid01539" glyph="cid01558"/>
          </LigatureSet>
          <LigatureSet glyph="cid01559">
            <Ligature components="cid01540" glyph="uniE206"/>
            <Ligature components="cid01539" glyph="cid01560"/>
          </LigatureSet>
          <LigatureSet glyph="cid01561">
            <Ligature components="cid01540" glyph="uniE207"/>
            <Ligature components="cid01539" glyph="cid01562"/>
          </LigatureSet>
          <LigatureSet glyph="cid01563">
            <Ligature components="cid01540" glyph="uniE208"/>
            <Ligature components="cid01539" glyph="cid01564"/>
          </LigatureSet>
          <LigatureSet glyph="cid01565">
            <Ligature components="cid01540" glyph="uniE209"/>
            <Ligature components="cid01539" glyph="cid01566"/>
          </LigatureSet>
サシスセソ
          <LigatureSet glyph="cid01567">
            <Ligature components="cid01540" glyph="uniE20A"/>
            <Ligature components="cid01539" glyph="cid01568"/>
          </LigatureSet>
          <LigatureSet glyph="cid01569">
            <Ligature components="cid01540" glyph="uniE20B"/>
            <Ligature components="cid01539" glyph="cid01570"/>
          </LigatureSet>
          <LigatureSet glyph="cid01571">
            <Ligature components="cid01540" glyph="uniE20C"/>
            <Ligature components="cid01539" glyph="cid01572"/>
          </LigatureSet>
          <LigatureSet glyph="cid01573">
            <Ligature components="cid01540" glyph="uniE20D"/>
            <Ligature components="cid01539" glyph="cid01574"/>
          </LigatureSet>
          <LigatureSet glyph="cid01575">
            <Ligature components="cid01540" glyph="uniE20E"/>
            <Ligature components="cid01539" glyph="cid01576"/>
          </LigatureSet>
タチッツテト
          <LigatureSet glyph="cid01577">
            <Ligature components="cid01540" glyph="uniE20F"/>
            <Ligature components="cid01539" glyph="cid01578"/>
          </LigatureSet>
          <LigatureSet glyph="cid01579">
            <Ligature components="cid01540" glyph="uniE210"/>
            <Ligature components="cid01539" glyph="cid01580"/>
          </LigatureSet>
          <LigatureSet glyph="cid01581">
            <Ligature components="cid01540" glyph="uniE291"/>
            <Ligature components="cid01539" glyph="uniE261"/>
          </LigatureSet>
          <LigatureSet glyph="cid01582">
            <Ligature components="cid01540" glyph="uniE211"/>
            <Ligature components="cid01539" glyph="cid01583"/>
          </LigatureSet>
          <LigatureSet glyph="cid01584">
            <Ligature components="cid01540" glyph="uniE212"/>
            <Ligature components="cid01539" glyph="cid01585"/>
          </LigatureSet>
          <LigatureSet glyph="cid01586">
            <Ligature components="cid01540" glyph="uniE213"/>
            <Ligature components="cid01539" glyph="cid01587"/>
          </LigatureSet>
ナニヌネノ
          <LigatureSet glyph="cid01588">
            <Ligature components="cid01540" glyph="uniE214"/>
            <Ligature components="cid01539" glyph="uniE1E5"/>
          </LigatureSet>
          <LigatureSet glyph="cid01589">
            <Ligature components="cid01540" glyph="uniE215"/>
            <Ligature components="cid01539" glyph="uniE1E6"/>
          </LigatureSet>
          <LigatureSet glyph="cid01590">
            <Ligature components="cid01540" glyph="uniE216"/>
            <Ligature components="cid01539" glyph="uniE1E7"/>
          </LigatureSet>
          <LigatureSet glyph="cid01591">
            <Ligature components="cid01540" glyph="uniE217"/>
            <Ligature components="cid01539" glyph="uniE1E8"/>
          </LigatureSet>
          <LigatureSet glyph="cid01592">
            <Ligature components="cid01540" glyph="uniE218"/>
            <Ligature components="cid01539" glyph="uniE1E9"/>
          </LigatureSet>
ハヒフヘホ
          <LigatureSet glyph="cid01593">
            <Ligature components="cid01540" glyph="cid01595"/>
            <Ligature components="cid01539" glyph="cid01594"/>
          </LigatureSet>
          <LigatureSet glyph="cid01596">
            <Ligature components="cid01540" glyph="cid01598"/>
            <Ligature components="cid01539" glyph="cid01597"/>
          </LigatureSet>
          <LigatureSet glyph="cid01599">
            <Ligature components="cid01540" glyph="cid01601"/>
            <Ligature components="cid01539" glyph="cid01600"/>
          </LigatureSet>
          <LigatureSet glyph="cid01602">
            <Ligature components="cid01540" glyph="cid01604"/>
            <Ligature components="cid01539" glyph="cid01603"/>
          </LigatureSet>
          <LigatureSet glyph="cid01605">
            <Ligature components="cid01540" glyph="cid01607"/>
            <Ligature components="cid01539" glyph="cid01606"/>
          </LigatureSet>
マミムメモ
          <LigatureSet glyph="cid01608">
            <Ligature components="cid01540" glyph="uniE219"/>
            <Ligature components="cid01539" glyph="uniE1EA"/>
          </LigatureSet>
          <LigatureSet glyph="cid01609">
            <Ligature components="cid01540" glyph="uniE21A"/>
            <Ligature components="cid01539" glyph="uniE1EB"/>
          </LigatureSet>
          <LigatureSet glyph="cid01610">
            <Ligature components="cid01540" glyph="uniE21B"/>
            <Ligature components="cid01539" glyph="uniE1EC"/>
          </LigatureSet>
          <LigatureSet glyph="cid01611">
            <Ligature components="cid01540" glyph="uniE21C"/>
            <Ligature components="cid01539" glyph="uniE1ED"/>
          </LigatureSet>
          <LigatureSet glyph="cid01612">
            <Ligature components="cid01540" glyph="uniE21D"/>
            <Ligature components="cid01539" glyph="uniE1EE"/>
          </LigatureSet>
ャヤュユョヨ
          <LigatureSet glyph="cid01613">
            <Ligature components="cid01540" glyph="uniE2A3"/>
            <Ligature components="cid01539" glyph="uniE273"/>
          </LigatureSet>
          <LigatureSet glyph="cid01614">
            <Ligature components="cid01540" glyph="uniE21E"/>
            <Ligature components="cid01539" glyph="uniE1EF"/>
          </LigatureSet>
          <LigatureSet glyph="cid01615">
            <Ligature components="cid01540" glyph="uniE2A4"/>
            <Ligature components="cid01539" glyph="uniE274"/>
          </LigatureSet>
          <LigatureSet glyph="cid01616">
            <Ligature components="cid01540" glyph="uniE21F"/>
            <Ligature components="cid01539" glyph="uniE1F0"/>
          </LigatureSet>
          <LigatureSet glyph="cid01617">
            <Ligature components="cid01540" glyph="uniE2A5"/>
            <Ligature components="cid01539" glyph="uniE275"/>
          </LigatureSet>
          <LigatureSet glyph="cid01618">
            <Ligature components="cid01540" glyph="uniE220"/>
            <Ligature components="cid01539" glyph="uniE1F1"/>
          </LigatureSet>
ラリルレロ
          <LigatureSet glyph="cid01619">
            <Ligature components="cid01540" glyph="uniE221"/>
            <Ligature components="cid01539" glyph="uniE1F2"/>
          </LigatureSet>
          <LigatureSet glyph="cid01620">
            <Ligature components="cid01540" glyph="uniE222"/>
            <Ligature components="cid01539" glyph="uniE1F3"/>
          </LigatureSet>
          <LigatureSet glyph="cid01621">
            <Ligature components="cid01540" glyph="uniE223"/>
            <Ligature components="cid01539" glyph="uniE1F4"/>
          </LigatureSet>
          <LigatureSet glyph="cid01622">
            <Ligature components="cid01540" glyph="uniE224"/>
            <Ligature components="cid01539" glyph="uniE1F5"/>
          </LigatureSet>
          <LigatureSet glyph="cid01623">
            <Ligature components="cid01540" glyph="uniE225"/>
            <Ligature components="cid01539" glyph="uniE1F6"/>
          </LigatureSet>
ワヰヱヲン
          <LigatureSet glyph="cid01625">
            <Ligature components="cid01540" glyph="uniE226"/>
            <Ligature components="cid01539" glyph="cid01633"/>
          </LigatureSet>
          <LigatureSet glyph="cid01626">
            <Ligature components="cid01540" glyph="uniE227"/>
            <Ligature components="cid01539" glyph="cid01634"/>
          </LigatureSet>
          <LigatureSet glyph="cid01627">
            <Ligature components="cid01540" glyph="uniE228"/>
            <Ligature components="cid01539" glyph="cid01635"/>
          </LigatureSet>
          <LigatureSet glyph="cid01628">
            <Ligature components="cid01540" glyph="uniE229"/>
            <Ligature components="cid01539" glyph="cid01636"/>
          </LigatureSet>
          <LigatureSet glyph="cid01629">
            <Ligature components="cid01540" glyph="uniE22A"/>
            <Ligature components="cid01539" glyph="uniE1F7"/>
          </LigatureSet>
ヽ
          <LigatureSet glyph="cid01639">
            <Ligature components="cid01539" glyph="cid01640"/>
          </LigatureSet>

 

Flashで外部音声ファイル(wav形式)を再生

$
0
0

http://helpx.adobe.com/jp/flash/using/using-sounds-flash.htmlを読むと興味深い記述があった。

Flash Professional に読み込むことのできるサウンドファイル形式は、次のとおりです。

Adobe Sound(*.asnd)。Adobe® Soundbooth™ のネイティブサウンド形式です。
Wave(.wav)
AIFF(.aif、.aifc)
mp3

その他にも、以下のサウンドファイル形式を読み込むこともできます。
Sound Designer® II(.sd2)
Sun AU(.au、.snd)
FLAC(.flac)
Ogg Vorbis(.ogg、.oga)

これはホントなのか。 oggも再生可能か試してみた。

外部mp3,wav,oggをストリーミング再生してみる

http://snipplr.com/view/31915/as3-loading-and-playing-an-external-mp3-file/のコードを元に、以下をビルド。 swfと同じフォルダーに test.wav, test.mp3, test.oggを配置。

package {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.net.URLRequest;

    /**
     * ...
     * @author foo
     */
    public class Main extends Sprite {
        private var preloadBottom:Number;

        public function Main():void {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }

        private function init(e:Event = null):void {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            // entry point

            var snd:Sound = new Sound();
            var chnl:SoundChannel = new SoundChannel();
            snd.load(new URLRequest('test.mp3'));
            //snd.load(new URLRequest('test.ogg'));
            //snd.load(new URLRequest('test.wav'));
            snd.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
            function onComplete(e:Event):void {
                chnl = snd.play();
            }
        }
    }
}

mp3ならストリーミング再生可能。oggとwavは不可。と分かった。

ogg対応なのは、Flash Proでflaファイルにoggを内部埋め込みのときだろう。 ストリーミング(外部ファイル読み込み)だとmp3のみ使えるということだね。

実際は内部埋め込みであればmp3で問題ない。外部読み込みのときこそ、mp3以外を使いたいのだ。mp3はライセンス料問題があるからだ。

ライブラリ使用してwavとogg対応?

しかし、外部wavやoggファイルを再生する方法があるという。

外部oggファイルはよく分からず。

http://stackoverflow.com/questions/9165189/flash-as3-ogg-sound-delayed-adobe-alchemy-libraryhttp://labs.byhook.com/2011/02/22/ogg-vorbis-encoder-decoder-for-flash/を見るとできるようだが、後者から実際にDLしてサンプルswfをローカルで動かし、ローカルのoggを再生してみたら、2m00s(2分0秒)のoggファイル(465KB)のデコードに30秒くらいかかるし、音声が2倍速で再生されてる感じ。これは常用は難しい。

as3wavsound で外部wav再生

まあwavだけでも対応してみよう。 こっちは簡単。

http://stackoverflow.com/questions/12538076/playing-successive-wav-sounds-in-as3を参考に、FlashDevelpのsrcフォルダー以下に、as3wavsound https://code.google.com/p/as3wavsound/を展開して出てきたsrc以下のフォルダーをcopy。 swfと同じフォルダー(bin)以下に test.wavを配置。 src/Main.asは以下。

package {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.utils.ByteArray;
    import org.as3wavsound.WavSound;
    import org.as3wavsound.WavSoundChannel;

    /**
     * ...
     * @author foo
     */
    public class Main extends Sprite {

        public function Main():void {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }

        private function init(e:Event = null):void {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            // entry point

            var ld:URLLoader = new URLLoader();
            ld.dataFormat = 'binary'; //この行は必要だった
            ld.load(new URLRequest('test.wav'));
            ld.addEventListener(Event.COMPLETE, onComplete);

            function onComplete(e:Event):void {
                var snd:WavSound = new WavSound(e.currentTarget.data as ByteArray);
                var chnl:WavSoundChannel = snd.play();
            }
        }
    }
}

デコード時間ほぼ無しでいきなり再生。こっちは問題なく使える。

注意すべきはwavファイルのフォーマットで 44100/22050/11025 kHz で、かつ 8/16 bitだけ対応。48000kHzや24bitはムリなのね。モノラルは再生できた。

 

TTXを使用してTrueTypeフォントのcmapテーブルを修正

$
0
0

IPAゴシック」フォントの「饅」(U+9945) 「頭」(U+982D)を、「○」(U+25CB)で表示するためのTTX使用方法を説明。

[話者]『さいきん「饅頭(まんじゅう)」の「饅」「頭」の2文字を見るだけで、顔が青ざめて‥‥』という人がいるとする。

[合いの手]それは大変だね(棒)

[話者]IPAゴシック」というフォントの「饅」(U+9945) 「頭」(U+982D)を、「○」(U+25CB)で表示されるようにしよう。

FontForgeIPAゴシックの個々の字形を修正してもよいのだが http://itouhiro.hatenablog.com/entry/20140910/fontで書いたようにFontForgeで読み書きするとフォントがおかしくなることがある。

ここはFontForgeでフォントを書き出すのではなく、TTX/FontToolsでフォントのcmapテーブルを修正する方法を説明する。

[合いの手]「饅」はわかるけど、 U+9945 は何? どこで調べるの?

[話者] U+9945 というのはUnicodeのコードポイントだよ。文字番号。

Unicodeでは、文字集合中の文字をあらわす符号位置(コードポイント、符号点を参照)に、「Unicodeスカラ値」という非負整数値が割り振られている。Unicodeスカラ値は "U+"の後に十六進法でその値を続けることで表す。

引用元: http://ja.wikipedia.org/wiki/Unicode

テキストエディターのMeryなら文字の前にカーソルもってくればUnicode値を表示する。

f:id:itouhiro:20141004145225p:plain

それ以外でも、「饅 Unicode」でGoogle検索で検索すれば分かる。

グリフ名

まずグリフ(字形)名を見てみよう。この「IPAゴシック」の場合 「饅」(U+9945)のグリフ名は aj7220だな。FontForgeだと[エレメント-グリフ情報-Glyph Name]で確認できるぞ。

f:id:itouhiro:20141004112014p:plain

同様に「頭」(U+982D)のグリフ名は aj3204

f:id:itouhiro:20141004112144p:plain

「○」(U+25CB)のグリフ名は aj723

f:id:itouhiro:20141004112945p:plain

[合いの手]グリフ(字形)ごとに名前がついているのか。

[話者]このグリフ名はフォントごとに異なる。 たとえばNasuフォントだと「饅」(U+9945)のグリフ名は cid44662だったりする。

cmapテーブルを取り出し書き換える

TTXを使い、cmapテーブルを取り出す。 TTXの導入方法は http://itouhiro.hatenablog.com/entry/20140910/font参照。

$ ttx -t cmap ipag.ttf
Dumping "ipag.ttf" to "ipag.ttx"...
Dumping 'cmap' table...
$

ipag.ttxの中身はこんな感じ。

      ...
      <map code="0x25cb" name="aj723"/><!-- WHITE CIRCLE -->
      ...
      <map code="0x9945" name="aj7220"/><!-- CJK UNIFIED IDEOGRAPH-9945 -->
      ...
      <map code="0x982d" name="aj3204"/><!-- CJK UNIFIED IDEOGRAPH-982D -->
      ...

f:id:itouhiro:20141004114039p:plain

[合いの手]確かに U+9945 のnameは aj7220になっているね。

[話者]このcmapテーブル定義を以下のように書き換える。

      ...
      <map code="0x25cb" name="aj723"/><!-- WHITE CIRCLE -->
      ...
      <map code="0x9945" name="aj723"/><!-- CJK UNIFIED IDEOGRAPH-9945 -->
      ...
      <map code="0x982d" name="aj723"/><!-- CJK UNIFIED IDEOGRAPH-982D -->
      ...

[合いの手]「饅」(U+9945) 「頭」(U+982D)のnameを aj723に変更したのか。

[話者]ここで注意だ。

<map code="0x9945" name="aj7220"/><!-- CJK UNIFIED IDEOGRAPH-9945 -->

の行、

<map code="0x982d" name="aj3204"/><!-- CJK UNIFIED IDEOGRAPH-982D -->

の行は「複数」ある。すべて書き換えなくてはならないので、テキストエディターの「すべて置換」などを使おう。

[合いの手]一つじゃないんだ?

[話者]このフォントの場合だと、cmapのformatとplatformIDで以下の3つがあって、

<cmap_format_4 platformID="0" platEncID="3" language="0"> ..  </cmap_format_4>

    <cmap_format_4 platformID="3" platEncID="1" language="0"> ..  </cmap_format_4>

    <cmap_format_12 platformID="3" platEncID="10" format="12" reserved="0" length="124000" language="0" nGroups="10332"> .. </cmap_format_4>

それぞれが

<map code="0x9945" name="aj7220"/><!-- CJK UNIFIED IDEOGRAPH-9945 -->

を含んでいるんだ。 だからそれを全部書き換える必要がある。

cmapのformatについては http://vanillasky-room.cocolog-nifty.com/blog/2008/02/opentype6cmap-d.htmlに説明あり。

フォーマット4は2バイトエンコーディングフォーマットである。フォーマット8、10、12は4バイトエンコーディングフォーマットである。MicrosoftWindows向けのサロゲートペアに対応したUnicodeフォントを作成する時、フォーマット4とフォーマット12を組み合わせて使うように推奨している。

cmapのplatformIDについては http://vanillasky-room.cocolog-nifty.com/blog/2008/02/opentype3name-a.htmlに説明あり。

プラットフォームIDプラットフォーム名
0Unicode
1Macintosh
2ISO
3Microsoft
4カスタム

[合いの手]ふうん。

cmapテーブルを置き換えたTrueTypeフォントを生成

[話者]そしてttxファイル名をipag.ttxからipag_new.ttxにでも変えておく。 そして新しいttfファイルを生成。

$ ttx -m ipag.ttf ipag_new.ttx
Compiling "ipag_new.ttx" to "ipag_new.ttf"...
Parsing 'cmap' table...
$

f:id:itouhiro:20141004122046p:plain

f:id:itouhiro:20141004122055p:plain

[話者]「○」(U+25CB)の表示も「○」のままだ。 つまり、以下の3つの文字は、同じ字形で表示されることになる。

  • 「饅」(U+9945)
  • 「頭」(U+982D)
  • 「○」(U+25CB)

[合いの手]確かに表示は変わったね。しかし特定の文字を見たくないという個人の些細な感情をこんな技術で満たしてよいのだろうか。

スクリプト

[話者] node.jsのスクリプトにした。

使い方は以下。WindowsのPortableGit(msysgit) https://github.com/msysgit/msysgit/releases環境で実行している。

rm *.ttx *_new*; node cmapReplace.js foo.ttf

cmapReplace.js

var fs = require('fs');
var exec = require('child_process').exec;

if (process.argv.length != 3){
  console.log('usage: rm *.ttx *_new*; node cmapReplace.js foo.ttf');
  process.exit(0);
}

var orgFontFileName = process.argv[2];
exec('ttx -t cmap '+ orgFontFileName, function(err, stdoutTxt, stderrTxt){
  console.log('ttx -t cmap '+ orgFontFileName);
  console.log(stdoutTxt+stderrTxt);
  var orgTtxName = orgFontFileName.replace(/\.ttf/i, '.ttx');

  var newTtxName = replaceCmap(orgTtxName);

  exec('ttx -m '+ orgFontFileName + ' ' + newTtxName, function(err, stdoutTxt, stderrTxt){
    console.log('ttx -m '+ orgFontFileName + ' ' + newTtxName);
    console.log(stdoutTxt+stderrTxt);
  });
});


function replaceCmap(orgFileName){
  var fileContent = fs.readFileSync(orgFileName) + '';
  fileContent = fileContent.replace(/\r/g, '').replace(/\uFEFF/g, '').replace(/\n*$/, '');
  var lines = fileContent.split(/\n/);

  var ngChars = '0x9945 0x982d'.split(' '); //「饅」「頭」
  var toBeReplaced = '0x25cb'; //「○」

  var toBeGlyphName = getGlyphName(toBeReplaced, lines);

  for(var i=0; i<ngChars.length; i++){
    var ngGlyphName = getGlyphName(ngChars[i], lines);
    fileContent = fileContent.replace(new RegExp(ngGlyphName+'"','g'), toBeGlyphName+'"')
  }

  var newFileName = orgFileName.replace('\.ttx','_new.ttx');
  fs.writeFileSync(newFileName, fileContent);
  console.log('(replace): ' + orgFileName + ' -> ' + newFileName);
  return newFileName;
}

function getGlyphName(theGlyph, lines){
  var m;
  var n;
  for (var i=0; i<lines.length; i++){
    if (lines[i].match(theGlyph)){
      if (m = lines[i].match('name="([^\"]+)"/>')){
        return m[1];
      }
    }
  }
  console.log('error: '+theGlyph+' not found.');
  process.exit(-1);
}

 

 

 

 

Fonts & Encodings

Fonts & Encodings

TTXを使用してTrueTypeフォントのglyfテーブルを修正

$
0
0

IPAゴシック」フォントの「‼」(U+203C)、「⁉」(U+2049)の字形を修正する。ただしFontForgeをフォント出力に使わない。TTX/FontToolsでglyfテーブルを書き換えてフォントを出力する。

TTXを使用してTrueTypeフォントのcmapテーブルを修正
http://itouhiro.hatenablog.com/entry/20141004/font
の続き

[話者]Unicodeには「!!」「!?」をそれぞれ1文字にした

‼  U+203C
⁉  U+2049

が用意されているんだが、全角幅と規定されていない。

[合いの手]漫画のセリフでよく使われてるね。漫画のセリフはたいてい縦書きだから、全角になってると便利なんだけど。 ところで「規定」ってどこかにルールでもあるのかい?

[話者]wikipedia:東アジアの文字幅http://www.unicode.org/reports/tr11/に解説があるよ。具体的には http://www.unicode.org/Public/UCD/latest/ucd/にある EastAsianWidth.txtが決めてる。

203C..203D;N     # Po     [2] DOUBLE EXCLAMATION MARK..INTERROBANG
...
2047..2051;N     # Po    [11] DOUBLE QUESTION MARK..TWO ASTERISKS ALIGNED VERTICALLY

とある。203Cも2049も N つまり「日本語圏では使われていなかった」とかいう理由で幅が決まってない。全角にしてるフォントもあるけど、IPAゴシックでは半角なんだよね。

そこで、手作業で全角にしてみるだろ。

FontForgeで字形修正

もともとは半角。

f:id:itouhiro:20141004175119p:plain

[メトリック>幅を設定]で2048にして全角幅にする。全角!?の字形をコピーペーストする。

f:id:itouhiro:20141004175133p:plain

FontForgeで[ファイル>フォントを出力] でTrueTypeフォントを出力する。[ ] Validate Before Savingのチェックを外すと素早く保存されるぞ。

f:id:itouhiro:20141004175304p:plain

ちなみにFontForgeの[ファイル>保存]でsfdファイルを保存して、そのsfdファイルを読む込むと何かおかしくなっていたりする。sfdよりttfで保存するほうがむしろ信頼性があると感じる。

[合いの手]でもFontForgeIPAゴシックを「TrueTypeフォント」出力すると、 http://itouhiro.hatenablog.com/entry/20140910/fontに書いたとおりフォントがおかしくなるよね。直さなくていいの?

[話者]直さなくていいよ。字形変更したTrueTypeフォントで、実際に使うのはglyfテーブルだけだからね。

TTXで字形置き換え

双方のglyfテーブルをTTXで出力する。 ipag.ttfが変更前のフォント。 IPAGothic.ttfは変更したフォント。

$ ttx -t glyf ipag.ttf
Dumping "ipag.ttf" to "ipag.ttx"...
Dumping 'glyf' table...

$ ttx -t glyf IPAGothic.ttf
Dumping "IPAGothic.ttf" to "IPAGothic.ttx"...
Dumping 'glyf' table...

$

このあと、ipag.ttxファイルを書き換える。 IPAGothic.ttxに含まれる、変更した字形のグリフ名(aj12111.hwaj12112.hw)の箇所だけを、ipag.ttxに持ってくればいい。

手作業でテキストエディターで書き換えてもいいんだけど、ttxファイルひとつで52MBもあったりして、あと何文字も置き換えるのはスクリプトのほうが確実なので、ここではnode.jsスクリプトで書き換えることにする。

glyfReplace.js

var fs = require('fs');

if (process.argv.length != 4){
  console.log('usage: node this.js origianl.ttx newglyph.ttx');
  process.exit(1);
}

var replaceCharacters = 'aj12111.hw aj12112.hw'; //U+203C, U+2049

var repChars = replaceCharacters.split(' ');
var orgFile = fs.readFileSync(process.argv[2]) + '';
var glyfFile = fs.readFileSync(process.argv[3]) + '';

var i;
for(i=0; i<repChars.length; i++){
  var re = '[ \t]*<TTGlyph name="' +repChars[i]+ '"[\\s\\S]*?</TTGlyph>'; 
  var re2 = '[ \t]*<TTGlyph name="' +repChars[i]+ '"/><!-- contains no outline data -->'; 
  var matchGlyph = glyfFile.match(RegExp(re));
  var newGlyph = matchGlyph[0];

  var m;
  var matched;
  if (m = orgFile.match(re)){
    //console.log('orgFile match ' + repChars[i]);
    matched = m[0];
    orgFile = orgFile.replace(matched, newGlyph);
  }else{
    console.log(repChars[i] + ' not match.');
    m = orgFile.match(re2);
    if (m){
      matched = m[0];
      orgFile = orgFile.replace(matched, newGlyph);
    }else{
      console.log(repChars[i] + ' not match. ignored.');
    }
  }
}
fs.writeFileSync('new.ttx', orgFile);

このスクリプト

$ node glyfReplace.js ipag.ttx IPAGothic.ttx

と使うと、新しく new.ttxが作られる。

それを使って、もとのipag.ttfのglyfテーブルを置き換え。

$ ttx -m ipag.ttf new.ttx
Compiling "new.ttx" to "new.ttf"...
Parsing 'glyf' table...

new.ttfが修正版のフォントだ。

f:id:itouhiro:20141004182718p:plain

[合いの手]確かに変わったぞ。

 

 

 

Fonts & Encodings

Fonts & Encodings

ActionScript3でBulkLoaderを使い複数の外部ファイルを読み込む

$
0
0

Flash ActionScript3で複数の外部ファイルを読み込むには、BulkLoaderが便利なようだ。使ってみる。

f:id:itouhiro:20141006122929j:plain

https://github.com/arthur-debert/BulkLoaderで最新版を取得して、srcに展開し、以下をビルド。

package {
    import flash.display.Bitmap;
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.events.Event;
    import br.com.stimuli.loading.BulkLoader;
    import br.com.stimuli.loading.BulkProgressEvent;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.utils.ByteArray;
    import org.as3wavsound.WavSound;
    import org.as3wavsound.WavSoundChannel;

    /**
     * ...
     * @author foo
     */
    [SWF(width = "410", height = "580", frameRate = "30", backgroundColor = "0x888888")]
    public class Main extends Sprite {
        private var loader:BulkLoader;

        public function Main():void {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }

        private function init(e:Event = null):void {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            // entry point

            loader = new BulkLoader('main');
            loader.addEventListener(BulkProgressEvent.COMPLETE, onLoadComplete);
            loader.addEventListener(BulkProgressEvent.PROGRESS, onLoadProgress);
            loader.add('test.jpg', { id:'bg1', priority:20 } );
            loader.add('test.png');
            loader.add('test.swf', { pausedAtStart:true } );
            loader.add('test.txt');
            loader.add('test.wav', { id:'bgm1', type:BulkLoader.TYPE_BINARY } );
            loader.start();
        }

        private function onLoadProgress(e:BulkProgressEvent):void {
            // https://github.com/arthur-debert/BulkLoader/wiki/Reporting-Loading-Progress
            // trace('ratio:'+e.percentLoaded+' (loaded'+e.bytesLoaded+', total:'+e.bytesTotal+')'); bytesTotalが0のまま
            trace('items loaded:'+e.itemsLoaded+', total:'+e.itemsTotal);
        }

        private function onLoadComplete(e:BulkProgressEvent):void {
            // https://github.com/arthur-debert/BulkLoader/wiki/Accessing-Loaded-Content

            addChild(loader.getBitmap('bg1'));

            var chara:Bitmap = loader.getBitmap('test.png');
            chara.y = 580-252;
            addChild(chara);

            var mc:MovieClip = loader.getMovieClip('test.swf');
            mc.x = 310;
            addChild(mc);

            var theTxt:String = loader.getText('test.txt');
            var tf:TextField = new TextField();
            tf.defaultTextFormat = new TextFormat('Noto Sans Japanese Regular', 16, 0x000000);
            tf.wordWrap = true;
            var speechBaloon:MovieClip = new MovieClip();
            speechBaloon.graphics.beginFill(0xffffff, 0.5);
            speechBaloon.graphics.drawRoundRect(15, 15, 380, 200, 5, 5);
            speechBaloon.graphics.endFill();
            addChild(speechBaloon);
            tf.x = 20;
            tf.y = 20;
            tf.width = 370;
            tf.height = 190;
            tf.text = theTxt;
            addChild(tf);

            var snd:WavSound = new WavSound(loader.getBinary('test.wav'));
            var chnl:WavSoundChannel = snd.play();
        }
    }
}

動作はしている。swfのpausedAtStart:true は効いてないような。

使用した素材は以下。

外部音声はライセンス料問題があるのでwav。swfに内蔵させるんだったらmp3でいいんだけど。

参考になった資料

Progress Percentage

長いロード時間を待つには、ロード進捗率表示がほしい。 上のソースだと「ロード中アイテムの個数」しか表示しないので大ざっぱ過ぎる。

パーセンテージを表示するには https://github.com/arthur-debert/BulkLoader/wiki/Reporting-Loading-Progressによると各アイテムに weight を指定しろ、と書いてある。

ソースを以下にすると%表示できた。 ここではweightの数値は ファイルの容量(単位:バイト)にしているが、細かすぎる気はするので、単位をKBにしてよいと思う。

        private function init(e:Event = null):void {
            ...
            loader.add('test.jpg', { id:'bg1', priority:20, weight:9580 } );
            loader.add('test.png', { weight:36459 } );
            loader.add('test.swf', { pausedAtStart:true, weight:996 } );
            loader.add('test.txt', { weight: 486 } );
            loader.add('test.wav', { id:'bgm1', type:BulkLoader.TYPE_BINARY, weight:225164 } );
            ...
        }

        private function onLoadProgress(e:BulkProgressEvent):void {
            // https://github.com/arthur-debert/BulkLoader/wiki/Reporting-Loading-Progress
            // trace('ratio:'+e.percentLoaded+' (loaded'+e.bytesLoaded+', total:'+e.bytesTotal+')'); //bytesTotalが0のまま
            //trace('items loaded:'+e.itemsLoaded+', total:'+e.itemsTotal); //ロード中アイテムの個数
            trace('ratio:'+int(e.weightPercent*100)+' (loaded item'+e.itemsLoaded+', total item:'+e.itemsTotal+')');
        }

remove

以下のように書くと、swfのpausedAtStartも効くようになった。swf再生のためにplay()が必要。 使用しなくなったらremove()すればよいらしい。EventListenerはremoveやremoveAllで消えないらしいので個別にremoveEventListener()したほうがよいようだ。参考: https://github.com/arthur-debert/BulkLoader/wiki/Memory-Management

        private function onLoadComplete(e:BulkProgressEvent):void {
            // https://github.com/arthur-debert/BulkLoader/wiki/Accessing-Loaded-Content
            loader.removeEventListener(BulkProgressEvent.COMPLETE, onLoadComplete);
            loader.removeEventListener(BulkProgressEvent.PROGRESS, onLoadProgress);

            var bg:Bitmap = loader.getBitmap('bg1');
            var chara:Bitmap = loader.getBitmap('test.png');
            var mc:MovieClip = loader.getMovieClip('test.swf');
            var theTxt:String = loader.getText('test.txt');
            var wav:ByteArray = loader.getBinary('test.wav');

            loader.removeAll(); //loader.getXXX()はできなくなるが、loader.add()は可能
            loader = null;
            BulkLoader.removeAllLoaders(); //loader.add()も不可


            addChild(bg);

            chara.y = 580-252;
            addChild(chara);

            mc.x = 310;
            addChild(mc);
            mc.play();

            var tf:TextField = new TextField();
            tf.defaultTextFormat = new TextFormat('Noto Sans Japanese Regular', 16, 0x000000);
            tf.wordWrap = true;
            var speechBaloon:MovieClip = new MovieClip();
            speechBaloon.graphics.beginFill(0xffffff, 0.5);
            speechBaloon.graphics.drawRoundRect(15, 15, 380, 200, 5, 5);
            speechBaloon.graphics.endFill();
            addChild(speechBaloon);
            tf.x = 20;
            tf.y = 20;
            tf.width = 370;
            tf.height = 190;
            tf.text = theTxt;
            addChild(tf);

            var snd:WavSound = new WavSound(wav);
            var chnl:WavSoundChannel = snd.play(0,999);
        }

 

 

 

 

ActionScript 3.0 イメージエフェクト - スクリプトで作る画像効果

ActionScript 3.0 イメージエフェクト - スクリプトで作る画像効果

Uemaruフォント:縦長で等幅の丸ゴシックフリーフォント

$
0
0

Uemaru(うえまる)フォントを作成したので公開します。

f:id:itouhiro:20141012161429j:plain

 

濁点・半濁点を文字の上に付けたTrueTypeアウトラインフォントです。
「モトヤLマルベリ3等幅」を改変しました。 Uetenフォントの姉妹フォントになります。

Uemaru(うえまる)フォントの特徴

  • 丸ゴシックの等幅フォント
  • 少し縦長の字形。
  • 濁点・半濁点は文字の上に付く。
  • 半濁点が大きめ。
  • JIS第1・第2水準の文字をすべて収録。
  • 「モトヤLマルベリ3等幅」に存在しない記号をいくつか「M+ OUTLINE FONTS」から追加した。
  • 「あ」+「゛」のような濁点・半濁点合成字形を収録。外字または合字として使用可能。

仕様:

  • 縦書きに非対応。
  • 濁点・半濁点合成字形は「合字としては」Adobe製品では使用不可。外字としては可能。
  • ウェイト(太さ)はRegularしかない。

フォント名は「文字の上に半濁点(マル)をつける」ことから命名しました。

f:id:itouhiro:20141012171721p:plain

ダウンロード

version 2014.1012
https://sourceforge.jp/downloads/users/7/7303/uemaru-font-20141012.zip (3MB)

フリーフォントです。ライセンスはApache License。

改変箇所

  • 横幅を92%に縮小。つまり少し縦長の字形にした。
  • 濁点・半濁点を文字の上に付ける。
  • 存在しない記号をいくつか「M+ OUTLINE FONTS」から追加した。
  • 「あ」+「゛」のような濁点・半濁点合成字形を追加。
  • 「―」(U+2015 HORIZONTAL BAR)を横に伸ばした。
  • U+005C をバックスラッシュ字形にした。
  • 行幅(フォントの縦幅)を少し広くする。濁点・半濁点を上に置いたため。

Uetenフォントとの違い

Uetenフォント http://itouhiro.hatenablog.com/entry/20140502/fontと同じ作り方で作成しています。見た目は似ていますが、以下が違います。

フォント名改変元フォント収録文字ウェイト(太さ)ライセンス
UemaruモトヤLマルベリ3等幅JIS第1・第2水準すべて。さらに記号を追加1ウェイト(Regular)Apacheライセンス
UetenRounded M+フォント JIS第1水準すべて。第2水準は不完全7ウェイト(Thin/Regular/Bold/..)M+フォントライセンス

f:id:itouhiro:20141012165105p:plain

f:id:itouhiro:20141012165116p:plain

ページの読み込みを高速化し、Web アプリケーションや
オンラインゲームのパフォーマンスを強化しました。
美しいタイポグラフィ、タッチスクリーンインタフェース
「ビルより大きいって聞いてたのに……」
「――まあまあ、まずは挨拶からだ」
ア゙パ
あ゛は゜
あ゙い゙ゔえ゙お゙
カ゚キ゚ク゚ケ゚コ゚



合字/外字として使用

合字として使用

「あ U+3042」+「合成用濁点 U+3099」として入力。 http://itouhiro.hatenablog.com/entry/20140925/fontなどからコピーペーストするのが早いかも。

外字として使用

IME(ここではATOK2012)のUnicode文字パレットで、U+E100 以降の外字を入力。

f:id:itouhiro:20141012170929p:plain

外字としてならAdobe Illustratorなどでも表示可能。ゲームエンジンで使う場合も外字のほうが都合いいかも。

f:id:itouhiro:20141012171430p:plain

[合いの手]ところでこの外字表に「ゔ」がないのはなぜ?

[話者]「ゔ」は U+3094 に置くことになっている。そこを探せばあるよ。 参考: wikipedia:ヴ

f:id:itouhiro:20141014103312p:plain

[合いの手]外字ならどこでも一文字に見えるから、外字のほうがいいんじゃないの?

[話者]外字は「違うフォント」で見るとまったく表示されないという欠点があるよ。 ただし、このフォントの外字は、以下のフォントと同じ位置に同じ外字を置いてある。つまり以下のフォントなら同じ外字を使えるよ。

しかしそれ以外のフォントでは外字を表示できない。

合字なら未対応フォントでも、たとえば「あ U+3042」+「合成用濁点 U+3099」なら「あ」は表示される(合成用濁点は位置がずれたりもあるけど)。使用フォントを固定できる環境以外では、合字のほうが安全だな。

おまけ

Uemaruフォント作成途中のフォントも収録。

MLMaruCircle(エムエル・マル・サークル)フォント

uemaru-font-20141012/MLMaruCircle-W3-mono.ttfに収録。

Uemaruフォントとの違い:

  • 各文字の横幅を縮小していない。モトヤLマルベリ3等幅と同じ横幅。
  • 行幅(フォントの縦幅)もモトヤLマルベリ3等幅と同じ。
  • 濁点・半濁点は文字の上ではなく、モトヤLマルベリ3等幅と同じ位置にある。
  • 「ぱぴぷぺぽパピプペポ」の半濁点が大きい(140%)。
  • 「あ」+「゛」のような濁点・半濁点合成字形は収録していない。

仕様:

  • 縦書きに非対応。

フォント名は「モトヤLマルベリ3等幅」の英語名「MotoyaLMaru」を多少変えました。 ウェイトが Regular ではなく「W3 mono」になっているのは、「モトヤLマルベリ3等幅」と同じです。

f:id:itouhiro:20141012165130p:plain

f:id:itouhiro:20141012165138p:plain

ChangeLog

  • version 2014.1012
    • first release

License

  • Uemaruフォント・MLMaruCircleフォントは、Apache 2.0 License のもとで使用することができます。
  • 「モトヤLマルベリ3等幅」由来の文字グリフの著作権は株式会社モトヤ様が所有しています。
  • 「M+ OUTLINE FONTS」由来の文字グリフの著作権は M+ FONTS PROJECT 様が所有しています。

Copyright(C)2010 MOTOYA CO.,LTD.
Copyright(c) 2014 M+ FONTS PROJECT
Copyright(c) 2014 itouhiro

Copyright(c) 2014 itouhiro

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Apache 2.0 License の日本語訳は、以下から参照することができます。 http://sourceforge.jp/projects/opensource/wiki/licenses%2FApache_License_2.0

作成環境

参考

 

 

 

はてなブログ、はてなダイアリー、Tumblr、Bloggerを比較

$
0
0

無料ブログサービスを比較した(2012年7月現在)。私はブログを技術メモに使っていて、ソースコードやFlash表示を必要としている。日記用途には使わない。その観点での比較。


Tumblr

f:id:itouhiro:20120711225151p:plain
Tumblrをブログとして使う

利点

  • 広告なし
  • 見た目がいい(PC/Android)
  • Markdown記法ラク
  • 1記事1URL
  • Syntax Highlight(ソースコードの色分け)がラクで見やすい

欠点

はてなブログ

f:id:itouhiro:20120711225211p:plain
はてなブログ

利点

欠点

  • まだベータ。仕様が決定してない。objectタグやiframeタグが使えるのか使えないのか
  • 広告入る(末尾に1つ)
  • 大きな画像が縮小表示される(元画像へのリンクはあり)
  • 日付にもリンクが存在するのがイヤだ。1記事2URLになるから
  • なんだか表示が重い(PC) ←背景画像なくすと軽くなったかも
  • Syntax Highlightの色使いが読みにくい。個人的には Comment の部分を色変えてくれる程度の簡単なのでいいんだけど、はてなブログのは過剰に色分けしてしかもその色が読みにくいという‥‥
  • はてなキーワード」へのリンクが邪魔‥‥(しかしデザインCSS a.keyword{border:0;} で線を消すと何かものたりない気もしてくる)

はてなダイアリー

f:id:itouhiro:20120711225219p:plain
はてなダイアリー

利点

  • 画像貼り付けが簡単
  • はてな記法ラク
  • 1記事1URLにできる(日記モードにしてh2タグを使わなければ、日付のリンクだけにできる)
  • URLの文字数が短い
  • 大きな画像を等倍表示できる
  • はてなキーワード」へのリンクは閾値を減らせば、あまり気にならない


欠点

  • 広告が入る(Androidの場合、記事冒頭に1つ、末尾に1つ)
  • 文字コードEUC-JP。U+005CがBackSlashではなく半角円記号で表示されるとか一部のUnicode文字がうまく保存できないなどの問題がある
  • ページデザインは、大きな画像を等倍表示できるテーマの場合、あまりデザインがよくない

Blogger

f:id:itouhiro:20120711225227p:plain
Blogger (blogspot.jp)

利点

  • 広告なし
  • 1記事1URL
  • デザインの自由度は高い
  • objectタグ、iframeタグも使える。JavaScript(SyntaxHighlighterなど)も使用可能

欠点

  • 記事書くためにHTML編集するのが面倒
  • 画像貼り付けはpicasaにアップロードすれば容量制限はないが、手順が面倒
  • 大きな画像が縮小表示される
  • ページトップに「不正行為を報告」という文言があり、印象がよくない
  • デザインのカスタマイズが面倒。なんだか重い
  • URLが視聴者の国によって変わる。blogspot.jp になったり blogspot.com になったり

ほかにも WordPress.com も無料ブログサービスだが、少し見たが使い方が難しそうだった。



現在は はてなダイアリーをメインに使っている。

しかし「はてな」は はてなブログへ移行するのを勧めている。しかしはてなブログに移るとブログURLが変わってしまうし、はてなダイアリーになかった問題もでてくる。どうせブログURLが変わるなら、ほかのサービスに移るのも一つの手だ。



はてなブログは 1記事2URL を回避できない(しかしなぜ日付にリンク貼るのか理解できない。日記という用途を重視ということか)ので、あまりそそられない。

Bloggerは記事書くのが面倒。移行先として有力なのはTumblr。でも記事書いて画像貼るのがラクなのは はてなブログが一番かも。



必ず結果が出るブログ運営テクニック100 プロ・ブロガーが教える“俺メディア”の極意

必ず結果が出るブログ運営テクニック100 プロ・ブロガーが教える“俺メディア”の極意


Webページの文字列を置き換えするコマンド(ブックマークレット)

$
0
0

Webページの文字列を置き換えするコマンドをbookmarkletで作成したのでメモ。


1. bookmarkを追加して、URLに以下を入れる。bookmarkのタイトルは「[置換]」とかにする。

javascript:(function(){s=prompt('検索する文字列');d=prompt('置換後の文字列');document.body.innerHTML=document.body.innerHTML.replace(s,d,'g');})()


2. 文字を置換したいページで、そのbookmarkを選択する。

f:id:itouhiro:20130411004547p:plain





3. 置換文字入力ボックスが2回出てくる。最初のに置換元、次の入力欄に置換後の文字列を入れればよい。
f:id:itouhiro:20130411004841p:plain


作った理由

以下のページで、「いいこと書かれてるんだけど語尾が読みにくいので文字置換をしたい」と書かれている。
http://b.hatena.ne.jp/entry/togetter.com/li/477867


私も置換したくて、JavaScriptでなんとかならないか調べたら、bookmarkletしかなかった。ブラウザのURL欄に入力するのは昨今のブラウザでは無効らしい。

javascript:(function(){s='砂';d='す';document.body.innerHTML=document.body.innerHTML.replace(s,d,'g');})

ソースのsはsourceの略。dはdestinationの略。




 

GoogleChrome27でUserScriptがiframe内部で動作しない件

$
0
0

GoogleChrome27でUserScript(拙作WebAborn)が動作しないことがあると報告いただきました。


「userscript Google Chrome 27」でGoogle検索したところ、海外サイトに回答が見つかりました。iframeの内部ではUserScriptが無効になるようです。

追記: 2013-07-11
Google Chrome 28では修正されました。以下の問題はありません。


こちらでもiframeテストしてみました。再現しました。テストURL: http://japaneseinput.web.fc2.com/xpath/iframeTest-top.html

f:id:itouhiro:20130528015606p:plain


原因

Google Chrome 27の記事
http://www.forest.impress.co.jp/docs/news/20130408_594976.html
を読むと、Google Chrome 27ではJavaScriptの実行について仕様変更されているので、それが原因と思われます。


http://stackoverflow.com/questions/16695289/userscript-no-longer-runs-on-iframes-in-chrome-27
の修正方法( %PROFILE%\Default\Extensions\ランダム文字列\1.0_0\manifest.jsonに「"all_frames" : true,」を追加)は試したけど効果ありませんでした。


一時しのぎの対処法ですがUser Stylesheetでiframeを表示しない方法を試したら、GoogleChromeの「履歴」「設定」なども表示されません。この対処法もよくないです。

結論

https://code.google.com/p/chromium/issues/detail?id=242710
に不具合報告が上がっているので、そのうちGoogle Chromeが修正されるのではないでしょうか。
修正されるまではGoogleChrome旧版か、Firefoxを使うのがよいと思います。


追記: 2013-07-11
Google Chrome 28で確認したところ、修正されていました。


最近のFirefoxはVer19くらいでまた軽くなりました。
一方GoogleChromeはVer22?からMacTypeも効果ないですし、 User Javascriptのインストール手順も面倒になってきています。




 

PixelMplus(ピクセル・エムプラス) ‥ 8bitビットマップふうフリーフォント

$
0
0

f:id:itouhiro:20130601225314p:plain


PixelMplus(ピクセル・エムプラス)というフォントを作成しました。
8bitゲーム機のビットマップフォントのような感じを出せるフリーフォントです。

特徴


ビットマップフォントのように見えるが、アウトラインのみのTrueTypeフォント。埋め込みビットマップは なし。ボールド体(太字)あり。

f:id:itouhiro:20130602124852p:plain




JIS第1・第2水準のすべての漢字を収録。ISO-8859-1(Latin-1)の文字も収録。そのほかにもいくつかの記号を追加。

f:id:itouhiro:20130602122311p:plain

ヿ〼     ヿ
テハートのエレヘーター デパートのエレベーター

記号 紋章は☀♨☂ この武器は〠!

方向指示 ▷▶◁◀

トランプマーク ♤♠♢♦♡♥♧♣



実体は単なるTrueType等幅フォントテキストエディターで使用することもできる。

f:id:itouhiro:20130601232148p:plain




ライセンスは自由なM+ FONT LICENSE。
元にしたM+ bitmap fontsは10年以上前から使用されているので安心して使用できる。

これらのフォントはフリー(自由な)ソフトウエアです。
あらゆる改変の有無に関わらず、また商業的な利用であっても、自由にご利用、複製、再配布することができますが、全て無保証とさせていただきます。


引用元: http://mplus-fonts.sourceforge.jp/mplus-bitmap-fonts/#license

ダウンロード


http://sourceforge.jp/projects/mix-mplus-ipa/downloads/58930/PixelMplus-20130602.zip/のダウンロード (1.4MB)


PixelMplus12 と PixelMplus10 の2種類のフォントがあります。
元にしたビットマップフォントが 12ピクセルであるか、10ピクセルであるか、の点が違います。
どちらも大きさは同じです。



制限事項

縦書きには対応していません。



謝辞

PixelMplusは、ビットマップフォント M+ bitmap fonts http://mplus-fonts.sourceforge.jp/mplus-bitmap-fonts/をアウトライン化したフォントです。
M+ FONTS PROJECTの皆さんありがとうございます。


JIS X 0213Unicode文字コード変換表は以下を使用させていただきました。


冒頭のRPG的画像は「First Seed Material」 http://www.tekepon.net/fsm/の提供フリー素材「マップチップ」「キャラクターチップ」を使用させていただきました。



制作メモ

ソースコード、BDFファイル等
http://sourceforge.jp/projects/mix-mplus-ipa/downloads/58930/PixelMplus-20130602-src.tar.xz/のダウンロード(1.8MB)


制作環境

ビットマップフォント(BDF)編集


アウトラインフォント生成


BDF仕様については以下を参照。
http://hp.vector.co.jp/authors/VA013241/font/bdf.html


JIS X 0213の含む文字については以下を参照。
http://www.asahi-net.or.jp/~ax2s-kmtn/ref/jisx0213/









 

フォントの縦書きグリフを確認するIllustratorCS5向けjsxスクリプト

$
0
0

f:id:itouhiro:20130717003317p:plain


M+ LOG にある記事 http://mplus-fonts.sourceforge.jp/cgi-bin/blosxom.cgi/2013/07/05#mplus_fonts-130705-2の画像のように表示して、フォントの縦書きグリフを確認したい。
しかしIllustratorに不慣れな私が手作業で文字を置くと、正確な位置に置けない気がする。


そこで、文字を配置してくれるAdobe Illustrator CS5向けのjsxを作成した。

verticaltext.jsx

// http://mplus-fonts.sourceforge.jp/cgi-bin/blosxom.cgi/2013/07/05#mplus_fonts-130705-2 と同じような表を作成する

fontName = 'mplus-1p-bold';
fontSize = 32;
lineGap = 8;

// http://ja.wikipedia.org/wiki/引用符 , http://ja.wikipedia.org/wiki/括弧
texts = [
  '■あ亜',
  '‥…、。',
  '〈〉《》「」',
  '『』【】〔〕',
  '〖〗〘〙〜',
  'ぁぃぅぇぉ',
  'っゃゅょ',
  'ァィゥェォ',
  'ッャュョヮ',
  'ヵヶー()',
  ',.:=',
  '[]{}~',
  '― ̄_〝〟〞',
  '‘’“”',
  'ゎゕゖ',
];

theDoc = app.activeDocument;
theLayer = theDoc.activeLayer;
maxLength = 0;
for (i=0; i<texts.length; i++) {
  if (texts[i].length > maxLength) maxLength = texts[i].length;
}
for (i=0; i<texts.length; i++) {
  for (j=0; j<maxLength; j++) {
    putBox(-50-(fontSize*j), theDoc.width-50-((fontSize+lineGap)*i), fontSize,fontSize);
  }
  for (j=0; j<texts[i].length; j++) {
    letter = texts[i].charAt(j);
    putLetter(-50-(fontSize*j), theDoc.width-50-((fontSize+lineGap)*i), letter);
  }
}

function setColor(r, g, b) {
  var col = new RGBColor();
  col.red = r;
  col.green = g;
  col.blue = b;
  return col;
}

function putBox(atop, aleft, w, h) {
  rect = theLayer.pathItems.rectangle(atop,aleft, w,h);
  rect.filled = false; //塗り
  rect.stroked = true; //線
  rect.strokeWidth = 0.7; //pt
  rect.strokeColor = setColor(0xE5, 0xE5, 0xE5);
}

// http://cssdk.host.adobe.com/sdk/1.0/docs/WebHelp/references/csawlib/com/adobe/illustrator/package-detail.html
// http://logic.moo.jp/memo.php/category/10/tag/illustrator/
// http://d.hatena.ne.jp/itouhiro/20090614
function putLetter(atop, aleft, txt) {
  var caption = theLayer.textFrames.add();
  caption.top = atop + fontSize/5;
  caption.left = aleft + fontSize/10;
  caption.contents = string_as_unicode_escape(txt);
  caption.textRange.characterAttributes.textFont = app.textFonts.getByName(fontName);
  caption.textRange.characterAttributes.size = fontSize/4;
  caption.textRange.characterAttributes.fillColor = setColor(0xE0, 0xE0, 0xFF);

  var letter = theLayer.textFrames.add();
  letter.top = atop + fontSize/3;
  letter.left = aleft + fontSize/2;
  letter.contents = txt;
  letter.orientation = TextOrientation.VERTICAL;
  letter.textRange.characterAttributes.textFont = app.textFonts.getByName(fontName);
  letter.textRange.characterAttributes.size = fontSize;
}

// http://stackoverflow.com/questions/5786483/char-to-hex-in-javascript
function string_as_unicode_escape(input) {
    function pad_four(input) {
        var l = input.length;
        if (l == 0) return '0000';
        if (l == 1) return '000' + input;
        if (l == 2) return '00' + input;
        if (l == 3) return '0' + input;
        return input;
    }
    var output = '';
    for (var i = 0, l = input.length; i < l; i++)
        output += 'U+' + pad_four(input.charCodeAt(i).toString(16).toUpperCase());
    return output;
}


実行方法は以下。

  1. 上のスクリプトをテキストファイルに保存する。文字コードUTF-8にする。
  2. Illustrator CS5で[ファイル-新規]で新規ドキュメントをひらく。「プリント A4 横」などにする。
  3. [ファイル-スクリプト-その他のスクリプト]で、保存したテキストファイルを選択する。

fontNameは http://logic.moo.jp/data/archives/788.htmlで調べた。
fontSizeの数値の単位はpt。



http://sourceforge.jp/projects/mplus-fonts/lists/archive/dev/2013-July/000736.htmlでM+フォントの縦書き改善の報告と、試作フォントが提示されていたので、Illustratorでの表示を確認するために作成した。

この記事冒頭の画像は M+ 1p bold での表示だが、かなり改善されたことを確認できた。



Illustrator ABC

Illustrator ABC





 

ATOK 2013のローマ字入力で、候補ウィンドウで数字キーを打鍵して文字入力できない件

$
0
0

[話者] ATOK2013で こまってることがある。


漢字変換の選択候補を出しているとき、

  • 「かな入力」なら 1,2,..,9,0 のキーを押すと変換確定して、次の文字を入力できるのだが、
  • 「ローマ字入力」では 1,2,..,9,0 のキーを押しても「変換確定して次の文字入力」にならないんだ。


[合いの手]な、何を言っているんだ? 意味がわからないよ。


[話者]「かな入力」だと以下の画像のようになる。


かな入力時の「ぬ(1)」~「わ(0)」の動作で「カナを入力」を選んだときと、「候補選択」を選んだときの挙動の違いだ。


f:id:itouhiro:20130722172819g:plain

[合いの手]う、うん。


[話者]オレはこの画像の(4)~(6)の手順をいつも使って漢字変換していたんだ。


数字キーで候補選択は しない。候補選択はいつも、[SPACE]キー連打したりカーソルキーで戻したりして選ぶ。


で[SPACE]キーで候補を選択してある状態で、次に入力したい文字(または[Enter]キー)を入力することで、変換確定をしていた。


[合いの手]それで?


[話者]「ローマ字入力」には「候補選択」しかないんだ。「文字を入力」がない。この画像見てくれよ。
f:id:itouhiro:20130503004119p:plain


どっちを選んでも、「候補選択」が変わるだけなんだ。
f:id:itouhiro:20130722172958p:plain



[合いの手]でも、ローマ字入力では「数字キー」は文字入力に使わないよね。候補選択キーを「数字」にしておいたらいいんじゃないの?


[話者]いや、使うだろ。たとえばさ、
「○○化学10株」と書こうとして、

  1. かがく と入力して、[space]を2回押したら選択候補ウィンドウがでてくる。
  2. 「化学」という候補を選択する。
  3. 「10株」と入力するために [1]キーを押す。
  4. すると「科学」と変換確定されてしまったではないか。
    文字入力のために[1]キーを押したのに、候補選択のために[1]を押したと、ATOKが誤認識したのだ。


[合いの手]なるほど。確かに数字入力で始まることもあるねえ。


[話者]ATOKの この挙動 直してくれないかなあ、と思うわけさ。


ちなみにGoogle日本語入力は、ローマ字入力か かな入力かに関わらず、候補選択キーを

  • なし
  • 1-9
  • A-L

で選択できる。

f:id:itouhiro:20130722180028g:plain


[合いの手]ATOKが気に入らないならGoogle日本語入力使えということか。


[話者]でもATOKはよろしくない日本語を注意してくれるとか良い点もあるからな。
Google日本語入力しかないというのもいやだし。ATOKにも奮起してもらいたい。


[合いの手]実際、Google日本語入力はオープンソースだし今後も残るだろうけど、ATOKは危なっかしく感じるよ。










 

Unityで外部ファイルの読み書き(C#)

$
0
0

Unityで外部テキストファイルを読み書きしてみる。そのあとで画像の読み込みもする。

環境

Unity4.1.5
Windows7 64bit

Path

まずはPathを調べる。

using UnityEngine;
using System.Collections;

public class Camera : MonoBehaviour {
	private string pathtxt = "";

	// Use this for initialization
	void Start () {
		string txt = Application.dataPath;
		string txt2 = Application.persistentDataPath;
		pathtxt = "dataPath:"+txt+"\npersistentDataPath:"+txt2;
		Debug.Log(pathtxt);
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	void OnGUI(){
		GUI.TextArea(new Rect(5,5,Screen.width,50), pathtxt);
	}
}

UnityEditorで実行した場合
f:id:itouhiro:20130825223448p:plain
ちなみにProjectは以下にある。 C:\Users\***\Documents\tryExternalText



Windowsアプリ化した場合
f:id:itouhiro:20130825224039p:plain
ちなみに Z:\WinApp.exe にexeを配置している。これだけでは動作しないので、Z:\WinApp_Data (フォルダー) も配置した。


ところでCamera.csというファイルはシステムでも使われてるのでファイル名変えてくれ、とUnityから警告されていた。Main.csに変更する。


ファイル書込

次にファイルを書き込んでみる。このソースコード Main.cs は、Unity+MonoDevelopのデフォルト環境で作成したが、文字コードUTF-8 BOMなし LF だった。

using UnityEngine;
using System.Collections;
using System.IO; //System.IO.FileInfo, System.IO.StreamReader, System.IO.StreamWriter
using System; //Exception
using System.Text; //Encoding

public class Main : MonoBehaviour {
	private string guitxt = "";
	private string outputFileName = "tryExternalText.txt";
	// Use this for initialization
	void Start () {
		string txt = Application.dataPath;
		string txt2 = Application.persistentDataPath;
		guitxt = "dataPath:"+txt+"\npersistentDataPath:"+txt2+"\n";
		ReadFile();
		Debug.Log(guitxt);
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	void OnGUI(){
		GUI.TextArea(new Rect(5,5,Screen.width,50), guitxt);
	}
	
	void WriteFile(string txt){
		FileInfo fi = new FileInfo(Application.dataPath + "/" + outputFileName);
		using (StreamWriter sw = fi.AppendText()){
			sw.WriteLine(guitxt);
		}
	}
	
	void ReadFile(){
		FileInfo fi = new FileInfo(Application.dataPath + "/" + outputFileName);
		try {
			using (StreamReader sr = new StreamReader(fi.OpenRead(), Encoding.UTF8)){
				guitxt = sr.ReadToEnd();
			}
		} catch (Exception e){
			guitxt += SetDefaultText();
			WriteFile(guitxt);
		}
	}
	
	string SetDefaultText(){
		return "C#あ\n";
	}
}

f:id:itouhiro:20130826112450p:plain


なんだか書き込むとき文字が化ける。
UTF-8の「あ」は 0xE3 0x81 0x82 なのだが、書き込まれたバイト列は 0xE7 0xB8 0xBA 0x3F 0x6E だった。後半の2バイトは"C#あ\n"の後ろの \ n なのか。ちなみにこの \n をソースコードから除去すると parsing errorでUnityでコンパイル・実行できない。


ファイル読込

いっぽう読み込みは‥‥
f:id:itouhiro:20130826113414p:plain
tryExternalText.txtの中身を書き換えてやると、読み込みは問題ない。WinApp化しても同じだった。


日本語文字列はソースコードに埋め込まず、外部テキストファイルに持たせるのが賢いかもしれない。


外部画像ファイルを読み込む

次は外部JPGファイルを読み込む。Planeのテクスチャーとして貼る。
ちなみに Camera pos(0,10,0) Rot(90,0,0) scale(1,1,1)
Plane pos(0,0,0) Rot(0,0,0) scale(1,1,1)

using UnityEngine;
using System.Collections;
using System.IO; //FileStream

public class Plane : MonoBehaviour {
	private string imgFile = "unsplash.com-rula-sibai-pink-flowers-small.jpg";
	
	// Use this for initialization
	void Start () {
		Texture2D tex = new Texture2D(0,0);
		tex.LoadImage(LoadBin(Application.dataPath + "/" + imgFile));
		gameObject.renderer.material.mainTexture = tex;
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	byte[] LoadBin(string path){
		FileStream fs = new FileStream(path, FileMode.Open);
		BinaryReader br = new BinaryReader(fs);
		byte[] buf = br.ReadBytes( (int)br.BaseStream.Length);
		br.Close();
		return buf;
	}
}

f:id:itouhiro:20130826140344p:plain

画像ファイルは http://unsplash.com/のPublic domain画像を使用。
Planeのサイズを画像の縦横比とあわせないといけないのか。


元画像と上下も反転してるが、これは Camera Rot(90,180,0)にしたら直った。
f:id:itouhiro:20130826142658j:plain







 

Windowsでgit環境を整える

$
0
0

PortableGitをインストール
PortableGit-1.8.3-preview20130601.7z
設定の参考
http://blog.segu.jp/2012/05/git-portable.html

git-bash.batに以下を追加

set HOME=C:\Users\%USERNAME%\Documents
cd %HOME%

コマンドプロンプトの見た目を変える

bash設定

ブランチ名をプロンプトに表示
http://d.hatena.ne.jp/hirose31/20090519/1242664458
を参考にした。PortableGitインストール先のc:/home/bin/PortableGit/etc/git-completion.bashをそのまま読み込む。

GIT_COMPL='../../../home/bin/PortableGit/etc/git-completion.bash'if [-r"$GIT_COMPL"];thenexport PS1="\$(__git_ps1 \"\e[36m%s\e[m \")\e[33m\w\$\e[m "elseexport PS1="\e[33m\w\$\e[m "fi

プロンプトの色変更について
http://www.m-bsys.com/linux/echo-color-1
を参考にした。


git logのフォーマットを変更
http://stackoverflow.com/questions/7853332/git-log-date-formats
を参考に。

# for Git-BashGIT_COMPL='../../../home/bin/PortableGit/etc/git-completion.bash'if [-r"$GIT_COMPL"];thenexport PS1="\$(__git_ps1 \"\e[36m%s\e[m \")\e[33m\w\$\e[m "elseexport PS1="\e[33m\w\$\e[m "fialias ls="ls -Fa --show-control-chars"alias ll="ls -l"alias lr="ll -tr"alias lv="less"alias gs="git status --porcelain -b"alias gl="git log -n30 --pretty=format:'%Cgreen%ad%x08%x08%x08%x08%x08%x08%x08%x08%x08%Creset %s' --date=iso"alias gw="git whatchanged"


http://nuclearsquid.com/writings/git-tricks-tips-workflows/
を参考に、gitの代わりに g と入力すればよいようにした。
$ g co te[TAB]

$ git checkout te[TAB]
と同じように、testing というブランチ名が補完される。

# for Git-Bash
GIT_COMPL='../../../home/bin/PortableGit/etc/git-completion.bash'
if [ -r "$GIT_COMPL" ]; then
  export PS1="\$(__git_ps1 \"\e[36m%s\e[m \")\e[33m\w\$\e[m "
else
  export PS1="\e[33m\w\$\e[m "
fi
alias ls="ls -Fa --show-control-chars"
alias ll="ls -l"
alias lr="ll -tr"
alias lv="less"
alias gs="git status --porcelain -b"
# n24,n25.. needs hitting-key more
alias gl="git log -n22 --pretty=format:'%Cgreen%ad%x08%x08%x08%x08%x08%x08%x08%x08%x08%Creset %s' --date=iso"
alias gw="git whatchanged -n22"
alias gb="git branch"
alias g='git'
complete -o default -o nospace -F _git g

ちなみに alias gc='git checkout' だけだとブランチ名補完がきかない。


UnityのC#ファイルをEmacsで編集(Windows)

$
0
0

環境

EmacsMonoDevelopやVisualStudioと比較したあと、EmacsC#設定を示します。

MonoDevelop

f:id:itouhiro:20130921234827p:plain
Unity付属のテキストエディタMonoDevelopはインテリセンス的補完や動的補完(Emacsでいう dynamic abbribiation 略してdabbrevVimの入力補完)もできるしEmacsキーバインドにもできて なかなかよいのだが、問題もある。

  • 日本語入力中に文字が見えない。漢字変換し終わったら見えるが、ひらがな入力中・漢字変換中に見えないので困る。
  • なんか動作が遅い。もっとキビキビ動いてほしいなあ。


あとUnity本体にも問題がある。

  • C#ファイル」を新規作成すると「UTF-8 BOM無し」ファイルを作るのだが、これだとWindows版Unity4.1.5で日本語含むC#ファイルがコンパイルエラーを起こす(Mac版ではコンパイルエラーにならない)。「UTF-8 BOM有り」に変換するとWindowsでコンパイル通る。

VisualStudio 2010 Express

f:id:itouhiro:20130921234946p:plain

にも同じことが書いてある。そこではVisualStudioを使うとよい、と書かれているのでやってみた。しかし私の場合だめだった。

  • インテリセンス補完が効かない。

VisualStudioには動的補完がないようなので、インテリセンスで補完できないのは、ぜんぜん補完できないということだ。無料版のExpressなのが悪いのだろうか? 私の設定がまずいのか? いちおうUnityEditor.dll指定してるはずなのだが。

あと

  • 改行コードがLFとCRLFが混ざる。
  • TABと半角空白の区別が見た目でつかない。(設定でどうにかなる?)

という問題もある。


Emacs for gnupack

f:id:itouhiro:20130921235155p:plain
そこで使い慣れたEmacsです。

  • csharp-modeというのを導入すればインデントやキーワード色つけが可能だ。
  • インテリセンス補完はないが、dabbrevがあるので、すでにEmacsの読み込んだファイルのどこかに単語があれば補完できる。
  • 「*.cs」という拡張子のファイルを保存するとき、文字コードUTF-8 BOM有り」改行コード「LF」に自動変換できる。
  • 改行コードLFとCRLFが混ざったのも一目で見て分かる、修正できる。
  • TAB文字と半角空白の区別、trailing whitespaceも、設定次第でカラー表示できる。
  • 動作もキビキビ。起動だけは遅めだ(MonoDevelopやVisualStudioよりは早い)が、Unityと組み合わせるときの私の設定だと「Unityより前」に起動しておいて、ずーっと起動しっぱなしで使うので問題ない。


ただし csharp-mode を導入してもインデントが変だ。
http://www.emacswiki.org/emacs/CSharpModeの画像のインデント、奇妙でしょう。
f:id:itouhiro:20130921235452p:plain
関数のインデントはいいのだが、その中のifやforで {} が後ろに下がる。

  if (a == b)
      {
          Debug.Log("good");
      }

みたいになるのだ。

に修正方法が書いてあったが、そのとおりにしても、こちらの環境では直らない。

の設定ファイルは効果があった。
ただしインデントが半角空白x2だったので、半角空白x4になおしたのが以下。

csharp-setting.el: modify csharp-mode setting. copied alm ...

これで VisualStudio準拠のC#コーディング規則 http://msdn.microsoft.com/ja-jp/library/ff926074.aspxC#書ける。


Emacs自体の設定は

[SetEnv]
    _font_         = Ricty Discord
    HOME           = z:\home

[Emacs]
    geometry       = 100x60+0+0
    fontName       = %_font_%
    fontSize       = 12
    colorTheme     = simple-1
  • Z:\home\.emacs.d 配下に init.elやcsharp-mode.elを置く。
  • Windowsの環境変数設定で EMACS_SERVER_FILE=Z:\home\.emacs.d\server\server と指定。

f:id:itouhiro:20130922002710p:plain

  • Unityで [Edit - Preference - External - Editor] を開いてC:\home\bin\gnupack\app\emacs\emacs\bin\emacsclientw.exe と指定する。
  • Emacsをあらかじめ起動しておく。
  • UnityでC#ファイルをダブルクリックすると、Emacsで読み込まれる。
  • EmacsC#ファイルを閉じるのは通常の操作(私はC-x bでBufferList出してd x)ではだめで、C-x # とする。しかし多数のファイルを開いてしまっていてまとめて閉じたいときにそれは面倒なので、そんなときはEmacs自体を一度閉じてまた起動する。
  • なぜかUnityでC#ダブルクリックしてもEmacsが反応しなくなってしまったときはEmacsを再起動。


私のEmacs設定すべてについては
https://gist.github.com/itouhiroの init.el, emacs23.el, ntemacs23.el, ntemacs24.el にある。上に示したcsharp-sedtting.elというのは実際にはntemacs23.elに含んでいる。Emacs24.2の設定だがEmacs23でも使える。





Emacs実践入門 ?思考を直感的にコード化し、開発を加速する (WEB+DB PRESS plus)

Emacs実践入門 ?思考を直感的にコード化し、開発を加速する (WEB+DB PRESS plus)


 

C#とUnity4で書籍『Unity入門』(1)

$
0
0

サポートサイト http://unity-yb.github.io/

[話者]の本でUnityを学ぶ。ただしこの本は

という動作環境の説明になっていて、現在の主流の

  • Unity 4.x
  • C#

の環境とズレがある。
そこで、その差を埋めながら学ぶのをこのブログに記録しておくぞ。

[合いの手]ネットではver3の本は今となっては役に立たないぞとか言われてるけど、そうなの?


[話者]そんなことはないぞ。後述するけどパーティクルもアニメーションも旧システムが残されてるから、それを選べば、この本はそのまま実行できる。

さて http://unity3d.com/unity/download/archiveで無料版Unityを取得する。

環境

Chapter 1 Unityスタートガイド

Unity3.4の後、2013年10月現在はいろいろUnityも変わった。この本の説明との違いを挙げると‥‥

  • Unity Android / Unity iPhoneを無料版で使用できる。
  • Unity3.5より、パーティクルシステムが新しくなった。Shurikenシュリケン)と呼ばれる。以前のも使用可能。
  • Unity4.0より、アニメーションシステムが新しくなった。Mecanim(メカニム)と呼ばれる。以前のも使用可能。
  • Unity4.0より、モバイル版でもダイナミックフォント使用可能になった。
  • Unity4.2より、デスクトップ版のみリアルタイムシャドウを無料版で使用できる。
  • Unity3.5より、外部バージョン管理システムを無料版で使用できる。Unity4.2ではForceTextも可能。
  • Unity3.5でFlash出力(プレビュー版)が有効になり、Unity4.0以降は製品版を購入できたが、Unity4.2の前にFlash出力停止された。


[合いの手]いろいろ無料になってるんだね。


Chapter 2 バランスゲーム

f:id:itouhiro:20130930235222p:plain

[話者] Sceneビューの操作、この本Mac基準に書いてあるので

視線旋回
Altキー+マウスドラッグ
視点の平行移動
Altキー+コマンドキー(WindowsではCtrlキー)+マウスドラッグ
ズームアップ
マウスホイール
オブジェクトに視点合わせ
[F]キー

とか書いてあるけど、Windowsなら

視線旋回
右ドラッグ(右クリックしたあと押したままマウス移動)
視点の平行移動
ホイールドラッグ(ホイールをクリックしたあと押したままマウス移動)

で可能だ。‥‥と思ったのだが、「Alt+ドラッグ」と「右ドラッグ」は挙動が違う。

  • 「Alt+ドラッグ」は(0,0,0)中心の回転
  • 「右ドラッグ」はSceneパネル最下部中央を中心とした回転




板に[Component - Physics - RigidBody]を与えた上で IsKinematic をONにしているが、これRigidBodyを与えない場合でも同じ挙動なんだよな。PhysicMaterialもRigidBodyなくても指定できるし。


Windowsアプリにしたら、いきなり最大化でどう停止するかこまった。Alt+Enterで通常のウィンドウに戻った。


Unity3とUnity4の違いは、この章では現れなかった。


JavaScript(JS)をC#に書き換えるのは、この章では以下だけだ。

  1. Vector3(0,0,1)new Vector3(0,0,1)
  2. 小数点のある数字 30.0はfをつける → 30.0f


[合いの手]この章はスクリプト2行しか書かないからね。


[話者]他にもJSでfunction Update()C#void Update()も違うけど、これは最初から入力されて用意されてるから問題じゃないだろ。



Chapter 3 モバイル向けにビルド


Chapter2で作ったサンプルを、モバイル向けに再設計している。ソースコードを2行書き換えている。
PlayerSettingのBundleIdentifier(バンドル識別子)に「地域コード.開発者名.アプリ名」使うののが一般的らしい。「jp.yamada.BallAndCube」みたいに。


この章はそれだけかな。



Chapter 4 迷路ゲーム

f:id:itouhiro:20131002161230p:plain


あらかじめ説明しとくと、UnityのJavaScriptでは
function OnTriggerEnter (other : Collider) { .. }

function OnTriggerEnter (other : Collider):void { .. }
と書くこともできる。関数の返り値の型「:void」とか「:int」とかは書いてもいいけど省略できるんだ。ちなみに本物のJavaScriptでは「:void」とか指定するとダメだぞ。“Unityの” JavaScriptは特殊なんだ。


C#の場合、関数は
void OnTriggerEnter (Collider other) { .. }
のように書く。

  • 「function」は要らない
  • JavaScriptで「:void」「:Collider」のように書いていた「:」以下の型指定を、関数名・変数名の「前」に書く

これを守ればあとは機械的に書き換えればよい。


[合いの手] UnityのJavaScriptは本物と違うのか‥‥。


[話者]そうなのさ。でもC#は本物と同じだぞ。
JavaScriptC#に書き換えるのは、この章では以下だ。

Trap.js→Trap.cs

function OnTriggerEnter (other : Collider)
↓
void OnTriggerEnter(Collider otherObj)  //C#では「function」はいらない。返り値の型を明示。



var respawn : GameObject = GameObject.FindWithTag("Respawn");
↓
GameObject respawn = GameObject.FindWithTag("Respawn");
または
var respawn = GameObject.FindWithTag("Respawn"); //C#では代入文など型を推定できる場合、型を「var」とも書ける。


Goal.js→Goal.cs

var labelStyle : GUIStyle;
private var ballCount : int; // public class Goal : MonoBehaviour { .. } の中に書くこと
private var counter : int;
private var cleared : boolean;
↓
public GUIStyle labelStyle;
private int ballCount;
private int counter;
private bool cleared;



ballCount = GameObject.FindGameObjectsWithTag("Ball").length;
↓
ballCount = GameObject.FindGameObjectsWithTag("Ball").Length;



var sw  : int = Screen.width;
var sh  : int = Screen.height;
GUI.Label(Rect(sw/6, sh/3, sw*2/3, sh/3), "CLEAR !!", labelStyle);
↓
int sw = Screen.width;
int sh = Screen.height;
GUI.Label(new Rect(sw/6, sh/3, sw*2/3, sh/3), "CLEAR !!", labelStyle);



function OnTriggerEnter (otherObj : Collider) {
‥‥
yield WaitForSeconds(2.0);
Application.LoadLevel("Title");
↓
void OnTriggerEnter(Collider otherObj) {
‥‥
Invoke("ChangeSceneToTitle", 2.0f); //Unity-JavascriptのyieldはC#では同じようには使えない

void ChangeSceneToTitle()
{
    Application.LoadLevel("Title");
}

こんな感じ。Unity-JavaScriptyield WaitForSeconds(2.0);は単にC#yield return new WaitForSeconds(2.0);と書き換えるだけでは動作しないんだよね。以下に詳しく書いてある。今回はInvoke()で置き換えた。


ちなみに、
JSでVector3(0,0,1)のように数値を指定する場合、C#new Vector3(0,0,1)と書くが、JSでVector3.forwardのように既に指定済みの数値を使う場合、C#でもVector3.forwardでよい。

この要領で、ほかも書き換えればいい。


[合いの手]今回はJavaScriptC#の書き換え箇所も多めだね。


[話者]でもyieldを除けば、機械的な書き換えですむから難しくないよ。


Unity3とUnity4の違いだが、フォント関連に違いがある。

「Unity3.4ではモバイルでダイナミックフォントが使えない」とこの本に書いてあるが、Unity4.0以降はモバイルでもダイナミックフォント使えるようになってる。だからデスクトップ(Windows/Mac)の設定のままで、モバイル(Android/iPhone)でも文字表示できるぞ。

f:id:itouhiro:20131002190510p:plain


あとAndroidの[戻る]ボタンで終了するために、TitleScreen.csとGravityController.csのUpdate()に以下を入れておくとよい。

        //PCでESC or Androidで[戻る]
        if(Input.GetKey(KeyCode.Escape)) Application.Quit();


思ったんだが、これは画面横より縦のほうがいい気がする。縦にする場合、操作方向が変わるので以下の変更が必要だ。

        //Physics.gravity = new Vector3(-accel.y, accel.z, accel.x) * 50.0f;
        Physics.gravity = new Vector3(accel.x, accel.z, accel.y) * 50.0f;

f:id:itouhiro:20131005215057j:plain





 

WindowsXP+一太郎2013でgdi++,gdipp,MacTypeを調査

$
0
0

縦書き

WindowsXP一太郎2013で試した。

一太郎2013 玄 特別優待版 DL版 [ダウンロード]

一太郎2013 玄 特別優待版 DL版 [ダウンロード]




横書きならgdipp効いている。
画像: 一太郎からClearType表示はしていない。gdippの効果で文字が滑らか
f:id:itouhiro:20130501231718p:plain



[ファイル-文書スタイル-縦組み文書に変換]で縦書きに変換すると‥‥。
f:id:itouhiro:20130501232041p:plain



縦書きはgdi++,MacType等どれもFreeType効果ないことがわかった。
画像: ClearTypeの効いてない画面。これはガタガタだ
f:id:itouhiro:20130501231544p:plain



一太郎の機能でClearType効かせることならできる。これでよしとするしかないようだ。
画像: ClearTypeの効いた画面。さきほどよりはマシになった。FreeTypeに比べるとガタつきがあるのだ‥‥
f:id:itouhiro:20130501231557p:plain


エディタモードでも横書きならキレイ。
f:id:itouhiro:20130501232430p:plain


前置き

WindowsXP/7ではフォントのアンチエイリアス表示に ClearTypeが使われている。これは欧米では評価が高いそうだが、日本語に関してはガタついた感じに見えてよろしくない。


Windowsは「メイリオ」フォントだけはClearTypeでキレイに見えるよう調整されているが、ほかのフォントはガタガタだ。


それを補うために、Linuxで使われているFreeTypeWindowsのフォントレンダラーとして使うソフトが現れた。


gdi++FreeType版は日本生まれだが、開発が止まってしまった。これはソースコードを公開していたので、後継バージョンを生み出すことになる。


gdi++ Heliumは日本の開発者が gdi++を開発して軽量化したものだ。しかし「ソースはいつか公開する」といいながら一度も公開せずに、開発が止まった。


gdippは中国の開発者が、gdi++を元に開発している。
MacTypeも中国の開発者が開発している。これもgdi++を元にしてると思われる。ClearTypeに不満がある漢字圏のユーザーだけが開発しているのが現状だ。

Arch Linux 2014.07.03 をVirtualBoxにインストール

$
0
0

Debian6の上で動作するVirtualBox 4.3.14内で、Arch Linux 2014.07.03 をインストールしました。その記録。

手順は
http://note.chiebukuro.yahoo.co.jp/detail/n267693
を参考にしました。


基本システムをインストール

まずは 558MBのisoファイルをダウンロード。

f:id:itouhiro:20140730085303p:plain
f:id:itouhiro:20140730085511p:plain


VirtualBoxで仮想ディスクを作成し、isoをセット([Setting - Storage - Empty - CD/DVD drive - Choose a virtual CD/DVD file..])して、起動。設定は[メモリ 512MB, HDD 40GB, Audioなし] あとはデフォルトです。
f:id:itouhiro:20140730194818p:plain


Linuxのインストールは一般的には簡単なのですが、Arch Linuxは難しい感じです。それはインストール領域(パーティション)を自分で指定する必要があるから。


cfdiskを使います。
f:id:itouhiro:20140730090225p:plain

swap /dev/sda1
linux /dev/sda2

の2パーティションを作成します。
まずswap領域を 1 GBで作成。[New → Primary → 1024 → End → Type → 82]
残りの領域を linuxに割り当て。 [New → Primary → Enter → Beginning → Bootable] (このBeginning → Bootableはやらなくてよいかも。というかやってない)
[Write → yes → Quit]

f:id:itouhiro:20140730092528g:plain

確保した領域に対して、ファイルシステム・SWAP作成。

# mkfs.ext4 /dev/sda1
# mkfs.ext4 /dev/sda2

# mount /dev/sda2 /mnt
# mkswap /dev/sda1
# swapon /dev/sda1

f:id:itouhiro:20140730093037p:plain


次はbase systemをネット経由で取得するらしい。mirror list のテキストファイルを編集します。

# vi /etc/pacman.d/mirrorlist

f:id:itouhiro:20140730093617p:plain


Japan を上に持ってきて保存。
それでは基本ファイルをインストール。

# pacstrap /mnt base base-devel

f:id:itouhiro:20140730093832p:plain


fstabを生成。

# genfstab -p /mnt >> /mnt/etc/fstab


/mntの中に入ります。

# arch-chroot /mnt

f:id:itouhiro:20140730095927p:plain


ロケールを編集して、「en_US.UTF-8UTF-8」だけコメントアウトします。

# vi /etc/locale.gen

f:id:itouhiro:20140730100050p:plain



ロケールを有効化します。

# locale-gen
# echo LANG=en_US.UTF-8 > /etc/locale.conf
# export LANG=en_US.UTF-8


キーボード設定で日本語キーボードを設定「KEYMAP=jp106」します。

# vi /etc/vconsole.conf

f:id:itouhiro:20140730100652p:plain


タイムゾーンを設定します。

# ln -s /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
# hwclock --systohc --utc


rootのパスワードを設定します。

# passwd

f:id:itouhiro:20140730100916p:plain


ブートローダgrubをインストールします。

# pacman -S grub 
# grub-install --target=i386-pc --recheck --debug /dev/sda
# grub-mkconfig -o /boot/grub/grub.cfg

f:id:itouhiro:20140730101214p:plain
f:id:itouhiro:20140730101257p:plain


ネットワーク設定です。DHCPで接続するよう指定。

# systemctl enable dhcpcd.service

電源OFFです。

# exit
# umount -R /mnt
# poweroff

GUI環境インストール

isoファイルを外します。


ネットワーク#2を[Host Only]で追加します。
f:id:itouhiro:20140730114354p:plain


ArchLinux起動。

一般ユーザーを追加。'sudo'を使用可能にするため、visudoで「foo ALL=(ALL) NOPASSWD:ALL」を追加。

# useradd -m foo
# passwd foo
# visudo


X Window Systemを導入。VirtualBox使用なのでデバイスドライバーは xf86-video-vesa。

# pacman -S xorg-server xorg-server-utils xorg-xinit xorg-xclock xterm
# pacman -S xf86-video-vesa
# pacman -S xfce4

f:id:itouhiro:20140730102824p:plain
途中、何か聞かれたら Y か Enter か Default で。
f:id:itouhiro:20140730103509p:plain


ディスプレイマネージャ(ログイン時からGUIになってるやつ)は導入しません。コンソールで起動して、必要なときだけ以下コマンドでGUIを立ち上げるのが私の使用法には合っているためです。

# startxfce4

f:id:itouhiro:20140730103143j:plain

「ログアウト」してXを終了。


ここまででArch Linuxを使えるようになりました。
このあとは、SSHトンネリングで使うための設定なので、人によっては必要ないです。



ネットワーク設定

ネットワーク設定します。

まずSSHサーバーを入れます。

# pacman -Ss ssh | less
# pacman -Ss openssh
# pacman -S openssh

ArchLinuxはインストールしただけじゃ起動してくれないようだ。Debianは起動してくれたのだけど。

# systemctl start sshd.service
# systemctl enable sshd.service


ネットワークインターフェース #1, #2 ともにDHCPになってしまっているようなので、個別に設定します。
まずネットワークインターフェースの名前を調べる。今回の環境では #1は「enp0s3」、#2は「enp0s8」という名でした。

# ls /sys/class/net


IPアドレス割り当て状態を調べる。

# ip addr


DHCP設定を無効にしましょう。

# systemctl --type=service
# systemctl stop dhcpcd.service
# systemctl disable dhcpcd.service

一度ArchLinux再起動してもいいかも。

# reboot


ArchLinuxには、 systemctl と似た netctl というネットワーク設定ツールがあるので、それを使用します。まずはインストール。

# pacman -Ss netctl
# pacman -S netctl


「enp0s3」は通常のインターネット接続に使うのでDHCP。「enp0s8」はSSHトンネリングのために導入したのでstatic IP。 それぞれの設定サンプルファイルをcopyして少し書き換えます。

# cp -p /etc/netctl/examples/ethernet-dhcp /etc/netctl/en1
# cp -p /etc/netctl/examples/ethernet-static /etc/netctl/en2


/etc/netctl/en1 の中身を書き換える。Interfaceの部分を変えただけです。

Description='A basic dhcp ethernet connection'
Interface=enp0s3
Connection=ethernet
IP=dhcp
## for DHCPv6
#IP6=dhcp
## for IPv6 autoconfiguration
#IP6=stateless


/etc/netctl/en2 の中身を書き換える。

Description='A basic static ethernet connection'
#AutoWired=yes
Interface=enp0s8
Connection=ethernet
IP=static
Address=('192.168.56.102/24')
Gateway='192.168.56.1'
DNS=('192.168.56.1 8.8.8.8')


接続できるかテスト実行。

# netctl start en1
# netctl start en2


SSHトンネリング接続成功。
f:id:itouhiro:20140730113504p:plain


このネットワーク設定をArchLinux起動時に実行するよう指定。

# netctl enable en1
# netctl enable en2


SSHトンネリングしたとき、SSHログインできるまでが長い(1分ほど待たされる)のは以下の書き換えで解決。

--- /etc/ssh/sshd_config.orig   2014-04-21 04:38:44.000000000 +0900
+++ /etc/ssh/sshd_config        2014-07-30 15:48:49.351163875 +0900
@@ -114,3 +114,3 @@
 #ClientAliveCountMax 3
-#UseDNS yes
+UseDNS no
 #PidFile /run/sshd.pid

VNCも入れる。まずは一度起動して初期ファイルを ~/.vncに生成させます。そのときパスワード入力も必要です。パスワードは入力したくないけど -passwd というオプションはないと言われるし‥‥

$ sudo pacman -S tigervnc
$ vncserver
$ vncserver -kill :1
$ vi .vnc/xstartup
$ chmod 755 ~/.vnc/xstartup


xstartupの中身。
~/.vnc/xstartup

#!/bin/sh
export XKL_XMODMAP_DISABLE=1
exec startxfce4


VNCサーバーの :1 は 192.168.56.102:5901 ポートでつなげる。PuTTYSSHトンネリング設定すると、192.168.56.102:5901 にlocalhost:5902 でアクセス可能。

VNC起動。画面が出てくるまで1分待たされるのはソフト起動待ち?

$ vncserver :1

f:id:itouhiro:20140730162159p:plain





‥‥しかしここまでの設定だとSSHトンネリングは成功する一方、外部ネットワークにつながらない( ping www.google.com の応答がない)。

$ sudo netctl stop en1
$ sudo netctl stop en2
$ sudo systemctl start dhcpcd.service

すれば、一時的に外部につながるようになりますが、SSHトンネリング不可です。netctlのDHCPとdhcpcdのDHCPは何か違うのか‥‥


調べると、

$ sudo netctl stop en2

だけ実行すれば外部ネットワークにつながる( ping www.google.com の応答あり)と判明した。en2の何かわるいのか‥‥DNSGatewayの記述がじゃまなのでは?
/etc/netctl/en2 の中身を書き換える。

Description='A basic static ethernet connection'
#AutoWired=yes
Interface=enp0s8
Connection=ethernet
IP=static
Address=('192.168.56.102/24')
# Gateway='192.168.56.1'
# DNS=('192.168.56.1 8.8.8.8')

こうすると、SSHトンネリングも可能で、しかも外部ネットワークにつながるようになった。




Linuxシステム[実践]入門 (Software Design plus)

Linuxシステム[実践]入門 (Software Design plus)

FontForge 2.0.20140101 日本語対応版をArch Linuxにインストール

$
0
0

f:id:itouhiro:20140824150917p:plain


Arch Linuxのインストールは http://itouhiro.hatenablog.com/entry/20140730/linuxを参照。

まずは Arch Build System をインストール。

# pacman -S abs

https://www.archlinux.org/packages/extra/i686/fontforge/
を見ると「Repository: Extra」とある。

/etc/abs.conf でextraの前に ! がないか確認する。

REPOS=(core extra !community !testing !community-testing
       !staging !community-staging !gnome-unstable !kde-unstable)

absコマンドを実行して、absツリーを取得。

# abs

/etc/makepkg.conf を書き換えてPACKAGERを設定。

#PACKAGER="John Doe <john@doe.com>"
PACKAGER="Itou Hiroki <itouhiro !atmark! users.sourceforge.jp>"

このあとはrootではなく、一般ユーザーで実行します。

ビルドディレクトリの作成

$ mkdir ~/abs
$ cp -pr /var/abs/extra/fontforge ~/abs/
$ cd ~/abs/fontforge/


日本語パッチの準備
http://www.geocities.jp/meir000/fontforge/の日本語縦書きパッチを取得。

$ wget http://www.geocities.jp/meir000/fontforge/fontforge-20140104-vmetrics.patch.txt
$ sha1sum fontforge-20140104-vmetrics.patch.txt
$ vi PKGBUILD


編集する箇所

--- PKGBUILD.orig       2014-07-31 07:05:48.000000000 +0900
+++ PKGBUILD    2014-07-31 16:20:41.938494158 +0900
@@ -16,10 +16,12 @@
          'python2' 'desktop-file-utils' 'gtk-update-icon-cache' 'hicolor-icon-theme')
 source=("https://github.com/fontforge/fontforge/archive/${_pkgver}.tar.gz"
         'http://fontforge.org/cidmaps.tgz'
-        'giflib.patch')
+        'giflib.patch'
+        'fontforge-20140104-vmetrics.patch.txt')
 sha1sums=('abce297e53e8b6ff6f08871e53d1eb0be5ab82e7'
           'efbc7c9d3e95159f5600dc71f9cccb370e46bb94'
-          '420dd1dd75d72719f3203d832bfa8c1c7e7eef86')
+          '420dd1dd75d72719f3203d832bfa8c1c7e7eef86'
+          'f056b3ae8afb432b289000c2193c221cddc5830f')

 options=('!makeflags')
 install=install
@@ -28,6 +30,7 @@
        cd "${srcdir}/${pkgname}-${_pkgver}"
        sed '/fontforge_package_name/s/^#//' -i configure.ac
        patch -p1 -i ../giflib.patch
+       patch -p1 -i ../fontforge-20140104-vmetrics.patch.txt
        ./autogen.sh
 }


ビルド

$ makepkg -s


ビルドを待つ。

[foo@localhost fontforge]$ makepkg -s
/usr/bin/makepkg: eval: line 2272: unexpected EOF while looking for matching `"'
/usr/bin/makepkg: eval: line 2273: syntax error: unexpected end of file
==> Making package: fontforge 20140101-3 (Thu Jul 31 16:14:44 JST 2014)
==> Checking runtime dependencies...
==> Installing missing dependencies...
warning: skipping target: libspiro
resolving dependencies...
looking for inter-conflicts...

Packages (7): libsodium-0.6.1-1  giflib-5.1.0-1  libspiro-1:0.2-1
              libunicodenames-1.1.0_beta1-1  libxkbui-1.0.2-5  python2-2.7.8-1
              zeromq-4.0.4-3

Total Download Size:    10.07 MiB
Total Installed Size:   72.74 MiB

:: Proceed with installation? [Y/n] Y

...

==> Making package: fontforge 20140101-3 (Thu Jul 31 16:22:16 JST 2014)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Found 2.0.20140101.tar.gz
  -> Found cidmaps.tgz
  -> Found giflib.patch
  -> Found fontforge-20140104-vmetrics.patch.txt
==> Validating source files with sha1sums...
    2.0.20140101.tar.gz ... Passed
    cidmaps.tgz ... Passed
    giflib.patch ... Passed
    fontforge-20140104-vmetrics.patch.txt ... Passed
==> Extracting sources...
  -> Extracting 2.0.20140101.tar.gz with bsdtar
  -> Extracting cidmaps.tgz with bsdtar
==> Starting prepare()...
patching file gutils/gimagereadgif.c
patching file fontforge/splinechar.c
patching file fontforge/splinefont.c
patching file fontforge/tottfgpos.c
patching file fontforgeexe/charview.c
patching file fontforgeexe/cvpointer.c
Preparing the fontforge build system...please wait

Found GNU Autoconf version 2.69

...

==> Creating package "fontforge"...
  -> Generating .PKGINFO file...
  -> Adding install file...
  -> Generating .MTREE file...
  -> Compressing package...
==> Leaving fakeroot environment.
==> Finished making: fontforge 20140101-3 (Thu Jul 31 17:17:25 JST 2014)
[foo@localhost fontforge]$ ls
./                   fontforge-20140101-3-i686.pkg.tar.xz   pkg/
../                  fontforge-20140104-vmetrics.patch.txt  PKGBUILD
2.0.20140101.tar.gz  giflib.patch                           PKGBUILD.orig
cidmaps.tgz          install                                src/
[foo@localhost fontforge]$

patchも適切に適用されたようである。


これをインストール。

$ sudo pacman -U fontforge-20140101-3-i686.pkg.tar.xz

f:id:itouhiro:20140731172926p:plain

Viewing all 107 articles
Browse latest View live