Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

キーボードフォントを変更する #103

Merged
merged 9 commits into from
Apr 6, 2015
Merged

Conversation

inao
Copy link
Collaborator

@inao inao commented Apr 3, 2015

@naoya @gfx
すみません、お手数ですが、後述しているテストコードの追加をお願いできませんでしょうか?

目的

キーボードフォントを、従来のKeyMother、Key Snd Motherから、Keyboard-JP-Regular.otfに変更したいです。

メリット

メリットは以下です。

  • 入力した文字と変換後の文字が一致している
    • たとえば従来は、「Ctrl」は「l」にマッピングされていた
  • その結果、PDFでの検索が有効になった(「Ctrl」などで検索できる)
  • その結果、音声読上げソフトで正しく読み上げられるようになった
  • 文字種が増えた
    • 従来は⌘キーなどはなかった

非対応キー

ただし、Keyboard-JP-Regular.otf対応文字のうち、Shift-JIS(現状、InDesignへの取り込み時にShift-JISに変換する必要がある)にはない以下のキーには対応していません。

  • ~
  • \

また、 #95 と同様の問題が発生することを避けるため、バッククォート(`)にも対応させていません。

非対応キーに対応する方法

自由置換設定にUnicode番号を記載する形で設定すれば利用可能ですが、特に使うことがなさそうなキーばかりですので、現状は設定していません。

テストコード追加のお願い

以下が、テストコードです。

長いので新規ファイルとして追加したいのですが、ファイルの命名規則(冒頭の数字の意味は?)と、冒頭のPerlコード部分に何を書けばよいのかわかりませんでしたので、お願いさせていただけないでしょうか?

テスト自体は実行方法がわからなかったので未検証ですが、キーボードフォントにうまく変換されることは手もとで確認済みですので、おそらくテストも通ると思われます。

=== alphabet
--- in md2inao
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
--- expected
<ParaStyle:本文><cFont:Keyboard-JP>A<cFont:><cFont:Keyboard-JP>B<cFont:><cFont:Keyboard-JP>C<cFont:><cFont:Keyboard-JP>D<cFont:><cFont:Keyboard-JP>E<cFont:><cFont:Keyboard-JP>F<cFont:><cFont:Keyboard-JP>G<cFont:><cFont:Keyboard-JP>H<cFont:><cFont:Keyboard-JP>I<cFont:><cFont:Keyboard-JP>J<cFont:><cFont:Keyboard-JP>K<cFont:><cFont:Keyboard-JP>L<cFont:><cFont:Keyboard-JP>M<cFont:><cFont:Keyboard-JP>N<cFont:><cFont:Keyboard-JP>O<cFont:><cFont:Keyboard-JP>P<cFont:><cFont:Keyboard-JP>Q<cFont:><cFont:Keyboard-JP>R<cFont:><cFont:Keyboard-JP>S<cFont:><cFont:Keyboard-JP>T<cFont:><cFont:Keyboard-JP>U<cFont:><cFont:Keyboard-JP>V<cFont:><cFont:Keyboard-JP>W<cFont:><cFont:Keyboard-JP>X<cFont:><cFont:Keyboard-JP>Y<cFont:><cFont:Keyboard-JP>Z<cFont:>

=== alphabet
--- in md2inao
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
--- expected
<ParaStyle:本文><cFont:Keyboard-JP>a<cFont:><cFont:Keyboard-JP>b<cFont:><cFont:Keyboard-JP>c<cFont:><cFont:Keyboard-JP>d<cFont:><cFont:Keyboard-JP>e<cFont:><cFont:Keyboard-JP>f<cFont:><cFont:Keyboard-JP>g<cFont:><cFont:Keyboard-JP>h<cFont:><cFont:Keyboard-JP>i<cFont:><cFont:Keyboard-JP>j<cFont:><cFont:Keyboard-JP>k<cFont:><cFont:Keyboard-JP>l<cFont:><cFont:Keyboard-JP>m<cFont:><cFont:Keyboard-JP>n<cFont:><cFont:Keyboard-JP>o<cFont:><cFont:Keyboard-JP>p<cFont:><cFont:Keyboard-JP>q<cFont:><cFont:Keyboard-JP>r<cFont:><cFont:Keyboard-JP>s<cFont:><cFont:Keyboard-JP>t<cFont:><cFont:Keyboard-JP>u<cFont:><cFont:Keyboard-JP>v<cFont:><cFont:Keyboard-JP>w<cFont:><cFont:Keyboard-JP>x<cFont:><cFont:Keyboard-JP>y<cFont:><cFont:Keyboard-JP>z<cFont:>

=== number
--- in md2inao
0
1
2
3
4
5
6
7
8
9
--- expected
<ParaStyle:本文><cFont:Keyboard-JP>0<cFont:><cFont:Keyboard-JP>1<cFont:><cFont:Keyboard-JP>2<cFont:><cFont:Keyboard-JP>3<cFont:><cFont:Keyboard-JP>4<cFont:><cFont:Keyboard-JP>5<cFont:><cFont:Keyboard-JP>6<cFont:><cFont:Keyboard-JP>7<cFont:><cFont:Keyboard-JP>8<cFont:><cFont:Keyboard-JP>9<cFont:>

=== hiragana
--- in md2inao
あ
い
う
え
お
か
き
く
け
こ
さ
し
す
せ
そ
た
ち
つ
て
と
な
に
ぬ
ね
の
は
ひ
ふ
へ
ほ
ま
み
む
め
も
や
ゆ
よ
ら
り
る
れ
ろ
わ
を
ん
ぁ
ぃ
ぅ
ぇ
ぉ
ゃ
ゅ
ょ
っ
--- expected
<ParaStyle:本文><cFont:Keyboard-JP>あ<cFont:><cFont:Keyboard-JP>い<cFont:><cFont:Keyboard-JP>う<cFont:><cFont:Keyboard-JP>え<cFont:><cFont:Keyboard-JP>お<cFont:><cFont:Keyboard-JP>か<cFont:><cFont:Keyboard-JP>き<cFont:><cFont:Keyboard-JP>く<cFont:><cFont:Keyboard-JP>け<cFont:><cFont:Keyboard-JP>こ<cFont:><cFont:Keyboard-JP>さ<cFont:><cFont:Keyboard-JP>し<cFont:><cFont:Keyboard-JP>す<cFont:><cFont:Keyboard-JP>せ<cFont:><cFont:Keyboard-JP>そ<cFont:><cFont:Keyboard-JP>た<cFont:><cFont:Keyboard-JP>ち<cFont:><cFont:Keyboard-JP>つ<cFont:><cFont:Keyboard-JP>て<cFont:><cFont:Keyboard-JP>と<cFont:><cFont:Keyboard-JP>な<cFont:><cFont:Keyboard-JP>に<cFont:><cFont:Keyboard-JP>ぬ<cFont:><cFont:Keyboard-JP>ね<cFont:><cFont:Keyboard-JP>の<cFont:><cFont:Keyboard-JP>は<cFont:><cFont:Keyboard-JP>ひ<cFont:><cFont:Keyboard-JP>ふ<cFont:><cFont:Keyboard-JP>へ<cFont:><cFont:Keyboard-JP>ほ<cFont:><cFont:Keyboard-JP>ま<cFont:><cFont:Keyboard-JP>み<cFont:><cFont:Keyboard-JP>む<cFont:><cFont:Keyboard-JP>め<cFont:><cFont:Keyboard-JP>も<cFont:><cFont:Keyboard-JP>や<cFont:><cFont:Keyboard-JP>ゆ<cFont:><cFont:Keyboard-JP>よ<cFont:><cFont:Keyboard-JP>ら<cFont:><cFont:Keyboard-JP>り<cFont:><cFont:Keyboard-JP>る<cFont:><cFont:Keyboard-JP>れ<cFont:><cFont:Keyboard-JP>ろ<cFont:><cFont:Keyboard-JP>わ<cFont:><cFont:Keyboard-JP>を<cFont:><cFont:Keyboard-JP>ん<cFont:><cFont:Keyboard-JP>ぁ<cFont:><cFont:Keyboard-JP>ぃ<cFont:><cFont:Keyboard-JP>ぅ<cFont:><cFont:Keyboard-JP>ぇ<cFont:><cFont:Keyboard-JP>ぉ<cFont:><cFont:Keyboard-JP>ゃ<cFont:><cFont:Keyboard-JP>ゅ<cFont:><cFont:Keyboard-JP>ょ<cFont:><cFont:Keyboard-JP>っ<cFont:>

=== modifier
--- in md2inao
Alt
Backspace
Break
Caps
CapsLock
Cmd
Command
Control
Ctrl
Del
Delete
End
Enter
Esc
Fn
Go
Home
Ins
Insert
NumLock
Option
PageDown
PageUp
Pause
PgDn
PgUp
PrintScreen
Return
ScrollLock
Shift
Space
SysRq
Tab
Windows
--- expected
<ParaStyle:本文><cFont:Keyboard-JP>Alt<cFont:><cFont:Keyboard-JP>Backspace<cFont:><cFont:Keyboard-JP>Break<cFont:><cFont:Keyboard-JP>Caps<cFont:><cFont:Keyboard-JP>CapsLock<cFont:><cFont:Keyboard-JP>Cmd<cFont:><cFont:Keyboard-JP>Command<cFont:><cFont:Keyboard-JP>Control<cFont:><cFont:Keyboard-JP>Ctrl<cFont:><cFont:Keyboard-JP>Del<cFont:><cFont:Keyboard-JP>Delete<cFont:><cFont:Keyboard-JP>End<cFont:><cFont:Keyboard-JP>Enter<cFont:><cFont:Keyboard-JP>Esc<cFont:><cFont:Keyboard-JP>Fn<cFont:><cFont:Keyboard-JP>Go<cFont:><cFont:Keyboard-JP>Home<cFont:><cFont:Keyboard-JP>Ins<cFont:><cFont:Keyboard-JP>Insert<cFont:><cFont:Keyboard-JP>NumLock<cFont:><cFont:Keyboard-JP>Option<cFont:><cFont:Keyboard-JP>PageDown<cFont:><cFont:Keyboard-JP>PageUp<cFont:><cFont:Keyboard-JP>Pause<cFont:><cFont:Keyboard-JP>PgDn<cFont:><cFont:Keyboard-JP>PgUp<cFont:><cFont:Keyboard-JP>PrintScreen<cFont:><cFont:Keyboard-JP>Return<cFont:><cFont:Keyboard-JP>ScrollLock<cFont:><cFont:Keyboard-JP>Shift<cFont:><cFont:Keyboard-JP>Space<cFont:><cFont:Keyboard-JP>SysRq<cFont:><cFont:Keyboard-JP>Tab<cFont:><cFont:Keyboard-JP>Windows<cFont:>

=== modifier
--- in md2inao
alt
caps
capslock
clear
command
control
ctrl
del
delete
end
enter
esc
fn
home
ins
option
pagedown
pageup
return
shift
space
tab
--- expected
<ParaStyle:本文><cFont:Keyboard-JP>alt<cFont:><cFont:Keyboard-JP>caps<cFont:><cFont:Keyboard-JP>capslock<cFont:><cFont:Keyboard-JP>clear<cFont:><cFont:Keyboard-JP>command<cFont:><cFont:Keyboard-JP>control<cFont:><cFont:Keyboard-JP>ctrl<cFont:><cFont:Keyboard-JP>del<cFont:><cFont:Keyboard-JP>delete<cFont:><cFont:Keyboard-JP>end<cFont:><cFont:Keyboard-JP>enter<cFont:><cFont:Keyboard-JP>esc<cFont:><cFont:Keyboard-JP>fn<cFont:><cFont:Keyboard-JP>home<cFont:><cFont:Keyboard-JP>ins<cFont:><cFont:Keyboard-JP>option<cFont:><cFont:Keyboard-JP>pagedown<cFont:><cFont:Keyboard-JP>pageup<cFont:><cFont:Keyboard-JP>return<cFont:><cFont:Keyboard-JP>shift<cFont:><cFont:Keyboard-JP>space<cFont:><cFont:Keyboard-JP>tab<cFont:>

=== function
--- in md2inao
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
F13
F14
F15
F16
F17
F18
--- expected
<ParaStyle:本文><cFont:Keyboard-JP>F1<cFont:><cFont:Keyboard-JP>F2<cFont:><cFont:Keyboard-JP>F3<cFont:><cFont:Keyboard-JP>F4<cFont:><cFont:Keyboard-JP>F5<cFont:><cFont:Keyboard-JP>F6<cFont:><cFont:Keyboard-JP>F7<cFont:><cFont:Keyboard-JP>F8<cFont:><cFont:Keyboard-JP>F9<cFont:><cFont:Keyboard-JP>F10<cFont:><cFont:Keyboard-JP>F11<cFont:><cFont:Keyboard-JP>F12<cFont:><cFont:Keyboard-JP>F13<cFont:><cFont:Keyboard-JP>F14<cFont:><cFont:Keyboard-JP>F15<cFont:><cFont:Keyboard-JP>F16<cFont:><cFont:Keyboard-JP>F17<cFont:><cFont:Keyboard-JP>F18<cFont:>

=== omake
--- in md2inao
POWER
EJECT
SELECT
START
--- expected
<ParaStyle:本文><cFont:Keyboard-JP>POWER<cFont:><cFont:Keyboard-JP>EJECT<cFont:><cFont:Keyboard-JP>SELECT<cFont:><cFont:Keyboard-JP>START<cFont:>

=== japanese
--- in md2inao
改行
空白
英数
かな
漢字
スペース
ローマ字
カタカナひらがな
半角/全角
変換
無変換
--- expected
<ParaStyle:本文><cFont:Keyboard-JP>改行<cFont:><cFont:Keyboard-JP>空白<cFont:><cFont:Keyboard-JP>英数<cFont:><cFont:Keyboard-JP>かな<cFont:><cFont:Keyboard-JP>漢字<cFont:><cFont:Keyboard-JP>スペース<cFont:><cFont:Keyboard-JP>ローマ字<cFont:><cFont:Keyboard-JP>カタカナひらがな<cFont:><cFont:Keyboard-JP>半角/全角<cFont:><cFont:Keyboard-JP>変換<cFont:><cFont:Keyboard-JP>無変換<cFont:>

=== arrow
--- in md2inao
↑
↓
→
←
--- expected
<ParaStyle:本文><cFont:Keyboard-JP>↑<cFont:><cFont:Keyboard-JP>↓<cFont:><cFont:Keyboard-JP>→<cFont:><cFont:Keyboard-JP>←<cFont:>

=== symbol
--- in md2inao
!
"
#
$
%
&
'
(
)
=
-
^
|
¥
@
{
}
[
]
;
:
+
_
*
/
?
,
.
<
>
「
」
、
。
・
゛
゜
ー
--- expected
<ParaStyle:本文><cFont:Keyboard-JP>!<cFont:><cFont:Keyboard-JP>"<cFont:><cFont:Keyboard-JP>#<cFont:><cFont:Keyboard-JP>$<cFont:><cFont:Keyboard-JP>%<cFont:><cFont:Keyboard-JP>&<cFont:><cFont:Keyboard-JP>'<cFont:><cFont:Keyboard-JP>(<cFont:><cFont:Keyboard-JP>)<cFont:><cFont:Keyboard-JP>=<cFont:><cFont:Keyboard-JP>-<cFont:><cFont:Keyboard-JP>^<cFont:><cFont:Keyboard-JP>|<cFont:><cFont:Keyboard-JP>¥<cFont:><cFont:Keyboard-JP>@<cFont:><cFont:Keyboard-JP>{<cFont:><cFont:Keyboard-JP>}<cFont:><cFont:Keyboard-JP>[<cFont:><cFont:Keyboard-JP>]<cFont:><cFont:Keyboard-JP>;<cFont:><cFont:Keyboard-JP>:<cFont:><cFont:Keyboard-JP>+<cFont:><cFont:Keyboard-JP>_<cFont:><cFont:Keyboard-JP>*<cFont:><cFont:Keyboard-JP>/<cFont:><cFont:Keyboard-JP>?<cFont:><cFont:Keyboard-JP>,<cFont:><cFont:Keyboard-JP>.<cFont:><cFont:Keyboard-JP><<cFont:><cFont:Keyboard-JP><cFont:><cFont:Keyboard-JP>「<cFont:><cFont:Keyboard-JP>」<cFont:><cFont:Keyboard-JP>、<cFont:><cFont:Keyboard-JP>。<cFont:><cFont:Keyboard-JP>・<cFont:><cFont:Keyboard-JP>゛<cFont:><cFont:Keyboard-JP>゜<cFont:><cFont:Keyboard-JP>ー<cFont:>

@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.21% when pulling 640fd81 on keyboard-font-replace into 493c554 on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.21% when pulling 640fd81 on keyboard-font-replace into 493c554 on master.

@naoya
Copy link
Owner

naoya commented Apr 3, 2015

ひとまずコピペされてるテスト、追加してみたんですが通らないですね。

@inao
Copy link
Collaborator Author

inao commented Apr 3, 2015

@naoya
うわ、申し訳ございません。
テストのどの行が失敗していますでしょうか?
(見方がわかりませんでした)

@naoya
Copy link
Owner

naoya commented Apr 3, 2015

https://travis-ci.org/naoya/md2inao/jobs/56996211

ここの出力みればわかると思います。ほぼ全部落ちてるかな

@inao
Copy link
Collaborator Author

inao commented Apr 3, 2015

ありがとうございます!
調査します。

@inao
Copy link
Collaborator Author

inao commented Apr 3, 2015

あ、バカでした。
<kbd></kbd>で括り忘れている(恥)。
少々お待ちを……。

@naoya
Copy link
Owner

naoya commented Apr 3, 2015

ちなみに手元には cpanm と carton を入れて、md2inao のディレクトリにいき

$ carton
$ carton exec prove -l

でテストできます。一行目のは Bundler の bundle コマンド相当で、モジュールのインストールです。二行目のがテストの実行。なので、いちどモジュールが入ったら二行目を打つだけでよいです。

@inao
Copy link
Collaborator Author

inao commented Apr 3, 2015

@naoya
う、だめですね………。

https://travis-ci.org/naoya/md2inao/jobs/56997292

gotの行がgot: '↑▲↓▲→▲←▲みたいになっているのはなぜでしょうか?

手もとでは正しく動作を確認できているのですけど。

% cpanm Carton
Carton is up to date. (v1.0.12)
% carton install
Installing modules using /Users/inao/〜
Complete! Modules were installed into /Users/inao/〜
% carton exec -- perl bin/md2inao.pl test.md > test.txt

test.mdです。

<kbd>A</kbd>
<kbd>B</kbd>
<kbd>C</kbd>
<kbd>D</kbd>
<kbd>E</kbd>
<kbd>F</kbd>
<kbd>G</kbd>

test.txtです。

<SJIS-MAC>
<ParaStyle:本文><cFont:Keyboard-JP>A<cFont:><cFont:Keyboard-JP>B<cFont:><cFont:Keyboard-JP>C<cFont:><cFont:Keyboard-JP>D<cFont:><cFont:Keyboard-JP>E<cFont:><cFont:Keyboard-JP>F<cFont:><cFont:Keyboard-JP>G<cFont:>

@naoya
Copy link
Owner

naoya commented Apr 3, 2015

ああ、これ InDesign のテストでしたね。inao 記法の方のテストコマンドコピってました。修正します

@naoya
Copy link
Owner

naoya commented Apr 3, 2015

だいたい通るようになりましたが symbol のテストだけ、落ちますね。

@inao
Copy link
Collaborator Author

inao commented Apr 3, 2015

テストの実行方法ありがとうございます。
手もとでも動かせました。これから出ちゃいますので、あとでREADMEにも書いておきます。

ああ、これ InDesign のテストでしたね。inao 記法の方のテストコマンドコピってました。修正します

ありがとうございます!

だいたい通るようになりましたが symbol のテストだけ、落ちますね。

のちほど確認させていただきます!

@inao
Copy link
Collaborator Author

inao commented Apr 4, 2015

<>が失敗していますね。
タグなので<005C><とかでエスケープされて変換されています。

ただこれは、この挙動のほうが正しい(=テスコードのほうを変更する必要がある)かもですので、InDesignに取り込んでみて検証しなきゃですね。週明けに会社で検証します。

@inao
Copy link
Collaborator Author

inao commented Apr 6, 2015

@naoya
現在の実装が正しかったです。
テストコードを修正しました。ローカルでのテストも通しました。
Travis CIのテストが通ったらマージさせていただきます。

いろいろご協力ありがとうございました 🙇

@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.21% when pulling f0ca390 on keyboard-font-replace into 493c554 on master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.21% when pulling f0ca390 on keyboard-font-replace into 493c554 on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.21% when pulling f0ca390 on keyboard-font-replace into 493c554 on master.

inao added a commit that referenced this pull request Apr 6, 2015
キーボードフォントを変更する
@inao inao merged commit a5947a8 into master Apr 6, 2015
@inao inao deleted the keyboard-font-replace branch April 6, 2015 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants