rsyntaxtree 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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-2018 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
@@ -1,4 +1,4 @@
1
1
  module RSyntaxTree
2
- VERSION = "0.7.2"
2
+ VERSION = "0.7.3"
3
3
  end
4
4
 
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.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoichiro Hasebe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-05 00:00:00.000000000 Z
11
+ date: 2018-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rmagick
@@ -51,20 +51,26 @@ files:
51
51
  - README.md
52
52
  - Rakefile
53
53
  - bin/rsyntaxtree
54
- - fonts/DroidSans.ttf
55
- - fonts/DroidSerif-Regular.ttf
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/NotoSansMonoCJKjp-Regular.otf
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/imgutils.rb
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
Binary file
Binary file
@@ -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
-