objc2_core_text/generated/
CTFontTraits.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "objc2")]
6use objc2::__framework_prelude::*;
7use objc2_core_foundation::*;
8
9use crate::*;
10
11extern "C" {
12    /// kCTFontSymbolicTrait
13    ///
14    /// Dictionary key to access the symbolic traits value.
15    ///
16    /// Use this key to access the symbolic traits value from the font traits dictionary. The value is returned as a CFNumberRef.
17    ///
18    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontsymbolictrait?language=objc)
19    pub static kCTFontSymbolicTrait: &'static CFString;
20}
21
22extern "C" {
23    /// kCTFontWeightTrait
24    ///
25    /// Dictionary key to access the weight trait value.
26    ///
27    /// Use this key to access the normalized weight trait from the font traits dictionary. The value returned is a CFNumberRef representing a float value between -1.0 and 1.0 for normalized weight. The value of 0.0 corresponds to the regular or medium font weight.
28    ///
29    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontweighttrait?language=objc)
30    pub static kCTFontWeightTrait: &'static CFString;
31}
32
33extern "C" {
34    /// kCTFontWidthTrait
35    ///
36    /// Dictionary key to access the width (condense/expand) trait value.
37    ///
38    /// Use this key to access the normalized proportion trait from the font traits dictionary. This value corresponds to the relative inter-glyph spacing for a given font. The value returned is a CFNumberRef representing a float between -1.0 and 1.0. The value of 0.0 corresponds to regular glyph spacing while negative values represent condensed glyph spacing.
39    ///
40    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontwidthtrait?language=objc)
41    pub static kCTFontWidthTrait: &'static CFString;
42}
43
44extern "C" {
45    /// kCTFontSlantTrait
46    ///
47    /// Dictionary key to access the slant trait value.
48    ///
49    /// Use this key to access the normalized slant angle from the font traits dictionary. The value returned is a CFNumberRef representing a float value between -1.0 and 1.0 for normalized slant angle. The value or 0.0 corresponds to 0 degree clockwise rotation from the vertical and 1.0 corresponds to 30 degrees clockwise rotation.
50    ///
51    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontslanttrait?language=objc)
52    pub static kCTFontSlantTrait: &'static CFString;
53}
54
55/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontclassmaskshift?language=objc)
56pub const kCTFontClassMaskShift: c_uint = 28;
57
58/// Symbolic representation of stylistic font attributes.
59///
60/// CTFontSymbolicTraits symbolically describes stylistic aspects of a font. The top 4 bits is used to describe appearance of the font while the lower 28 bits for typeface. The font appearance information represented by the upper 4 bits can be used for stylistic font matching.
61///
62/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontsymbolictraits?language=objc)
63// NS_OPTIONS
64#[repr(transparent)]
65#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
66pub struct CTFontSymbolicTraits(pub u32);
67bitflags::bitflags! {
68    impl CTFontSymbolicTraits: u32 {
69        #[doc(alias = "kCTFontTraitItalic")]
70        const TraitItalic = 1<<0;
71        #[doc(alias = "kCTFontTraitBold")]
72        const TraitBold = 1<<1;
73        #[doc(alias = "kCTFontTraitExpanded")]
74        const TraitExpanded = 1<<5;
75        #[doc(alias = "kCTFontTraitCondensed")]
76        const TraitCondensed = 1<<6;
77        #[doc(alias = "kCTFontTraitMonoSpace")]
78        const TraitMonoSpace = 1<<10;
79        #[doc(alias = "kCTFontTraitVertical")]
80        const TraitVertical = 1<<11;
81        #[doc(alias = "kCTFontTraitUIOptimized")]
82        const TraitUIOptimized = 1<<12;
83        #[doc(alias = "kCTFontTraitColorGlyphs")]
84        const TraitColorGlyphs = 1<<13;
85        #[doc(alias = "kCTFontTraitComposite")]
86        const TraitComposite = 1<<14;
87        #[doc(alias = "kCTFontTraitClassMask")]
88        const TraitClassMask = 15<<kCTFontClassMaskShift;
89        #[doc(alias = "kCTFontItalicTrait")]
90        const ItalicTrait = CTFontSymbolicTraits::TraitItalic.0;
91        #[doc(alias = "kCTFontBoldTrait")]
92        const BoldTrait = CTFontSymbolicTraits::TraitBold.0;
93        #[doc(alias = "kCTFontExpandedTrait")]
94        const ExpandedTrait = CTFontSymbolicTraits::TraitExpanded.0;
95        #[doc(alias = "kCTFontCondensedTrait")]
96        const CondensedTrait = CTFontSymbolicTraits::TraitCondensed.0;
97        #[doc(alias = "kCTFontMonoSpaceTrait")]
98        const MonoSpaceTrait = CTFontSymbolicTraits::TraitMonoSpace.0;
99        #[doc(alias = "kCTFontVerticalTrait")]
100        const VerticalTrait = CTFontSymbolicTraits::TraitVertical.0;
101        #[doc(alias = "kCTFontUIOptimizedTrait")]
102        const UIOptimizedTrait = CTFontSymbolicTraits::TraitUIOptimized.0;
103        #[doc(alias = "kCTFontColorGlyphsTrait")]
104        const ColorGlyphsTrait = CTFontSymbolicTraits::TraitColorGlyphs.0;
105        #[doc(alias = "kCTFontCompositeTrait")]
106        const CompositeTrait = CTFontSymbolicTraits::TraitComposite.0;
107        #[doc(alias = "kCTFontClassMaskTrait")]
108        const ClassMaskTrait = CTFontSymbolicTraits::TraitClassMask.0;
109    }
110}
111
112#[cfg(feature = "objc2")]
113unsafe impl Encode for CTFontSymbolicTraits {
114    const ENCODING: Encoding = u32::ENCODING;
115}
116
117#[cfg(feature = "objc2")]
118unsafe impl RefEncode for CTFontSymbolicTraits {
119    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
120}
121
122/// Stylistic class values.
123///
124/// CTFontStylisticClass classifies certain stylistic qualities of the font. These values correspond closely to the font class values in the OpenType 'OS/2' table. The class values are bundled in the upper four bits of the CTFontSymbolicTraits and can be obtained via the kCTFontTraitClassMask.
125///
126/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontstylisticclass?language=objc)
127// NS_OPTIONS
128#[repr(transparent)]
129#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
130pub struct CTFontStylisticClass(pub u32);
131bitflags::bitflags! {
132    impl CTFontStylisticClass: u32 {
133        #[doc(alias = "kCTFontClassUnknown")]
134        const ClassUnknown = 0<<kCTFontClassMaskShift;
135        #[doc(alias = "kCTFontClassOldStyleSerifs")]
136        const ClassOldStyleSerifs = 1<<kCTFontClassMaskShift;
137        #[doc(alias = "kCTFontClassTransitionalSerifs")]
138        const ClassTransitionalSerifs = 2<<kCTFontClassMaskShift;
139        #[doc(alias = "kCTFontClassModernSerifs")]
140        const ClassModernSerifs = 3<<kCTFontClassMaskShift;
141        #[doc(alias = "kCTFontClassClarendonSerifs")]
142        const ClassClarendonSerifs = 4<<kCTFontClassMaskShift;
143        #[doc(alias = "kCTFontClassSlabSerifs")]
144        const ClassSlabSerifs = 5<<kCTFontClassMaskShift;
145        #[doc(alias = "kCTFontClassFreeformSerifs")]
146        const ClassFreeformSerifs = 7<<kCTFontClassMaskShift;
147        #[doc(alias = "kCTFontClassSansSerif")]
148        const ClassSansSerif = 8<<kCTFontClassMaskShift;
149        #[doc(alias = "kCTFontClassOrnamentals")]
150        const ClassOrnamentals = 9<<kCTFontClassMaskShift;
151        #[doc(alias = "kCTFontClassScripts")]
152        const ClassScripts = 10<<kCTFontClassMaskShift;
153        #[doc(alias = "kCTFontClassSymbolic")]
154        const ClassSymbolic = 12<<kCTFontClassMaskShift;
155        #[doc(alias = "kCTFontUnknownClass")]
156        const UnknownClass = CTFontStylisticClass::ClassUnknown.0;
157        #[doc(alias = "kCTFontOldStyleSerifsClass")]
158        const OldStyleSerifsClass = CTFontStylisticClass::ClassOldStyleSerifs.0;
159        #[doc(alias = "kCTFontTransitionalSerifsClass")]
160        const TransitionalSerifsClass = CTFontStylisticClass::ClassTransitionalSerifs.0;
161        #[doc(alias = "kCTFontModernSerifsClass")]
162        const ModernSerifsClass = CTFontStylisticClass::ClassModernSerifs.0;
163        #[doc(alias = "kCTFontClarendonSerifsClass")]
164        const ClarendonSerifsClass = CTFontStylisticClass::ClassClarendonSerifs.0;
165        #[doc(alias = "kCTFontSlabSerifsClass")]
166        const SlabSerifsClass = CTFontStylisticClass::ClassSlabSerifs.0;
167        #[doc(alias = "kCTFontFreeformSerifsClass")]
168        const FreeformSerifsClass = CTFontStylisticClass::ClassFreeformSerifs.0;
169        #[doc(alias = "kCTFontSansSerifClass")]
170        const SansSerifClass = CTFontStylisticClass::ClassSansSerif.0;
171        #[doc(alias = "kCTFontOrnamentalsClass")]
172        const OrnamentalsClass = CTFontStylisticClass::ClassOrnamentals.0;
173        #[doc(alias = "kCTFontScriptsClass")]
174        const ScriptsClass = CTFontStylisticClass::ClassScripts.0;
175        #[doc(alias = "kCTFontSymbolicClass")]
176        const SymbolicClass = CTFontStylisticClass::ClassSymbolic.0;
177    }
178}
179
180#[cfg(feature = "objc2")]
181unsafe impl Encode for CTFontStylisticClass {
182    const ENCODING: Encoding = u32::ENCODING;
183}
184
185#[cfg(feature = "objc2")]
186unsafe impl RefEncode for CTFontStylisticClass {
187    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
188}