objc2_app_kit/generated/
NSFont.rs

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