//
//  CoreText+Private.swift
//  OpenSwiftUICore

#if canImport(CoreText)
package import CoreText
package import CoreText_Private
import CoreFoundation
package import Foundation

// MARK: - Private CoreText APIs

// MARK: - CTFontSymbolicTraits

extension CTFontSymbolicTraits {
    package static let tightLeading = CTFontSymbolicTraits(rawValue: 1 << 15)
    package static let looseLeading = CTFontSymbolicTraits(rawValue: 1 << 16)
}

// MARK: - CTFontDescriptor private API

/// Private CoreText function to get the weight value from a font descriptor.
///
/// - Parameter descriptor: The font descriptor to query.
/// - Returns: The weight value as a CGFloat.
@_silgen_name("CTFontDescriptorGetWeight")
package func CTFontDescriptorGetWeight(_ descriptor: CTFontDescriptor) -> CGFloat

@_silgen_name("CTFontDescriptorGetSymbolicTraits")
package func CTFontDescriptorGetSymbolicTraits(
    _ descriptor: CTFontDescriptor
) -> CTFontSymbolicTraits

@_silgen_name("CTFontDescriptorGetTextStyleSize")
package func CTFontDescriptorGetTextStyleSize(
    _ textStyle: CFString,
    _ sizeCategory: CFString,
    _: Int32,
    _ weight: UnsafePointer<CGFloat>?,
    _ size: UnsafePointer<CGFloat>? // FIXME
) -> CGFloat

@_silgen_name("CTFontDescriptorCreateWithTextStyleAndAttributes")
package func CTFontDescriptorCreateWithTextStyleAndAttributes(
    _ textStyle: CFString,
    _ sizeCategory: CFString,
    _ attributes: CFDictionary
) -> CTFontDescriptor

@_silgen_name("CTFontDescriptorIsSystemUIFont")
package func CTFontDescriptorIsSystemUIFont(_ descriptor: CTFontDescriptor) -> Bool

@_silgen_name("CTFontDescriptorCreateForUIType")
package func CTFontDescriptorCreateForUIType(
    _ uiType: CTFontUIFontType,
    _ size: CGFloat,
    _ language: CFString?
) -> CTFontDescriptor

// MARK: - CTFont private API

@_silgen_name("CTFontCopySystemUIFontExcessiveLineHeightCharacterSet")
package func CTFontCopySystemUIFontExcessiveLineHeightCharacterSet() -> CFCharacterSet?

@_silgen_name("CTFontCopyTallestTextStyleLanguageForString")
package func CTFontCopyTallestTextStyleLanguageForString(
    _ string: CFString
) -> CFString?

@_silgen_name("CTFontGetLanguageAwareOutsets")
package func CTFontGetLanguageAwareOutsets(
    _ font: CTFont,
    _ left: UnsafeMutablePointer<CGFloat>,
    _ top: UnsafeMutablePointer<CGFloat>,
    _ right: UnsafeMutablePointer<CGFloat>,
    _ bottom: UnsafeMutablePointer<CGFloat>
) -> Bool

@_silgen_name("CTFontGetClippingMetrics")
package func CTFontGetClippingMetrics(
    _ font: CTFont,
    _ ascent: UnsafeMutablePointer<CGFloat>,
    _ descent: UnsafeMutablePointer<CGFloat>
) -> Bool

@_silgen_name("CTFontIsSystemUIFont")
package func CTFontIsSystemUIFont(_ font: CTFont) -> Bool

@_silgen_name("CTFontGetWeight")
package func CTFontGetWeight(_ font: CTFont) -> CGFloat

@_silgen_name("CTFontGetAccessibilityBoldWeightOfWeight")
package func CTFontGetAccessibilityBoldWeightOfWeight(_ weight: CGFloat) -> CGFloat

// MARK: - TraitKey

@_silgen_name("kCTFontUIFontDesignTrait")
let kCTFontUIFontDesignTrait: CFString

@_silgen_name("kCTFontGradeTrait")
let kCTFontGradeTrait: CFString?

@_silgen_name("kCTFontLegibilityWeightAttribute")
let kCTFontLegibilityWeightAttribute: CFString

@_silgen_name("kCTFontDescriptorLanguageAttribute")
let kCTFontDescriptorLanguageAttribute: CFString

@_silgen_name("kCTFontLanguageAwareLineHeightRatioAttribute")
let kCTFontLanguageAwareLineHeightRatioAttribute: CFString

// MARK: - CTFontTextStyle

@_silgen_name("kCTUIFontTextStyleTitle0")
let kCTUIFontTextStyleTitle0: CFString

@_silgen_name("kCTUIFontTextStyleTitle1")
let kCTUIFontTextStyleTitle1: CFString

@_silgen_name("kCTUIFontTextStyleTitle2")
let kCTUIFontTextStyleTitle2: CFString

@_silgen_name("kCTUIFontTextStyleTitle3")
let kCTUIFontTextStyleTitle3: CFString

@_silgen_name("kCTUIFontTextStyleHeadline")
let kCTUIFontTextStyleHeadline: CFString

@_silgen_name("kCTUIFontTextStyleSubhead")
let kCTUIFontTextStyleSubhead: CFString

@_silgen_name("kCTUIFontTextStyleBody")
let kCTUIFontTextStyleBody: CFString

@_silgen_name("kCTUIFontTextStyleCallout")
let kCTUIFontTextStyleCallout: CFString

@_silgen_name("kCTUIFontTextStyleFootnote")
let kCTUIFontTextStyleFootnote: CFString

@_silgen_name("kCTUIFontTextStyleCaption1")
let kCTUIFontTextStyleCaption1: CFString

@_silgen_name("kCTUIFontTextStyleCaption2")
let kCTUIFontTextStyleCaption2: CFString

@_silgen_name("kCTUIFontTextStyleExtraLargeTitle")
let kCTUIFontTextStyleExtraLargeTitle: CFString

@_silgen_name("kCTUIFontTextStyleExtraLargeTitle2")
let kCTUIFontTextStyleExtraLargeTitle2: CFString

@_silgen_name("kCTUIFontTextStyleCaption3")
let kCTUIFontTextStyleCaption3: CFString

@_silgen_name("kCTUIFontTextStyleFootnote2")
let kCTUIFontTextStyleFootnote2: CFString

let kUICTFontTextStyleShortCaption1: CFString = "UICTFontTextStyleShortCaption1" as CFString

let kUICTFontTextStyleShortCaption2: CFString = "UICTFontTextStyleShortCaption2" as CFString

// MARK: - CTFontDesign

@_silgen_name("kCTFontUIFontDesignDefault")
let kCTFontUIFontDesignDefault: CFString

@_silgen_name("kCTFontUIFontDesignSerif")
let kCTFontUIFontDesignSerif: CFString

@_silgen_name("kCTFontUIFontDesignRounded")
let kCTFontUIFontDesignRounded: CFString

@_silgen_name("kCTFontUIFontDesignMonospaced")
let kCTFontUIFontDesignMonospaced: CFString

@_silgen_name("kCTFontUIFontDesignCompact")
let kCTFontUIFontDesignCompact: CFString

@_silgen_name("kCTFontUIFontDesignCompactRounded")
let kCTFontUIFontDesignCompactRounded: CFString

@_silgen_name("kCTFontUIFontDesignSoft")
let kCTFontUIFontDesignSoft: CFString

@_silgen_name("kCTFontUIFontDesignCompactSoft")
let kCTFontUIFontDesignCompactSoft: CFString

// MARK: - CTFontContentSizeCategory

@_silgen_name("kCTFontContentSizeCategoryXS")
let kCTFontContentSizeCategoryXS: CFString

@_silgen_name("kCTFontContentSizeCategoryS")
let kCTFontContentSizeCategoryS: CFString

@_silgen_name("kCTFontContentSizeCategoryM")
let kCTFontContentSizeCategoryM: CFString

@_silgen_name("kCTFontContentSizeCategoryL")
let kCTFontContentSizeCategoryL: CFString

@_silgen_name("kCTFontContentSizeCategoryXL")
let kCTFontContentSizeCategoryXL: CFString

@_silgen_name("kCTFontContentSizeCategoryXXL")
let kCTFontContentSizeCategoryXXL: CFString

@_silgen_name("kCTFontContentSizeCategoryXXXL")
let kCTFontContentSizeCategoryXXXL: CFString

@_silgen_name("kCTFontContentSizeCategoryAccessibilityM")
let kCTFontContentSizeCategoryAccessibilityM: CFString

@_silgen_name("kCTFontContentSizeCategoryAccessibilityL")
let kCTFontContentSizeCategoryAccessibilityL: CFString

@_silgen_name("kCTFontContentSizeCategoryAccessibilityXL")
let kCTFontContentSizeCategoryAccessibilityXL: CFString

@_silgen_name("kCTFontContentSizeCategoryAccessibilityXXL")
let kCTFontContentSizeCategoryAccessibilityXXL: CFString

@_silgen_name("kCTFontContentSizeCategoryAccessibilityXXXL")
let kCTFontContentSizeCategoryAccessibilityXXXL: CFString

// MARK: - CTFontWeight

@_silgen_name("kCTFontWeightRegular")
let kCTFontWeightRegular: CGFloat

@_silgen_name("kCTFontWeightHeavy")
let kCTFontWeightHeavy: CGFloat

// MARK: - CTFontWidth

@_silgen_name("kCTFontWidthCompressed")
let kCTFontWidthCompressed: CGFloat

@_silgen_name("kCTFontWidthCondensed")
let kCTFontWidthCondensed: CGFloat

@_silgen_name("kCTFontWidthExpanded")
let kCTFontWidthExpanded: CGFloat

@_silgen_name("kCTFontWidthStandard")
let kCTFontWidthStandard: CGFloat

@_silgen_name("kCTFontWidthTrait")
let kCTFontWidthTrait: CFString

// MARK: - CTAdaptiveImageGlyph

@available(macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, visionOS 2.0, *)
extension CTAdaptiveImageGlyph {
    @_silgen_name("$sSo20CTAdaptiveImageGlyphC8CoreTextE09_adaptivebC014convertingFromAB10Foundation16AttributedStringVACE08AdaptivebC0V_tFZ")
    package static func _adaptiveImageGlyph(
        convertingFrom adaptiveImageGlyph: AttributedString.AdaptiveImageGlyph
    ) -> CTAdaptiveImageGlyph
}

// MARK: - Attribute Name

@_silgen_name("kCTTextScaleRatioAttributeName")
let kCTTextScaleRatioAttributeName: CFString

@_silgen_name("NSTextEncapsulationAttributeName")
let NSTextEncapsulationAttributeName: NSAttributedString.Key

#endif
