Class: BDFFont
- Inherits:
-
Object
- Object
- BDFFont
- Defined in:
- bdffont.rb
Overview
Note:
iso8859, jisx0208, iso10646 のみに対応
BDFフォント描画用クラス
Instance Attribute Summary (collapse)
-
- (Integer) height
readonly
バウンディングボックスの縦幅(最大値).
-
- (Integer) ofsy
readonly
バウンディングボックスのyオフセット.
Instance Method Summary (collapse)
-
- (Object?) [](index)
配列として指定した際に、BDFフォント1文字分用のクラスを返す.
-
- (Object) add(bdffilename, col = [255, 255, 255, 255])
BDFファイルを追加。.
-
- (BDFFont) initialize(bdffilename, col = [255, 255, 255, 255])
constructor
コンストラクタ.
Constructor Details
- (BDFFont) initialize(bdffilename, col = [255, 255, 255, 255])
コンストラクタ
218 219 220 221 222 223 224 225 |
# File 'bdffont.rb', line 218 def initialize(bdffilename, col = [255, 255, 255, 255]) @bdffiles = [] bdfd = BDFdata.new(bdffilename, col) @bdffiles.push(bdfd) @width = bdfd.width @height = bdfd.height @ofsy = bdfd.ofsy end |
Instance Attribute Details
- (Integer) height (readonly)
Returns バウンディングボックスの縦幅(最大値)
208 209 210 |
# File 'bdffont.rb', line 208 def height @height end |
- (Integer) ofsy (readonly)
Returns バウンディングボックスのyオフセット
211 212 213 |
# File 'bdffont.rb', line 211 def ofsy @ofsy end |
Instance Method Details
- (Object?) [](index)
配列として指定した際に、BDFフォント1文字分用のクラスを返す
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'bdffont.rb', line 249 def [](index) @bdffiles.each do |d| code = nil case d.charset when :jisx0208 code = self.sjis2jisx0208(index.ord) when :jisx0213 # ΉBϊ@Ȃ code = self.sjis2jisx0208(index.ord) # code = index.encode("UTF-8", "Windows-31J").ord # code = index.encode("EUC-JISX0213", "Windows-31J").ord # code = index.encode("EUC-JP-2004", "Windows-31J").ord when :iso10646 code = index.encode("UTF-8", "Windows-31J").ord else code = index.ord end return d.bdf_dic[code] if d.bdf_dic.has_key?(code) end return nil end |
- (Object) add(bdffilename, col = [255, 255, 255, 255])
BDFファイルを追加。
漢字BDFフォント(jisx0208)でクラスを生成した後、 英数字BDFフォント(iso8859)を一緒に含める時に使う。
235 236 237 238 239 240 241 |
# File 'bdffont.rb', line 235 def add(bdffilename, col = [255, 255, 255, 255]) bdfd = BDFdata.new(bdffilename, col) @bdffiles.push(bdfd) @width = bdfd.width if @width < bdfd.width @height = bdfd.height if @height < bdfd.height @ofsy = bdfd.ofsy if @ofsy.abs < bdfd.ofsy.abs end |