rays 0.1.46 → 0.1.48
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 +4 -4
- data/.doc/ext/rays/bitmap.cpp +499 -0
- data/.doc/ext/rays/camera.cpp +2 -2
- data/.doc/ext/rays/defs.cpp +35 -11
- data/.doc/ext/rays/font.cpp +50 -2
- data/.doc/ext/rays/native.cpp +2 -4
- data/.doc/ext/rays/painter.cpp +111 -6
- data/.doc/ext/rays/polygon.cpp +152 -41
- data/.doc/ext/rays/polyline.cpp +89 -10
- data/.doc/ext/rays/rays.cpp +91 -11
- data/.doc/ext/rays/{noise.cpp → util.cpp} +2 -2
- data/.github/workflows/test.yml +0 -1
- data/ChangeLog.md +38 -0
- data/Rakefile +4 -4
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +501 -0
- data/ext/rays/camera.cpp +2 -2
- data/ext/rays/defs.cpp +35 -11
- data/ext/rays/defs.h +56 -3
- data/ext/rays/font.cpp +56 -4
- data/ext/rays/native.cpp +2 -4
- data/ext/rays/painter.cpp +125 -11
- data/ext/rays/polygon.cpp +161 -41
- data/ext/rays/polyline.cpp +95 -9
- data/ext/rays/rays.cpp +91 -11
- data/ext/rays/{noise.cpp → util.cpp} +2 -2
- data/include/rays/defs.h +24 -0
- data/include/rays/font.h +17 -3
- data/include/rays/matrix.h +2 -0
- data/include/rays/painter.h +29 -1
- data/include/rays/polygon.h +57 -33
- data/include/rays/polyline.h +20 -1
- data/include/rays/ruby/polygon.h +0 -11
- data/include/rays/ruby/rays.h +4 -0
- data/include/rays/{noise.h → util.h} +2 -2
- data/lib/rays/color.rb +1 -1
- data/lib/rays/font.rb +1 -1
- data/lib/rays/image.rb +1 -1
- data/lib/rays/painter.rb +13 -2
- data/lib/rays/point.rb +1 -1
- data/lib/rays/polygon.rb +54 -16
- data/lib/rays/polyline.rb +54 -8
- data/lib/rays.rb +0 -1
- data/rays.gemspec +2 -2
- data/src/color_space.cpp +2 -2
- data/src/font.cpp +24 -2
- data/src/font.h +8 -1
- data/src/ios/font.mm +88 -27
- data/src/matrix.cpp +8 -0
- data/src/osx/font.mm +90 -28
- data/src/osx/helper.h +2 -2
- data/src/osx/helper.mm +2 -2
- data/src/painter.cpp +227 -90
- data/src/painter.h +11 -3
- data/src/polygon.cpp +588 -205
- data/src/polyline.cpp +154 -28
- data/src/polyline.h +3 -5
- data/src/shader.cpp +36 -4
- data/src/shader.h +1 -1
- data/src/texture.cpp +2 -2
- data/src/{noise.cpp → util.cpp} +1 -1
- data/src/win32/font.cpp +1 -1
- data/test/test_bitmap.rb +16 -2
- data/test/test_color.rb +4 -0
- data/test/test_font.rb +20 -2
- data/test/test_image.rb +18 -18
- data/test/test_point.rb +1 -1
- data/test/test_polygon.rb +52 -45
- data/test/test_polyline.rb +191 -72
- metadata +11 -17
- data/.doc/ext/rays/polygon_line.cpp +0 -97
- data/ext/rays/polygon_line.cpp +0 -100
- data/lib/rays/polygon_line.rb +0 -33
- data/test/test_polygon_line.rb +0 -164
data/lib/rays/color.rb
CHANGED
data/lib/rays/font.rb
CHANGED
data/lib/rays/image.rb
CHANGED
data/lib/rays/painter.rb
CHANGED
@@ -118,9 +118,20 @@ module Rays
|
|
118
118
|
replace: BLEND_REPLACE
|
119
119
|
}
|
120
120
|
|
121
|
+
const_symbol_accessor :texcoord_mode, **{
|
122
|
+
image: TEXCOORD_IMAGE,
|
123
|
+
normal: TEXCOORD_NORMAL
|
124
|
+
}
|
125
|
+
|
126
|
+
const_symbol_accessor :texcoord_wrap, **{
|
127
|
+
clamp: TEXCOORD_CLAMP,
|
128
|
+
repeat: TEXCOORD_REPEAT
|
129
|
+
}
|
130
|
+
|
121
131
|
universal_accessor :background, :fill, :stroke, :color,
|
122
|
-
:stroke_width, :stroke_cap, :stroke_join, :miter_limit,
|
123
|
-
:nsegment, :blend_mode, :
|
132
|
+
:stroke_width, :stroke_outset, :stroke_cap, :stroke_join, :miter_limit,
|
133
|
+
:nsegment, :blend_mode, :texture, :texcoord_mode, :texcoord_wrap,
|
134
|
+
:shader, :clip, :font
|
124
135
|
|
125
136
|
private
|
126
137
|
|
data/lib/rays/point.rb
CHANGED
data/lib/rays/polygon.rb
CHANGED
@@ -8,45 +8,83 @@ module Rays
|
|
8
8
|
class Polygon
|
9
9
|
|
10
10
|
include Enumerable
|
11
|
+
include Comparable
|
11
12
|
|
12
|
-
def initialize(*args, loop: true)
|
13
|
-
setup args, loop
|
13
|
+
def initialize(*args, loop: true, colors: nil, texcoords: nil)
|
14
|
+
setup args, loop, colors, texcoords
|
14
15
|
end
|
15
16
|
|
16
|
-
def transform(
|
17
|
-
|
18
|
-
|
19
|
-
lines = block.call lines if block
|
20
|
-
self.class.new(*lines)
|
17
|
+
def transform(&block)
|
18
|
+
polylines = block.call to_a
|
19
|
+
self.class.new(*polylines)
|
21
20
|
end
|
22
21
|
|
23
22
|
def intersects(obj)
|
24
23
|
!(self & obj).empty?
|
25
24
|
end
|
26
25
|
|
27
|
-
def
|
28
|
-
|
26
|
+
def <=>(o)
|
27
|
+
(size <=> o.size).then {|cmp| return cmp if cmp != 0}
|
28
|
+
to_a.zip(o.to_a).each {|a, b| cmp = a <=> b; return cmp if cmp != 0}
|
29
|
+
0
|
30
|
+
end
|
31
|
+
|
32
|
+
def inspect()
|
33
|
+
"#<Rays::Polygon [#{map {|polyline| polyline.inspect}.join ', '}]>"
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.points(*points)
|
37
|
+
points! points
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.line(*points, loop: false)
|
41
|
+
line! points, loop
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.lines(*points)
|
45
|
+
lines! points
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.triangles(*points, loop: true, colors: nil, texcoords: nil)
|
49
|
+
triangles! points, loop, colors, texcoords
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.triangle_strip(*points, colors: nil, texcoords: nil)
|
53
|
+
triangle_strip! points, colors, texcoords
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.triangle_fan(*points, colors: nil, texcoords: nil)
|
57
|
+
triangle_fan! points, colors, texcoords
|
29
58
|
end
|
30
59
|
|
31
60
|
def self.rect(
|
32
|
-
*args, round: nil, lt: nil, rt: nil, lb: nil, rb: nil,
|
61
|
+
*args, round: nil, lt: nil, rt: nil, lb: nil, rb: nil,
|
62
|
+
nsegment: nil)
|
63
|
+
|
64
|
+
rect! args, round, lt, rt, lb, rb, nsegment
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.quads(*points, loop: true, colors: nil, texcoords: nil)
|
68
|
+
quads! points, loop, colors, texcoords
|
69
|
+
end
|
33
70
|
|
34
|
-
|
71
|
+
def self.quad_strip(*points, colors: nil, texcoords: nil)
|
72
|
+
quad_strip! points, colors, texcoords
|
35
73
|
end
|
36
74
|
|
37
75
|
def self.ellipse(
|
38
76
|
*args, center: nil, radius: nil, hole: nil, from: nil, to: nil,
|
39
77
|
nsegment: nil)
|
40
78
|
|
41
|
-
|
79
|
+
ellipse! args, center, radius, hole, from, to, nsegment
|
42
80
|
end
|
43
81
|
|
44
|
-
def self.curve(*
|
45
|
-
|
82
|
+
def self.curve(*points, loop: false)
|
83
|
+
curve! points, loop
|
46
84
|
end
|
47
85
|
|
48
|
-
def self.bezier(*
|
49
|
-
|
86
|
+
def self.bezier(*points, loop: false)
|
87
|
+
bezier! points, loop
|
50
88
|
end
|
51
89
|
|
52
90
|
end# Polygon
|
data/lib/rays/polyline.rb
CHANGED
@@ -7,20 +7,66 @@ module Rays
|
|
7
7
|
class Polyline
|
8
8
|
|
9
9
|
include Enumerable
|
10
|
+
include Comparable
|
10
11
|
|
11
|
-
def initialize(
|
12
|
-
|
12
|
+
def initialize(
|
13
|
+
*points, loop: false, fill: nil, colors: nil, texcoords: nil, hole: false)
|
14
|
+
|
15
|
+
setup points, loop, (fill != nil ? fill : loop), colors, texcoords, hole
|
16
|
+
end
|
17
|
+
|
18
|
+
def with(**kwargs)
|
19
|
+
points_, loop_, fill_, colors_, texcoords_, hole_ =
|
20
|
+
kwargs.values_at :points, :loop, :fill, :colors, :texcoords, :hole
|
21
|
+
self.class.new(
|
22
|
+
*(points_ || (points? ? points : [])),
|
23
|
+
loop: loop_ != nil ? loop_ : loop?,
|
24
|
+
fill: fill_ != nil ? fill_ : fill?,
|
25
|
+
colors: colors_ || (colors? ? colors : nil),
|
26
|
+
texcoords: texcoords_ || (texcoords? ? texcoords : nil),
|
27
|
+
hole: hole_ != nil ? hole_ : hole?)
|
28
|
+
end
|
29
|
+
|
30
|
+
def points()
|
31
|
+
each_point.to_a
|
32
|
+
end
|
33
|
+
|
34
|
+
def colors()
|
35
|
+
each_color.to_a
|
36
|
+
end
|
37
|
+
|
38
|
+
def texcoords()
|
39
|
+
each_texcoord.to_a
|
40
|
+
end
|
41
|
+
|
42
|
+
def each_point(&block)
|
43
|
+
block ? each_point!(&block) : enum_for(:each_point!)
|
44
|
+
end
|
45
|
+
|
46
|
+
def each_color(&block)
|
47
|
+
block ? each_color!(&block) : enum_for(:each_color!)
|
48
|
+
end
|
49
|
+
|
50
|
+
def each_texcoord(&block)
|
51
|
+
block ? each_texcoord!(&block) : enum_for(:each_texcoord!)
|
13
52
|
end
|
14
53
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
54
|
+
alias each each_point
|
55
|
+
|
56
|
+
def <=>(o)
|
57
|
+
(size <=> o.size) .then {|cmp| return cmp if cmp != 0}
|
58
|
+
(loop? <=> o.loop?).then {|cmp| return cmp if cmp != 0}
|
59
|
+
(fill? <=> o.fill?).then {|cmp| return cmp if cmp != 0}
|
60
|
+
points .zip(o.points) .each {|a, b| cmp = a <=> b; return cmp if cmp != 0}
|
61
|
+
colors .zip(o.colors) .each {|a, b| cmp = a <=> b; return cmp if cmp != 0}
|
62
|
+
texcoords.zip(o.texcoords).each {|a, b| cmp = a <=> b; return cmp if cmp != 0}
|
63
|
+
0
|
20
64
|
end
|
21
65
|
|
22
66
|
def inspect()
|
23
|
-
|
67
|
+
p = points.map {|o| o.to_a.join ','}.join ', '
|
68
|
+
c, t = colors.size, texcoords.size
|
69
|
+
"#<Rays::Polyline [#{p}] loop:#{loop?} fill:#{fill?} hole:#{hole?} colors:#{c} texcoords:#{t}>"
|
24
70
|
end
|
25
71
|
|
26
72
|
end# Polyline
|
data/lib/rays.rb
CHANGED
data/rays.gemspec
CHANGED
@@ -25,8 +25,8 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.platform = Gem::Platform::RUBY
|
26
26
|
s.required_ruby_version = '>= 3.0.0'
|
27
27
|
|
28
|
-
s.add_runtime_dependency 'xot', '~> 0.1.
|
29
|
-
s.add_runtime_dependency 'rucy', '~> 0.1.
|
28
|
+
s.add_runtime_dependency 'xot', '~> 0.1.41'
|
29
|
+
s.add_runtime_dependency 'rucy', '~> 0.1.43'
|
30
30
|
|
31
31
|
s.files = `git ls-files`.split $/
|
32
32
|
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
|
data/src/color_space.cpp
CHANGED
@@ -70,8 +70,8 @@ namespace Rays
|
|
70
70
|
static const int BPPS[] =
|
71
71
|
{
|
72
72
|
0, // UNKNOWN
|
73
|
-
8, 16,
|
74
|
-
8, 16,
|
73
|
+
8, 16, 24, 32, 32, // GRAY
|
74
|
+
8, 16, 24, 32, 32, // ALPHA
|
75
75
|
24, 32, 32, 32, 32, // RGB(A)
|
76
76
|
24, 32, 32, 32, 32, // BGR(A)
|
77
77
|
96, 128, 128, // RGB(A) float
|
data/src/font.cpp
CHANGED
@@ -27,7 +27,7 @@ namespace Rays
|
|
27
27
|
if (pixel_density != for_pixel_density)
|
28
28
|
{
|
29
29
|
rawfont_for_pixel_density =
|
30
|
-
RawFont(rawfont
|
30
|
+
RawFont(rawfont, rawfont.size() * pixel_density);
|
31
31
|
for_pixel_density = pixel_density;
|
32
32
|
}
|
33
33
|
|
@@ -37,8 +37,16 @@ namespace Rays
|
|
37
37
|
};// Font::Data
|
38
38
|
|
39
39
|
|
40
|
+
Font
|
41
|
+
load_font (const char* path, coord size)
|
42
|
+
{
|
43
|
+
Font font;
|
44
|
+
font.self->rawfont = RawFont_load(path, size);
|
45
|
+
return font;
|
46
|
+
}
|
47
|
+
|
40
48
|
const Font&
|
41
|
-
|
49
|
+
get_default_font ()
|
42
50
|
{
|
43
51
|
static const Font FONT(NULL);
|
44
52
|
return FONT;
|
@@ -79,12 +87,26 @@ namespace Rays
|
|
79
87
|
{
|
80
88
|
}
|
81
89
|
|
90
|
+
Font
|
91
|
+
Font::dup () const
|
92
|
+
{
|
93
|
+
Font f;
|
94
|
+
f.self->rawfont = RawFont(self->rawfont, self->rawfont.size());
|
95
|
+
return f;
|
96
|
+
}
|
97
|
+
|
82
98
|
String
|
83
99
|
Font::name () const
|
84
100
|
{
|
85
101
|
return self->rawfont.name();
|
86
102
|
}
|
87
103
|
|
104
|
+
void
|
105
|
+
Font::set_size (coord size)
|
106
|
+
{
|
107
|
+
self->rawfont = RawFont(self->rawfont, size);
|
108
|
+
}
|
109
|
+
|
88
110
|
coord
|
89
111
|
Font::size () const
|
90
112
|
{
|
data/src/font.h
CHANGED
@@ -15,11 +15,15 @@ namespace Rays
|
|
15
15
|
class RawFont
|
16
16
|
{
|
17
17
|
|
18
|
+
typedef RawFont This;
|
19
|
+
|
18
20
|
public:
|
19
21
|
|
20
22
|
RawFont ();
|
21
23
|
|
22
|
-
RawFont (const char* name, coord size
|
24
|
+
RawFont (const char* name, coord size);
|
25
|
+
|
26
|
+
RawFont (const This& obj, coord size);
|
23
27
|
|
24
28
|
~RawFont ();
|
25
29
|
|
@@ -58,6 +62,9 @@ namespace Rays
|
|
58
62
|
coord* ascent = NULL, coord* descent = NULL, coord* leading = NULL);
|
59
63
|
|
60
64
|
|
65
|
+
RawFont RawFont_load (const char* path, coord size);
|
66
|
+
|
67
|
+
|
61
68
|
}// Rays
|
62
69
|
|
63
70
|
|
data/src/ios/font.mm
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
#include "../font.h"
|
3
3
|
|
4
4
|
|
5
|
+
#include <memory>
|
5
6
|
#import <CoreGraphics/CGContext.h>
|
6
7
|
#import <CoreText/CoreText.h>
|
7
8
|
#include "rays/exception.h"
|
@@ -12,15 +13,23 @@ namespace Rays
|
|
12
13
|
{
|
13
14
|
|
14
15
|
|
16
|
+
typedef std::shared_ptr<const __CFDictionary> CFDictionaryPtr;
|
17
|
+
|
18
|
+
typedef std::shared_ptr<const __CFAttributedString> CFAttributedStringPtr;
|
19
|
+
|
20
|
+
typedef std::shared_ptr<CGDataProvider> CGDataProviderPtr;
|
21
|
+
|
22
|
+
typedef std::shared_ptr<CGFont> CGFontPtr;
|
23
|
+
|
24
|
+
typedef std::shared_ptr<const __CTLine> CTLinePtr;
|
25
|
+
|
26
|
+
|
15
27
|
struct RawFont::Data
|
16
28
|
{
|
17
29
|
|
18
|
-
CTFontRef font;
|
30
|
+
CTFontRef font = NULL;
|
19
31
|
|
20
|
-
|
21
|
-
: font(NULL)
|
22
|
-
{
|
23
|
-
}
|
32
|
+
String path;
|
24
33
|
|
25
34
|
~Data ()
|
26
35
|
{
|
@@ -34,7 +43,7 @@ namespace Rays
|
|
34
43
|
};// RawFont::Data
|
35
44
|
|
36
45
|
|
37
|
-
static
|
46
|
+
static CTLinePtr
|
38
47
|
make_line (CTFontRef font, const char* str)
|
39
48
|
{
|
40
49
|
if (!font || !str || *str == '\0')
|
@@ -50,18 +59,67 @@ namespace Rays
|
|
50
59
|
};
|
51
60
|
size_t nkeys = sizeof(keys) / sizeof(keys[0]);
|
52
61
|
|
53
|
-
|
54
|
-
|
55
|
-
|
62
|
+
CFDictionaryPtr attr(
|
63
|
+
CFDictionaryCreate(
|
64
|
+
NULL, (const void**) &keys, (const void**) &values, nkeys,
|
65
|
+
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks),
|
66
|
+
CFRelease);
|
67
|
+
|
68
|
+
CFAttributedStringPtr attrstr(
|
69
|
+
CFAttributedStringCreate(NULL, cfstring(str).get(), attr.get()),
|
70
|
+
CFRelease);
|
56
71
|
|
57
|
-
|
58
|
-
|
59
|
-
|
72
|
+
return CTLinePtr(
|
73
|
+
CTLineCreateWithAttributedString(attrstr.get()),
|
74
|
+
CFRelease);
|
75
|
+
}
|
60
76
|
|
61
|
-
|
62
|
-
|
77
|
+
const FontFamilyMap&
|
78
|
+
get_font_families ()
|
79
|
+
{
|
80
|
+
static const FontFamilyMap MAP = []() {
|
81
|
+
NSFontManager* fm = NSFontManager.sharedFontManager;
|
63
82
|
|
64
|
-
|
83
|
+
FontFamilyMap map;
|
84
|
+
for (NSString* family in fm.availableFontFamilies)
|
85
|
+
{
|
86
|
+
FontFamilyMap::mapped_type array;
|
87
|
+
for (NSArray<NSString*>* members in [fm availableMembersOfFontFamily: family])
|
88
|
+
array.emplace_back(members[0].UTF8String);
|
89
|
+
map[family.UTF8String] = array;
|
90
|
+
}
|
91
|
+
return map;
|
92
|
+
}();
|
93
|
+
return MAP;
|
94
|
+
}
|
95
|
+
|
96
|
+
RawFont
|
97
|
+
RawFont_load (const char* path, coord size)
|
98
|
+
{
|
99
|
+
if (!path)
|
100
|
+
argument_error(__FILE__, __LINE__);
|
101
|
+
|
102
|
+
CGDataProviderPtr data_provider(
|
103
|
+
CGDataProviderCreateWithFilename(path),
|
104
|
+
CGDataProviderRelease);
|
105
|
+
if (!data_provider)
|
106
|
+
rays_error(__FILE__, __LINE__, "failed to create CGDataProvider");
|
107
|
+
|
108
|
+
CGFontPtr cgfont(
|
109
|
+
CGFontCreateWithDataProvider(data_provider.get()),
|
110
|
+
CGFontRelease);
|
111
|
+
if (!cgfont)
|
112
|
+
rays_error(__FILE__, __LINE__, "failed to create CGFont");
|
113
|
+
|
114
|
+
CTFontRef ctfont = CTFontCreateWithGraphicsFont(
|
115
|
+
cgfont.get(), size, NULL, NULL);
|
116
|
+
if (!ctfont)
|
117
|
+
rays_error(__FILE__, __LINE__, "failed to create CTFont");
|
118
|
+
|
119
|
+
RawFont rawfont;
|
120
|
+
rawfont.self->font = ctfont;
|
121
|
+
rawfont.self->path = path;
|
122
|
+
return rawfont;
|
65
123
|
}
|
66
124
|
|
67
125
|
|
@@ -76,6 +134,15 @@ namespace Rays
|
|
76
134
|
: CTFontCreateUIFontForLanguage(kCTFontSystemFontType, size, NULL);
|
77
135
|
}
|
78
136
|
|
137
|
+
RawFont::RawFont (const This& obj, coord size)
|
138
|
+
{
|
139
|
+
const char* path = obj.self->path.empty() ? NULL : obj.self->path.c_str();
|
140
|
+
if (path)
|
141
|
+
*this = RawFont_load(path, size);
|
142
|
+
else
|
143
|
+
self->font = CTFontCreateWithName(cfstring(obj.name()).get(), size, NULL);
|
144
|
+
}
|
145
|
+
|
79
146
|
RawFont::~RawFont ()
|
80
147
|
{
|
81
148
|
}
|
@@ -92,7 +159,7 @@ namespace Rays
|
|
92
159
|
|
93
160
|
if (*str == '\0') return;
|
94
161
|
|
95
|
-
|
162
|
+
CTLinePtr line = make_line(self->font, str);
|
96
163
|
if (!line)
|
97
164
|
rays_error(__FILE__, __LINE__, "creating CTLineRef failed.");
|
98
165
|
|
@@ -112,10 +179,8 @@ namespace Rays
|
|
112
179
|
CGContextSaveGState(context);
|
113
180
|
CGContextSetTextMatrix(context, CGAffineTransformIdentity);
|
114
181
|
CGContextSetTextPosition(context, x, context_height - ascent - y);
|
115
|
-
CTLineDraw(line, context);
|
182
|
+
CTLineDraw(line.get(), context);
|
116
183
|
CGContextRestoreGState(context);
|
117
|
-
|
118
|
-
CFRelease(line);
|
119
184
|
}
|
120
185
|
|
121
186
|
String
|
@@ -123,14 +188,13 @@ namespace Rays
|
|
123
188
|
{
|
124
189
|
if (!*this) return "";
|
125
190
|
|
126
|
-
|
191
|
+
CFStringPtr str(CTFontCopyFullName(self->font), CFRelease);
|
127
192
|
|
128
193
|
enum {BUFSIZE = 2048};
|
129
194
|
char buf[BUFSIZE + 1];
|
130
|
-
if (!CFStringGetCString(str, buf, BUFSIZE, kCFStringEncodingUTF8))
|
195
|
+
if (!CFStringGetCString(str.get(), buf, BUFSIZE, kCFStringEncodingUTF8))
|
131
196
|
buf[0] = '\0';
|
132
197
|
|
133
|
-
CFRelease(str);
|
134
198
|
return buf;
|
135
199
|
}
|
136
200
|
|
@@ -152,14 +216,11 @@ namespace Rays
|
|
152
216
|
|
153
217
|
if (*str == '\0') return 0;
|
154
218
|
|
155
|
-
|
219
|
+
CTLinePtr line = make_line(self->font, str);
|
156
220
|
if (!line)
|
157
221
|
rays_error(__FILE__, __LINE__, "creating CTLineRef failed.");
|
158
222
|
|
159
|
-
|
160
|
-
CFRelease(line);
|
161
|
-
|
162
|
-
return w;
|
223
|
+
return CTLineGetTypographicBounds(line.get(), NULL, NULL, NULL);
|
163
224
|
}
|
164
225
|
|
165
226
|
coord
|
data/src/matrix.cpp
CHANGED