This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var canvas = document.getElementById("myCanvas"); | |
var context = canvas.getContext("2d"); | |
// if backingStorePixelRatio is less than devicePixelRatio, everything needs to be scaled up | |
var ratio = (context.webkitBackingStorePixelRatio < window.devicePixelRatio) ? (window.devicePixelRatio || 1) : 1; | |
if (ratio > 1) { | |
canvas.width *= ratio; | |
canvas.height *= ratio; | |
context.scale(ratio, ratio); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Japanese text normalization (fullwidth to halfwidth) | |
function normalize(s) { | |
function zentohan(c) { | |
var z2h = { | |
'ガ':'ガ','ギ':'ギ','グ':'グ','ゲ':'ゲ','ゴ':'ゴ', | |
'ザ':'ザ','ジ':'ジ','ズ':'ズ','ゼ':'ゼ','ゾ':'ゾ', | |
'ダ':'ダ','ヂ':'ヂ','ヅ':'ヅ','デ':'デ','ド':'ド', | |
'バ':'バ','パ':'パ','ビ':'ビ','ピ':'ピ','ブ':'ブ', | |
'プ':'プ','ベ':'ベ','ペ':'ペ','ボ':'ボ','ポ':'ポ','ヴ':'ヴ', | |
'ァ':'ァ','ア':'ア','ィ':'ィ','イ':'イ','ゥ':'ゥ','ウ':'ウ','ェ':'ェ','エ':'エ','ォ':'ォ','オ':'オ', |