rsyntaxtree 0.6.92 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6ad7b71169247421655b54b4d81049209dea63e
4
- data.tar.gz: cc0769fc2a20c71dc35e9472d0a9a31d6b7f0e13
3
+ metadata.gz: a5dcdb349a03810a145b1f240feee3ccc72f9f4f
4
+ data.tar.gz: a696ad43029ef6ea253f40a7277c621e52166fee
5
5
  SHA512:
6
- metadata.gz: 8fa57fddcdee21e06ca2793791868268770ab4e56d6f0b4c4b002c831c9c843512b2db2860589a31dcf7c7dd828f48aa873988622793f93a605ae224f9acd5bd
7
- data.tar.gz: b9a26b9894a8fdd7dbb2333d4e4a34ee14d0c8ea53ce15cb111e8401402ca855ec2d1ba080d59c6e2e095d03c96d43844f91f072877341d69d4d9b3b3b0d3b49
6
+ metadata.gz: ea1203926e30c5e02083f0975cb39856cc223ee83d8a9da69792f417b164b55b8f74818f125891aee088d71ccb90e2c451e11b9c2fa829bdae57108689985166
7
+ data.tar.gz: 5dfa20627985562e499262b3e107f0c2fb020d831be3b29c1f47625ad4d381e42aaa70f22fbfbc2e665a5974d2c066f0add3744b6fa99d9bb209fdc8b3269762
data/Gemfile CHANGED
@@ -1,9 +1,4 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem 'sinatra'
4
- gem 'haml'
5
3
  gem 'rmagick'
6
4
  gem 'trollop'
7
- group :development do
8
- gem 'thin'
9
- end
data/README.md CHANGED
@@ -1,14 +1,12 @@
1
1
  # RSyntaxTree: yet another syntax tree generator in Ruby
2
2
 
3
- RSyntaxTree is a graphical syntax tree generator written in the Ruby programming language. It is basically a port of [phpSyntaxTree](http://ironcreek.net/phpsyntaxtree/) created by André Eisenbach.
3
+ **RSyntaxTree** is a graphical syntax tree generator written in the Ruby programming language inspired by [phpSyntaxTree](http://ironcreek.net/phpsyntaxtree/).
4
4
 
5
- While phpSyntaxTree does not accept **multi-byte characters** as those in Chinese, Japanese, and Korean, RSyntaxTree handles text of any language as long as encoded in UTF-8 and fonts have been installed. Additionally, RSyntaxTree can output **symmetrized** tree diagrams, a functionality that is not implemented in phpSyntaxTree.
6
-
7
- RSyntaxTree consists of an easy-to-use command-line app and a web-based interface made with [Sinatra](http://www.sinatrarb.com) web framework.
5
+ - - -
8
6
 
9
7
  ### Web Interface
10
8
 
11
- Working web interface of a previous version of RSyntaxTree is available at http://yohasebe.com/rsyntaxtree . New version will be deployed soon.
9
+ Working web interface of is available at <https://yohasebe.com/rsyntaxtree>.
12
10
 
13
11
  ### Installation
14
12
 
@@ -16,26 +14,29 @@ Working web interface of a previous version of RSyntaxTree is available at http:
16
14
 
17
15
  ### Usage
18
16
 
19
- For the web interface, see Usage section in http://yohasebe.com/rsyntaxtree .
17
+ For the web interface, see Usage section of <https://yohasebe.com/rsyntaxtree>.
20
18
 
21
19
  For the command-line interface, type `$rsyntaxtree -h` after installation. Here's what you get:
22
20
 
23
- RSyntaxTree, (linguistic) syntax tree generator written in Ruby.
24
-
25
- Usage:
26
- rsyntaxtree [options] "[VP [VP [V set] [NP bracket notation]] [ADV here]]"
27
- where [options] are:
28
- --outdir, -o <s>: Output directory (default: present working directory) (default: ./)
29
- --format, -f <s>: Output format: png, pdf, or svg (default: png)
30
- --leafstyle, -l <s>: visual style of tree leaves: auto, triangle, bar, or nothing (default: auto)
31
- --fontstyle, -n <s>: Font style: sans-serif, serif, jp-gothic, jp-mincho, cjk (default: cjk)
32
- --font, -t <s>: Path to a ttf font used to generate tree
33
- --fontsize, -s <i>: Font size: 8-20 (default: 16)
34
- --color, -c <s>: Color text and bars: on or off (default: on)
35
- --symmetrize, -y <s>: Generate symmetrical, balanced tree: on or off (default: on)
36
- --autosub, -a <s>: Put subscript numbers to nodes: on or off (default: off)
37
- --version, -v: Print version and exit
38
- --help, -h: Show this message
21
+ ```text
22
+ RSyntaxTree, (linguistic) syntax tree generator written in Ruby.
23
+
24
+ Usage:
25
+ rsyntaxtree [options] "[VP [VP [V set] [NP bracket notation]] [ADV here]]"
26
+ where [options] are:
27
+ -o, --outdir=<s> Output directory (default: ./)
28
+ -f, --format=<s> Output format: png, pdf, or svg (default: png)
29
+ -l, --leafstyle=<s> visual style of tree leaves: auto, triangle, bar, or nothing (default: auto)
30
+ -n, --fontstyle=<s> Font style (available when ttf font is specified): sans, serif, mono, cjk (default: sans)
31
+ -t, --font=<s> Path to a ttf font used to generate tree (optional)
32
+ -s, --fontsize=<i> Size: 8-26 (default: 16)
33
+ -m, --margin=<i> Margin: 0-120 (default: 0)
34
+ -c, --color=<s> Color text and bars: on or off (default: on)
35
+ -y, --symmetrize=<s> Generate symmetrical, balanced tree: on or off (default: on)
36
+ -a, --autosub=<s> Put subscript numbers to nodes: on or off (default: off)
37
+ -v, --version Print version and exit
38
+ -h, --help Show this message
39
+ ```
39
40
 
40
41
  ### Tips
41
42
 
@@ -49,11 +50,13 @@ You can put a subscript to any node by putting the _ character between the main
49
50
 
50
51
  Bracket notation (auto-subscript-on):
51
52
 
52
- [S [NP RSyntaxTree^][VP [V generates][NP multilingual syntax trees]]]
53
+ ```text
54
+ [S [NP RSyntaxTree^][VP [V generates][NP multilingual syntax trees]]]
55
+ ```
53
56
 
54
57
  Resulting PNG
55
58
 
56
- ![RSyntaxTree generates multilingual syntax trees](http://yohasebe.com/img/rsyntaxtree_example3.png)
59
+ ![RSyntaxTree generates multilingual syntax trees](https://i.gyazo.com/8d8cbce1e8d8d45c0dda0741009641fd.png)
57
60
 
58
61
  ### Development
59
62
 
@@ -61,7 +64,7 @@ For the latest updates and downloads please visit http://github.com/yohasebe/rsy
61
64
 
62
65
  ### Author
63
66
 
64
- Yoichiro Hasebe yohasebe@gmail.com
67
+ Yoichiro Hasebe <yohasebe@gmail.com>
65
68
 
66
69
  ### License
67
70
 
data/bin/rsyntaxtree CHANGED
@@ -7,7 +7,7 @@ require 'rsyntaxtree'
7
7
  require 'trollop'
8
8
 
9
9
  opts = Trollop::options do
10
- version "RSyntaxTree #{RSyntaxTree::VERSION} (c) 2012 Yoichiro Hasebe"
10
+ version "RSyntaxTree #{RSyntaxTree::VERSION} (c) 2018 Yoichiro Hasebe"
11
11
  banner <<-EOS
12
12
  RSyntaxTree, (linguistic) syntax tree generator written in Ruby.
13
13
 
@@ -22,11 +22,13 @@ EOS
22
22
  :default => "png"
23
23
  opt :leafstyle, "visual style of tree leaves: auto, triangle, bar, or nothing",
24
24
  :default => "auto"
25
- opt :fontstyle, "Font style (available when ttf font is specified): sans-serif, serif, jp-gothic, jp-mincho, cjk",
26
- :default => "cjk"
25
+ opt :fontstyle, "Font style (available when ttf font is specified): sans, serif, mono, cjk",
26
+ :default => "sans"
27
27
  opt :font, "Path to a ttf font used to generate tree (optional)", :type => String
28
- opt :fontsize, "Font size: 8-20",
28
+ opt :fontsize, "Size: 8-26",
29
29
  :default => 16
30
+ opt :margin, "Margin: 0-120",
31
+ :default => 0
30
32
  opt :color, "Color text and bars: on or off",
31
33
  :default => "on"
32
34
  opt :symmetrize, "Generate symmetrical, balanced tree: on or off",
@@ -38,30 +40,31 @@ end
38
40
  Trollop::die :outdir, "must be an exsting directory path" unless FileTest::directory?(opts[:outdir])
39
41
  Trollop::die :format, "must be png or svg" unless /\A(png|pdf|svg)\z/ =~ opts[:format]
40
42
  Trollop::die :leafstyle, "must be auto, triangle, bar, or nothing" unless /\A(auto|triangle|bar|nothing)\z/ =~ opts[:leafstyle]
41
- Trollop::die :fontstyle, "must be sans-serif, serif, jp-gothic, jp-mincho, or cjk" unless /\A(sans\-serif|serif|jp\-gothic|jp\-mincho|cjk)\z/ =~ opts[:fontstyle]
43
+ Trollop::die :fontstyle, "must be sans, serif, mono, cjk" unless /\A(sans|serif|mono|cjk)\z/ =~ opts[:fontstyle]
42
44
  Trollop::die :font, "must be path to an existing ttf font" if opts[:font] && !File::exists?(opts[:font])
43
- Trollop::die :fontsize, "must be in the range 8-20" unless opts[:fontsize] >= 8 && opts[:fontsize] <= 20
45
+ Trollop::die :fontsize, "must be in the range 8-26" unless opts[:fontsize] >= 8 && opts[:fontsize] <= 26
46
+ Trollop::die :margin, "must be in the range 0-120" if opts[:margin] < 0 || opts[:margin] > 120
44
47
  Trollop::die :color, "must be either on or off" unless /\A(on|off)\z/ =~ opts[:color]
45
48
  Trollop::die :symmetrize, "must be either on or off" unless /\A(on|off)\z/ =~ opts[:symmetrize]
46
49
  Trollop::die :autosub, "must be either on or off" unless /\A(on|off)\z/ =~ opts[:autosub]
47
50
 
48
51
  string_opts = {}
49
52
  opts.each do |key, value|
50
- string_opts[key.to_s] = value unless key == :font && !value
53
+ string_opts[key.to_sym] = value unless key == :font && !value
51
54
  end
52
55
 
53
56
  data = ARGV[0]
54
57
 
55
58
  unless data && RSGenerator.check_data(data)
56
- puts "bracket notation given is invalid"
59
+ puts "Error: given bracket notation is invalid; try 'rsyntaxtree --help' "
57
60
  exit
58
61
  end
59
62
 
60
- string_opts["data"] = data
63
+ string_opts[:data] = data
61
64
 
62
65
  rsg = RSGenerator.new(string_opts)
63
- ext = string_opts["format"]
64
- outfile = File.new(File.expand_path(string_opts["outdir"]) + "/syntree." + ext, "wb")
66
+ ext = string_opts[:format]
67
+ outfile = File.new(File.expand_path(string_opts[:outdir]) + "/syntree." + ext, "wb")
65
68
  case ext
66
69
  when "png"
67
70
  outfile.write rsg.draw_png
Binary file
Binary file
Binary file
data/lib/rsyntaxtree.rb CHANGED
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
12
12
  # excellent program phpSyntaxTree.
13
- # Copyright (c) 2007-2009 Yoichiro Hasebe <yohasebe@gmail.com>
13
+ # Copyright (c) 2007-2018 Yoichiro Hasebe <yohasebe@gmail.com>
14
14
  # Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
15
15
  #
16
16
  # This program is free software; you can redistribute it and/or modify
@@ -28,7 +28,6 @@
28
28
  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29
29
 
30
30
  $LOAD_PATH << File.join( File.dirname(__FILE__), 'rsyntaxtree')
31
- $LOAD_PATH << File.join( File.dirname(__FILE__), '../helpers')
32
31
 
33
32
  require 'uri'
34
33
  require 'imgutils'
@@ -38,32 +37,18 @@ require 'string_parser'
38
37
  require 'tree_graph'
39
38
  require 'svg_graph'
40
39
  require 'error_message'
41
- require 'helpers'
42
40
  require 'version'
41
+ require 'pp'
43
42
 
44
43
  FONT_DIR = File.expand_path(File.dirname(__FILE__) + "/../fonts")
45
44
 
46
- ##################################################
47
- # if !development?
48
- # # load and store Google Analytics code, if any, to a variable
49
- # ga_path = File.dirname(__FILE__) + "/../google_analytics_tracking_code"
50
- # if File.exists?(ga_path)
51
- # gfile = File.open(ga_path, "r:UTF-8:UTF-8")
52
- # $GOOGLE_CODE = gfile.read
53
- # gfile.close
54
- # else
55
- # $GOOGLE_CODE = ""
56
- # end
57
- # end
58
- ##################################################
59
-
60
45
  class RSGenerator
61
- include Helpers
62
46
  def initialize(params = {})
63
47
  new_params = {}
64
- params.each do |key, value|
48
+ params.each do |keystr, value|
49
+ key = keystr.to_sym
65
50
  case key
66
- when "data"
51
+ when :data
67
52
  data = URI.unescape(value)
68
53
  data = data.gsub('-AMP-', '&')
69
54
  .gsub('-PERCENT-', "%")
@@ -72,83 +57,80 @@ class RSGenerator
72
57
  .gsub('-OABRACKET-', '<')
73
58
  .gsub('-CABRACKET-', '>')
74
59
  new_params[key] = data
75
- when "symmetrize", "color", "autosub"
76
- new_params[key] = value == "on"? true : false
77
- when "fontsize"
60
+ when :symmetrize, :color, :autosub
61
+ new_params[key] = value && value != "off" ? true : false
62
+ when :fontsize
63
+ new_params[key] = value.to_i
64
+ when :margin
78
65
  new_params[key] = value.to_i
79
- when "fontstyle"
80
- if value == "sans-serif"
81
- new_params["font"] = FONT_DIR + "/DroidSans.ttf"
82
- elsif value == "serif"
83
- new_params["font"] = FONT_DIR + "/DroidSerif-Regular.ttf"
84
- elsif value == "jp-gothic"
85
- new_params["font"] = FONT_DIR + "/ipagp.ttf"
86
- elsif value == "jp-mincho"
87
- new_params["font"] = FONT_DIR + "/ipamp.ttf"
88
- elsif value == "cjk"
89
- new_params["font"] = FONT_DIR + "/wqy-zenhei.ttf"
90
- elsif value == "aru"
91
- new_params["font"] = FONT_DIR + "/ArialUnicode.ttf"
92
- elsif value == "tnr"
93
- new_params["font"] = FONT_DIR + "/TimesNewRoman.ttf"
94
- elsif value == "noto"
95
- new_params["font"] = FONT_DIR + "/NotoSansCJK.ttc"
66
+ when :fontstyle
67
+ if value == "noto-sans" || value == "sans"
68
+ new_params[:font] = FONT_DIR + "/NotoSansCJKjp-Regular.otf"
69
+ elsif value == "noto-serif" || value == "serif"
70
+ new_params[:font] = FONT_DIR + "/NotoSerifCJKjp-Regular.otf"
71
+ elsif value == "noto-mono" || value == "mono"
72
+ new_params[:font] = FONT_DIR + "/NotoSansMonoCJKjp-Regular.otf"
73
+ elsif value == "western-sans"
74
+ new_params[:font] = FONT_DIR + "/DroidSans.ttf"
75
+ elsif value == "western-serif"
76
+ new_params[:font] = FONT_DIR + "/DroidSerif-Regular.ttf"
77
+ elsif value == "cjk zenhei" || value == "cjk"
78
+ new_params[:font] = FONT_DIR + "/wqy-zenhei.ttf"
96
79
  end
97
80
  else
98
81
  new_params[key] = value
99
82
  end
100
83
  end
101
84
 
102
-
103
85
  @params = {
104
- "symmetrize" => true,
105
- "color" => true,
106
- "autosub" => false,
107
- "fontsize" => 18,
108
- "format" => "png",
109
- "leafstyle" => "auto",
110
- "font" => FONT_DIR + "/ipagp.ttf",
111
- "filename" => "syntree",
112
- "data" => "",
86
+ :symmetrize => true,
87
+ :color => true,
88
+ :autosub => false,
89
+ :fontsize => 18,
90
+ :format => "png",
91
+ :leafstyle => "auto",
92
+ :font => FONT_DIR + "/NotoSansCKjp-Regular.otf",
93
+ :filename => "syntree",
94
+ :data => "",
95
+ :margin => 0
113
96
  }
114
97
 
115
98
  @params.merge! new_params
116
99
  end
117
100
 
118
101
  def self.check_data(text)
119
- # StringParser.validate_text(text)
120
102
  sp = StringParser.new(text)
121
103
  sp.valid?
122
104
  end
123
105
 
124
106
  def draw_png
125
- @params["format"] = "png"
107
+ @params[:format] = "png"
126
108
  draw_tree
127
109
  end
128
110
 
129
111
  def draw_pdf
130
- @params["format"] = "pdf"
112
+ @params[:format] = "pdf"
131
113
  draw_tree
132
114
  end
133
115
 
134
116
  def draw_tree
135
- sp = StringParser.new(@params["data"])
117
+ sp = StringParser.new(@params[:data])
136
118
  sp.parse
137
- sp.auto_subscript if @params["autosub"]
119
+ sp.auto_subscript if @params[:autosub]
138
120
  elist = sp.get_elementlist
139
121
  graph = TreeGraph.new(elist,
140
- @params["symmetrize"], @params["color"], @params["leafstyle"], @params["font"], @params["fontsize"], @params["format"])
141
- graph.to_blob(@params["format"])
122
+ @params[:symmetrize], @params[:color], @params[:leafstyle], @params[:font], @params[:fontsize], @params[:format], @params[:margin])
123
+ graph.to_blob(@params[:format])
142
124
  end
143
125
 
144
126
  def draw_svg
145
- @params["format"] = "svg"
146
- sp = StringParser.new(@params["data"].gsub('&', '&amp;').gsub('%', '&#37;'))
127
+ @params[:format] = "svg"
128
+ sp = StringParser.new(@params[:data].gsub('&', '&amp;').gsub('%', '&#37;'))
147
129
  sp.parse
148
- sp.auto_subscript if @params["autosub"]
130
+ sp.auto_subscript if @params[:autosub]
149
131
  elist = sp.get_elementlist
150
132
  graph = SVGGraph.new(elist,
151
- @params["symmetrize"], @params["color"], @params["leafstyle"], @params["font"], @params["fontsize"])
133
+ @params[:symmetrize], @params[:color], @params[:leafstyle], @params[:font], @params[:fontsize])
152
134
  graph.svg_data
153
135
  end
154
136
  end
@@ -10,7 +10,7 @@
10
10
  # This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
11
11
  # excellent program phpSyntaxTree.
12
12
  #
13
- # Copyright (c) 2007-2009 Yoichiro Hasebe <yohasebe@gmail.com>
13
+ # Copyright (c) 2007-2018 Yoichiro Hasebe <yohasebe@gmail.com>
14
14
  # Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
15
15
  #
16
16
  # This program is free software; you can redistribute it and/or modify
@@ -10,7 +10,7 @@
10
10
  # This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
11
11
  # excellent program phpSyntaxTree.
12
12
  #
13
- # Copyright (c) 2007-2009 Yoichiro Hasebe <yohasebe@gmail.com>
13
+ # Copyright (c) 2007-2018 Yoichiro Hasebe <yohasebe@gmail.com>
14
14
  # Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
15
15
  #
16
16
  # This program is free software; you can redistribute it and/or modify
@@ -134,4 +134,4 @@ class ElementList
134
134
  end
135
135
 
136
136
  end
137
-
137
+
@@ -10,7 +10,7 @@
10
10
  # This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
11
11
  # excellent program phpSyntaxTree.
12
12
  #
13
- # Copyright (c) 2007-2009 Yoichiro Hasebe <yohasebe@gmail.com>
13
+ # Copyright (c) 2007-2018 Yoichiro Hasebe <yohasebe@gmail.com>
14
14
  # Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
15
15
  #
16
16
  # This program is free software; you can redistribute it and/or modify
@@ -10,7 +10,7 @@
10
10
  # This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
11
11
  # excellent program phpSyntaxTree.
12
12
  #
13
- # Copyright (c) 2007-2009 Yoichiro Hasebe <yohasebe@gmail.com>
13
+ # Copyright (c) 2007-2018 Yoichiro Hasebe <yohasebe@gmail.com>
14
14
  # Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
15
15
  #
16
16
  # This program is free software; you can redistribute it and/or modify
@@ -11,7 +11,7 @@
11
11
  # This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
12
12
  # excellent program phpSyntaxTree.
13
13
  #
14
- # Copyright (c) 2007-2009 Yoichiro Hasebe <yohasebe@gmail.com>
14
+ # Copyright (c) 2007-2018 Yoichiro Hasebe <yohasebe@gmail.com>
15
15
  # Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
16
16
  #
17
17
  # This program is free software; you can redistribute it and/or modify
@@ -10,7 +10,7 @@
10
10
  # This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
11
11
  # excellent program phpSyntaxTree.
12
12
  #
13
- # Copyright (c) 2007-2009 Yoichiro Hasebe <yohasebe@gmail.com>
13
+ # Copyright (c) 2007-2018 Yoichiro Hasebe <yohasebe@gmail.com>
14
14
  # Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
15
15
  #
16
16
  # This program is free software; you can redistribute it and/or modify
@@ -10,7 +10,7 @@
10
10
  # This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
11
11
  # excellent program phpSyntaxTree.
12
12
  #
13
- # Copyright (c) 2007-2009 Yoichiro Hasebe <yohasebe@gmail.com>
13
+ # Copyright (c) 2007-2018 Yoichiro Hasebe <yohasebe@gmail.com>
14
14
  # Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
15
15
  #
16
16
  # This program is free software; you can redistribute it and/or modify
@@ -33,25 +33,27 @@ require 'elementlist'
33
33
  require 'rmagick'
34
34
  include Magick
35
35
 
36
- E_WIDTH = 60 # Element width
37
- E_PADD = 7 # Element height padding
38
- V_SPACE = 20
39
- H_SPACE = 10
40
- B_SIDE = 5
41
- B_TOPBOT = 5
36
+ # Double to make image retina ready
37
+ E_WIDTH = 60 * 2 # Element width
38
+ E_PADD = 7 * 2 # Element height padding
39
+ V_SPACE = 20 * 2
40
+ H_SPACE = 10 * 2
41
+ B_SIDE = 5 * 2
42
+ B_TOPBOT = 5 * 2
42
43
 
43
44
  class TreeGraph
44
45
 
45
46
  def initialize(e_list, symmetrize = true, color = true, terminal = "auto",
46
- font = "Helvetica", font_size = 10, simple = false)
47
+ font = "Helvetica", font_size = 10, simple = false, margin = 0)
47
48
 
48
- # Store parameters
49
+ # Store parameters (double font size and margin to make image retina ready)
49
50
  @e_list = e_list
50
51
  @font = font
51
- @font_size = font_size
52
52
  @terminal = terminal
53
53
  @symmetrize = symmetrize
54
54
  @simple = simple
55
+ @font_size = font_size * 2
56
+ @margin = margin * 2
55
57
 
56
58
  # Element dimensions
57
59
  @e_width = E_WIDTH
@@ -104,6 +106,7 @@ class TreeGraph
104
106
  # by Geoffrey Grosenbach
105
107
  def to_blob(fileformat='PNG')
106
108
  draw
109
+ @im.border!(@margin, @margin, "white")
107
110
  return @im.to_blob do
108
111
  self.format = fileformat
109
112
  end