#!ruby -Ks # -*- mode: ruby; encoding: sjis -*- # Last updated: <2014/03/29 22:32:42 +0900> # # フォント内の記号を一覧表示してみるテスト # # Ruby 1.9.3 + DXRuby 1.4.1 を使用。 require 'dxruby' sw, sh = 1024, 768 # ウインドウサイズ bgcol = [96, 96, 96] # ウインドウ背景色 ih = 12 * 3 + 8 # フォント名表示部分の高さ cw, ch = 72, 72 + ih # 画像サイズ fsize = cw - 14 # フォントサイズ chr_list = { # 種類 , フォント名, 文字コード "arrow0" => ["MS ゴシック", "\u21a0"], "block0" => ["MS ゴシック", "\u2591"], "block1" => ["MS ゴシック", "\u2593"], "block2" => ["MS ゴシック", "\u25a9"], "circle0" => ["MS ゴシック", "\u25cc"], "triangle0" => ["MS ゴシック", "\u25b3"], "sun" => ["MS ゴシック", "\u2600"], "cloud" => ["MS ゴシック", "\u2601"], "snowman" => ["MS ゴシック", "\u2603"], "star0" => ["MS ゴシック", "\u2606"], "go" => ["MS ゴシック", "\u261e"], "dead" => ["MS ゴシック", "\u2620"], "danger" => ["MS ゴシック", "\u2622"], "smile" => ["MS ゴシック", "\u263a"], "moon0" => ["MS ゴシック", "\u263e"], "rook0" => ["MS ゴシック", "\u2656"], "rook1" => ["MS ゴシック", "\u265c"], "heart" => ["MS ゴシック", "\u2665"], "music" => ["MS ゴシック", "\u266a"], "plane" => ["MS ゴシック", "\u2708"], "cross0" => ["MS ゴシック", "\u2719"], "hex0" => ["MS ゴシック", "\u2721"], "star1" => ["MS ゴシック", "\u2739"], "flower" => ["MS ゴシック", "\u2741"], "snow" => ["MS ゴシック", "\u2744"], "arrow1" => ["MS ゴシック", "\u279f"], "arrow2" => ["MS ゴシック", "\u27a2"], "postman" => ["MS ゴシック", "\u3020"], "bell" => ["Wingdings", "\u0025"], "candle" => ["Wingdings", "\u0027"], "sandglass" => ["Wingdings", "\u0036"], "pc" => ["Wingdings", "\u003a"], "tape" => ["Wingdings", "\u003e"], "bomb" => ["Wingdings", "\u004d"], "flag0" => ["Wingdings", "\u004f"], "cross1" => ["Wingdings", "\u00aa"], "arrow3" => ["Wingdings", "\u00d6"], "winmark" => ["Wingdings", "\u00ff"], "trash" => ["Wingdings 2", "\u0033"], "check0" => ["Wingdings 2", "\u0054"], "check1" => ["Wingdings 2", "\u0056"], "spider" => ["Webdings", "\u0021"], "trophy" => ["Webdings", "\u0025"], "deco" => ["Webdings", "\u0026"], "eye" => ["Webdings", "\u004e"], "bicycle" => ["Webdings", "\u0062"], "gift" => ["Webdings", "\u0065"], "car0" => ["Webdings", "\u0066"], "car1" => ["Webdings", "\u0068"], "satellite" => ["Webdings", "\u006b"], "ship" => ["Webdings", "\u006f"], "car2" => ["Webdings", "\u0070"], "car3" => ["Webdings", "\u0076"], "flag1" => ["Webdings", "\u0077"], "woman0" => ["Webdings", "\u0081"], "car4" => ["Webdings", "\u008d"], "drum" => ["Webdings", "\u0090"], "monalisa" => ["Webdings", "\u00ad"], "key" => ["Webdings", "\u00d1"], "wind0" => ["Webdings", "\u00de"], "wind1" => ["Webdings", "\u00df"], "moon1" => ["Webdings", "\u00e0"], "squirrel" => ["Webdings", "\u00f2"], "fish" => ["Webdings", "\u00f4"], "dog" => ["Webdings", "\u00f5"], "cat" => ["Webdings", "\u00f6"], "pigeon" => ["Webdings", "\u00ff"], "motorcycle" => ["Webdings", "\u0152"], "car5" => ["Webdings", "\u017d"], "woman1" => ["Webdings", "\u0192"], "snowb" => ["Webdings", "\u02c6"], "gold" => ["Webdings", "\u2018"], "man0" => ["Webdings", "\u201a"], "ski" => ["Webdings", "\u2021"], "knife" => ["Webdings", "\u2022"], "surfer" => ["Webdings", "\u2039"], "man1" => ["Webdings", "\u20ac"], } font_def = Font.new(12) imgs = Hash.new() c = 0 # 各文字を画像に書き込む chr_list.each_key do |key| fontname, code = chr_list[key] font = Font.new(fsize, fontname) # imgs[key] = Image.new(cw, ch).drawFont(2, 2, code, font) imgs[key] = Image.new(cw, ch).drawFontEx(2, 2, code, font, :color=>[255, 128, 0], :aa=>true, :edge=>true, :edge_color=>C_BLACK, :edge_width=>4, :edge_level=>4) # 指定文字列やフォント名を描画 y = ch - ih [key, fontname, format("\\u%04x", code.ord)].each do |s| imgs[key].drawFontEx(4, y, s, font_def, :aa=>false) y += 12 end end Window.bgcolor = bgcol # 背景色設定 Window.resize(sw, sh) # ウインドウサイズ設定 # メインループ Window.loop do break if Input.keyPush?(K_ESCAPE) # ESCが押されたら終了 # 画像を描画 x = 0 y = 0 imgs.each_key do |key| Window.draw(x, y, imgs[key]) x += cw if x + cw > Window.width x = 0 y += ch end end end