dvi 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/License.txt +56 -0
- data/Manifest.txt +37 -0
- data/README.txt +10 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +72 -0
- data/config/requirements.rb +17 -0
- data/lib/dvi.rb +99 -0
- data/lib/dvi/lsr.rb +41 -0
- data/lib/dvi/opcode.rb +515 -0
- data/lib/dvi/tfm.rb +68 -0
- data/lib/dvi/tfm/format.rb +290 -0
- data/lib/dvi/util.rb +37 -0
- data/lib/dvi/version.rb +9 -0
- data/log/debug.log +0 -0
- data/misc/latex/latex.dvi +0 -0
- data/misc/latex/latex.tex +4 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/spec/dvi_spec.rb +17 -0
- data/spec/lsr_spec.rb +11 -0
- data/spec/opcode_spec.rb +881 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/tfm_spec.rb +167 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/dvi.rake +16 -0
- data/tasks/environment.rake +7 -0
- data/tasks/rspec.rake +21 -0
- data/tasks/website.rake +17 -0
- data/website/index.html +119 -0
- data/website/index.txt +55 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.rhtml +48 -0
- metadata +87 -0
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
-fs --colour
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
gem 'rspec'
|
6
|
+
require 'spec'
|
7
|
+
end
|
8
|
+
|
9
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), "..", "lib")
|
10
|
+
|
11
|
+
require "pp"
|
12
|
+
require "dvi"
|
13
|
+
|
14
|
+
$TEXMF = File.join(File.dirname(__FILE__), "..", "tmp")
|
15
|
+
Dvi::LsR.default = Dvi::LsR.new($TEXMF)
|
16
|
+
|
data/spec/tfm_spec.rb
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper.rb')
|
2
|
+
|
3
|
+
describe Dvi::Tfm do
|
4
|
+
before do
|
5
|
+
@ps = Dvi::Processor.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "can read tfm files." do
|
9
|
+
Proc.new do
|
10
|
+
Dvi::Tfm.read(Dvi::LsR.default.find("cmr8.tfm"))
|
11
|
+
end.should_not raise_error(Dvi::Tfm::Format::Error)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe Dvi::Tfm, " when cmr8.tfm" do
|
16
|
+
before do
|
17
|
+
@tfm = Dvi::Tfm.read(Dvi::LsR.default.find("cmr8.tfm"))
|
18
|
+
end
|
19
|
+
|
20
|
+
it "font_size should be 8pt." do
|
21
|
+
@tfm.design_size.should == 8.0
|
22
|
+
end
|
23
|
+
|
24
|
+
it "font_coding_scheme should be 'TeX text.'" do
|
25
|
+
@tfm.font_coding_scheme.should == "TeX text"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "font_identifier should be 'CMR'." do
|
29
|
+
@tfm.font_identifier.should == "CMR"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should contains 128 character informations." do
|
33
|
+
@tfm.char.size.should == 128
|
34
|
+
end
|
35
|
+
|
36
|
+
it "width of 'a' should be 0.531258(design-size unit)." do
|
37
|
+
(@tfm.char[97].width*1000000).round.should == 531258
|
38
|
+
end
|
39
|
+
|
40
|
+
it "height of 'a' should be 0.430555(design-size unit)." do
|
41
|
+
(@tfm.char[97].height*1000000).round.should == 430555
|
42
|
+
end
|
43
|
+
|
44
|
+
it "depth of 'a' should be 0." do
|
45
|
+
@tfm.char[97].depth.should == 0
|
46
|
+
end
|
47
|
+
|
48
|
+
it "italic correction size of 'a' should be 0." do
|
49
|
+
@tfm.char[97].italic_correction.should == 0
|
50
|
+
end
|
51
|
+
|
52
|
+
it "lig_kern size of 'a' should be 4." do
|
53
|
+
@tfm.char[97].kerning.size.should == 4
|
54
|
+
end
|
55
|
+
|
56
|
+
it "kerning of 'a' should be a kind of Dvi::Tfm::Kerning." do
|
57
|
+
@tfm.char[97].kerning.values.each do |k|
|
58
|
+
k.should be_a_kind_of(Dvi::Tfm::Kerning)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it "the kenring amount of 'av' should be -0.029514(design-size unit)." do
|
63
|
+
(@tfm.char[97].kerning[118].amount*1000000).round.should == -29514
|
64
|
+
end
|
65
|
+
|
66
|
+
it "the kenring amount of 'aj' should be 0.059029(design-size unit)." do
|
67
|
+
(@tfm.char[97].kerning[106].amount*1000000).round.should == 59029
|
68
|
+
end
|
69
|
+
|
70
|
+
it "the kenring amount of 'ay' should be -0.029514(design-size unit)." do
|
71
|
+
(@tfm.char[97].kerning[121].amount*1000000).round.should == -29514
|
72
|
+
end
|
73
|
+
|
74
|
+
it "the kenring amount of 'aw' should be -0.029514(design-size unit)." do
|
75
|
+
(@tfm.char[97].kerning[119].amount*1000000).round.should == -29514
|
76
|
+
end
|
77
|
+
|
78
|
+
it "ligature of 'fi' should be 12. (MAYBE)" do
|
79
|
+
@tfm.char[102].ligature[105].index.should == 12
|
80
|
+
end
|
81
|
+
|
82
|
+
it "ligature of 'ff' should be 11. (MAYBE)" do
|
83
|
+
@tfm.char[102].ligature[102].index.should == 11
|
84
|
+
end
|
85
|
+
|
86
|
+
it "ligature of 'fl' should be 13. (MAYBE)" do
|
87
|
+
@tfm.char[102].ligature[108].index.should == 13
|
88
|
+
end
|
89
|
+
|
90
|
+
it "width of 'y' should be width 0.560772(design-size unit)." do
|
91
|
+
(@tfm.char[121].width*1000000).round.should == 560772
|
92
|
+
end
|
93
|
+
|
94
|
+
it "height of 'y' should be 0.430555(design-size unit)." do
|
95
|
+
(@tfm.char[121].height*1000000).round.should == 430555
|
96
|
+
end
|
97
|
+
|
98
|
+
it "depth of 'y' should be 0.194445(design-size unit)." do
|
99
|
+
(@tfm.char[121].depth*1000000).round.should == 194445
|
100
|
+
end
|
101
|
+
|
102
|
+
it "italic correction size of 'y' should be 0.014757(design-size unit)." do
|
103
|
+
(@tfm.char[121].italic_correction*1000000).round.should == 14757
|
104
|
+
end
|
105
|
+
|
106
|
+
after do
|
107
|
+
@tfm = nil
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe Dvi::Tfm, " when cmb10.tfm" do
|
112
|
+
before do
|
113
|
+
@tfm = Dvi::Tfm.read(Dvi::LsR.default.find("cmb10.tfm"))
|
114
|
+
end
|
115
|
+
|
116
|
+
it "font_size should be 10pt." do
|
117
|
+
@tfm.design_size.should == 10.0
|
118
|
+
end
|
119
|
+
|
120
|
+
it "font_coding_scheme should be 'TeX text.'" do
|
121
|
+
@tfm.font_coding_scheme.should == "TeX text"
|
122
|
+
end
|
123
|
+
|
124
|
+
it "font_identifier should be 'CMB'." do
|
125
|
+
@tfm.font_identifier.should == "CMB"
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should contains 128 character informations." do
|
129
|
+
@tfm.char.size.should == 128
|
130
|
+
end
|
131
|
+
|
132
|
+
it "width of 'a' should be 0.486113(design-size unit)." do
|
133
|
+
(@tfm.char[97].width*1000000).round.should == 486113
|
134
|
+
end
|
135
|
+
|
136
|
+
it "height of 'a' should be 0.444445(design-size unit)." do
|
137
|
+
(@tfm.char[97].height*1000000).round.should == 444445
|
138
|
+
end
|
139
|
+
|
140
|
+
it "depth of 'a' should be 0." do
|
141
|
+
@tfm.char[97].depth.should == 0
|
142
|
+
end
|
143
|
+
|
144
|
+
it "italic correction size of 'a' should be 0." do
|
145
|
+
@tfm.char[97].italic_correction.should == 0
|
146
|
+
end
|
147
|
+
|
148
|
+
it "width of 'y' should be width 0.527781(design-size unit)." do
|
149
|
+
(@tfm.char[121].width*1000000).round.should == 527781
|
150
|
+
end
|
151
|
+
|
152
|
+
it "height of 'y' should be 0.444445(design-size unit)." do
|
153
|
+
(@tfm.char[121].height*1000000).round.should == 444445
|
154
|
+
end
|
155
|
+
|
156
|
+
it "depth of 'y' should be 0.194445(design-size unit)." do
|
157
|
+
(@tfm.char[121].depth*1000000).round.should == 194445
|
158
|
+
end
|
159
|
+
|
160
|
+
it "italic correction size of 'y' should be 0.013888(design-size unit)." do
|
161
|
+
(@tfm.char[121].italic_correction*1000000).round.should == 13888
|
162
|
+
end
|
163
|
+
|
164
|
+
after do
|
165
|
+
@tfm = nil
|
166
|
+
end
|
167
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
desc 'Release the website and new gem version'
|
2
|
+
task :deploy => [:check_version, :website, :release] do
|
3
|
+
puts "Remember to create SVN tag:"
|
4
|
+
puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
5
|
+
"svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
6
|
+
puts "Suggested comment:"
|
7
|
+
puts "Tagging release #{CHANGES}"
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
11
|
+
task :local_deploy => [:website_generate, :install_gem]
|
12
|
+
|
13
|
+
task :check_version do
|
14
|
+
unless ENV['VERSION']
|
15
|
+
puts 'Must pass a VERSION=x.y.z release version'
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
unless ENV['VERSION'] == VERS
|
19
|
+
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
|
25
|
+
task :install_gem_no_doc => [:clean, :package] do
|
26
|
+
sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
|
27
|
+
end
|
28
|
+
|
29
|
+
namespace :manifest do
|
30
|
+
desc 'Recreate Manifest.txt to include ALL files'
|
31
|
+
task :refresh do
|
32
|
+
`rake check_manifest | patch -p0 > Manifest.txt`
|
33
|
+
end
|
34
|
+
end
|
data/tasks/dvi.rake
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
namespace "dvi" do
|
2
|
+
desc "Download sample tfm files."
|
3
|
+
task :download_tfm do
|
4
|
+
url = "http://www.ctan.org/get/fonts/cm/tfm"
|
5
|
+
[ "cmr8.tfm", "cmr10.tfm", "cmr12.tfm", "cmb10.tfm" ].each do |name|
|
6
|
+
unless File.exist?(File.join(File.dirname(__FILE__), "..", "tmp", "tfm", name))
|
7
|
+
sh %{ curl --create-dirs --location -o tmp/tfm/#{name} #{url}/#{name} }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "Make ls-R."
|
13
|
+
task :lsr => :download_tfm do
|
14
|
+
sh %{mktexlsr tmp}
|
15
|
+
end
|
16
|
+
end
|
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/*_spec.rb']
|
21
|
+
end
|
data/tasks/website.rake
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
desc 'Generate website files'
|
2
|
+
task :website_generate => :ruby_env do
|
3
|
+
(Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
|
4
|
+
sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
desc 'Upload website files to rubyforge'
|
9
|
+
task :website_upload do
|
10
|
+
host = "#{rubyforge_username}@rubyforge.org"
|
11
|
+
remote_dir = "/var/www/gforge-projects/#{PATH}/"
|
12
|
+
local_dir = 'website'
|
13
|
+
sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate and upload website files'
|
17
|
+
task :website => [:website_generate, :website_upload, :publish_docs]
|
data/website/index.html
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
7
|
+
<title>
|
8
|
+
ruby-dvi
|
9
|
+
</title>
|
10
|
+
<script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
|
11
|
+
<style>
|
12
|
+
|
13
|
+
</style>
|
14
|
+
<script type="text/javascript">
|
15
|
+
window.onload = function() {
|
16
|
+
settings = {
|
17
|
+
tl: { radius: 10 },
|
18
|
+
tr: { radius: 10 },
|
19
|
+
bl: { radius: 10 },
|
20
|
+
br: { radius: 10 },
|
21
|
+
antiAlias: true,
|
22
|
+
autoPad: true,
|
23
|
+
validTags: ["div"]
|
24
|
+
}
|
25
|
+
var versionBox = new curvyCorners(settings, document.getElementById("version"));
|
26
|
+
versionBox.applyCornersToAll();
|
27
|
+
}
|
28
|
+
</script>
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="main">
|
32
|
+
|
33
|
+
<h1>ruby-dvi</h1>
|
34
|
+
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/dvi"; return false'>
|
35
|
+
<p>Get Version</p>
|
36
|
+
<a href="http://rubyforge.org/projects/dvi" class="numbers">0.1.0</a>
|
37
|
+
</div>
|
38
|
+
<h2>What</h2>
|
39
|
+
|
40
|
+
|
41
|
+
<p>This is a library to read <acronym title="DeVice Independent">DVI</acronym> and <acronym title="TeX Font Metric">TFM</acronym> file format.</p>
|
42
|
+
|
43
|
+
|
44
|
+
<h2>Installing</h2>
|
45
|
+
|
46
|
+
|
47
|
+
<p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">dvi</span></pre></p>
|
48
|
+
|
49
|
+
|
50
|
+
<h2><span class="caps">API</span> document</h2>
|
51
|
+
|
52
|
+
|
53
|
+
<p><a href="http://dvi.rubyforge.org/rdoc/">http://dvi.rubyforge.org/rdoc/</a></p>
|
54
|
+
|
55
|
+
|
56
|
+
<h2>The basics</h2>
|
57
|
+
|
58
|
+
|
59
|
+
<h3>Read <span class="caps">DVI</span> file</h3>
|
60
|
+
|
61
|
+
|
62
|
+
<p><pre class='syntax'>
|
63
|
+
<span class="constant">Dvi</span><span class="punct">.</span><span class="ident">read</span><span class="punct">(</span><span class="constant">File</span><span class="punct">.</span><span class="ident">open</span><span class="punct">(</span><span class="ident">path</span><span class="punct">))</span>
|
64
|
+
</pre></p>
|
65
|
+
|
66
|
+
|
67
|
+
<h3>Read <span class="caps">TFM</span> file</h3>
|
68
|
+
|
69
|
+
|
70
|
+
<p><pre class='syntax'>
|
71
|
+
<span class="constant">Dvi</span><span class="punct">::</span><span class="constant">Tfm</span><span class="punct">.</span><span class="ident">read</span><span class="punct">(</span><span class="constant">File</span><span class="punct">.</span><span class="ident">open</span><span class="punct">(</span><span class="ident">path</span><span class="punct">))</span>
|
72
|
+
</pre></p>
|
73
|
+
|
74
|
+
|
75
|
+
<h2>Test</h2>
|
76
|
+
|
77
|
+
|
78
|
+
<pre>rake spec</pre>
|
79
|
+
|
80
|
+
<p>You should run before test:</p>
|
81
|
+
|
82
|
+
|
83
|
+
<pre>rake dvi:lsr</pre>
|
84
|
+
|
85
|
+
<h2>Forum</h2>
|
86
|
+
|
87
|
+
|
88
|
+
<p><a href="http://groups.google.com/group/ruby-dvi">http://groups.google.com/group/ruby-dvi</a></p>
|
89
|
+
|
90
|
+
|
91
|
+
<h2>How to submit patches</h2>
|
92
|
+
|
93
|
+
|
94
|
+
<p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people’s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
|
95
|
+
|
96
|
+
|
97
|
+
<p>The trunk repository is <code>svn://rubyforge.org/var/svn/dvi/trunk</code> for anonymous access.</p>
|
98
|
+
|
99
|
+
|
100
|
+
<h2>License</h2>
|
101
|
+
|
102
|
+
|
103
|
+
<p>This code is free to use under the terms of the Ruby license.</p>
|
104
|
+
|
105
|
+
|
106
|
+
<h2>Contact</h2>
|
107
|
+
|
108
|
+
|
109
|
+
<p>Comments are welcome. Send an email to <a href="mailto:keita.yamaguchi@gmail.com">Keita Yamaguchi</a> or the <a href="http://groups.google.com/group/ruby-dvi">forum</a></p>
|
110
|
+
<p class="coda">
|
111
|
+
<a href="keita.yamaguchi@gmail.com">FIXME full name</a>, 18th December 2007<br>
|
112
|
+
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
113
|
+
</p>
|
114
|
+
</div>
|
115
|
+
|
116
|
+
<!-- insert site tracking codes here, like Google Urchin -->
|
117
|
+
|
118
|
+
</body>
|
119
|
+
</html>
|
data/website/index.txt
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
h1. ruby-dvi
|
2
|
+
|
3
|
+
h2. What
|
4
|
+
|
5
|
+
This is a library to read DVI(DeVice Independent) and TFM(TeX Font Metric) file format.
|
6
|
+
|
7
|
+
h2. Installing
|
8
|
+
|
9
|
+
<pre syntax="ruby">sudo gem install dvi</pre>
|
10
|
+
|
11
|
+
h2. API document
|
12
|
+
|
13
|
+
"http://dvi.rubyforge.org/rdoc/":http://dvi.rubyforge.org/rdoc/
|
14
|
+
|
15
|
+
h2. The basics
|
16
|
+
|
17
|
+
|
18
|
+
h3. Read DVI file
|
19
|
+
|
20
|
+
<pre syntax="ruby">
|
21
|
+
Dvi.read(File.open(path))
|
22
|
+
</pre>
|
23
|
+
|
24
|
+
h3. Read TFM file
|
25
|
+
|
26
|
+
<pre syntax="ruby">
|
27
|
+
Dvi::Tfm.read(File.open(path))
|
28
|
+
</pre>
|
29
|
+
|
30
|
+
h2. Test
|
31
|
+
|
32
|
+
<pre>rake spec</pre>
|
33
|
+
|
34
|
+
You should run before test:
|
35
|
+
|
36
|
+
<pre>rake dvi:lsr</pre>
|
37
|
+
|
38
|
+
h2. Forum
|
39
|
+
|
40
|
+
"http://groups.google.com/group/ruby-dvi":http://groups.google.com/group/ruby-dvi
|
41
|
+
|
42
|
+
h2. How to submit patches
|
43
|
+
|
44
|
+
Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.
|
45
|
+
|
46
|
+
The trunk repository is <code>svn://rubyforge.org/var/svn/dvi/trunk</code> for anonymous access.
|
47
|
+
|
48
|
+
h2. License
|
49
|
+
|
50
|
+
This code is free to use under the terms of the Ruby license.
|
51
|
+
|
52
|
+
h2. Contact
|
53
|
+
|
54
|
+
Comments are welcome. Send an email to "Keita Yamaguchi":mailto:keita.yamaguchi@gmail.com or the "forum":http://groups.google.com/group/ruby-dvi
|
55
|
+
|