You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core-text/src/run.rs
+47-20Lines changed: 47 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -7,15 +7,15 @@
7
7
// option. This file may not be copied, modified, or distributed
8
8
// except according to those terms.
9
9
10
-
use std::borrow::Cow;
11
-
use std::os::raw::c_void;
12
-
use std::slice;
13
-
use core_foundation::base::{CFIndex,CFTypeID,TCFType,CFType,CFRange};
10
+
use core_foundation::base::{CFIndex,CFRange,CFType,CFTypeID,TCFType};
14
11
use core_foundation::dictionary::{CFDictionary,CFDictionaryRef};
15
12
use core_foundation::string::CFString;
13
+
use core_graphics::base::CGFloat;
16
14
use core_graphics::font::CGGlyph;
17
15
use core_graphics::geometry::CGPoint;
18
-
use core_graphics::base::{CGFloat};
16
+
use std::borrow::Cow;
17
+
use std::os::raw::c_void;
18
+
use std::slice;
19
19
20
20
usecrate::line::TypographicBounds;
21
21
@@ -41,9 +41,7 @@ impl CTRun {
41
41
}
42
42
}
43
43
pubfnglyph_count(&self) -> CFIndex{
44
-
unsafe{
45
-
CTRunGetGlyphCount(self.0)
46
-
}
44
+
unsafe{CTRunGetGlyphCount(self.0)}
47
45
}
48
46
49
47
pubfnglyphs(&self) -> Cow<[CGGlyph]>{
@@ -91,12 +89,26 @@ impl CTRun {
91
89
letmut descent = 0.0;
92
90
letmut leading = 0.0;
93
91
unsafe{
94
-
let range = CFRange{
95
-
location:0,
96
-
length:0,
97
-
};
98
-
let width = CTRunGetTypographicBounds(self.as_concrete_TypeRef(), range,&mut ascent,&mut descent,&mut leading);
99
-
TypographicBounds{ width, ascent, descent, leading }
92
+
// The portion of the run to calculate the typographic bounds for. By setting this to 0,
93
+
// CoreText will measure the bounds from start to end, see https://developer.apple.com/documentation/coretext/1510569-ctrungettypographicbounds?language=objc.
94
+
let range = CFRange{
95
+
location:0,
96
+
length:0,
97
+
};
98
+
99
+
let width = CTRunGetTypographicBounds(
100
+
self.as_concrete_TypeRef(),
101
+
range,
102
+
&mut ascent,
103
+
&mut descent,
104
+
&mut leading,
105
+
);
106
+
TypographicBounds{
107
+
width,
108
+
ascent,
109
+
descent,
110
+
leading,
111
+
}
100
112
}
101
113
}
102
114
@@ -124,21 +136,30 @@ impl CTRun {
124
136
#[test]
125
137
fncreate_runs(){
126
138
use core_foundation::attributed_string::CFMutableAttributedString;
0 commit comments