chunky_text 0.2.7 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb7831b044adeeb0d9678712e1af80e62d9927b7
4
- data.tar.gz: c552886c9542495fb695f01b3879bf2265895185
3
+ metadata.gz: 4ff1543d7340a36fb71b91b4b7d9ce276137219a
4
+ data.tar.gz: da202e5c968f5c1d66db7e473825fc94f755ef9d
5
5
  SHA512:
6
- metadata.gz: 779d1528d0d55e8fd9e41014055c3c1b0e14b713deb6724fcd4c123193f10b6783933feeb8cda8fdbf7564844bf53c7adc69af4e0e4b49221afb520e4bee92a9
7
- data.tar.gz: bcd550412ee657429c0a96e4694b025dda37e7f46580e2bef2b2956fa9f701b91d049374edbae2059ab8984d56935ac7872a78c6f9d98a7055c145c7e2857a6e
6
+ metadata.gz: 40f9033a891b6e0bfde872315bcee20ab2ec508b6fb474cfeae09216d8acaa4b20fca26b3895e0aabae001ed36ed27e8b7cac48e5c4638b8c7a64d70fcc967e9
7
+ data.tar.gz: 093b94ca438ee7caabfcabcb7e2db2f51a78d3b8f580a2a4727400db2eee9bc21b8a4104cc72da09cd84b18567b3a60c04333185215d295d2731821ebdfcd65d
data/chunky_text.gemspec CHANGED
@@ -4,13 +4,13 @@ Gem::Specification.new do |s|
4
4
  s.description = File.read(File.join(File.dirname(__FILE__), 'README'))
5
5
  s.license = "MIT"
6
6
  s.requirements= ['chunky_png gem must be installed.']
7
- s.version = "0.2.7"
7
+ s.version = "0.3.0"
8
8
  s.author = "Marco Bagnaresi"
9
9
  s.email = "info@mbcraft.it"
10
10
  s.homepage = "http://www.mbcraft.it/products/chunky_text.php"
11
11
  s.platform = Gem::Platform::RUBY
12
12
  s.required_ruby_version = '>=1.9'
13
- s.files = Dir['font/**','test/**','**']
13
+ s.files = Dir['font_editor/**','font/**','test/**','**']
14
14
  s.require_paths = ['.']
15
15
  s.add_development_dependency 'rspec', '~>3'
16
16
  s.add_development_dependency 'rake', '~>0'
data/font/default_font.rb CHANGED
@@ -4,6 +4,12 @@ Characters list taken from :
4
4
 
5
5
  http://www.interfacebus.com/html_escape_codes.html
6
6
 
7
+ and from :
8
+
9
+ http://ascii-code.com/
10
+
11
+ Thanks!!
12
+
7
13
  =end
8
14
  module ChunkyText::Font
9
15
 
@@ -124,10 +124,29 @@ module ChunkyText::Font
124
124
  'ñ' => [[[34.0,81.0],[35.0,42.0],],[[36.0,54.0],[43.0,49.0],[50.0,45.0],[61.0,45.0],[69.0,53.0],[70.0,82.0],],[[35.0,32.0],[38.0,29.0],[42.0,28.0],[52.0,33.0],[53.0,34.0],[56.0,37.0],[60.0,36.0],[66.0,32.0],[69.0,30.0],],],
125
125
  'é' => [[[63.0,66.0],[59.0,73.0],[50.0,79.0],[43.0,79.0],[37.0,73.0],[32.0,65.0],[29.0,52.0],[31.0,43.0],[41.0,40.0],[54.0,40.0],[63.0,47.0],[64.0,53.0],[30.0,54.0],],[[42.0,31.0],[56.0,22.0],],],
126
126
  'è' => [[[62.0,69.0],[59.0,75.0],[52.0,80.0],[47.0,80.0],[41.0,80.0],[35.0,74.0],[30.0,66.0],[31.0,59.0],[34.0,50.0],[40.0,44.0],[51.0,41.0],[59.0,46.0],[63.0,55.0],[33.0,54.0],],[[55.0,35.0],[39.0,25.0],],],
127
+ 'ê' => [[[39.0,60.0],[64.0,60.0],[67.0,55.0],[63.0,50.0],[58.0,45.0],[47.0,44.0],[44.0,45.0],[41.0,51.0],[39.0,58.0],[42.0,77.0],[48.0,80.0],[59.0,80.0],[63.0,76.0],[66.0,73.0],],[[42.0,31.0],[51.0,22.0],[61.0,34.0],],],
128
+ 'ë' => [[[39.0,53.0],[66.0,53.0],[63.0,44.0],[60.0,39.0],[54.0,36.0],[45.0,37.0],[40.0,40.0],[38.0,53.0],[38.0,57.0],[42.0,73.0],[48.0,78.0],[50.0,78.0],[56.0,79.0],[59.0,77.0],[62.0,73.0],[64.0,71.0],],[[44.0,26.0],[40.0,26.0],[40.0,18.0],[45.0,18.0],[47.0,19.0],[47.0,23.0],[45.0,25.0],],[[59.0,28.0],[54.0,21.0],[56.0,21.0],[59.0,18.0],[63.0,21.0],[61.0,29.0],],],
127
129
  'ò' => [[[55.0,80.0],[50.0,80.0],[42.0,79.0],[34.0,70.0],[31.0,64.0],[31.0,56.0],[38.0,46.0],[52.0,45.0],[69.0,62.0],[67.0,71.0],[60.0,79.0],[50.0,80.0],],[[59.0,35.0],[37.0,22.0],],],
130
+ 'ó' => [[[54.0,82.0],[45.0,81.0],[41.0,80.0],[35.0,75.0],[33.0,67.0],[35.0,60.0],[38.0,54.0],[44.0,49.0],[55.0,46.0],[61.0,51.0],[63.0,57.0],[65.0,68.0],[55.0,82.0],],[[43.0,36.0],[57.0,27.0],],],
131
+ 'ô' => [[[54.0,82.0],[47.0,81.0],[40.0,78.0],[36.0,66.0],[35.0,58.0],[38.0,52.0],[46.0,49.0],[52.0,49.0],[61.0,54.0],[67.0,70.0],[66.0,77.0],[56.0,82.0],],[[40.0,40.0],[50.0,30.0],[59.0,41.0],],],
132
+ 'õ' => [[[56.0,82.0],[46.0,81.0],[40.0,77.0],[36.0,71.0],[36.0,62.0],[41.0,53.0],[45.0,51.0],[56.0,50.0],[63.0,57.0],[66.0,65.0],[64.0,76.0],[57.0,81.0],],[[40.0,38.0],[46.0,33.0],[50.0,31.0],[55.0,34.0],[56.0,39.0],[57.0,41.0],[68.0,41.0],[68.0,37.0],[69.0,34.0],],],
133
+ 'ö' => [[[50.0,81.0],[43.0,79.0],[38.0,75.0],[34.0,71.0],[33.0,66.0],[34.0,60.0],[38.0,55.0],[43.0,53.0],[50.0,53.0],[60.0,56.0],[64.0,69.0],[62.0,76.0],[51.0,81.0],],[[43.0,43.0],[36.0,42.0],[35.0,38.0],[41.0,34.0],[45.0,36.0],[46.0,42.0],[44.0,44.0],],[[57.0,45.0],[53.0,42.0],[52.0,37.0],[58.0,34.0],[63.0,40.0],[59.0,45.0],],],
128
134
  'à' => [[[33.0,46.0],[39.0,43.0],[46.0,43.0],[55.0,42.0],[63.0,57.0],[62.0,66.0],[60.0,75.0],[64.0,79.0],[71.0,81.0],],[[61.0,69.0],[59.0,73.0],[53.0,77.0],[48.0,80.0],[40.0,80.0],[38.0,80.0],[33.0,74.0],[33.0,68.0],[41.0,62.0],[51.0,61.0],[57.0,66.0],[62.0,69.0],],[[55.0,32.0],[38.0,23.0],],],
135
+ 'á' => [[[64.0,73.0],[59.0,77.0],[48.0,82.0],[38.0,80.0],[33.0,71.0],[32.0,58.0],[36.0,53.0],[45.0,50.0],[52.0,50.0],[58.0,54.0],[65.0,65.0],[66.0,71.0],],[[32.0,36.0],[38.0,34.0],[46.0,33.0],[54.0,34.0],[62.0,38.0],[68.0,55.0],[68.0,60.0],[66.0,67.0],[66.0,70.0],[66.0,75.0],[73.0,81.0],],[[42.0,24.0],[53.0,15.0],],],
136
+ 'â' => [[[52.0,79.0],[46.0,79.0],[37.0,75.0],[34.0,68.0],[36.0,59.0],[45.0,54.0],[60.0,53.0],[67.0,72.0],[52.0,80.0],],[[34.0,42.0],[39.0,39.0],[53.0,34.0],[60.0,37.0],[68.0,55.0],[68.0,64.0],[67.0,73.0],[67.0,77.0],[70.0,81.0],[75.0,82.0],],[[39.0,26.0],[48.0,16.0],[62.0,28.0],],],
137
+ 'ã' => [[[68.0,63.0],[66.0,71.0],[53.0,83.0],[46.0,83.0],[40.0,82.0],[36.0,67.0],[36.0,60.0],[37.0,53.0],[44.0,48.0],[51.0,46.0],[60.0,47.0],[70.0,63.0],],[[37.0,36.0],[47.0,28.0],[61.0,30.0],[69.0,58.0],[69.0,66.0],[69.0,72.0],[71.0,79.0],[73.0,83.0],],[[37.0,19.0],[40.0,16.0],[47.0,11.0],[53.0,18.0],[56.0,22.0],[63.0,22.0],[65.0,19.0],[67.0,17.0],[69.0,13.0],],],
138
+ 'ä' => [[[59.0,80.0],[54.0,81.0],[49.0,81.0],[38.0,79.0],[35.0,73.0],[35.0,68.0],[38.0,63.0],[44.0,60.0],[54.0,58.0],[61.0,62.0],[66.0,76.0],[60.0,81.0],],[[35.0,48.0],[39.0,45.0],[47.0,40.0],[55.0,38.0],[60.0,44.0],[65.0,63.0],[65.0,68.0],[66.0,76.0],[68.0,80.0],[72.0,82.0],[75.0,81.0],],[[42.0,28.0],[40.0,28.0],[38.0,27.0],[37.0,24.0],[39.0,22.0],[42.0,22.0],[45.0,28.0],[43.0,30.0],],[[55.0,29.0],[53.0,29.0],[52.0,26.0],[52.0,24.0],[60.0,27.0],[56.0,30.0],],],
139
+ 'å' => [[[54.0,80.0],[39.0,75.0],[36.0,69.0],[35.0,62.0],[41.0,56.0],[47.0,54.0],[58.0,54.0],[62.0,56.0],[66.0,63.0],[67.0,67.0],[63.0,76.0],[55.0,81.0],],[[36.0,44.0],[41.0,37.0],[44.0,34.0],[50.0,32.0],[54.0,32.0],[61.0,33.0],[65.0,38.0],[69.0,57.0],[69.0,62.0],[68.0,71.0],[69.0,76.0],[73.0,81.0],[75.0,81.0],],[[52.0,24.0],[48.0,23.0],[46.0,21.0],[46.0,18.0],[48.0,15.0],[52.0,15.0],[54.0,16.0],[56.0,19.0],[57.0,24.0],[53.0,25.0],],],
129
140
  'ù' => [[[33.0,44.0],[33.0,52.0],[35.0,63.0],[40.0,72.0],[44.0,78.0],[49.0,79.0],[54.0,80.0],[61.0,77.0],[64.0,72.0],[67.0,62.0],[68.0,47.0],],[[68.0,80.0],[68.0,53.0],],[[60.0,40.0],[41.0,25.0],],],
141
+ 'ú' => [[[35.0,42.0],[35.0,68.0],[35.0,76.0],[47.0,82.0],[59.0,82.0],[64.0,76.0],[64.0,42.0],[66.0,84.0],],[[45.0,36.0],[60.0,25.0],],],
142
+ 'û' => [[[33.0,42.0],[33.0,66.0],[35.0,72.0],[41.0,78.0],[64.0,76.0],[66.0,55.0],[66.0,44.0],[68.0,79.0],],[[40.0,35.0],[51.0,26.0],[59.0,36.0],],],
143
+ 'ü' => [[[35.0,43.0],[36.0,66.0],[38.0,73.0],[42.0,79.0],[55.0,82.0],[61.0,78.0],[67.0,45.0],[68.0,82.0],],[[46.0,35.0],[43.0,33.0],[40.0,29.0],[44.0,27.0],[47.0,28.0],[48.0,32.0],[46.0,36.0],],[[59.0,36.0],[55.0,32.0],[55.0,29.0],[59.0,27.0],[62.0,30.0],[62.0,34.0],[58.0,37.0],],],
144
+ 'ý' => [[[38.0,75.0],[45.0,82.0],[50.0,81.0],[63.0,35.0],],[[56.0,59.0],[39.0,37.0],],[[47.0,32.0],[56.0,24.0],],],
145
+ 'ÿ' => [[[39.0,74.0],[41.0,79.0],[48.0,82.0],[55.0,76.0],[58.0,62.0],[66.0,34.0],],[[59.0,57.0],[39.0,38.0],],[[47.0,32.0],[43.0,30.0],[42.0,25.0],[46.0,24.0],[49.0,27.0],[48.0,34.0],],[[58.0,33.0],[55.0,30.0],[55.0,26.0],[57.0,25.0],[60.0,26.0],[61.0,28.0],[59.0,33.0],],],
130
146
  'ì' => [[[48.0,81.0],[47.0,42.0],],[[55.0,35.0],[41.0,26.0],],],
147
+ 'í' => [[[42.0,80.0],[57.0,81.0],],[[51.0,81.0],[50.0,40.0],],[[45.0,41.0],[56.0,41.0],],[[47.0,29.0],[55.0,21.0],],],
148
+ 'î' => [[[45.0,81.0],[57.0,82.0],],[[52.0,82.0],[52.0,42.0],],[[48.0,42.0],[57.0,42.0],],[[47.0,28.0],[53.0,21.0],[59.0,30.0],],],
149
+ 'ï' => [[[42.0,82.0],[58.0,81.0],],[[51.0,82.0],[51.0,42.0],],[[45.0,42.0],[59.0,42.0],],[[48.0,29.0],[44.0,30.0],[42.0,29.0],[42.0,26.0],[45.0,23.0],[46.0,24.0],[48.0,28.0],],[[56.0,32.0],[54.0,30.0],[54.0,27.0],[54.0,26.0],[59.0,23.0],[61.0,26.0],[62.0,31.0],[57.0,33.0],],],
131
150
  'É' => [[[79.0,28.0],[21.0,28.0],[21.0,80.0],[76.0,81.0],],[[21.0,52.0],[49.0,55.0],],[[30.0,22.0],[63.0,7.0],],],
132
151
  'È' => [[[79.0,31.0],[20.0,32.0],[22.0,80.0],[80.0,82.0],],[[23.0,54.0],[48.0,56.0],],[[62.0,25.0],[36.0,7.0],],],
133
152
  'Ê' => [[[63.0,81.0],[41.0,82.0],[43.0,39.0],[63.0,40.0],],[[44.0,60.0],[55.0,60.0],],[[45.0,31.0],[52.0,25.0],[58.0,34.0],],],
@@ -144,6 +163,7 @@ module ChunkyText::Font
144
163
  'Õ' => [[[49.0,80.0],[43.0,78.0],[39.0,76.0],[32.0,72.0],[32.0,62.0],[33.0,54.0],[35.0,46.0],[39.0,40.0],[45.0,35.0],[56.0,34.0],[65.0,61.0],[56.0,78.0],[49.0,80.0],],[[37.0,28.0],[39.0,25.0],[46.0,23.0],[49.0,27.0],[51.0,30.0],[57.0,31.0],[59.0,29.0],[64.0,24.0],],],
145
164
  'Ö' => [[[48.0,81.0],[42.0,81.0],[40.0,80.0],[37.0,77.0],[34.0,63.0],[34.0,56.0],[34.0,51.0],[38.0,44.0],[42.0,39.0],[47.0,38.0],[55.0,41.0],[60.0,45.0],[64.0,60.0],[64.0,67.0],[61.0,73.0],[57.0,78.0],[49.0,82.0],],[[40.0,31.0],[37.0,31.0],[35.0,28.0],[37.0,25.0],[41.0,25.0],[43.0,28.0],[41.0,32.0],],[[56.0,33.0],[51.0,32.0],[50.0,30.0],[53.0,28.0],[55.0,26.0],[59.0,30.0],[59.0,32.0],[56.0,33.0],],],
146
165
  '×' => [[[40.0,59.0],[62.0,40.0],],[[61.0,62.0],[43.0,39.0],],],
166
+ '÷' => [[[29.0,52.0],[70.0,53.0],],[[51.0,71.0],[45.0,70.0],[41.0,67.0],[42.0,65.0],[47.0,62.0],[52.0,63.0],[55.0,68.0],[52.0,72.0],],[[50.0,43.0],[45.0,42.0],[43.0,38.0],[43.0,33.0],[49.0,32.0],[56.0,36.0],[57.0,41.0],[50.0,45.0],],],
147
167
  'Ø' => [[[51.0,82.0],[44.0,80.0],[36.0,77.0],[31.0,68.0],[30.0,59.0],[30.0,47.0],[32.0,38.0],[36.0,32.0],[43.0,31.0],[52.0,31.0],[58.0,34.0],[65.0,52.0],[66.0,63.0],[64.0,72.0],[59.0,77.0],[53.0,83.0],],[[27.0,81.0],[68.0,29.0],],],
148
168
  'À' => [[[26.0,82.0],[51.0,25.0],[70.0,81.0],],[[40.0,56.0],[62.0,56.0],],[[63.0,23.0],[34.0,6.0],],],
149
169
  'Á' => [[[35.0,80.0],[49.0,35.0],[65.0,80.0],],[[42.0,63.0],[59.0,62.0],],[[43.0,30.0],[56.0,23.0],],],
@@ -0,0 +1,18 @@
1
+
2
+ class Dot extends Object2D implements Drawable {
3
+
4
+ int r;
5
+
6
+ Dot() {
7
+ r = 3;
8
+ }
9
+
10
+ Dot(int radius) {
11
+ r = radius;
12
+ }
13
+
14
+ void draw() {
15
+ fill(0);
16
+ ellipse(x-r,y-r,r*2,r*2);
17
+ }
18
+ }
@@ -0,0 +1,6 @@
1
+
2
+ interface Drawable {
3
+
4
+ void prepare();
5
+ void draw();
6
+ }
@@ -0,0 +1,23 @@
1
+
2
+ static class DrawableList {
3
+
4
+ static ArrayList<Drawable> drawables = new ArrayList<Drawable>();
5
+
6
+ static void add(Drawable d) {
7
+ drawables.add(d);
8
+ }
9
+
10
+ static void remove(Drawable d) {
11
+ drawables.remove(d);
12
+ }
13
+
14
+ static void drawAll() {
15
+ for (int i=0;i<drawables.size();i++) {
16
+ Drawable d = drawables.get(i);
17
+ d.prepare();
18
+ d.draw();
19
+ }
20
+
21
+ }
22
+
23
+ }
@@ -0,0 +1,50 @@
1
+
2
+
3
+ class Object2D implements Position2D{
4
+
5
+ float x = width/2,y = height/2;
6
+ float sx = 1.0,sy = 1.0;
7
+ float a = 0;
8
+
9
+ float getX() {
10
+ return x;
11
+ }
12
+ float getY() {
13
+ return y;
14
+ }
15
+
16
+ void translateTo(float newX,float newY) {
17
+ x = newX;
18
+ y = newY;
19
+ }
20
+
21
+ void translate(PVector v) {
22
+ x+= v.x;
23
+ y+= v.y;
24
+ }
25
+
26
+ void scaleTo(float scaleX,float scaleY) {
27
+ sx = scaleX;
28
+ sy = scaleY;
29
+ }
30
+
31
+ void scale(PVector v) {
32
+ sx+= v.x;
33
+ sy+= v.y;
34
+ }
35
+
36
+ void rotateTo(float angle) {
37
+ a = angle;
38
+ }
39
+
40
+ void rotate(PVector v) {
41
+ a+= v.x;
42
+ }
43
+
44
+ void prepare() {
45
+ translateTo(x,y);
46
+ scaleTo(sx,sy);
47
+ rotateTo(a);
48
+ }
49
+
50
+ }
@@ -0,0 +1,34 @@
1
+
2
+ class PathLineDrawer implements Drawable {
3
+
4
+ PointList path;
5
+
6
+ PathLineDrawer(PointList p) {
7
+ path = p;
8
+ }
9
+
10
+ PointList getPointList() {
11
+ return path;
12
+ }
13
+
14
+ void prepare() {}
15
+
16
+ void draw() {
17
+ strokeWeight(FONT_DRAW_WEIGHT);
18
+
19
+ int currentIndex = 0;
20
+ PVector currentPoint = null;
21
+ PVector lastPoint = null;
22
+ while (currentIndex<path.size()) {
23
+ lastPoint = currentPoint;
24
+ currentPoint = path.get(currentIndex);
25
+ currentIndex++;
26
+ PVector p0 = lastPoint;
27
+ PVector p1 = currentPoint;
28
+ if (p0!=null && p1!=null)
29
+ line(p0.x,p0.y,p1.x,p1.y);
30
+ }
31
+
32
+ }
33
+
34
+ }
@@ -0,0 +1,77 @@
1
+
2
+ class PointList {
3
+ ArrayList<PVector> points = new ArrayList<PVector>();
4
+ boolean debugMode = false;
5
+
6
+ void debug() {
7
+ debugMode = true;
8
+ }
9
+
10
+ void generatePoints() {
11
+ for (int i=0;i<points.size();i++) {
12
+ Dot d = new Dot();
13
+ PVector p = points.get(i);
14
+ d.translateTo(p.x,p.y);
15
+ DrawableList.add(d);
16
+ }
17
+
18
+ }
19
+
20
+ PVector get(int i) {
21
+ return points.get(i);
22
+ }
23
+
24
+ int size() {
25
+ return points.size();
26
+ }
27
+
28
+ void add(float x,float y) {
29
+
30
+ PVector v = new PVector(x,y);
31
+ if (debugMode) {
32
+ Dot d = new Dot();
33
+ d.translateTo(v.x,v.y);
34
+ DrawableList.add(d);
35
+ }
36
+
37
+ points.add(v);
38
+ }
39
+
40
+ void translateAll(PVector v) {
41
+ for (int i=0;i<points.size();i++) {
42
+ PVector p = points.get(i);
43
+ p = PVector.add(p,v);
44
+ points.set(i,p);
45
+ }
46
+ }
47
+
48
+ void scaleAll(PVector v) {
49
+ for (int i=0;i<points.size();i++) {
50
+ PVector p = points.get(i);
51
+ p = p.cross(v);
52
+ points.set(i,p);
53
+ }
54
+ }
55
+
56
+
57
+ void loadFrom(String file) {
58
+ JSONArray array = loadJSONArray(file);
59
+ for (int i=0;i<array.size();i++) {
60
+ JSONObject obj = array.getJSONObject(i);
61
+ add(obj.getFloat("x"),obj.getFloat("y"));
62
+ }
63
+ }
64
+
65
+ void saveTo(String file) {
66
+ JSONArray array = new JSONArray();
67
+ for (int i=0;i<points.size();i++) {
68
+ PVector v = points.get(i);
69
+ JSONObject obj = new JSONObject();
70
+ obj.setFloat("x",v.x);
71
+ obj.setFloat("y",v.y);
72
+ array.setJSONObject(i,obj);
73
+ }
74
+ saveJSONArray(array,file);
75
+ }
76
+
77
+ }
@@ -0,0 +1,9 @@
1
+
2
+ interface Position2D {
3
+
4
+ float getX();
5
+ float getY();
6
+
7
+ void translateTo(float x,float y);
8
+ void translate(PVector v);
9
+ }
@@ -0,0 +1,9 @@
1
+ ==== About this font editor ====
2
+
3
+ This font editor is made with processing. I used this to create the
4
+ included default font.
5
+
6
+ If you create your own font and want them included in the next gem versions
7
+ send me font class(es) and i'll include them in the gem build.
8
+
9
+ -Marco Bagnaresi
@@ -0,0 +1,136 @@
1
+
2
+ //FONT EDITOR for chunky_text
3
+
4
+ //Here you can adjust values to customize the font editing.
5
+ //The font draw area is WIDTH and HEIGHT, its position on the canvas is OFFSET_X and OFFSET_Y
6
+ //Font draw helpers are TOP, BOTTOM, LEFT, RIGHT and SMALL, which are drawn as grey lines.
7
+
8
+ final int OFFSET_X = 200;
9
+ final int OFFSET_Y = 200;
10
+ final int WIDTH = 100;
11
+ final int HEIGHT = 100;
12
+
13
+ final int TOP_Y = 20;
14
+ final int BOTTOM_Y = 80;
15
+ final int LEFT_X = 20;
16
+ final int RIGHT_X = 80;
17
+ final int SMALL_Y = 40;
18
+
19
+ final int FONT_DRAW_WEIGHT = 1;
20
+
21
+ //You can even customize keys ...
22
+
23
+ final int PRINT_DUMP_KEYCODE = DOWN;
24
+ final int PREPARE_FOR_CHARACTER_KEYCODE = UP;
25
+ final int CLEAN_AREA_KEYCODE = ENTER;
26
+
27
+ //
28
+ // code follows ...
29
+ //
30
+
31
+ boolean printKey = false;
32
+ PointList currentPl = new PointList();
33
+
34
+ ArrayList<PathLineDrawer> toDraw = new ArrayList<PathLineDrawer>();
35
+
36
+ void horizontal(int y) {
37
+ strokeWeight(1);
38
+ stroke(128,128,128);
39
+ line(OFFSET_X,OFFSET_Y+y,OFFSET_X+WIDTH,OFFSET_Y+y);
40
+ }
41
+
42
+ void vertical(int x) {
43
+ strokeWeight(1);
44
+ stroke(128,128,128);
45
+ line(OFFSET_X+x,OFFSET_Y,OFFSET_X+x,OFFSET_Y+HEIGHT);
46
+ }
47
+
48
+ void clearBackground() {
49
+ strokeWeight(1);
50
+ stroke(0,0,0);
51
+ rect(OFFSET_X,OFFSET_Y,WIDTH,HEIGHT);
52
+ }
53
+
54
+ void reset() {
55
+ clearBackground();
56
+ vertical(LEFT_X);
57
+ vertical(RIGHT_X);
58
+ horizontal(TOP_Y);
59
+ horizontal(SMALL_Y);
60
+ horizontal(BOTTOM_Y);
61
+ clean();
62
+ breakList();
63
+ }
64
+
65
+ void setup() {
66
+ size(640,480);
67
+ reset();
68
+
69
+ print("INSTRUCTIONS : ");
70
+ print("");
71
+ print("Use left mouse button to draw linked segments, and right mouse button to start a new polyline.\n");
72
+ print("Press up arrow, then the key you want to dump.\n");
73
+ print("Then press down arrow to print the dump.\n");
74
+ print("Press enter to clean the area after a character is finished or you make some mistakes during draw.\n");
75
+ print("When the editing is finished, copy the output from the console to the class font you\'re creating.\n");
76
+ print("-------------------------------------------------------\n\n");
77
+
78
+ }
79
+
80
+ void draw () {
81
+ stroke(0,0,0);
82
+ for (int i=0;i<toDraw.size();i++) {
83
+ PathLineDrawer d = toDraw.get(i);
84
+ d.draw();
85
+ }
86
+ }
87
+
88
+ void breakList() {
89
+ currentPl = new PointList();
90
+ toDraw.add(new PathLineDrawer(currentPl));
91
+ }
92
+
93
+ void clean() {
94
+ toDraw.clear();
95
+
96
+ }
97
+
98
+ void mouseClicked() {
99
+ if (mouseButton==LEFT) {
100
+ currentPl.add(mouseX,mouseY);
101
+ }
102
+ if (mouseButton==RIGHT) {
103
+ breakList();
104
+ }
105
+ }
106
+
107
+ void keyPressed() {
108
+
109
+ if (printKey) {
110
+ printKey = false;
111
+ print("'"+key+"' => ");
112
+ }
113
+ if (keyCode==PRINT_DUMP_KEYCODE) {
114
+ print("[");
115
+ for (int i=0;i<toDraw.size();i++) {
116
+ print ("[");
117
+ PointList pl = toDraw.get(i).getPointList();
118
+ for (int j=0;j<pl.size();j++) {
119
+ print ("[");
120
+ print ((pl.get(j).x-OFFSET_X)+","+(pl.get(j).y-OFFSET_Y));
121
+ print ("],");
122
+ }
123
+ print ("],");
124
+ }
125
+ print("],");
126
+ print("\n");
127
+ }
128
+
129
+ if (keyCode==PREPARE_FOR_CHARACTER_KEYCODE) {
130
+ printKey = true;
131
+ }
132
+
133
+ if (keyCode==CLEAN_AREA_KEYCODE) {
134
+ reset();
135
+ }
136
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chunky_text
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Bagnaresi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-23 00:00:00.000000000 Z
11
+ date: 2015-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -73,6 +73,15 @@ files:
73
73
  - chunky_text.rb
74
74
  - font/default_font.rb
75
75
  - font/default_font.rb~
76
+ - font_editor/Dot.pde
77
+ - font_editor/Drawable.pde
78
+ - font_editor/DrawableList.pde
79
+ - font_editor/Object2D.pde
80
+ - font_editor/PathLineDrawer.pde
81
+ - font_editor/PointList.pde
82
+ - font_editor/Position2D.pde
83
+ - font_editor/README.md
84
+ - font_editor/font_editor.pde
76
85
  - font_metrics.rb
77
86
  homepage: http://www.mbcraft.it/products/chunky_text.php
78
87
  licenses: