rsyntaxtree 0.7.1 → 0.7.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +1 -1
- data/README.md +9 -8
- data/bin/rsyntaxtree +22 -15
- data/fonts/NotoSans-Bold.ttf +0 -0
- data/fonts/NotoSans-BoldItalic.ttf +0 -0
- data/fonts/NotoSans-Italic.ttf +0 -0
- data/fonts/NotoSans-Regular.ttf +0 -0
- data/fonts/NotoSerif-Bold.ttf +0 -0
- data/fonts/NotoSerif-BoldItalic.ttf +0 -0
- data/fonts/NotoSerif-Italic.ttf +0 -0
- data/fonts/NotoSerif-Regular.ttf +0 -0
- data/lib/rsyntaxtree.rb +77 -44
- data/lib/rsyntaxtree/element.rb +2 -20
- data/lib/rsyntaxtree/elementlist.rb +2 -18
- data/lib/rsyntaxtree/error_message.rb +23 -18
- data/lib/rsyntaxtree/graph.rb +305 -0
- data/lib/rsyntaxtree/string_parser.rb +28 -38
- data/lib/rsyntaxtree/svg_graph.rb +133 -314
- data/lib/rsyntaxtree/tree_graph.rb +151 -318
- data/lib/rsyntaxtree/utils.rb +20 -0
- data/lib/rsyntaxtree/version.rb +1 -1
- data/rsyntaxtree.gemspec +1 -1
- metadata +19 -14
- data/fonts/DroidSans.ttf +0 -0
- data/fonts/DroidSerif-Regular.ttf +0 -0
- data/fonts/NotoSansMonoCJKjp-Regular.otf +0 -0
- data/lib/rsyntaxtree/imgutils.rb +0 -70
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
#==========================
|
5
|
+
# utils.rb
|
6
|
+
#==========================
|
7
|
+
#
|
8
|
+
# Image utility functions to inspect text font metrics
|
9
|
+
#
|
10
|
+
# This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
|
11
|
+
# excellent program phpSyntaxTree.
|
12
|
+
#
|
13
|
+
# Copyright (c) 2007-2021 Yoichiro Hasebe <yohasebe@gmail.com>
|
14
|
+
# Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
|
15
|
+
|
16
|
+
class String
|
17
|
+
def contains_cjk?
|
18
|
+
!!(self =~ /\p{Han}|\p{Katakana}|\p{Hiragana}|\p{Hangul}/)
|
19
|
+
end
|
20
|
+
end
|
data/lib/rsyntaxtree/version.rb
CHANGED
data/rsyntaxtree.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsyntaxtree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoichiro Hasebe
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rmagick
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.16.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: optimist
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '0'
|
41
41
|
description: Yet another syntax tree generator made with Ruby and RMagick
|
42
42
|
email:
|
43
43
|
- yohasebe@gmail.com
|
@@ -51,27 +51,33 @@ files:
|
|
51
51
|
- README.md
|
52
52
|
- Rakefile
|
53
53
|
- bin/rsyntaxtree
|
54
|
-
- fonts/
|
55
|
-
- fonts/
|
54
|
+
- fonts/NotoSans-Bold.ttf
|
55
|
+
- fonts/NotoSans-BoldItalic.ttf
|
56
|
+
- fonts/NotoSans-Italic.ttf
|
57
|
+
- fonts/NotoSans-Regular.ttf
|
56
58
|
- fonts/NotoSansCJKjp-Regular.otf
|
57
|
-
- fonts/
|
59
|
+
- fonts/NotoSerif-Bold.ttf
|
60
|
+
- fonts/NotoSerif-BoldItalic.ttf
|
61
|
+
- fonts/NotoSerif-Italic.ttf
|
62
|
+
- fonts/NotoSerif-Regular.ttf
|
58
63
|
- fonts/NotoSerifCJKjp-Regular.otf
|
59
64
|
- fonts/wqy-zenhei.ttf
|
60
65
|
- lib/rsyntaxtree.rb
|
61
66
|
- lib/rsyntaxtree/element.rb
|
62
67
|
- lib/rsyntaxtree/elementlist.rb
|
63
68
|
- lib/rsyntaxtree/error_message.rb
|
64
|
-
- lib/rsyntaxtree/
|
69
|
+
- lib/rsyntaxtree/graph.rb
|
65
70
|
- lib/rsyntaxtree/string_parser.rb
|
66
71
|
- lib/rsyntaxtree/svg_graph.rb
|
67
72
|
- lib/rsyntaxtree/tree_graph.rb
|
73
|
+
- lib/rsyntaxtree/utils.rb
|
68
74
|
- lib/rsyntaxtree/version.rb
|
69
75
|
- rsyntaxtree.gemspec
|
70
76
|
homepage: http://github.com/yohasebe/rsyntaxtree
|
71
77
|
licenses:
|
72
78
|
- MIT
|
73
79
|
metadata: {}
|
74
|
-
post_install_message:
|
80
|
+
post_install_message:
|
75
81
|
rdoc_options: []
|
76
82
|
require_paths:
|
77
83
|
- lib
|
@@ -86,9 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
92
|
- !ruby/object:Gem::Version
|
87
93
|
version: '0'
|
88
94
|
requirements: []
|
89
|
-
|
90
|
-
|
91
|
-
signing_key:
|
95
|
+
rubygems_version: 3.2.3
|
96
|
+
signing_key:
|
92
97
|
specification_version: 4
|
93
98
|
summary: RSyntaxTree is a graphical syntax tree generator written in Ruby
|
94
99
|
test_files: []
|
data/fonts/DroidSans.ttf
DELETED
Binary file
|
Binary file
|
Binary file
|
data/lib/rsyntaxtree/imgutils.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# -*- coding: utf-8 -*-
|
3
|
-
|
4
|
-
#==========================
|
5
|
-
# imgutils.rb
|
6
|
-
#==========================
|
7
|
-
#
|
8
|
-
# Image utility functions to inspect text font metrics
|
9
|
-
#
|
10
|
-
# This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
|
11
|
-
# excellent program phpSyntaxTree.
|
12
|
-
#
|
13
|
-
# Copyright (c) 2007-2018 Yoichiro Hasebe <yohasebe@gmail.com>
|
14
|
-
# Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
|
15
|
-
#
|
16
|
-
# This program is free software; you can redistribute it and/or modify
|
17
|
-
# it under the terms of the GNU General Public License as published by
|
18
|
-
# the Free Software Foundation; either version 2 of the License, or
|
19
|
-
# (at your option) any later version.
|
20
|
-
#
|
21
|
-
# This program is distributed in the hope that it will be useful,
|
22
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24
|
-
# GNU General Public License for more details.
|
25
|
-
#
|
26
|
-
# You should have received a copy of the GNU General Public License
|
27
|
-
# along with this program; if not, write to the Free Software
|
28
|
-
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
29
|
-
|
30
|
-
# require 'rubygems'
|
31
|
-
require 'rmagick'
|
32
|
-
include Magick
|
33
|
-
|
34
|
-
def img_get_txt_metrics(text, font, font_size, multiline)
|
35
|
-
|
36
|
-
background = Image.new(500, 250)
|
37
|
-
|
38
|
-
gc = Draw.new
|
39
|
-
gc.annotate(background, 0, 0, 0, 0, text) do |gc|
|
40
|
-
gc.font = font
|
41
|
-
gc.pointsize = font_size
|
42
|
-
gc.gravity = CenterGravity
|
43
|
-
gc.stroke = 'none'
|
44
|
-
end
|
45
|
-
|
46
|
-
if multiline
|
47
|
-
metrics = gc.get_multiline_type_metrics(background, text)
|
48
|
-
else
|
49
|
-
metrics = gc.get_type_metrics(background, text)
|
50
|
-
end
|
51
|
-
|
52
|
-
return metrics
|
53
|
-
end
|
54
|
-
|
55
|
-
def img_get_txt_width(text, font = "Verdana", font_size = 10, multibyte = false)
|
56
|
-
|
57
|
-
metrics = img_get_txt_metrics(text, font, font_size, multibyte)
|
58
|
-
x = metrics.width
|
59
|
-
return x
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
def img_get_txt_height(text, font = "Verdana", font_size = 10, multibyte = false)
|
64
|
-
|
65
|
-
metrics = img_get_txt_metrics(text, font, font_size, multibyte)
|
66
|
-
y = metrics.height
|
67
|
-
return y
|
68
|
-
|
69
|
-
end
|
70
|
-
|