Class: Resedit::FontConvertCommand

Inherits:
ConvertCommand show all
Defined in:
lib/resedit/app/font_convert.rb

Instance Attribute Summary

Attributes inherited from ConvertCommand

#fname

Attributes inherited from AppCommand

#names, #ohash, #opts, #params, #type

Instance Method Summary collapse

Methods inherited from ConvertCommand

#backup, #getOutName, #job

Methods inherited from AppCommand

#addOption, #addParam, #job, #log, #logd, #loge, #parseParams, #run

Constructor Details

#initialize(fname, cmdname = 'font') ⇒ FontConvertCommand

Returns a new instance of FontConvertCommand.



7
8
9
10
# File 'lib/resedit/app/font_convert.rb', line 7

def initialize(fname, cmdname='font')
    super(cmdname, fname)
    @font = nil
end

Instance Method Details

#export(outname) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/resedit/app/font_convert.rb', line 29

def export(outname)
    logd("exporting font #{@resname} to #{outname}")
    File.open(@resname, "rb"){|file|
        @font = mkfont(file)
        unpack(file) if @font
    }
    raise "Font not unpacked" if !@font
    @font.save(outname+'.png')
end

#import(inname) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/resedit/app/font_convert.rb', line 12

def import(inname)
    logd("importing font #{inname} to #{@resname}")
    back = backup()
    File.open(back,"rb"){|file|
        @font = mkfont(file)
        @font.load(inname+'.png')
        StringIO.open("","w+b"){|stream|
            pack(file, stream)
            stream.seek(0)
            File.open(@resname,"wb"){|out|
                out.write(stream.read())
            }
        }
    }
end

#mkfont(file) ⇒ Object



40
41
42
# File 'lib/resedit/app/font_convert.rb', line 40

def mkfont(file)
    raise "Not implemented."
end

#pack(file, outstream) ⇒ Object



44
45
46
# File 'lib/resedit/app/font_convert.rb', line 44

def pack(file, outstream)
    raise "Not implemented."
end

#unpack(file) ⇒ Object



48
49
50
# File 'lib/resedit/app/font_convert.rb', line 48

def unpack(file)
    raise "Not implemented."
end