objc2_app_kit/generated/
NSFont.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8#[cfg(feature = "objc2-core-graphics")]
9#[cfg(target_vendor = "apple")]
10use objc2_core_graphics::*;
11use objc2_foundation::*;
12
13use crate::*;
14
15extern "C" {
16 #[cfg(feature = "objc2-core-foundation")]
20 pub static NSFontIdentityMatrix: NonNull<CGFloat>;
21}
22
23extern_class!(
24 #[unsafe(super(NSObject))]
26 #[derive(Debug, PartialEq, Eq, Hash)]
27 pub struct NSFont;
28);
29
30extern_conformance!(
31 unsafe impl NSCoding for NSFont {}
32);
33
34extern_conformance!(
35 unsafe impl NSCopying for NSFont {}
36);
37
38unsafe impl CopyingHelper for NSFont {
39 type Result = Self;
40}
41
42extern_conformance!(
43 unsafe impl NSObjectProtocol for NSFont {}
44);
45
46extern_conformance!(
47 unsafe impl NSSecureCoding for NSFont {}
48);
49
50impl NSFont {
51 extern_methods!(
52 #[cfg(feature = "objc2-core-foundation")]
53 #[unsafe(method(fontWithName:size:))]
55 #[unsafe(method_family = none)]
56 pub unsafe fn fontWithName_size(
57 font_name: &NSString,
58 font_size: CGFloat,
59 ) -> Option<Retained<NSFont>>;
60
61 #[cfg(feature = "objc2-core-foundation")]
62 #[unsafe(method(fontWithName:matrix:))]
63 #[unsafe(method_family = none)]
64 pub unsafe fn fontWithName_matrix(
65 font_name: &NSString,
66 font_matrix: NonNull<CGFloat>,
67 ) -> Option<Retained<NSFont>>;
68
69 #[cfg(all(feature = "NSFontDescriptor", feature = "objc2-core-foundation"))]
70 #[unsafe(method(fontWithDescriptor:size:))]
71 #[unsafe(method_family = none)]
72 pub unsafe fn fontWithDescriptor_size(
73 font_descriptor: &NSFontDescriptor,
74 font_size: CGFloat,
75 ) -> Option<Retained<NSFont>>;
76
77 #[cfg(feature = "NSFontDescriptor")]
78 #[unsafe(method(fontWithDescriptor:textTransform:))]
79 #[unsafe(method_family = none)]
80 pub unsafe fn fontWithDescriptor_textTransform(
81 font_descriptor: &NSFontDescriptor,
82 text_transform: Option<&NSAffineTransform>,
83 ) -> Option<Retained<NSFont>>;
84
85 #[cfg(feature = "objc2-core-foundation")]
86 #[unsafe(method(userFontOfSize:))]
88 #[unsafe(method_family = none)]
89 pub unsafe fn userFontOfSize(font_size: CGFloat) -> Option<Retained<NSFont>>;
90
91 #[cfg(feature = "objc2-core-foundation")]
92 #[unsafe(method(userFixedPitchFontOfSize:))]
93 #[unsafe(method_family = none)]
94 pub unsafe fn userFixedPitchFontOfSize(font_size: CGFloat) -> Option<Retained<NSFont>>;
95
96 #[unsafe(method(setUserFont:))]
97 #[unsafe(method_family = none)]
98 pub unsafe fn setUserFont(font: Option<&NSFont>);
99
100 #[unsafe(method(setUserFixedPitchFont:))]
101 #[unsafe(method_family = none)]
102 pub unsafe fn setUserFixedPitchFont(font: Option<&NSFont>);
103
104 #[cfg(feature = "objc2-core-foundation")]
105 #[unsafe(method(systemFontOfSize:))]
106 #[unsafe(method_family = none)]
107 pub unsafe fn systemFontOfSize(font_size: CGFloat) -> Retained<NSFont>;
108
109 #[cfg(feature = "objc2-core-foundation")]
110 #[unsafe(method(boldSystemFontOfSize:))]
111 #[unsafe(method_family = none)]
112 pub unsafe fn boldSystemFontOfSize(font_size: CGFloat) -> Retained<NSFont>;
113
114 #[cfg(feature = "objc2-core-foundation")]
115 #[unsafe(method(labelFontOfSize:))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn labelFontOfSize(font_size: CGFloat) -> Retained<NSFont>;
118
119 #[cfg(feature = "objc2-core-foundation")]
120 #[unsafe(method(titleBarFontOfSize:))]
121 #[unsafe(method_family = none)]
122 pub unsafe fn titleBarFontOfSize(font_size: CGFloat) -> Retained<NSFont>;
123
124 #[cfg(feature = "objc2-core-foundation")]
125 #[unsafe(method(menuFontOfSize:))]
126 #[unsafe(method_family = none)]
127 pub unsafe fn menuFontOfSize(font_size: CGFloat) -> Retained<NSFont>;
128
129 #[cfg(feature = "objc2-core-foundation")]
130 #[unsafe(method(menuBarFontOfSize:))]
131 #[unsafe(method_family = none)]
132 pub unsafe fn menuBarFontOfSize(font_size: CGFloat) -> Retained<NSFont>;
133
134 #[cfg(feature = "objc2-core-foundation")]
135 #[unsafe(method(messageFontOfSize:))]
136 #[unsafe(method_family = none)]
137 pub unsafe fn messageFontOfSize(font_size: CGFloat) -> Retained<NSFont>;
138
139 #[cfg(feature = "objc2-core-foundation")]
140 #[unsafe(method(paletteFontOfSize:))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn paletteFontOfSize(font_size: CGFloat) -> Retained<NSFont>;
143
144 #[cfg(feature = "objc2-core-foundation")]
145 #[unsafe(method(toolTipsFontOfSize:))]
146 #[unsafe(method_family = none)]
147 pub unsafe fn toolTipsFontOfSize(font_size: CGFloat) -> Retained<NSFont>;
148
149 #[cfg(feature = "objc2-core-foundation")]
150 #[unsafe(method(controlContentFontOfSize:))]
151 #[unsafe(method_family = none)]
152 pub unsafe fn controlContentFontOfSize(font_size: CGFloat) -> Retained<NSFont>;
153
154 #[cfg(all(feature = "NSFontDescriptor", feature = "objc2-core-foundation"))]
155 #[unsafe(method(systemFontOfSize:weight:))]
156 #[unsafe(method_family = none)]
157 pub unsafe fn systemFontOfSize_weight(
158 font_size: CGFloat,
159 weight: NSFontWeight,
160 ) -> Retained<NSFont>;
161
162 #[cfg(all(feature = "NSFontDescriptor", feature = "objc2-core-foundation"))]
163 #[unsafe(method(monospacedDigitSystemFontOfSize:weight:))]
164 #[unsafe(method_family = none)]
165 pub unsafe fn monospacedDigitSystemFontOfSize_weight(
166 font_size: CGFloat,
167 weight: NSFontWeight,
168 ) -> Retained<NSFont>;
169
170 #[cfg(all(feature = "NSFontDescriptor", feature = "objc2-core-foundation"))]
171 #[unsafe(method(systemFontOfSize:weight:width:))]
172 #[unsafe(method_family = none)]
173 pub unsafe fn systemFontOfSize_weight_width(
174 font_size: CGFloat,
175 weight: NSFontWeight,
176 width: NSFontWidth,
177 ) -> Retained<NSFont>;
178
179 #[cfg(all(feature = "NSFontDescriptor", feature = "objc2-core-foundation"))]
180 #[unsafe(method(monospacedSystemFontOfSize:weight:))]
181 #[unsafe(method_family = none)]
182 pub unsafe fn monospacedSystemFontOfSize_weight(
183 font_size: CGFloat,
184 weight: NSFontWeight,
185 ) -> Retained<NSFont>;
186
187 #[cfg(feature = "objc2-core-foundation")]
188 #[unsafe(method(fontWithSize:))]
189 #[unsafe(method_family = none)]
190 pub unsafe fn fontWithSize(&self, font_size: CGFloat) -> Retained<NSFont>;
191
192 #[cfg(feature = "objc2-core-foundation")]
193 #[unsafe(method(systemFontSize))]
194 #[unsafe(method_family = none)]
195 pub unsafe fn systemFontSize() -> CGFloat;
196
197 #[cfg(feature = "objc2-core-foundation")]
198 #[unsafe(method(smallSystemFontSize))]
199 #[unsafe(method_family = none)]
200 pub unsafe fn smallSystemFontSize() -> CGFloat;
201
202 #[cfg(feature = "objc2-core-foundation")]
203 #[unsafe(method(labelFontSize))]
204 #[unsafe(method_family = none)]
205 pub unsafe fn labelFontSize() -> CGFloat;
206
207 #[cfg(all(feature = "NSCell", feature = "objc2-core-foundation"))]
208 #[unsafe(method(systemFontSizeForControlSize:))]
209 #[unsafe(method_family = none)]
210 pub unsafe fn systemFontSizeForControlSize(control_size: NSControlSize) -> CGFloat;
211
212 #[unsafe(method(fontName))]
214 #[unsafe(method_family = none)]
215 pub unsafe fn fontName(&self) -> Retained<NSString>;
216
217 #[cfg(feature = "objc2-core-foundation")]
218 #[unsafe(method(pointSize))]
219 #[unsafe(method_family = none)]
220 pub unsafe fn pointSize(&self) -> CGFloat;
221
222 #[cfg(feature = "objc2-core-foundation")]
223 #[unsafe(method(matrix))]
224 #[unsafe(method_family = none)]
225 pub unsafe fn matrix(&self) -> NonNull<CGFloat>;
226
227 #[unsafe(method(familyName))]
228 #[unsafe(method_family = none)]
229 pub unsafe fn familyName(&self) -> Option<Retained<NSString>>;
230
231 #[unsafe(method(displayName))]
232 #[unsafe(method_family = none)]
233 pub unsafe fn displayName(&self) -> Option<Retained<NSString>>;
234
235 #[cfg(feature = "NSFontDescriptor")]
236 #[unsafe(method(fontDescriptor))]
237 #[unsafe(method_family = none)]
238 pub unsafe fn fontDescriptor(&self) -> Retained<NSFontDescriptor>;
239
240 #[unsafe(method(textTransform))]
241 #[unsafe(method_family = none)]
242 pub unsafe fn textTransform(&self) -> Retained<NSAffineTransform>;
243
244 #[unsafe(method(numberOfGlyphs))]
246 #[unsafe(method_family = none)]
247 pub unsafe fn numberOfGlyphs(&self) -> NSUInteger;
248
249 #[unsafe(method(mostCompatibleStringEncoding))]
250 #[unsafe(method_family = none)]
251 pub unsafe fn mostCompatibleStringEncoding(&self) -> NSStringEncoding;
252
253 #[unsafe(method(coveredCharacterSet))]
254 #[unsafe(method_family = none)]
255 pub unsafe fn coveredCharacterSet(&self) -> Retained<NSCharacterSet>;
256
257 #[unsafe(method(boundingRectForFont))]
258 #[unsafe(method_family = none)]
259 pub unsafe fn boundingRectForFont(&self) -> NSRect;
260
261 #[unsafe(method(maximumAdvancement))]
262 #[unsafe(method_family = none)]
263 pub unsafe fn maximumAdvancement(&self) -> NSSize;
264
265 #[cfg(feature = "objc2-core-foundation")]
266 #[unsafe(method(ascender))]
267 #[unsafe(method_family = none)]
268 pub unsafe fn ascender(&self) -> CGFloat;
269
270 #[cfg(feature = "objc2-core-foundation")]
271 #[unsafe(method(descender))]
272 #[unsafe(method_family = none)]
273 pub unsafe fn descender(&self) -> CGFloat;
274
275 #[cfg(feature = "objc2-core-foundation")]
276 #[unsafe(method(leading))]
277 #[unsafe(method_family = none)]
278 pub unsafe fn leading(&self) -> CGFloat;
279
280 #[cfg(feature = "objc2-core-foundation")]
281 #[unsafe(method(underlinePosition))]
282 #[unsafe(method_family = none)]
283 pub unsafe fn underlinePosition(&self) -> CGFloat;
284
285 #[cfg(feature = "objc2-core-foundation")]
286 #[unsafe(method(underlineThickness))]
287 #[unsafe(method_family = none)]
288 pub unsafe fn underlineThickness(&self) -> CGFloat;
289
290 #[cfg(feature = "objc2-core-foundation")]
291 #[unsafe(method(italicAngle))]
292 #[unsafe(method_family = none)]
293 pub unsafe fn italicAngle(&self) -> CGFloat;
294
295 #[cfg(feature = "objc2-core-foundation")]
296 #[unsafe(method(capHeight))]
297 #[unsafe(method_family = none)]
298 pub unsafe fn capHeight(&self) -> CGFloat;
299
300 #[cfg(feature = "objc2-core-foundation")]
301 #[unsafe(method(xHeight))]
302 #[unsafe(method_family = none)]
303 pub unsafe fn xHeight(&self) -> CGFloat;
304
305 #[unsafe(method(isFixedPitch))]
306 #[unsafe(method_family = none)]
307 pub unsafe fn isFixedPitch(&self) -> bool;
308
309 #[cfg(feature = "objc2-core-graphics")]
310 #[cfg(target_vendor = "apple")]
311 #[unsafe(method(boundingRectForCGGlyph:))]
315 #[unsafe(method_family = none)]
316 pub unsafe fn boundingRectForCGGlyph(&self, glyph: CGGlyph) -> NSRect;
317
318 #[cfg(feature = "objc2-core-graphics")]
319 #[cfg(target_vendor = "apple")]
320 #[unsafe(method(advancementForCGGlyph:))]
321 #[unsafe(method_family = none)]
322 pub unsafe fn advancementForCGGlyph(&self, glyph: CGGlyph) -> NSSize;
323
324 #[cfg(feature = "objc2-core-graphics")]
325 #[cfg(target_vendor = "apple")]
326 #[unsafe(method(getBoundingRects:forCGGlyphs:count:))]
327 #[unsafe(method_family = none)]
328 pub unsafe fn getBoundingRects_forCGGlyphs_count(
329 &self,
330 bounds: NSRectArray,
331 glyphs: NonNull<CGGlyph>,
332 glyph_count: NSUInteger,
333 );
334
335 #[cfg(feature = "objc2-core-graphics")]
336 #[cfg(target_vendor = "apple")]
337 #[unsafe(method(getAdvancements:forCGGlyphs:count:))]
338 #[unsafe(method_family = none)]
339 pub unsafe fn getAdvancements_forCGGlyphs_count(
340 &self,
341 advancements: NSSizeArray,
342 glyphs: NonNull<CGGlyph>,
343 glyph_count: NSUInteger,
344 );
345
346 #[unsafe(method(set))]
348 #[unsafe(method_family = none)]
349 pub unsafe fn set(&self);
350
351 #[cfg(feature = "NSGraphicsContext")]
352 #[unsafe(method(setInContext:))]
353 #[unsafe(method_family = none)]
354 pub unsafe fn setInContext(&self, graphics_context: &NSGraphicsContext);
355
356 #[unsafe(method(verticalFont))]
358 #[unsafe(method_family = none)]
359 pub unsafe fn verticalFont(&self) -> Retained<NSFont>;
360
361 #[unsafe(method(isVertical))]
362 #[unsafe(method_family = none)]
363 pub unsafe fn isVertical(&self) -> bool;
364 );
365}
366
367impl NSFont {
369 extern_methods!(
370 #[unsafe(method(init))]
371 #[unsafe(method_family = init)]
372 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
373
374 #[unsafe(method(new))]
375 #[unsafe(method_family = new)]
376 pub unsafe fn new() -> Retained<Self>;
377 );
378}
379
380extern "C" {
381 pub static NSAntialiasThresholdChangedNotification: &'static NSNotificationName;
385}
386
387extern "C" {
388 pub static NSFontSetChangedNotification: &'static NSNotificationName;
390}
391
392pub type NSGlyph = c_uint;
396
397pub const NSControlGlyph: c_uint = 0x00FFFFFF;
399pub const NSNullGlyph: c_uint = 0x0;
401
402#[repr(transparent)]
407#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
408pub struct NSFontRenderingMode(pub NSUInteger);
409impl NSFontRenderingMode {
410 #[doc(alias = "NSFontDefaultRenderingMode")]
411 pub const DefaultRenderingMode: Self = Self(0);
412 #[doc(alias = "NSFontAntialiasedRenderingMode")]
413 pub const AntialiasedRenderingMode: Self = Self(1);
414 #[doc(alias = "NSFontIntegerAdvancementsRenderingMode")]
415 pub const IntegerAdvancementsRenderingMode: Self = Self(2);
416 #[doc(alias = "NSFontAntialiasedIntegerAdvancementsRenderingMode")]
417 pub const AntialiasedIntegerAdvancementsRenderingMode: Self = Self(3);
418}
419
420unsafe impl Encode for NSFontRenderingMode {
421 const ENCODING: Encoding = NSUInteger::ENCODING;
422}
423
424unsafe impl RefEncode for NSFontRenderingMode {
425 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
426}
427
428#[deprecated]
431#[repr(transparent)]
432#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
433pub struct NSMultibyteGlyphPacking(pub NSUInteger);
434impl NSMultibyteGlyphPacking {
435 #[doc(alias = "NSNativeShortGlyphPacking")]
436 #[deprecated]
437 pub const NativeShortGlyphPacking: Self = Self(5);
438}
439
440unsafe impl Encode for NSMultibyteGlyphPacking {
441 const ENCODING: Encoding = NSUInteger::ENCODING;
442}
443
444unsafe impl RefEncode for NSMultibyteGlyphPacking {
445 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
446}
447
448extern "C-unwind" {
449 #[deprecated]
450 pub fn NSConvertGlyphsToPackedGlyphs(
451 gl_buf: NonNull<NSGlyph>,
452 count: NSInteger,
453 packing: NSMultibyteGlyphPacking,
454 packed_glyphs: NonNull<c_char>,
455 ) -> NSInteger;
456}
457
458impl NSFont {
460 extern_methods!(
461 #[unsafe(method(glyphWithName:))]
462 #[unsafe(method_family = none)]
463 pub unsafe fn glyphWithName(&self, name: &NSString) -> NSGlyph;
464
465 #[unsafe(method(boundingRectForGlyph:))]
466 #[unsafe(method_family = none)]
467 pub unsafe fn boundingRectForGlyph(&self, glyph: NSGlyph) -> NSRect;
468
469 #[unsafe(method(advancementForGlyph:))]
470 #[unsafe(method_family = none)]
471 pub unsafe fn advancementForGlyph(&self, glyph: NSGlyph) -> NSSize;
472
473 #[unsafe(method(getBoundingRects:forGlyphs:count:))]
474 #[unsafe(method_family = none)]
475 pub unsafe fn getBoundingRects_forGlyphs_count(
476 &self,
477 bounds: NSRectArray,
478 glyphs: NonNull<NSGlyph>,
479 glyph_count: NSUInteger,
480 );
481
482 #[unsafe(method(getAdvancements:forGlyphs:count:))]
483 #[unsafe(method_family = none)]
484 pub unsafe fn getAdvancements_forGlyphs_count(
485 &self,
486 advancements: NSSizeArray,
487 glyphs: NonNull<NSGlyph>,
488 glyph_count: NSUInteger,
489 );
490
491 #[unsafe(method(getAdvancements:forPackedGlyphs:length:))]
492 #[unsafe(method_family = none)]
493 pub unsafe fn getAdvancements_forPackedGlyphs_length(
494 &self,
495 advancements: NSSizeArray,
496 packed_glyphs: NonNull<c_void>,
497 length: NSUInteger,
498 );
499
500 #[unsafe(method(printerFont))]
502 #[unsafe(method_family = none)]
503 pub unsafe fn printerFont(&self) -> Retained<NSFont>;
504
505 #[unsafe(method(screenFont))]
506 #[unsafe(method_family = none)]
507 pub unsafe fn screenFont(&self) -> Retained<NSFont>;
508
509 #[unsafe(method(screenFontWithRenderingMode:))]
510 #[unsafe(method_family = none)]
511 pub unsafe fn screenFontWithRenderingMode(
512 &self,
513 rendering_mode: NSFontRenderingMode,
514 ) -> Retained<NSFont>;
515
516 #[unsafe(method(renderingMode))]
517 #[unsafe(method_family = none)]
518 pub unsafe fn renderingMode(&self) -> NSFontRenderingMode;
519 );
520}
521
522impl NSFont {
524 extern_methods!(
525 #[cfg(feature = "NSFontDescriptor")]
526 #[unsafe(method(preferredFontForTextStyle:options:))]
527 #[unsafe(method_family = none)]
528 pub unsafe fn preferredFontForTextStyle_options(
529 style: &NSFontTextStyle,
530 options: &NSDictionary<NSFontTextStyleOptionKey, AnyObject>,
531 ) -> Retained<NSFont>;
532 );
533}