// Automatically generated by clay-bindgen
// language: c

private alias OpaquePointer = RawPointer;
private alias UnknownType = Int;
private alias AUnionType = Int;


alias CGFloat = Float;

alias CGAffineTransform = Struct_CGAffineTransform;

record Struct_CGPoint (
    x : Float,
    y : Float,
);

alias CGPoint = Struct_CGPoint;

record Struct_CGSize (
    width : Float,
    height : Float,
);

alias CGSize = Struct_CGSize;

record Struct_CGRect (
    origin : CGPoint,
    size : CGSize,
);

alias CGRect = Struct_CGRect;

alias CGRectMinXEdge = 0;
alias CGRectMinYEdge = 1;
alias CGRectMaxXEdge = 2;
alias CGRectMaxYEdge = 3;

alias CGRectEdge = Int;

external CGPointZero : CGPoint;

external CGSizeZero : CGSize;

external CGRectZero : CGRect;

external CGRectNull : CGRect;

external CGRectInfinite : CGRect;

external CGRectGetMinX(
    rect : CGRect) : Float;

external CGRectGetMidX(
    rect : CGRect) : Float;

external CGRectGetMaxX(
    rect : CGRect) : Float;

external CGRectGetMinY(
    rect : CGRect) : Float;

external CGRectGetMidY(
    rect : CGRect) : Float;

external CGRectGetMaxY(
    rect : CGRect) : Float;

external CGRectGetWidth(
    rect : CGRect) : Float;

external CGRectGetHeight(
    rect : CGRect) : Float;

external CGPointEqualToPoint(
    point1 : CGPoint,
    point2 : CGPoint) : Bool;

external CGSizeEqualToSize(
    size1 : CGSize,
    size2 : CGSize) : Bool;

external CGRectEqualToRect(
    rect1 : CGRect,
    rect2 : CGRect) : Bool;

external CGRectStandardize(
    rect : CGRect) : CGRect;

external CGRectIsEmpty(
    rect : CGRect) : Bool;

external CGRectIsNull(
    rect : CGRect) : Bool;

external CGRectIsInfinite(
    rect : CGRect) : Bool;

external CGRectInset(
    rect : CGRect,
    dx : Float,
    dy : Float) : CGRect;

external CGRectIntegral(
    rect : CGRect) : CGRect;

external CGRectUnion(
    r1 : CGRect,
    r2 : CGRect) : CGRect;

external CGRectIntersection(
    r1 : CGRect,
    r2 : CGRect) : CGRect;

external CGRectOffset(
    rect : CGRect,
    dx : Float,
    dy : Float) : CGRect;

external CGRectDivide(
    rect : CGRect,
    slice : Pointer[CGRect],
    remainder : Pointer[CGRect],
    amount : Float,
    edge : CGRectEdge);

external CGRectContainsPoint(
    rect : CGRect,
    point : CGPoint) : Bool;

external CGRectContainsRect(
    rect1 : CGRect,
    rect2 : CGRect) : Bool;

external CGRectIntersectsRect(
    rect1 : CGRect,
    rect2 : CGRect) : Bool;

external CGPointCreateDictionaryRepresentation(
    point : CGPoint) : CFDictionaryRef;

external CGPointMakeWithDictionaryRepresentation(
    dict : CFDictionaryRef,
    point : Pointer[CGPoint]) : Bool;

external CGSizeCreateDictionaryRepresentation(
    size : CGSize) : CFDictionaryRef;

external CGSizeMakeWithDictionaryRepresentation(
    dict : CFDictionaryRef,
    size : Pointer[CGSize]) : Bool;

external CGRectCreateDictionaryRepresentation(
    argument0 : CGRect) : CFDictionaryRef;

external CGRectMakeWithDictionaryRepresentation(
    dict : CFDictionaryRef,
    rect : Pointer[CGRect]) : Bool;

record Struct_CGAffineTransform (
    a : Float,
    b : Float,
    c : Float,
    d : Float,
    tx : Float,
    ty : Float,
);

external CGAffineTransformIdentity : CGAffineTransform;

external CGAffineTransformMake(
    a : Float,
    b : Float,
    c : Float,
    d : Float,
    tx : Float,
    ty : Float) : CGAffineTransform;

external CGAffineTransformMakeTranslation(
    tx : Float,
    ty : Float) : CGAffineTransform;

external CGAffineTransformMakeScale(
    sx : Float,
    sy : Float) : CGAffineTransform;

external CGAffineTransformMakeRotation(
    angle : Float) : CGAffineTransform;

external CGAffineTransformIsIdentity(
    t : CGAffineTransform) : Bool;

external CGAffineTransformTranslate(
    t : CGAffineTransform,
    tx : Float,
    ty : Float) : CGAffineTransform;

external CGAffineTransformScale(
    t : CGAffineTransform,
    sx : Float,
    sy : Float) : CGAffineTransform;

external CGAffineTransformRotate(
    t : CGAffineTransform,
    angle : Float) : CGAffineTransform;

external CGAffineTransformInvert(
    t : CGAffineTransform) : CGAffineTransform;

external CGAffineTransformConcat(
    t1 : CGAffineTransform,
    t2 : CGAffineTransform) : CGAffineTransform;

external CGAffineTransformEqualToTransform(
    t1 : CGAffineTransform,
    t2 : CGAffineTransform) : Bool;

external CGPointApplyAffineTransform(
    point : CGPoint,
    t : CGAffineTransform) : CGPoint;

external CGSizeApplyAffineTransform(
    size : CGSize,
    t : CGAffineTransform) : CGSize;

external CGRectApplyAffineTransform(
    rect : CGRect,
    t : CGAffineTransform) : CGRect;

alias CGContextRef = OpaquePointer;

alias CGColorRef = OpaquePointer;

alias CGColorSpaceRef = OpaquePointer;

alias CGDataProviderRef = OpaquePointer;

alias CGDataProviderGetBytesCallback = CCodePointer[[RawPointer,RawPointer,UInt],[UInt]];

alias CGDataProviderSkipForwardCallback = CCodePointer[[RawPointer,Int64],[Int64]];

alias CGDataProviderRewindCallback = CCodePointer[[RawPointer],[]];

alias CGDataProviderReleaseInfoCallback = CCodePointer[[RawPointer],[]];

record Struct_CGDataProviderSequentialCallbacks (
    version : UInt,
    getBytes : CGDataProviderGetBytesCallback,
    skipForward : CGDataProviderSkipForwardCallback,
    rewind : CGDataProviderRewindCallback,
    releaseInfo : CGDataProviderReleaseInfoCallback,
);

alias CGDataProviderSequentialCallbacks = Struct_CGDataProviderSequentialCallbacks;

alias CGDataProviderGetBytePointerCallback = CCodePointer[[RawPointer],[RawPointer]];

alias CGDataProviderReleaseBytePointerCallback = CCodePointer[[RawPointer,RawPointer],[]];

alias CGDataProviderGetBytesAtPositionCallback = CCodePointer[[RawPointer,RawPointer,Int64,UInt],[UInt]];

record Struct_CGDataProviderDirectCallbacks (
    version : UInt,
    getBytePointer : CGDataProviderGetBytePointerCallback,
    releaseBytePointer : CGDataProviderReleaseBytePointerCallback,
    getBytesAtPosition : CGDataProviderGetBytesAtPositionCallback,
    releaseInfo : CGDataProviderReleaseInfoCallback,
);

alias CGDataProviderDirectCallbacks = Struct_CGDataProviderDirectCallbacks;

external CGDataProviderGetTypeID() : CULong;

external CGDataProviderCreateSequential(
    info : RawPointer,
    callbacks : Pointer[CGDataProviderSequentialCallbacks]) : CGDataProviderRef;

external CGDataProviderCreateDirect(
    info : RawPointer,
    size : Int64,
    callbacks : Pointer[CGDataProviderDirectCallbacks]) : CGDataProviderRef;

alias CGDataProviderReleaseDataCallback = CCodePointer[[RawPointer,RawPointer,UInt],[]];

external CGDataProviderCreateWithData(
    info : RawPointer,
    data : RawPointer,
    size : UInt,
    releaseData : CGDataProviderReleaseDataCallback) : CGDataProviderRef;

external CGDataProviderCreateWithCFData(
    data : CFDataRef) : CGDataProviderRef;

external CGDataProviderCreateWithURL(
    url : CFURLRef) : CGDataProviderRef;

external CGDataProviderCreateWithFilename(
    filename : Pointer[CChar]) : CGDataProviderRef;

external CGDataProviderRetain(
    provider : CGDataProviderRef) : CGDataProviderRef;

external CGDataProviderRelease(
    provider : CGDataProviderRef);

external CGDataProviderCopyData(
    provider : CGDataProviderRef) : CFDataRef;

alias CGDataProviderSkipBytesCallback = CCodePointer[[RawPointer,UInt],[]];

record Struct_CGDataProviderCallbacks (
    getBytes : CGDataProviderGetBytesCallback,
    skipBytes : CGDataProviderSkipBytesCallback,
    rewind : CGDataProviderRewindCallback,
    releaseProvider : CGDataProviderReleaseInfoCallback,
);

alias CGDataProviderCallbacks = Struct_CGDataProviderCallbacks;

alias CGDataProviderGetBytesAtOffsetCallback = CCodePointer[[RawPointer,RawPointer,UInt,UInt],[UInt]];

record Struct_CGDataProviderDirectAccessCallbacks (
    getBytePointer : CGDataProviderGetBytePointerCallback,
    releaseBytePointer : CGDataProviderReleaseBytePointerCallback,
    getBytes : CGDataProviderGetBytesAtOffsetCallback,
    releaseProvider : CGDataProviderReleaseInfoCallback,
);

alias CGDataProviderDirectAccessCallbacks = Struct_CGDataProviderDirectAccessCallbacks;

external CGDataProviderCreate(
    info : RawPointer,
    callbacks : Pointer[CGDataProviderCallbacks]) : CGDataProviderRef;

external CGDataProviderCreateDirectAccess(
    info : RawPointer,
    size : UInt,
    callbacks : Pointer[CGDataProviderDirectAccessCallbacks]) : CGDataProviderRef;

alias kCGRenderingIntentDefault = 0;
alias kCGRenderingIntentAbsoluteColorimetric = 1;
alias kCGRenderingIntentRelativeColorimetric = 2;
alias kCGRenderingIntentPerceptual = 3;
alias kCGRenderingIntentSaturation = 4;

alias CGColorRenderingIntent = Int;

alias kCGColorSpaceModelUnknown = 4294967295;
alias kCGColorSpaceModelMonochrome = 0;
alias kCGColorSpaceModelRGB = 1;
alias kCGColorSpaceModelCMYK = 2;
alias kCGColorSpaceModelLab = 3;
alias kCGColorSpaceModelDeviceN = 4;
alias kCGColorSpaceModelIndexed = 5;
alias kCGColorSpaceModelPattern = 6;

alias CGColorSpaceModel = Int;

external kCGColorSpaceGenericGray : CFStringRef;

external kCGColorSpaceGenericRGB : CFStringRef;

external kCGColorSpaceGenericCMYK : CFStringRef;

external kCGColorSpaceGenericRGBLinear : CFStringRef;

external kCGColorSpaceAdobeRGB1998 : CFStringRef;

external kCGColorSpaceSRGB : CFStringRef;

external kCGColorSpaceGenericGrayGamma2_2 : CFStringRef;

external CGColorSpaceCreateDeviceGray() : CGColorSpaceRef;

external CGColorSpaceCreateDeviceRGB() : CGColorSpaceRef;

external CGColorSpaceCreateDeviceCMYK() : CGColorSpaceRef;

external CGColorSpaceCreateCalibratedGray(
    whitePoint : Pointer[Float],
    blackPoint : Pointer[Float],
    gamma : Float) : CGColorSpaceRef;

external CGColorSpaceCreateCalibratedRGB(
    whitePoint : Pointer[Float],
    blackPoint : Pointer[Float],
    gamma : Pointer[Float],
    matrix : Pointer[Float]) : CGColorSpaceRef;

external CGColorSpaceCreateLab(
    whitePoint : Pointer[Float],
    blackPoint : Pointer[Float],
    range : Pointer[Float]) : CGColorSpaceRef;

external CGColorSpaceCreateWithICCProfile(
    data : CFDataRef) : CGColorSpaceRef;

external CGColorSpaceCreateICCBased(
    nComponents : UInt,
    range : Pointer[Float],
    profile : CGDataProviderRef,
    alternate : CGColorSpaceRef) : CGColorSpaceRef;

external CGColorSpaceCreateIndexed(
    baseSpace : CGColorSpaceRef,
    lastIndex : UInt,
    colorTable : Pointer[CUChar]) : CGColorSpaceRef;

external CGColorSpaceCreatePattern(
    baseSpace : CGColorSpaceRef) : CGColorSpaceRef;

external CGColorSpaceCreateWithPlatformColorSpace(
    ref_ : RawPointer) : CGColorSpaceRef;

external CGColorSpaceCreateWithName(
    name : CFStringRef) : CGColorSpaceRef;

external CGColorSpaceRetain(
    space : CGColorSpaceRef) : CGColorSpaceRef;

external CGColorSpaceRelease(
    space : CGColorSpaceRef);

external CGColorSpaceCopyName(
    space : CGColorSpaceRef) : CFStringRef;

external CGColorSpaceGetTypeID() : CULong;

external CGColorSpaceGetNumberOfComponents(
    space : CGColorSpaceRef) : UInt;

external CGColorSpaceGetModel(
    space : CGColorSpaceRef) : CGColorSpaceModel;

external CGColorSpaceGetBaseColorSpace(
    space : CGColorSpaceRef) : CGColorSpaceRef;

external CGColorSpaceGetColorTableCount(
    space : CGColorSpaceRef) : UInt;

external CGColorSpaceGetColorTable(
    space : CGColorSpaceRef,
    table : Pointer[CUChar]);

external CGColorSpaceCopyICCProfile(
    space : CGColorSpaceRef) : CFDataRef;

alias CGPatternRef = OpaquePointer;

alias kCGPatternTilingNoDistortion = 0;
alias kCGPatternTilingConstantSpacingMinimalDistortion = 1;
alias kCGPatternTilingConstantSpacing = 2;

alias CGPatternTiling = Int;

alias CGPatternDrawPatternCallback = CCodePointer[[RawPointer,OpaquePointer],[]];

alias CGPatternReleaseInfoCallback = CCodePointer[[RawPointer],[]];

record Struct_CGPatternCallbacks (
    version : UInt,
    drawPattern : CGPatternDrawPatternCallback,
    releaseInfo : CGPatternReleaseInfoCallback,
);

alias CGPatternCallbacks = Struct_CGPatternCallbacks;

external CGPatternGetTypeID() : CULong;

external CGPatternCreate(
    info : RawPointer,
    bounds : CGRect,
    matrix : CGAffineTransform,
    xStep : Float,
    yStep : Float,
    tiling : CGPatternTiling,
    isColored : Bool,
    callbacks : Pointer[CGPatternCallbacks]) : CGPatternRef;

external CGPatternRetain(
    pattern : CGPatternRef) : CGPatternRef;

external CGPatternRelease(
    pattern : CGPatternRef);

external CGColorCreate(
    space : CGColorSpaceRef,
    components : Pointer[Float]) : CGColorRef;

external CGColorCreateGenericGray(
    gray : Float,
    alpha : Float) : CGColorRef;

external CGColorCreateGenericRGB(
    red : Float,
    green : Float,
    blue : Float,
    alpha : Float) : CGColorRef;

external CGColorCreateGenericCMYK(
    cyan : Float,
    magenta : Float,
    yellow : Float,
    black : Float,
    alpha : Float) : CGColorRef;

external CGColorGetConstantColor(
    colorName : CFStringRef) : CGColorRef;

external CGColorCreateWithPattern(
    space : CGColorSpaceRef,
    pattern : CGPatternRef,
    components : Pointer[Float]) : CGColorRef;

external CGColorCreateCopy(
    color : CGColorRef) : CGColorRef;

external CGColorCreateCopyWithAlpha(
    color : CGColorRef,
    alpha : Float) : CGColorRef;

external CGColorRetain(
    color : CGColorRef) : CGColorRef;

external CGColorRelease(
    color : CGColorRef);

external CGColorEqualToColor(
    color1 : CGColorRef,
    color2 : CGColorRef) : Bool;

external CGColorGetNumberOfComponents(
    color : CGColorRef) : UInt;

external CGColorGetComponents(
    color : CGColorRef) : Pointer[Float];

external CGColorGetAlpha(
    color : CGColorRef) : Float;

external CGColorGetColorSpace(
    color : CGColorRef) : CGColorSpaceRef;

external CGColorGetPattern(
    color : CGColorRef) : CGPatternRef;

external CGColorGetTypeID() : CULong;

external kCGColorWhite : CFStringRef;

external kCGColorBlack : CFStringRef;

external kCGColorClear : CFStringRef;

alias CGFontRef = OpaquePointer;

alias CGFontIndex = UShort;

alias CGGlyph = UShort;

alias kCGFontPostScriptFormatType1 = 1;
alias kCGFontPostScriptFormatType3 = 3;
alias kCGFontPostScriptFormatType42 = 42;

alias CGFontPostScriptFormat = Int;

alias kCGFontIndexMax = 65534;
alias kCGFontIndexInvalid = 65535;
alias kCGGlyphMax = 65534;

external CGFontGetTypeID() : CULong;

external CGFontCreateWithPlatformFont(
    platformFontReference : RawPointer) : CGFontRef;

external CGFontCreateWithDataProvider(
    provider : CGDataProviderRef) : CGFontRef;

external CGFontCreateWithFontName(
    name : CFStringRef) : CGFontRef;

external CGFontCreateCopyWithVariations(
    font : CGFontRef,
    variations : CFDictionaryRef) : CGFontRef;

external CGFontRetain(
    font : CGFontRef) : CGFontRef;

external CGFontRelease(
    font : CGFontRef);

external CGFontGetNumberOfGlyphs(
    font : CGFontRef) : UInt;

external CGFontGetUnitsPerEm(
    font : CGFontRef) : Int;

external CGFontCopyPostScriptName(
    font : CGFontRef) : CFStringRef;

external CGFontCopyFullName(
    font : CGFontRef) : CFStringRef;

external CGFontGetAscent(
    font : CGFontRef) : Int;

external CGFontGetDescent(
    font : CGFontRef) : Int;

external CGFontGetLeading(
    font : CGFontRef) : Int;

external CGFontGetCapHeight(
    font : CGFontRef) : Int;

external CGFontGetXHeight(
    font : CGFontRef) : Int;

external CGFontGetFontBBox(
    font : CGFontRef) : CGRect;

external CGFontGetItalicAngle(
    font : CGFontRef) : Float;

external CGFontGetStemV(
    font : CGFontRef) : Float;

external CGFontCopyVariationAxes(
    font : CGFontRef) : CFArrayRef;

external CGFontCopyVariations(
    font : CGFontRef) : CFDictionaryRef;

external CGFontGetGlyphAdvances(
    font : CGFontRef,
    glyphs : Pointer[UShort],
    count : UInt,
    advances : Pointer[Int]) : Bool;

external CGFontGetGlyphBBoxes(
    font : CGFontRef,
    glyphs : Pointer[UShort],
    count : UInt,
    bboxes : Pointer[CGRect]) : Bool;

external CGFontGetGlyphWithGlyphName(
    font : CGFontRef,
    name : CFStringRef) : UShort;

external CGFontCopyGlyphNameForGlyph(
    font : CGFontRef,
    glyph : UShort) : CFStringRef;

external CGFontCanCreatePostScriptSubset(
    font : CGFontRef,
    format : CGFontPostScriptFormat) : Bool;

external CGFontCreatePostScriptSubset(
    font : CGFontRef,
    subsetName : CFStringRef,
    format : CGFontPostScriptFormat,
    glyphs : Pointer[UShort],
    count : UInt,
    encoding : Pointer[UShort]) : CFDataRef;

external CGFontCreatePostScriptEncoding(
    font : CGFontRef,
    encoding : Pointer[UShort]) : CFDataRef;

external CGFontCopyTableTags(
    font : CGFontRef) : CFArrayRef;

external CGFontCopyTableForTag(
    font : CGFontRef,
    tag : UInt) : CFDataRef;

external kCGFontVariationAxisName : CFStringRef;

external kCGFontVariationAxisMinValue : CFStringRef;

external kCGFontVariationAxisMaxValue : CFStringRef;

external kCGFontVariationAxisDefaultValue : CFStringRef;

alias CGGlyphMin = 0;
alias CGGlyphMax = 65534;

alias CGGradientRef = OpaquePointer;

alias kCGGradientDrawsBeforeStartLocation = 1;
alias kCGGradientDrawsAfterEndLocation = 2;

alias CGGradientDrawingOptions = UInt;

external CGGradientGetTypeID() : CULong;

external CGGradientCreateWithColorComponents(
    space : CGColorSpaceRef,
    components : Pointer[Float],
    locations : Pointer[Float],
    count : UInt) : CGGradientRef;

external CGGradientCreateWithColors(
    space : CGColorSpaceRef,
    colors : CFArrayRef,
    locations : Pointer[Float]) : CGGradientRef;

external CGGradientRetain(
    gradient : CGGradientRef) : CGGradientRef;

external CGGradientRelease(
    gradient : CGGradientRef);

alias CGImageRef = OpaquePointer;

alias kCGImageAlphaNone = 0;
alias kCGImageAlphaPremultipliedLast = 1;
alias kCGImageAlphaPremultipliedFirst = 2;
alias kCGImageAlphaLast = 3;
alias kCGImageAlphaFirst = 4;
alias kCGImageAlphaNoneSkipLast = 5;
alias kCGImageAlphaNoneSkipFirst = 6;
alias kCGImageAlphaOnly = 7;

alias CGImageAlphaInfo = Int;

alias kCGBitmapAlphaInfoMask = 31;
alias kCGBitmapFloatComponents = 256;
alias kCGBitmapByteOrderMask = 28672;
alias kCGBitmapByteOrderDefault = 0;
alias kCGBitmapByteOrder16Little = 4096;
alias kCGBitmapByteOrder32Little = 8192;
alias kCGBitmapByteOrder16Big = 12288;
alias kCGBitmapByteOrder32Big = 16384;

alias CGBitmapInfo = UInt;

external CGImageGetTypeID() : CULong;

external CGImageCreate(
    width : UInt,
    height : UInt,
    bitsPerComponent : UInt,
    bitsPerPixel : UInt,
    bytesPerRow : UInt,
    space : CGColorSpaceRef,
    bitmapInfo : UInt,
    provider : CGDataProviderRef,
    decode : Pointer[Float],
    shouldInterpolate : Bool,
    intent : CGColorRenderingIntent) : CGImageRef;

external CGImageMaskCreate(
    width : UInt,
    height : UInt,
    bitsPerComponent : UInt,
    bitsPerPixel : UInt,
    bytesPerRow : UInt,
    provider : CGDataProviderRef,
    decode : Pointer[Float],
    shouldInterpolate : Bool) : CGImageRef;

external CGImageCreateCopy(
    image : CGImageRef) : CGImageRef;

external CGImageCreateWithJPEGDataProvider(
    source : CGDataProviderRef,
    decode : Pointer[Float],
    shouldInterpolate : Bool,
    intent : CGColorRenderingIntent) : CGImageRef;

external CGImageCreateWithPNGDataProvider(
    source : CGDataProviderRef,
    decode : Pointer[Float],
    shouldInterpolate : Bool,
    intent : CGColorRenderingIntent) : CGImageRef;

external CGImageCreateWithImageInRect(
    image : CGImageRef,
    rect : CGRect) : CGImageRef;

external CGImageCreateWithMask(
    image : CGImageRef,
    mask : CGImageRef) : CGImageRef;

external CGImageCreateWithMaskingColors(
    image : CGImageRef,
    components : Pointer[Float]) : CGImageRef;

external CGImageCreateCopyWithColorSpace(
    image : CGImageRef,
    space : CGColorSpaceRef) : CGImageRef;

external CGImageRetain(
    image : CGImageRef) : CGImageRef;

external CGImageRelease(
    image : CGImageRef);

external CGImageIsMask(
    image : CGImageRef) : Bool;

external CGImageGetWidth(
    image : CGImageRef) : UInt;

external CGImageGetHeight(
    image : CGImageRef) : UInt;

external CGImageGetBitsPerComponent(
    image : CGImageRef) : UInt;

external CGImageGetBitsPerPixel(
    image : CGImageRef) : UInt;

external CGImageGetBytesPerRow(
    image : CGImageRef) : UInt;

external CGImageGetColorSpace(
    image : CGImageRef) : CGColorSpaceRef;

external CGImageGetAlphaInfo(
    image : CGImageRef) : CGImageAlphaInfo;

external CGImageGetDataProvider(
    image : CGImageRef) : CGDataProviderRef;

external CGImageGetDecode(
    image : CGImageRef) : Pointer[Float];

external CGImageGetShouldInterpolate(
    image : CGImageRef) : Bool;

external CGImageGetRenderingIntent(
    image : CGImageRef) : CGColorRenderingIntent;

external CGImageGetBitmapInfo(
    image : CGImageRef) : UInt;

alias CGMutablePathRef = OpaquePointer;

alias CGPathRef = OpaquePointer;

external CGPathGetTypeID() : CULong;

external CGPathCreateMutable() : CGMutablePathRef;

external CGPathCreateCopy(
    path : CGPathRef) : CGPathRef;

external CGPathCreateMutableCopy(
    path : CGPathRef) : CGMutablePathRef;

external CGPathRetain(
    path : CGPathRef) : CGPathRef;

external CGPathRelease(
    path : CGPathRef);

external CGPathEqualToPath(
    path1 : CGPathRef,
    path2 : CGPathRef) : Bool;

external CGPathMoveToPoint(
    path : CGMutablePathRef,
    m : Pointer[CGAffineTransform],
    x : Float,
    y : Float);

external CGPathAddLineToPoint(
    path : CGMutablePathRef,
    m : Pointer[CGAffineTransform],
    x : Float,
    y : Float);

external CGPathAddQuadCurveToPoint(
    path : CGMutablePathRef,
    m : Pointer[CGAffineTransform],
    cpx : Float,
    cpy : Float,
    x : Float,
    y : Float);

external CGPathAddCurveToPoint(
    path : CGMutablePathRef,
    m : Pointer[CGAffineTransform],
    cp1x : Float,
    cp1y : Float,
    cp2x : Float,
    cp2y : Float,
    x : Float,
    y : Float);

external CGPathCloseSubpath(
    path : CGMutablePathRef);

external CGPathAddRect(
    path : CGMutablePathRef,
    m : Pointer[CGAffineTransform],
    rect : CGRect);

external CGPathAddRects(
    path : CGMutablePathRef,
    m : Pointer[CGAffineTransform],
    rects : Pointer[CGRect],
    count : UInt);

external CGPathAddLines(
    path : CGMutablePathRef,
    m : Pointer[CGAffineTransform],
    points : Pointer[CGPoint],
    count : UInt);

external CGPathAddEllipseInRect(
    path : CGMutablePathRef,
    m : Pointer[CGAffineTransform],
    rect : CGRect);

external CGPathAddArc(
    path : CGMutablePathRef,
    m : Pointer[CGAffineTransform],
    x : Float,
    y : Float,
    radius : Float,
    startAngle : Float,
    endAngle : Float,
    clockwise : Bool);

external CGPathAddArcToPoint(
    path : CGMutablePathRef,
    m : Pointer[CGAffineTransform],
    x1 : Float,
    y1 : Float,
    x2 : Float,
    y2 : Float,
    radius : Float);

external CGPathAddPath(
    path1 : CGMutablePathRef,
    m : Pointer[CGAffineTransform],
    path2 : CGPathRef);

external CGPathIsEmpty(
    path : CGPathRef) : Bool;

external CGPathIsRect(
    path : CGPathRef,
    rect : Pointer[CGRect]) : Bool;

external CGPathGetCurrentPoint(
    path : CGPathRef) : CGPoint;

external CGPathGetBoundingBox(
    path : CGPathRef) : CGRect;

external CGPathGetPathBoundingBox(
    path : CGPathRef) : CGRect;

external CGPathContainsPoint(
    path : CGPathRef,
    m : Pointer[CGAffineTransform],
    point : CGPoint,
    eoFill : Bool) : Bool;

alias kCGPathElementMoveToPoint = 0;
alias kCGPathElementAddLineToPoint = 1;
alias kCGPathElementAddQuadCurveToPoint = 2;
alias kCGPathElementAddCurveToPoint = 3;
alias kCGPathElementCloseSubpath = 4;

alias CGPathElementType = Int;

record Struct_CGPathElement (
    type : CGPathElementType,
    points : Pointer[CGPoint],
);

alias CGPathElement = Struct_CGPathElement;

alias CGPathApplierFunction = CCodePointer[[RawPointer,Pointer[Struct_CGPathElement]],[]];

external CGPathApply(
    path : CGPathRef,
    info : RawPointer,
    function : CGPathApplierFunction);

alias CGPDFDocumentRef = OpaquePointer;

alias CGPDFPageRef = OpaquePointer;

alias CGPDFDictionaryRef = OpaquePointer;

alias CGPDFArrayRef = OpaquePointer;

alias CGPDFBoolean = CUChar;

alias CGPDFInteger = CLong;

alias CGPDFReal = Float;

alias CGPDFObjectRef = OpaquePointer;

alias kCGPDFObjectTypeNull = 1;
alias kCGPDFObjectTypeBoolean = 2;
alias kCGPDFObjectTypeInteger = 3;
alias kCGPDFObjectTypeReal = 4;
alias kCGPDFObjectTypeName = 5;
alias kCGPDFObjectTypeString = 6;
alias kCGPDFObjectTypeArray = 7;
alias kCGPDFObjectTypeDictionary = 8;
alias kCGPDFObjectTypeStream = 9;

alias CGPDFObjectType = Int;

external CGPDFObjectGetType(
    object : CGPDFObjectRef) : CGPDFObjectType;

external CGPDFObjectGetValue(
    object : CGPDFObjectRef,
    type : CGPDFObjectType,
    value : RawPointer) : Bool;

alias CGPDFStreamRef = OpaquePointer;

alias CGPDFDataFormatRaw = 0;
alias CGPDFDataFormatJPEGEncoded = 1;
alias CGPDFDataFormatJPEG2000 = 2;

alias CGPDFDataFormat = Int;

external CGPDFStreamGetDictionary(
    stream : CGPDFStreamRef) : CGPDFDictionaryRef;

external CGPDFStreamCopyData(
    stream : CGPDFStreamRef,
    format : Pointer[CGPDFDataFormat]) : CFDataRef;

alias CGPDFStringRef = OpaquePointer;

external CGPDFStringGetLength(
    string : CGPDFStringRef) : UInt;

external CGPDFStringGetBytePtr(
    string : CGPDFStringRef) : Pointer[CUChar];

external CGPDFStringCopyTextString(
    string : CGPDFStringRef) : CFStringRef;

external CGPDFStringCopyDate(
    string : CGPDFStringRef) : CFDateRef;

external CGPDFArrayGetCount(
    array : CGPDFArrayRef) : UInt;

external CGPDFArrayGetObject(
    array : CGPDFArrayRef,
    index : UInt,
    value : Pointer[CGPDFObjectRef]) : Bool;

external CGPDFArrayGetNull(
    array : CGPDFArrayRef,
    index : UInt) : Bool;

external CGPDFArrayGetBoolean(
    array : CGPDFArrayRef,
    index : UInt,
    value : Pointer[CUChar]) : Bool;

external CGPDFArrayGetInteger(
    array : CGPDFArrayRef,
    index : UInt,
    value : Pointer[CLong]) : Bool;

external CGPDFArrayGetNumber(
    array : CGPDFArrayRef,
    index : UInt,
    value : Pointer[Float]) : Bool;

external CGPDFArrayGetName(
    array : CGPDFArrayRef,
    index : UInt,
    value : Pointer[Pointer[CChar]]) : Bool;

external CGPDFArrayGetString(
    array : CGPDFArrayRef,
    index : UInt,
    value : Pointer[CGPDFStringRef]) : Bool;

external CGPDFArrayGetArray(
    array : CGPDFArrayRef,
    index : UInt,
    value : Pointer[CGPDFArrayRef]) : Bool;

external CGPDFArrayGetDictionary(
    array : CGPDFArrayRef,
    index : UInt,
    value : Pointer[CGPDFDictionaryRef]) : Bool;

external CGPDFArrayGetStream(
    array : CGPDFArrayRef,
    index : UInt,
    value : Pointer[CGPDFStreamRef]) : Bool;

external CGPDFDictionaryGetCount(
    dict : CGPDFDictionaryRef) : UInt;

external CGPDFDictionaryGetObject(
    dict : CGPDFDictionaryRef,
    key : Pointer[CChar],
    value : Pointer[CGPDFObjectRef]) : Bool;

external CGPDFDictionaryGetBoolean(
    dict : CGPDFDictionaryRef,
    key : Pointer[CChar],
    value : Pointer[CUChar]) : Bool;

external CGPDFDictionaryGetInteger(
    dict : CGPDFDictionaryRef,
    key : Pointer[CChar],
    value : Pointer[CLong]) : Bool;

external CGPDFDictionaryGetNumber(
    dict : CGPDFDictionaryRef,
    key : Pointer[CChar],
    value : Pointer[Float]) : Bool;

external CGPDFDictionaryGetName(
    dict : CGPDFDictionaryRef,
    key : Pointer[CChar],
    value : Pointer[Pointer[CChar]]) : Bool;

external CGPDFDictionaryGetString(
    dict : CGPDFDictionaryRef,
    key : Pointer[CChar],
    value : Pointer[CGPDFStringRef]) : Bool;

external CGPDFDictionaryGetArray(
    dict : CGPDFDictionaryRef,
    key : Pointer[CChar],
    value : Pointer[CGPDFArrayRef]) : Bool;

external CGPDFDictionaryGetDictionary(
    dict : CGPDFDictionaryRef,
    key : Pointer[CChar],
    value : Pointer[CGPDFDictionaryRef]) : Bool;

external CGPDFDictionaryGetStream(
    dict : CGPDFDictionaryRef,
    key : Pointer[CChar],
    value : Pointer[CGPDFStreamRef]) : Bool;

alias CGPDFDictionaryApplierFunction = CCodePointer[[Pointer[CChar],OpaquePointer,RawPointer],[]];

external CGPDFDictionaryApplyFunction(
    dict : CGPDFDictionaryRef,
    function : CGPDFDictionaryApplierFunction,
    info : RawPointer);

alias kCGPDFMediaBox = 0;
alias kCGPDFCropBox = 1;
alias kCGPDFBleedBox = 2;
alias kCGPDFTrimBox = 3;
alias kCGPDFArtBox = 4;

alias CGPDFBox = Int;

external CGPDFPageRetain(
    page : CGPDFPageRef) : CGPDFPageRef;

external CGPDFPageRelease(
    page : CGPDFPageRef);

external CGPDFPageGetDocument(
    page : CGPDFPageRef) : CGPDFDocumentRef;

external CGPDFPageGetPageNumber(
    page : CGPDFPageRef) : UInt;

external CGPDFPageGetBoxRect(
    page : CGPDFPageRef,
    box : CGPDFBox) : CGRect;

external CGPDFPageGetRotationAngle(
    page : CGPDFPageRef) : Int;

external CGPDFPageGetDrawingTransform(
    page : CGPDFPageRef,
    box : CGPDFBox,
    rect : CGRect,
    rotate : Int,
    preserveAspectRatio : Bool) : CGAffineTransform;

external CGPDFPageGetDictionary(
    page : CGPDFPageRef) : CGPDFDictionaryRef;

external CGPDFPageGetTypeID() : CULong;

external CGPDFDocumentCreateWithProvider(
    provider : CGDataProviderRef) : CGPDFDocumentRef;

external CGPDFDocumentCreateWithURL(
    url : CFURLRef) : CGPDFDocumentRef;

external CGPDFDocumentRetain(
    document : CGPDFDocumentRef) : CGPDFDocumentRef;

external CGPDFDocumentRelease(
    document : CGPDFDocumentRef);

external CGPDFDocumentGetVersion(
    document : CGPDFDocumentRef,
    majorVersion : Pointer[Int],
    minorVersion : Pointer[Int]);

external CGPDFDocumentIsEncrypted(
    document : CGPDFDocumentRef) : Bool;

external CGPDFDocumentUnlockWithPassword(
    document : CGPDFDocumentRef,
    password : Pointer[CChar]) : Bool;

external CGPDFDocumentIsUnlocked(
    document : CGPDFDocumentRef) : Bool;

external CGPDFDocumentAllowsPrinting(
    document : CGPDFDocumentRef) : Bool;

external CGPDFDocumentAllowsCopying(
    document : CGPDFDocumentRef) : Bool;

external CGPDFDocumentGetNumberOfPages(
    document : CGPDFDocumentRef) : UInt;

external CGPDFDocumentGetPage(
    document : CGPDFDocumentRef,
    pageNumber : UInt) : CGPDFPageRef;

external CGPDFDocumentGetCatalog(
    document : CGPDFDocumentRef) : CGPDFDictionaryRef;

external CGPDFDocumentGetInfo(
    document : CGPDFDocumentRef) : CGPDFDictionaryRef;

external CGPDFDocumentGetID(
    document : CGPDFDocumentRef) : CGPDFArrayRef;

external CGPDFDocumentGetTypeID() : CULong;

external CGPDFDocumentGetMediaBox(
    document : CGPDFDocumentRef,
    page : Int) : CGRect;

external CGPDFDocumentGetCropBox(
    document : CGPDFDocumentRef,
    page : Int) : CGRect;

external CGPDFDocumentGetBleedBox(
    document : CGPDFDocumentRef,
    page : Int) : CGRect;

external CGPDFDocumentGetTrimBox(
    document : CGPDFDocumentRef,
    page : Int) : CGRect;

external CGPDFDocumentGetArtBox(
    document : CGPDFDocumentRef,
    page : Int) : CGRect;

external CGPDFDocumentGetRotationAngle(
    document : CGPDFDocumentRef,
    page : Int) : Int;

alias CGFunctionRef = OpaquePointer;

alias CGFunctionEvaluateCallback = CCodePointer[[RawPointer,Pointer[Float],Pointer[Float]],[]];

alias CGFunctionReleaseInfoCallback = CCodePointer[[RawPointer],[]];

record Struct_CGFunctionCallbacks (
    version : UInt,
    evaluate : CGFunctionEvaluateCallback,
    releaseInfo : CGFunctionReleaseInfoCallback,
);

alias CGFunctionCallbacks = Struct_CGFunctionCallbacks;

external CGFunctionGetTypeID() : CULong;

external CGFunctionCreate(
    info : RawPointer,
    domainDimension : UInt,
    domain : Pointer[Float],
    rangeDimension : UInt,
    range : Pointer[Float],
    callbacks : Pointer[CGFunctionCallbacks]) : CGFunctionRef;

external CGFunctionRetain(
    function : CGFunctionRef) : CGFunctionRef;

external CGFunctionRelease(
    function : CGFunctionRef);

alias CGShadingRef = OpaquePointer;

external CGShadingGetTypeID() : CULong;

external CGShadingCreateAxial(
    space : CGColorSpaceRef,
    start : CGPoint,
    end : CGPoint,
    function : CGFunctionRef,
    extendStart : Bool,
    extendEnd : Bool) : CGShadingRef;

external CGShadingCreateRadial(
    space : CGColorSpaceRef,
    start : CGPoint,
    startRadius : Float,
    end : CGPoint,
    endRadius : Float,
    function : CGFunctionRef,
    extendStart : Bool,
    extendEnd : Bool) : CGShadingRef;

external CGShadingRetain(
    shading : CGShadingRef) : CGShadingRef;

external CGShadingRelease(
    shading : CGShadingRef);

alias kCGLineJoinMiter = 0;
alias kCGLineJoinRound = 1;
alias kCGLineJoinBevel = 2;

alias CGLineJoin = Int;

alias kCGLineCapButt = 0;
alias kCGLineCapRound = 1;
alias kCGLineCapSquare = 2;

alias CGLineCap = Int;

alias kCGPathFill = 0;
alias kCGPathEOFill = 1;
alias kCGPathStroke = 2;
alias kCGPathFillStroke = 3;
alias kCGPathEOFillStroke = 4;

alias CGPathDrawingMode = Int;

alias kCGTextFill = 0;
alias kCGTextStroke = 1;
alias kCGTextFillStroke = 2;
alias kCGTextInvisible = 3;
alias kCGTextFillClip = 4;
alias kCGTextStrokeClip = 5;
alias kCGTextFillStrokeClip = 6;
alias kCGTextClip = 7;

alias CGTextDrawingMode = Int;

alias kCGEncodingFontSpecific = 0;
alias kCGEncodingMacRoman = 1;

alias CGTextEncoding = Int;

alias kCGInterpolationDefault = 0;
alias kCGInterpolationNone = 1;
alias kCGInterpolationLow = 2;
alias kCGInterpolationMedium = 4;
alias kCGInterpolationHigh = 3;

alias CGInterpolationQuality = Int;

alias kCGBlendModeNormal = 0;
alias kCGBlendModeMultiply = 1;
alias kCGBlendModeScreen = 2;
alias kCGBlendModeOverlay = 3;
alias kCGBlendModeDarken = 4;
alias kCGBlendModeLighten = 5;
alias kCGBlendModeColorDodge = 6;
alias kCGBlendModeColorBurn = 7;
alias kCGBlendModeSoftLight = 8;
alias kCGBlendModeHardLight = 9;
alias kCGBlendModeDifference = 10;
alias kCGBlendModeExclusion = 11;
alias kCGBlendModeHue = 12;
alias kCGBlendModeSaturation = 13;
alias kCGBlendModeColor = 14;
alias kCGBlendModeLuminosity = 15;
alias kCGBlendModeClear = 16;
alias kCGBlendModeCopy = 17;
alias kCGBlendModeSourceIn = 18;
alias kCGBlendModeSourceOut = 19;
alias kCGBlendModeSourceAtop = 20;
alias kCGBlendModeDestinationOver = 21;
alias kCGBlendModeDestinationIn = 22;
alias kCGBlendModeDestinationOut = 23;
alias kCGBlendModeDestinationAtop = 24;
alias kCGBlendModeXOR = 25;
alias kCGBlendModePlusDarker = 26;
alias kCGBlendModePlusLighter = 27;

alias CGBlendMode = Int;

external CGContextGetTypeID() : CULong;

external CGContextSaveGState(
    c : CGContextRef);

external CGContextRestoreGState(
    c : CGContextRef);

external CGContextScaleCTM(
    c : CGContextRef,
    sx : Float,
    sy : Float);

external CGContextTranslateCTM(
    c : CGContextRef,
    tx : Float,
    ty : Float);

external CGContextRotateCTM(
    c : CGContextRef,
    angle : Float);

external CGContextConcatCTM(
    c : CGContextRef,
    transform : CGAffineTransform);

external CGContextGetCTM(
    c : CGContextRef) : CGAffineTransform;

external CGContextSetLineWidth(
    c : CGContextRef,
    width : Float);

external CGContextSetLineCap(
    c : CGContextRef,
    cap : CGLineCap);

external CGContextSetLineJoin(
    c : CGContextRef,
    join : CGLineJoin);

external CGContextSetMiterLimit(
    c : CGContextRef,
    limit : Float);

external CGContextSetLineDash(
    c : CGContextRef,
    phase : Float,
    lengths : Pointer[Float],
    count : UInt);

external CGContextSetFlatness(
    c : CGContextRef,
    flatness : Float);

external CGContextSetAlpha(
    c : CGContextRef,
    alpha : Float);

external CGContextSetBlendMode(
    context : CGContextRef,
    mode : CGBlendMode);

external CGContextBeginPath(
    c : CGContextRef);

external CGContextMoveToPoint(
    c : CGContextRef,
    x : Float,
    y : Float);

external CGContextAddLineToPoint(
    c : CGContextRef,
    x : Float,
    y : Float);

external CGContextAddCurveToPoint(
    c : CGContextRef,
    cp1x : Float,
    cp1y : Float,
    cp2x : Float,
    cp2y : Float,
    x : Float,
    y : Float);

external CGContextAddQuadCurveToPoint(
    c : CGContextRef,
    cpx : Float,
    cpy : Float,
    x : Float,
    y : Float);

external CGContextClosePath(
    c : CGContextRef);

external CGContextAddRect(
    c : CGContextRef,
    rect : CGRect);

external CGContextAddRects(
    c : CGContextRef,
    rects : Pointer[CGRect],
    count : UInt);

external CGContextAddLines(
    c : CGContextRef,
    points : Pointer[CGPoint],
    count : UInt);

external CGContextAddEllipseInRect(
    context : CGContextRef,
    rect : CGRect);

external CGContextAddArc(
    c : CGContextRef,
    x : Float,
    y : Float,
    radius : Float,
    startAngle : Float,
    endAngle : Float,
    clockwise : Int);

external CGContextAddArcToPoint(
    c : CGContextRef,
    x1 : Float,
    y1 : Float,
    x2 : Float,
    y2 : Float,
    radius : Float);

external CGContextAddPath(
    context : CGContextRef,
    path : CGPathRef);

external CGContextReplacePathWithStrokedPath(
    c : CGContextRef);

external CGContextIsPathEmpty(
    context : CGContextRef) : Bool;

external CGContextGetPathCurrentPoint(
    context : CGContextRef) : CGPoint;

external CGContextGetPathBoundingBox(
    context : CGContextRef) : CGRect;

external CGContextCopyPath(
    context : CGContextRef) : CGPathRef;

external CGContextPathContainsPoint(
    context : CGContextRef,
    point : CGPoint,
    mode : CGPathDrawingMode) : Bool;

external CGContextDrawPath(
    c : CGContextRef,
    mode : CGPathDrawingMode);

external CGContextFillPath(
    c : CGContextRef);

external CGContextEOFillPath(
    c : CGContextRef);

external CGContextStrokePath(
    c : CGContextRef);

external CGContextFillRect(
    c : CGContextRef,
    rect : CGRect);

external CGContextFillRects(
    c : CGContextRef,
    rects : Pointer[CGRect],
    count : UInt);

external CGContextStrokeRect(
    c : CGContextRef,
    rect : CGRect);

external CGContextStrokeRectWithWidth(
    c : CGContextRef,
    rect : CGRect,
    width : Float);

external CGContextClearRect(
    c : CGContextRef,
    rect : CGRect);

external CGContextFillEllipseInRect(
    context : CGContextRef,
    rect : CGRect);

external CGContextStrokeEllipseInRect(
    context : CGContextRef,
    rect : CGRect);

external CGContextStrokeLineSegments(
    c : CGContextRef,
    points : Pointer[CGPoint],
    count : UInt);

external CGContextClip(
    c : CGContextRef);

external CGContextEOClip(
    c : CGContextRef);

external CGContextClipToMask(
    c : CGContextRef,
    rect : CGRect,
    mask : CGImageRef);

external CGContextGetClipBoundingBox(
    c : CGContextRef) : CGRect;

external CGContextClipToRect(
    c : CGContextRef,
    rect : CGRect);

external CGContextClipToRects(
    c : CGContextRef,
    rects : Pointer[CGRect],
    count : UInt);

external CGContextSetFillColorWithColor(
    c : CGContextRef,
    color : CGColorRef);

external CGContextSetStrokeColorWithColor(
    c : CGContextRef,
    color : CGColorRef);

external CGContextSetFillColorSpace(
    context : CGContextRef,
    space : CGColorSpaceRef);

external CGContextSetStrokeColorSpace(
    context : CGContextRef,
    space : CGColorSpaceRef);

external CGContextSetFillColor(
    context : CGContextRef,
    components : Pointer[Float]);

external CGContextSetStrokeColor(
    context : CGContextRef,
    components : Pointer[Float]);

external CGContextSetFillPattern(
    context : CGContextRef,
    pattern : CGPatternRef,
    components : Pointer[Float]);

external CGContextSetStrokePattern(
    context : CGContextRef,
    pattern : CGPatternRef,
    components : Pointer[Float]);

external CGContextSetPatternPhase(
    context : CGContextRef,
    phase : CGSize);

external CGContextSetGrayFillColor(
    context : CGContextRef,
    gray : Float,
    alpha : Float);

external CGContextSetGrayStrokeColor(
    context : CGContextRef,
    gray : Float,
    alpha : Float);

external CGContextSetRGBFillColor(
    context : CGContextRef,
    red : Float,
    green : Float,
    blue : Float,
    alpha : Float);

external CGContextSetRGBStrokeColor(
    context : CGContextRef,
    red : Float,
    green : Float,
    blue : Float,
    alpha : Float);

external CGContextSetCMYKFillColor(
    context : CGContextRef,
    cyan : Float,
    magenta : Float,
    yellow : Float,
    black : Float,
    alpha : Float);

external CGContextSetCMYKStrokeColor(
    context : CGContextRef,
    cyan : Float,
    magenta : Float,
    yellow : Float,
    black : Float,
    alpha : Float);

external CGContextSetRenderingIntent(
    context : CGContextRef,
    intent : CGColorRenderingIntent);

external CGContextDrawImage(
    c : CGContextRef,
    rect : CGRect,
    image : CGImageRef);

external CGContextDrawTiledImage(
    c : CGContextRef,
    rect : CGRect,
    image : CGImageRef);

external CGContextGetInterpolationQuality(
    context : CGContextRef) : CGInterpolationQuality;

external CGContextSetInterpolationQuality(
    context : CGContextRef,
    quality : CGInterpolationQuality);

external CGContextSetShadowWithColor(
    context : CGContextRef,
    offset : CGSize,
    blur : Float,
    color : CGColorRef);

external CGContextSetShadow(
    context : CGContextRef,
    offset : CGSize,
    blur : Float);

external CGContextDrawLinearGradient(
    context : CGContextRef,
    gradient : CGGradientRef,
    startPoint : CGPoint,
    endPoint : CGPoint,
    options : UInt);

external CGContextDrawRadialGradient(
    context : CGContextRef,
    gradient : CGGradientRef,
    startCenter : CGPoint,
    startRadius : Float,
    endCenter : CGPoint,
    endRadius : Float,
    options : UInt);

external CGContextDrawShading(
    context : CGContextRef,
    shading : CGShadingRef);

external CGContextSetCharacterSpacing(
    context : CGContextRef,
    spacing : Float);

external CGContextSetTextPosition(
    c : CGContextRef,
    x : Float,
    y : Float);

external CGContextGetTextPosition(
    context : CGContextRef) : CGPoint;

external CGContextSetTextMatrix(
    c : CGContextRef,
    t : CGAffineTransform);

external CGContextGetTextMatrix(
    c : CGContextRef) : CGAffineTransform;

external CGContextSetTextDrawingMode(
    c : CGContextRef,
    mode : CGTextDrawingMode);

external CGContextSetFont(
    c : CGContextRef,
    font : CGFontRef);

external CGContextSetFontSize(
    c : CGContextRef,
    size : Float);

external CGContextSelectFont(
    c : CGContextRef,
    name : Pointer[CChar],
    size : Float,
    textEncoding : CGTextEncoding);

external CGContextShowGlyphsAtPositions(
    context : CGContextRef,
    glyphs : Pointer[UShort],
    positions : Pointer[CGPoint],
    count : UInt);

external CGContextShowText(
    c : CGContextRef,
    string : Pointer[CChar],
    length : UInt);

external CGContextShowTextAtPoint(
    c : CGContextRef,
    x : Float,
    y : Float,
    string : Pointer[CChar],
    length : UInt);

external CGContextShowGlyphs(
    c : CGContextRef,
    g : Pointer[UShort],
    count : UInt);

external CGContextShowGlyphsAtPoint(
    context : CGContextRef,
    x : Float,
    y : Float,
    glyphs : Pointer[UShort],
    count : UInt);

external CGContextShowGlyphsWithAdvances(
    c : CGContextRef,
    glyphs : Pointer[UShort],
    advances : Pointer[CGSize],
    count : UInt);

external CGContextDrawPDFPage(
    c : CGContextRef,
    page : CGPDFPageRef);

external CGContextDrawPDFDocument(
    c : CGContextRef,
    rect : CGRect,
    document : CGPDFDocumentRef,
    page : Int);

external CGContextBeginPage(
    c : CGContextRef,
    mediaBox : Pointer[CGRect]);

external CGContextEndPage(
    c : CGContextRef);

external CGContextRetain(
    c : CGContextRef) : CGContextRef;

external CGContextRelease(
    c : CGContextRef);

external CGContextFlush(
    c : CGContextRef);

external CGContextSynchronize(
    c : CGContextRef);

external CGContextSetShouldAntialias(
    context : CGContextRef,
    shouldAntialias : Bool);

external CGContextSetAllowsAntialiasing(
    context : CGContextRef,
    allowsAntialiasing : Bool);

external CGContextSetShouldSmoothFonts(
    context : CGContextRef,
    shouldSmoothFonts : Bool);

external CGContextSetAllowsFontSmoothing(
    context : CGContextRef,
    allowsFontSmoothing : Bool);

external CGContextSetShouldSubpixelPositionFonts(
    context : CGContextRef,
    shouldSubpixelPositionFonts : Bool);

external CGContextSetAllowsFontSubpixelPositioning(
    context : CGContextRef,
    allowsFontSubpixelPositioning : Bool);

external CGContextSetShouldSubpixelQuantizeFonts(
    context : CGContextRef,
    shouldSubpixelQuantizeFonts : Bool);

external CGContextSetAllowsFontSubpixelQuantization(
    context : CGContextRef,
    allowsFontSubpixelQuantization : Bool);

external CGContextBeginTransparencyLayer(
    context : CGContextRef,
    auxiliaryInfo : CFDictionaryRef);

external CGContextBeginTransparencyLayerWithRect(
    context : CGContextRef,
    rect : CGRect,
    auxiliaryInfo : CFDictionaryRef);

external CGContextEndTransparencyLayer(
    context : CGContextRef);

external CGContextGetUserSpaceToDeviceSpaceTransform(
    context : CGContextRef) : CGAffineTransform;

external CGContextConvertPointToDeviceSpace(
    context : CGContextRef,
    point : CGPoint) : CGPoint;

external CGContextConvertPointToUserSpace(
    context : CGContextRef,
    point : CGPoint) : CGPoint;

external CGContextConvertSizeToDeviceSpace(
    context : CGContextRef,
    size : CGSize) : CGSize;

external CGContextConvertSizeToUserSpace(
    context : CGContextRef,
    size : CGSize) : CGSize;

external CGContextConvertRectToDeviceSpace(
    context : CGContextRef,
    rect : CGRect) : CGRect;

external CGContextConvertRectToUserSpace(
    context : CGContextRef,
    rect : CGRect) : CGRect;

alias CGBitmapContextReleaseDataCallback = CCodePointer[[RawPointer,RawPointer],[]];

external CGBitmapContextCreateWithData(
    data : RawPointer,
    width : UInt,
    height : UInt,
    bitsPerComponent : UInt,
    bytesPerRow : UInt,
    space : CGColorSpaceRef,
    bitmapInfo : UInt,
    releaseCallback : CGBitmapContextReleaseDataCallback,
    releaseInfo : RawPointer) : CGContextRef;

external CGBitmapContextCreate(
    data : RawPointer,
    width : UInt,
    height : UInt,
    bitsPerComponent : UInt,
    bytesPerRow : UInt,
    space : CGColorSpaceRef,
    bitmapInfo : UInt) : CGContextRef;

external CGBitmapContextGetData(
    context : CGContextRef) : RawPointer;

external CGBitmapContextGetWidth(
    context : CGContextRef) : UInt;

external CGBitmapContextGetHeight(
    context : CGContextRef) : UInt;

external CGBitmapContextGetBitsPerComponent(
    context : CGContextRef) : UInt;

external CGBitmapContextGetBitsPerPixel(
    context : CGContextRef) : UInt;

external CGBitmapContextGetBytesPerRow(
    context : CGContextRef) : UInt;

external CGBitmapContextGetColorSpace(
    context : CGContextRef) : CGColorSpaceRef;

external CGBitmapContextGetAlphaInfo(
    context : CGContextRef) : CGImageAlphaInfo;

external CGBitmapContextGetBitmapInfo(
    context : CGContextRef) : UInt;

external CGBitmapContextCreateImage(
    context : CGContextRef) : CGImageRef;

alias CGDataConsumerRef = OpaquePointer;

alias CGDataConsumerPutBytesCallback = CCodePointer[[RawPointer,RawPointer,UInt],[UInt]];

alias CGDataConsumerReleaseInfoCallback = CCodePointer[[RawPointer],[]];

record Struct_CGDataConsumerCallbacks (
    putBytes : CGDataConsumerPutBytesCallback,
    releaseConsumer : CGDataConsumerReleaseInfoCallback,
);

alias CGDataConsumerCallbacks = Struct_CGDataConsumerCallbacks;

external CGDataConsumerGetTypeID() : CULong;

external CGDataConsumerCreate(
    info : RawPointer,
    callbacks : Pointer[CGDataConsumerCallbacks]) : CGDataConsumerRef;

external CGDataConsumerCreateWithURL(
    url : CFURLRef) : CGDataConsumerRef;

external CGDataConsumerCreateWithCFData(
    data : CFMutableDataRef) : CGDataConsumerRef;

external CGDataConsumerRetain(
    consumer : CGDataConsumerRef) : CGDataConsumerRef;

external CGDataConsumerRelease(
    consumer : CGDataConsumerRef);

alias kCGErrorSuccess = 0;
alias kCGErrorFailure = 1000;
alias kCGErrorIllegalArgument = 1001;
alias kCGErrorInvalidConnection = 1002;
alias kCGErrorInvalidContext = 1003;
alias kCGErrorCannotComplete = 1004;
alias kCGErrorNotImplemented = 1006;
alias kCGErrorRangeCheck = 1007;
alias kCGErrorTypeCheck = 1008;
alias kCGErrorInvalidOperation = 1010;
alias kCGErrorNoneAvailable = 1011;
alias kCGErrorNameTooLong = 1005;
alias kCGErrorNoCurrentPoint = 1009;
alias kCGErrorApplicationRequiresNewerSystem = 1015;
alias kCGErrorApplicationNotPermittedToExecute = 1016;
alias kCGErrorApplicationIncorrectExecutableFormatFound = 1023;
alias kCGErrorApplicationIsLaunching = 1024;
alias kCGErrorApplicationAlreadyRunning = 1025;
alias kCGErrorApplicationCanOnlyBeRunInOneSessionAtATime = 1026;
alias kCGErrorClassicApplicationsMustBeLaunchedByClassic = 1027;
alias kCGErrorForkFailed = 1028;
alias kCGErrorRetryRegistration = 1029;
alias kCGErrorFirst = 1000;
alias kCGErrorLast = 1029;

alias CGError = Int;

alias CGLayerRef = OpaquePointer;

external CGLayerCreateWithContext(
    context : CGContextRef,
    size : CGSize,
    auxiliaryInfo : CFDictionaryRef) : CGLayerRef;

external CGLayerRetain(
    layer : CGLayerRef) : CGLayerRef;

external CGLayerRelease(
    layer : CGLayerRef);

external CGLayerGetSize(
    layer : CGLayerRef) : CGSize;

external CGLayerGetContext(
    layer : CGLayerRef) : CGContextRef;

external CGContextDrawLayerInRect(
    context : CGContextRef,
    rect : CGRect,
    layer : CGLayerRef);

external CGContextDrawLayerAtPoint(
    context : CGContextRef,
    point : CGPoint,
    layer : CGLayerRef);

external CGLayerGetTypeID() : CULong;

alias CGPDFContentStreamRef = OpaquePointer;

external CGPDFContentStreamCreateWithPage(
    page : CGPDFPageRef) : CGPDFContentStreamRef;

external CGPDFContentStreamCreateWithStream(
    stream : CGPDFStreamRef,
    streamResources : CGPDFDictionaryRef,
    parent : CGPDFContentStreamRef) : CGPDFContentStreamRef;

external CGPDFContentStreamRetain(
    cs : CGPDFContentStreamRef) : CGPDFContentStreamRef;

external CGPDFContentStreamRelease(
    cs : CGPDFContentStreamRef);

external CGPDFContentStreamGetStreams(
    cs : CGPDFContentStreamRef) : CFArrayRef;

external CGPDFContentStreamGetResource(
    cs : CGPDFContentStreamRef,
    category : Pointer[CChar],
    name : Pointer[CChar]) : CGPDFObjectRef;

external CGPDFContextCreate(
    consumer : CGDataConsumerRef,
    mediaBox : Pointer[CGRect],
    auxiliaryInfo : CFDictionaryRef) : CGContextRef;

external CGPDFContextCreateWithURL(
    url : CFURLRef,
    mediaBox : Pointer[CGRect],
    auxiliaryInfo : CFDictionaryRef) : CGContextRef;

external CGPDFContextClose(
    context : CGContextRef);

external CGPDFContextBeginPage(
    context : CGContextRef,
    pageInfo : CFDictionaryRef);

external CGPDFContextEndPage(
    context : CGContextRef);

external CGPDFContextAddDocumentMetadata(
    context : CGContextRef,
    metadata : CFDataRef);

external CGPDFContextSetURLForRect(
    context : CGContextRef,
    url : CFURLRef,
    rect : CGRect);

external CGPDFContextAddDestinationAtPoint(
    context : CGContextRef,
    name : CFStringRef,
    point : CGPoint);

external CGPDFContextSetDestinationForRect(
    context : CGContextRef,
    name : CFStringRef,
    rect : CGRect);

external kCGPDFContextMediaBox : CFStringRef;

external kCGPDFContextCropBox : CFStringRef;

external kCGPDFContextBleedBox : CFStringRef;

external kCGPDFContextTrimBox : CFStringRef;

external kCGPDFContextArtBox : CFStringRef;

external kCGPDFContextTitle : CFStringRef;

external kCGPDFContextAuthor : CFStringRef;

external kCGPDFContextSubject : CFStringRef;

external kCGPDFContextKeywords : CFStringRef;

external kCGPDFContextCreator : CFStringRef;

external kCGPDFContextOwnerPassword : CFStringRef;

external kCGPDFContextUserPassword : CFStringRef;

external kCGPDFContextEncryptionKeyLength : CFStringRef;

external kCGPDFContextAllowsPrinting : CFStringRef;

external kCGPDFContextAllowsCopying : CFStringRef;

external kCGPDFContextOutputIntent : CFStringRef;

external kCGPDFXOutputIntentSubtype : CFStringRef;

external kCGPDFXOutputConditionIdentifier : CFStringRef;

external kCGPDFXOutputCondition : CFStringRef;

external kCGPDFXRegistryName : CFStringRef;

external kCGPDFXInfo : CFStringRef;

external kCGPDFXDestinationOutputProfile : CFStringRef;

external kCGPDFContextOutputIntents : CFStringRef;

alias CGPDFOperatorTableRef = OpaquePointer;

alias CGPDFScannerRef = OpaquePointer;

external CGPDFScannerCreate(
    cs : CGPDFContentStreamRef,
    table : CGPDFOperatorTableRef,
    info : RawPointer) : CGPDFScannerRef;

external CGPDFScannerRetain(
    scanner : CGPDFScannerRef) : CGPDFScannerRef;

external CGPDFScannerRelease(
    scanner : CGPDFScannerRef);

external CGPDFScannerScan(
    scanner : CGPDFScannerRef) : Bool;

external CGPDFScannerGetContentStream(
    scanner : CGPDFScannerRef) : CGPDFContentStreamRef;

external CGPDFScannerPopObject(
    scanner : CGPDFScannerRef,
    value : Pointer[CGPDFObjectRef]) : Bool;

external CGPDFScannerPopBoolean(
    scanner : CGPDFScannerRef,
    value : Pointer[CUChar]) : Bool;

external CGPDFScannerPopInteger(
    scanner : CGPDFScannerRef,
    value : Pointer[CLong]) : Bool;

external CGPDFScannerPopNumber(
    scanner : CGPDFScannerRef,
    value : Pointer[Float]) : Bool;

external CGPDFScannerPopName(
    scanner : CGPDFScannerRef,
    value : Pointer[Pointer[CChar]]) : Bool;

external CGPDFScannerPopString(
    scanner : CGPDFScannerRef,
    value : Pointer[CGPDFStringRef]) : Bool;

external CGPDFScannerPopArray(
    scanner : CGPDFScannerRef,
    value : Pointer[CGPDFArrayRef]) : Bool;

external CGPDFScannerPopDictionary(
    scanner : CGPDFScannerRef,
    value : Pointer[CGPDFDictionaryRef]) : Bool;

external CGPDFScannerPopStream(
    scanner : CGPDFScannerRef,
    value : Pointer[CGPDFStreamRef]) : Bool;

alias CGPDFOperatorCallback = CCodePointer[[OpaquePointer,RawPointer],[]];

external CGPDFOperatorTableCreate() : CGPDFOperatorTableRef;

external CGPDFOperatorTableRetain(
    table : CGPDFOperatorTableRef) : CGPDFOperatorTableRef;

external CGPDFOperatorTableRelease(
    table : CGPDFOperatorTableRef);

external CGPDFOperatorTableSetCallback(
    table : CGPDFOperatorTableRef,
    name : Pointer[CChar],
    callback : CGPDFOperatorCallback);

external kCTFontSymbolicTrait : CFStringRef;

external kCTFontWeightTrait : CFStringRef;

external kCTFontWidthTrait : CFStringRef;

external kCTFontSlantTrait : CFStringRef;

alias kCTFontClassMaskShift = 28;

alias kCTFontItalicTrait = 1;
alias kCTFontBoldTrait = 2;
alias kCTFontExpandedTrait = 32;
alias kCTFontCondensedTrait = 64;
alias kCTFontMonoSpaceTrait = 1024;
alias kCTFontVerticalTrait = 2048;
alias kCTFontUIOptimizedTrait = 4096;
alias kCTFontColorGlyphsTrait = 8192;
alias kCTFontClassMaskTrait = 4026531840;

alias CTFontSymbolicTraits = UInt;

alias kCTFontUnknownClass = 0;
alias kCTFontOldStyleSerifsClass = 268435456;
alias kCTFontTransitionalSerifsClass = 536870912;
alias kCTFontModernSerifsClass = 805306368;
alias kCTFontClarendonSerifsClass = 1073741824;
alias kCTFontSlabSerifsClass = 1342177280;
alias kCTFontFreeformSerifsClass = 1879048192;
alias kCTFontSansSerifClass = 2147483648;
alias kCTFontOrnamentalsClass = 2415919104;
alias kCTFontScriptsClass = 2684354560;
alias kCTFontSymbolicClass = 3221225472;

alias CTFontStylisticClass = UInt;

alias CTFontDescriptorRef = OpaquePointer;

external CTFontDescriptorGetTypeID() : CULong;

external kCTFontURLAttribute : CFStringRef;

external kCTFontNameAttribute : CFStringRef;

external kCTFontDisplayNameAttribute : CFStringRef;

external kCTFontFamilyNameAttribute : CFStringRef;

external kCTFontStyleNameAttribute : CFStringRef;

external kCTFontTraitsAttribute : CFStringRef;

external kCTFontVariationAttribute : CFStringRef;

external kCTFontSizeAttribute : CFStringRef;

external kCTFontMatrixAttribute : CFStringRef;

external kCTFontCascadeListAttribute : CFStringRef;

external kCTFontCharacterSetAttribute : CFStringRef;

external kCTFontLanguagesAttribute : CFStringRef;

external kCTFontBaselineAdjustAttribute : CFStringRef;

external kCTFontMacintoshEncodingsAttribute : CFStringRef;

external kCTFontFeaturesAttribute : CFStringRef;

external kCTFontFeatureSettingsAttribute : CFStringRef;

external kCTFontFixedAdvanceAttribute : CFStringRef;

external kCTFontOrientationAttribute : CFStringRef;

alias kCTFontDefaultOrientation = 0;
alias kCTFontHorizontalOrientation = 1;
alias kCTFontVerticalOrientation = 2;

alias CTFontOrientation = UInt;

external kCTFontFormatAttribute : CFStringRef;

alias kCTFontFormatUnrecognized = 0;
alias kCTFontFormatOpenTypePostScript = 1;
alias kCTFontFormatOpenTypeTrueType = 2;
alias kCTFontFormatTrueType = 3;
alias kCTFontFormatPostScript = 4;
alias kCTFontFormatBitmap = 5;

alias CTFontFormat = UInt;

external kCTFontRegistrationScopeAttribute : CFStringRef;

external kCTFontPriorityAttribute : CFStringRef;

alias kCTFontPrioritySystem = 10000;
alias kCTFontPriorityNetwork = 20000;
alias kCTFontPriorityComputer = 30000;
alias kCTFontPriorityUser = 40000;
alias kCTFontPriorityDynamic = 50000;
alias kCTFontPriorityProcess = 60000;

alias CTFontPriority = UInt;

external kCTFontEnabledAttribute : CFStringRef;

external CTFontDescriptorCreateWithNameAndSize(
    name : CFStringRef,
    size : Float) : CTFontDescriptorRef;

external CTFontDescriptorCreateWithAttributes(
    attributes : CFDictionaryRef) : CTFontDescriptorRef;

external CTFontDescriptorCreateCopyWithAttributes(
    original : CTFontDescriptorRef,
    attributes : CFDictionaryRef) : CTFontDescriptorRef;

external CTFontDescriptorCreateCopyWithVariation(
    original : CTFontDescriptorRef,
    variationIdentifier : CFNumberRef,
    variationValue : Float) : CTFontDescriptorRef;

external CTFontDescriptorCreateCopyWithFeature(
    original : CTFontDescriptorRef,
    featureTypeIdentifier : CFNumberRef,
    featureSelectorIdentifier : CFNumberRef) : CTFontDescriptorRef;

external CTFontDescriptorCreateMatchingFontDescriptors(
    descriptor : CTFontDescriptorRef,
    mandatoryAttributes : CFSetRef) : CFArrayRef;

external CTFontDescriptorCreateMatchingFontDescriptor(
    descriptor : CTFontDescriptorRef,
    mandatoryAttributes : CFSetRef) : CTFontDescriptorRef;

external CTFontDescriptorCopyAttributes(
    descriptor : CTFontDescriptorRef) : CFDictionaryRef;

external CTFontDescriptorCopyAttribute(
    descriptor : CTFontDescriptorRef,
    attribute : CFStringRef) : CFTypeRef;

external CTFontDescriptorCopyLocalizedAttribute(
    descriptor : CTFontDescriptorRef,
    attribute : CFStringRef,
    language : Pointer[CFStringRef]) : CFTypeRef;

alias CTFontRef = OpaquePointer;

external CTFontGetTypeID() : CULong;

external kCTFontCopyrightNameKey : CFStringRef;

external kCTFontFamilyNameKey : CFStringRef;

external kCTFontSubFamilyNameKey : CFStringRef;

external kCTFontStyleNameKey : CFStringRef;

external kCTFontUniqueNameKey : CFStringRef;

external kCTFontFullNameKey : CFStringRef;

external kCTFontVersionNameKey : CFStringRef;

external kCTFontPostScriptNameKey : CFStringRef;

external kCTFontTrademarkNameKey : CFStringRef;

external kCTFontManufacturerNameKey : CFStringRef;

external kCTFontDesignerNameKey : CFStringRef;

external kCTFontDescriptionNameKey : CFStringRef;

external kCTFontVendorURLNameKey : CFStringRef;

external kCTFontDesignerURLNameKey : CFStringRef;

external kCTFontLicenseNameKey : CFStringRef;

external kCTFontLicenseURLNameKey : CFStringRef;

external kCTFontSampleTextNameKey : CFStringRef;

external kCTFontPostScriptCIDNameKey : CFStringRef;

external CTFontCreateWithName(
    name : CFStringRef,
    size : Float,
    matrix : Pointer[CGAffineTransform]) : CTFontRef;

external CTFontCreateWithFontDescriptor(
    descriptor : CTFontDescriptorRef,
    size : Float,
    matrix : Pointer[CGAffineTransform]) : CTFontRef;

alias kCTFontOptionsDefault = 0;
alias kCTFontOptionsPreventAutoActivation = 1;
alias kCTFontOptionsPreferSystemFont = 4;

alias CTFontOptions = CULong;

external CTFontCreateWithNameAndOptions(
    name : CFStringRef,
    size : Float,
    matrix : Pointer[CGAffineTransform],
    options : CULong) : CTFontRef;

external CTFontCreateWithFontDescriptorAndOptions(
    descriptor : CTFontDescriptorRef,
    size : Float,
    matrix : Pointer[CGAffineTransform],
    options : CULong) : CTFontRef;

alias kCTFontNoFontType = 4294967295;
alias kCTFontUserFontType = 0;
alias kCTFontUserFixedPitchFontType = 1;
alias kCTFontSystemFontType = 2;
alias kCTFontEmphasizedSystemFontType = 3;
alias kCTFontSmallSystemFontType = 4;
alias kCTFontSmallEmphasizedSystemFontType = 5;
alias kCTFontMiniSystemFontType = 6;
alias kCTFontMiniEmphasizedSystemFontType = 7;
alias kCTFontViewsFontType = 8;
alias kCTFontApplicationFontType = 9;
alias kCTFontLabelFontType = 10;
alias kCTFontMenuTitleFontType = 11;
alias kCTFontMenuItemFontType = 12;
alias kCTFontMenuItemMarkFontType = 13;
alias kCTFontMenuItemCmdKeyFontType = 14;
alias kCTFontWindowTitleFontType = 15;
alias kCTFontPushButtonFontType = 16;
alias kCTFontUtilityWindowTitleFontType = 17;
alias kCTFontAlertHeaderFontType = 18;
alias kCTFontSystemDetailFontType = 19;
alias kCTFontEmphasizedSystemDetailFontType = 20;
alias kCTFontToolbarFontType = 21;
alias kCTFontSmallToolbarFontType = 22;
alias kCTFontMessageFontType = 23;
alias kCTFontPaletteFontType = 24;
alias kCTFontToolTipFontType = 25;
alias kCTFontControlContentFontType = 26;

alias CTFontUIFontType = UInt;

external CTFontCreateUIFontForLanguage(
    uiType : UInt,
    size : Float,
    language : CFStringRef) : CTFontRef;

external CTFontCreateCopyWithAttributes(
    font : CTFontRef,
    size : Float,
    matrix : Pointer[CGAffineTransform],
    attributes : CTFontDescriptorRef) : CTFontRef;

external CTFontCreateCopyWithSymbolicTraits(
    font : CTFontRef,
    size : Float,
    matrix : Pointer[CGAffineTransform],
    symTraitValue : UInt,
    symTraitMask : UInt) : CTFontRef;

external CTFontCreateCopyWithFamily(
    font : CTFontRef,
    size : Float,
    matrix : Pointer[CGAffineTransform],
    family : CFStringRef) : CTFontRef;

external CTFontCreateForString(
    currentFont : CTFontRef,
    string : CFStringRef,
    range : CFRange) : CTFontRef;

external CTFontCopyFontDescriptor(
    font : CTFontRef) : CTFontDescriptorRef;

external CTFontCopyAttribute(
    font : CTFontRef,
    attribute : CFStringRef) : CFTypeRef;

external CTFontGetSize(
    font : CTFontRef) : Float;

external CTFontGetMatrix(
    font : CTFontRef) : CGAffineTransform;

external CTFontGetSymbolicTraits(
    font : CTFontRef) : UInt;

external CTFontCopyTraits(
    font : CTFontRef) : CFDictionaryRef;

external CTFontCopyPostScriptName(
    font : CTFontRef) : CFStringRef;

external CTFontCopyFamilyName(
    font : CTFontRef) : CFStringRef;

external CTFontCopyFullName(
    font : CTFontRef) : CFStringRef;

external CTFontCopyDisplayName(
    font : CTFontRef) : CFStringRef;

external CTFontCopyName(
    font : CTFontRef,
    nameKey : CFStringRef) : CFStringRef;

external CTFontCopyLocalizedName(
    font : CTFontRef,
    nameKey : CFStringRef,
    language : Pointer[CFStringRef]) : CFStringRef;

external CTFontCopyCharacterSet(
    font : CTFontRef) : CFCharacterSetRef;

external CTFontGetStringEncoding(
    font : CTFontRef) : CULong;

external CTFontCopySupportedLanguages(
    font : CTFontRef) : CFArrayRef;

external CTFontGetGlyphsForCharacters(
    font : CTFontRef,
    characters : Pointer[UShort],
    glyphs : Pointer[UShort],
    count : CLong) : Bool;

external CTFontGetAscent(
    font : CTFontRef) : Float;

external CTFontGetDescent(
    font : CTFontRef) : Float;

external CTFontGetLeading(
    font : CTFontRef) : Float;

external CTFontGetUnitsPerEm(
    font : CTFontRef) : UInt;

external CTFontGetGlyphCount(
    font : CTFontRef) : CLong;

external CTFontGetBoundingBox(
    font : CTFontRef) : CGRect;

external CTFontGetUnderlinePosition(
    font : CTFontRef) : Float;

external CTFontGetUnderlineThickness(
    font : CTFontRef) : Float;

external CTFontGetSlantAngle(
    font : CTFontRef) : Float;

external CTFontGetCapHeight(
    font : CTFontRef) : Float;

external CTFontGetXHeight(
    font : CTFontRef) : Float;

external CTFontGetGlyphWithName(
    font : CTFontRef,
    glyphName : CFStringRef) : UShort;

external CTFontGetBoundingRectsForGlyphs(
    font : CTFontRef,
    orientation : UInt,
    glyphs : Pointer[UShort],
    boundingRects : Pointer[CGRect],
    count : CLong) : CGRect;

external CTFontGetAdvancesForGlyphs(
    font : CTFontRef,
    orientation : UInt,
    glyphs : Pointer[UShort],
    advances : Pointer[CGSize],
    count : CLong) : Double;

external CTFontGetVerticalTranslationsForGlyphs(
    font : CTFontRef,
    glyphs : Pointer[UShort],
    translations : Pointer[CGSize],
    count : CLong);

external CTFontCreatePathForGlyph(
    font : CTFontRef,
    glyph : UShort,
    transform : Pointer[CGAffineTransform]) : CGPathRef;

external kCTFontVariationAxisIdentifierKey : CFStringRef;

external kCTFontVariationAxisMinimumValueKey : CFStringRef;

external kCTFontVariationAxisMaximumValueKey : CFStringRef;

external kCTFontVariationAxisDefaultValueKey : CFStringRef;

external kCTFontVariationAxisNameKey : CFStringRef;

external CTFontCopyVariationAxes(
    font : CTFontRef) : CFArrayRef;

external CTFontCopyVariation(
    font : CTFontRef) : CFDictionaryRef;

external kCTFontFeatureTypeIdentifierKey : CFStringRef;

external kCTFontFeatureTypeNameKey : CFStringRef;

external kCTFontFeatureTypeExclusiveKey : CFStringRef;

external kCTFontFeatureTypeSelectorsKey : CFStringRef;

external kCTFontFeatureSelectorIdentifierKey : CFStringRef;

external kCTFontFeatureSelectorNameKey : CFStringRef;

external kCTFontFeatureSelectorDefaultKey : CFStringRef;

external kCTFontFeatureSelectorSettingKey : CFStringRef;

external CTFontCopyFeatures(
    font : CTFontRef) : CFArrayRef;

external CTFontCopyFeatureSettings(
    font : CTFontRef) : CFArrayRef;

external CTFontCopyGraphicsFont(
    font : CTFontRef,
    attributes : Pointer[CTFontDescriptorRef]) : CGFontRef;

external CTFontCreateWithGraphicsFont(
    graphicsFont : CGFontRef,
    size : Float,
    matrix : Pointer[CGAffineTransform],
    attributes : CTFontDescriptorRef) : CTFontRef;

alias kCTFontTableBASE = 1111577413;
alias kCTFontTableCFF = 1128678944;
alias kCTFontTableDSIG = 1146308935;
alias kCTFontTableEBDT = 1161970772;
alias kCTFontTableEBLC = 1161972803;
alias kCTFontTableEBSC = 1161974595;
alias kCTFontTableGDEF = 1195656518;
alias kCTFontTableGPOS = 1196445523;
alias kCTFontTableGSUB = 1196643650;
alias kCTFontTableJSTF = 1246975046;
alias kCTFontTableLTSH = 1280594760;
alias kCTFontTableOS2 = 1330851634;
alias kCTFontTablePCLT = 1346587732;
alias kCTFontTableVDMX = 1447316824;
alias kCTFontTableVORG = 1448038983;
alias kCTFontTableZapf = 1516335206;
alias kCTFontTableAcnt = 1633906292;
alias kCTFontTableAvar = 1635148146;
alias kCTFontTableBdat = 1650745716;
alias kCTFontTableBhed = 1651008868;
alias kCTFontTableBloc = 1651273571;
alias kCTFontTableBsln = 1651731566;
alias kCTFontTableCmap = 1668112752;
alias kCTFontTableCvar = 1668702578;
alias kCTFontTableCvt = 1668707360;
alias kCTFontTableFdsc = 1717859171;
alias kCTFontTableFeat = 1717920116;
alias kCTFontTableFmtx = 1718449272;
alias kCTFontTableFpgm = 1718642541;
alias kCTFontTableFvar = 1719034226;
alias kCTFontTableGasp = 1734439792;
alias kCTFontTableGlyf = 1735162214;
alias kCTFontTableGvar = 1735811442;
alias kCTFontTableHdmx = 1751412088;
alias kCTFontTableHead = 1751474532;
alias kCTFontTableHhea = 1751672161;
alias kCTFontTableHmtx = 1752003704;
alias kCTFontTableHsty = 1752396921;
alias kCTFontTableJust = 1786082164;
alias kCTFontTableKern = 1801810542;
alias kCTFontTableLcar = 1818452338;
alias kCTFontTableLoca = 1819239265;
alias kCTFontTableMaxp = 1835104368;
alias kCTFontTableMort = 1836020340;
alias kCTFontTableMorx = 1836020344;
alias kCTFontTableName = 1851878757;
alias kCTFontTableOpbd = 1869636196;
alias kCTFontTablePost = 1886352244;
alias kCTFontTablePrep = 1886545264;
alias kCTFontTableProp = 1886547824;
alias kCTFontTableTrak = 1953653099;
alias kCTFontTableVhea = 1986553185;
alias kCTFontTableVmtx = 1986884728;

alias CTFontTableTag = UInt;

alias kCTFontTableOptionNoOptions = 0;
alias kCTFontTableOptionExcludeSynthetic = 1;

alias CTFontTableOptions = UInt;

external CTFontCopyAvailableTables(
    font : CTFontRef,
    options : UInt) : CFArrayRef;

external CTFontCopyTable(
    font : CTFontRef,
    table : UInt,
    options : UInt) : CFDataRef;

alias CTFontCollectionRef = OpaquePointer;

alias CTMutableFontCollectionRef = OpaquePointer;

external CTFontCollectionGetTypeID() : CULong;

alias CTFontCollectionSortDescriptorsCallback = CCodePointer[[OpaquePointer,OpaquePointer,RawPointer],[CLong]];

external kCTFontCollectionRemoveDuplicatesOption : CFStringRef;

external CTFontCollectionCreateFromAvailableFonts(
    options : CFDictionaryRef) : CTFontCollectionRef;

external CTFontCollectionCreateWithFontDescriptors(
    queryDescriptors : CFArrayRef,
    options : CFDictionaryRef) : CTFontCollectionRef;

external CTFontCollectionCreateCopyWithFontDescriptors(
    original : CTFontCollectionRef,
    queryDescriptors : CFArrayRef,
    options : CFDictionaryRef) : CTFontCollectionRef;

external CTFontCollectionCreateMatchingFontDescriptors(
    collection : CTFontCollectionRef) : CFArrayRef;

external CTFontCollectionCreateMatchingFontDescriptorsSortedWithCallback(
    collection : CTFontCollectionRef,
    sortCallback : CTFontCollectionSortDescriptorsCallback,
    refCon : RawPointer) : CFArrayRef;

external kCTFontManagerErrorDomain : CFStringRef;

external kCTFontManagerErrorFontURLsKey : CFStringRef;

alias kCTFontManagerErrorFileNotFound = 101;
alias kCTFontManagerErrorInsufficientPermissions = 102;
alias kCTFontManagerErrorUnrecognizedFormat = 103;
alias kCTFontManagerErrorInvalidFontData = 104;
alias kCTFontManagerErrorAlreadyRegistered = 105;

alias kCTFontManagerErrorNotRegistered = 201;
alias kCTFontManagerErrorInUse = 202;
alias kCTFontManagerErrorSystemRequired = 202;

alias CTFontManagerError = CLong;

external CTFontManagerCopyAvailablePostScriptNames() : CFArrayRef;

external CTFontManagerCopyAvailableFontFamilyNames() : CFArrayRef;

external CTFontManagerCopyAvailableFontURLs() : CFArrayRef;

external CTFontManagerCompareFontFamilyNames(
    family1 : RawPointer,
    family2 : RawPointer,
    context : RawPointer) : CLong;

external CTFontManagerCreateFontDescriptorsFromURL(
    fileURL : CFURLRef) : CFArrayRef;

alias kCTFontManagerScopeNone = 0;
alias kCTFontManagerScopeProcess = 1;
alias kCTFontManagerScopeUser = 2;
alias kCTFontManagerScopeSession = 3;

alias CTFontManagerScope = UInt;

external CTFontManagerRegisterFontsForURL(
    fontURL : CFURLRef,
    scope : UInt,
    error : Pointer[CFErrorRef]) : Bool;

external CTFontManagerUnregisterFontsForURL(
    fontURL : CFURLRef,
    scope : UInt,
    error : Pointer[CFErrorRef]) : Bool;

external CTFontManagerRegisterGraphicsFont(
    font : CGFontRef,
    error : Pointer[CFErrorRef]) : Bool;

external CTFontManagerUnregisterGraphicsFont(
    font : CGFontRef,
    error : Pointer[CFErrorRef]) : Bool;

external CTFontManagerRegisterFontsForURLs(
    fontURLs : CFArrayRef,
    scope : UInt,
    errors : Pointer[CFArrayRef]) : Bool;

external CTFontManagerUnregisterFontsForURLs(
    fontURLs : CFArrayRef,
    scope : UInt,
    errors : Pointer[CFArrayRef]) : Bool;

external CTFontManagerEnableFontDescriptors(
    descriptors : CFArrayRef,
    enable : Bool);

external CTFontManagerGetScopeForURL(
    fontURL : CFURLRef) : UInt;

external CTFontManagerIsSupportedFont(
    fontURL : CFURLRef) : Bool;

external CTFontManagerCreateFontRequestRunLoopSource(
    sourceOrder : CLong,
    createMatchesCallback : UnknownType) : CFRunLoopSourceRef;

external kCTFontManagerBundleIdentifier : CFStringRef;

alias kCTFontManagerAutoActivationDefault = 0;
alias kCTFontManagerAutoActivationDisabled = 1;
alias kCTFontManagerAutoActivationEnabled = 2;
alias kCTFontManagerAutoActivationPromptUser = 3;

alias CTFontManagerAutoActivationSetting = UInt;

external CTFontManagerSetAutoActivationSetting(
    bundleIdentifier : CFStringRef,
    setting : UInt);

external CTFontManagerGetAutoActivationSetting(
    bundleIdentifier : CFStringRef) : UInt;

external kCTFontManagerRegisteredFontsChangedNotification : CFStringRef;

alias CTFrameRef = OpaquePointer;

external CTFrameGetTypeID() : CULong;

alias kCTFrameProgressionTopToBottom = 0;
alias kCTFrameProgressionRightToLeft = 1;

alias CTFrameProgression = UInt;

external kCTFrameProgressionAttributeName : CFStringRef;

external CTFrameGetStringRange(
    frame : CTFrameRef) : CFRange;

external CTFrameGetVisibleStringRange(
    frame : CTFrameRef) : CFRange;

external CTFrameGetPath(
    frame : CTFrameRef) : CGPathRef;

external CTFrameGetFrameAttributes(
    frame : CTFrameRef) : CFDictionaryRef;

external CTFrameGetLines(
    frame : CTFrameRef) : CFArrayRef;

external CTFrameGetLineOrigins(
    frame : CTFrameRef,
    range : CFRange,
    origins : Pointer[CGPoint]);

external CTFrameDraw(
    frame : CTFrameRef,
    context : CGContextRef);

alias CTLineRef = OpaquePointer;

alias kCTLineTruncationStart = 0;
alias kCTLineTruncationEnd = 1;
alias kCTLineTruncationMiddle = 2;

alias CTLineTruncationType = UInt;

external CTLineGetTypeID() : CULong;

external CTLineCreateWithAttributedString(
    string : CFAttributedStringRef) : CTLineRef;

external CTLineCreateTruncatedLine(
    line : CTLineRef,
    width : Double,
    truncationType : UInt,
    truncationToken : CTLineRef) : CTLineRef;

external CTLineCreateJustifiedLine(
    line : CTLineRef,
    justificationFactor : Float,
    justificationWidth : Double) : CTLineRef;

external CTLineGetGlyphCount(
    line : CTLineRef) : CLong;

external CTLineGetGlyphRuns(
    line : CTLineRef) : CFArrayRef;

external CTLineGetStringRange(
    line : CTLineRef) : CFRange;

external CTLineGetPenOffsetForFlush(
    line : CTLineRef,
    flushFactor : Float,
    flushWidth : Double) : Double;

external CTLineDraw(
    line : CTLineRef,
    context : CGContextRef);

external CTLineGetImageBounds(
    line : CTLineRef,
    context : CGContextRef) : CGRect;

external CTLineGetTypographicBounds(
    line : CTLineRef,
    ascent : Pointer[Float],
    descent : Pointer[Float],
    leading : Pointer[Float]) : Double;

external CTLineGetTrailingWhitespaceWidth(
    line : CTLineRef) : Double;

external CTLineGetStringIndexForPosition(
    line : CTLineRef,
    position : CGPoint) : CLong;

external CTLineGetOffsetForStringIndex(
    line : CTLineRef,
    charIndex : CLong,
    secondaryOffset : Pointer[Float]) : Float;

alias CTTypesetterRef = OpaquePointer;

external CTTypesetterGetTypeID() : CULong;

external kCTTypesetterOptionDisableBidiProcessing : CFStringRef;

external kCTTypesetterOptionForcedEmbeddingLevel : CFStringRef;

external CTTypesetterCreateWithAttributedString(
    string : CFAttributedStringRef) : CTTypesetterRef;

external CTTypesetterCreateWithAttributedStringAndOptions(
    string : CFAttributedStringRef,
    options : CFDictionaryRef) : CTTypesetterRef;

external CTTypesetterCreateLineWithOffset(
    typesetter : CTTypesetterRef,
    stringRange : CFRange,
    offset : Double) : CTLineRef;

external CTTypesetterCreateLine(
    typesetter : CTTypesetterRef,
    stringRange : CFRange) : CTLineRef;

external CTTypesetterSuggestLineBreakWithOffset(
    typesetter : CTTypesetterRef,
    startIndex : CLong,
    width : Double,
    offset : Double) : CLong;

external CTTypesetterSuggestLineBreak(
    typesetter : CTTypesetterRef,
    startIndex : CLong,
    width : Double) : CLong;

external CTTypesetterSuggestClusterBreakWithOffset(
    typesetter : CTTypesetterRef,
    startIndex : CLong,
    width : Double,
    offset : Double) : CLong;

external CTTypesetterSuggestClusterBreak(
    typesetter : CTTypesetterRef,
    startIndex : CLong,
    width : Double) : CLong;

alias CTFramesetterRef = OpaquePointer;

external CTFramesetterGetTypeID() : CULong;

external CTFramesetterCreateWithAttributedString(
    string : CFAttributedStringRef) : CTFramesetterRef;

external CTFramesetterCreateFrame(
    framesetter : CTFramesetterRef,
    stringRange : CFRange,
    path : CGPathRef,
    frameAttributes : CFDictionaryRef) : CTFrameRef;

external CTFramesetterGetTypesetter(
    framesetter : CTFramesetterRef) : CTTypesetterRef;

external CTFramesetterSuggestFrameSizeWithConstraints(
    framesetter : CTFramesetterRef,
    stringRange : CFRange,
    frameAttributes : CFDictionaryRef,
    constraints : CGSize,
    fitRange : Pointer[CFRange]) : CGSize;

alias CTGlyphInfoRef = OpaquePointer;

external CTGlyphInfoGetTypeID() : CULong;

alias kCTIdentityMappingCharacterCollection = 0;
alias kCTAdobeCNS1CharacterCollection = 1;
alias kCTAdobeGB1CharacterCollection = 2;
alias kCTAdobeJapan1CharacterCollection = 3;
alias kCTAdobeJapan2CharacterCollection = 4;
alias kCTAdobeKorea1CharacterCollection = 5;

alias CTCharacterCollection = UShort;

external CTGlyphInfoCreateWithGlyphName(
    glyphName : CFStringRef,
    font : CTFontRef,
    baseString : CFStringRef) : CTGlyphInfoRef;

external CTGlyphInfoCreateWithGlyph(
    glyph : UShort,
    font : CTFontRef,
    baseString : CFStringRef) : CTGlyphInfoRef;

external CTGlyphInfoCreateWithCharacterIdentifier(
    cid : UShort,
    collection : UShort,
    baseString : CFStringRef) : CTGlyphInfoRef;

external CTGlyphInfoGetGlyphName(
    glyphInfo : CTGlyphInfoRef) : CFStringRef;

external CTGlyphInfoGetCharacterIdentifier(
    glyphInfo : CTGlyphInfoRef) : UShort;

external CTGlyphInfoGetCharacterCollection(
    glyphInfo : CTGlyphInfoRef) : UShort;

alias CTParagraphStyleRef = OpaquePointer;

external CTParagraphStyleGetTypeID() : CULong;

alias kCTLeftTextAlignment = 0;
alias kCTRightTextAlignment = 1;
alias kCTCenterTextAlignment = 2;
alias kCTJustifiedTextAlignment = 3;
alias kCTNaturalTextAlignment = 4;

alias CTTextAlignment = CUChar;

alias kCTLineBreakByWordWrapping = 0;
alias kCTLineBreakByCharWrapping = 1;
alias kCTLineBreakByClipping = 2;
alias kCTLineBreakByTruncatingHead = 3;
alias kCTLineBreakByTruncatingTail = 4;
alias kCTLineBreakByTruncatingMiddle = 5;

alias CTLineBreakMode = CUChar;

alias kCTWritingDirectionNatural = 4294967295;
alias kCTWritingDirectionLeftToRight = 0;
alias kCTWritingDirectionRightToLeft = 1;

alias CTWritingDirection = CChar;

alias kCTParagraphStyleSpecifierAlignment = 0;
alias kCTParagraphStyleSpecifierFirstLineHeadIndent = 1;
alias kCTParagraphStyleSpecifierHeadIndent = 2;
alias kCTParagraphStyleSpecifierTailIndent = 3;
alias kCTParagraphStyleSpecifierTabStops = 4;
alias kCTParagraphStyleSpecifierDefaultTabInterval = 5;
alias kCTParagraphStyleSpecifierLineBreakMode = 6;
alias kCTParagraphStyleSpecifierLineHeightMultiple = 7;
alias kCTParagraphStyleSpecifierMaximumLineHeight = 8;
alias kCTParagraphStyleSpecifierMinimumLineHeight = 9;
alias kCTParagraphStyleSpecifierLineSpacing = 10;
alias kCTParagraphStyleSpecifierParagraphSpacing = 11;
alias kCTParagraphStyleSpecifierParagraphSpacingBefore = 12;
alias kCTParagraphStyleSpecifierBaseWritingDirection = 13;
alias kCTParagraphStyleSpecifierCount = 14;

alias CTParagraphStyleSpecifier = UInt;

record Struct_CTParagraphStyleSetting (
    spec : UInt,
    valueSize : UInt,
    value : RawPointer,
);

alias CTParagraphStyleSetting = Struct_CTParagraphStyleSetting;

external CTParagraphStyleCreate(
    settings : Pointer[CTParagraphStyleSetting],
    settingCount : CLong) : CTParagraphStyleRef;

external CTParagraphStyleCreateCopy(
    paragraphStyle : CTParagraphStyleRef) : CTParagraphStyleRef;

external CTParagraphStyleGetValueForSpecifier(
    paragraphStyle : CTParagraphStyleRef,
    spec : UInt,
    valueBufferSize : UInt,
    valueBuffer : RawPointer) : Bool;

alias CTRunRef = OpaquePointer;

alias kCTRunStatusNoStatus = 0;
alias kCTRunStatusRightToLeft = 1;
alias kCTRunStatusNonMonotonic = 2;
alias kCTRunStatusHasNonIdentityMatrix = 4;

alias CTRunStatus = UInt;

external CTRunGetTypeID() : CULong;

external CTRunGetGlyphCount(
    run : CTRunRef) : CLong;

external CTRunGetAttributes(
    run : CTRunRef) : CFDictionaryRef;

external CTRunGetStatus(
    run : CTRunRef) : UInt;

external CTRunGetGlyphsPtr(
    run : CTRunRef) : Pointer[UShort];

external CTRunGetGlyphs(
    run : CTRunRef,
    range : CFRange,
    buffer : Pointer[UShort]);

external CTRunGetPositionsPtr(
    run : CTRunRef) : Pointer[CGPoint];

external CTRunGetPositions(
    run : CTRunRef,
    range : CFRange,
    buffer : Pointer[CGPoint]);

external CTRunGetAdvancesPtr(
    run : CTRunRef) : Pointer[CGSize];

external CTRunGetAdvances(
    run : CTRunRef,
    range : CFRange,
    buffer : Pointer[CGSize]);

external CTRunGetStringIndicesPtr(
    run : CTRunRef) : Pointer[CLong];

external CTRunGetStringIndices(
    run : CTRunRef,
    range : CFRange,
    buffer : Pointer[CLong]);

external CTRunGetStringRange(
    run : CTRunRef) : CFRange;

external CTRunGetTypographicBounds(
    run : CTRunRef,
    range : CFRange,
    ascent : Pointer[Float],
    descent : Pointer[Float],
    leading : Pointer[Float]) : Double;

external CTRunGetImageBounds(
    run : CTRunRef,
    context : CGContextRef,
    range : CFRange) : CGRect;

external CTRunGetTextMatrix(
    run : CTRunRef) : CGAffineTransform;

external CTRunDraw(
    run : CTRunRef,
    context : CGContextRef,
    range : CFRange);

external kCTFontAttributeName : CFStringRef;

external kCTForegroundColorFromContextAttributeName : CFStringRef;

external kCTKernAttributeName : CFStringRef;

external kCTLigatureAttributeName : CFStringRef;

external kCTForegroundColorAttributeName : CFStringRef;

external kCTParagraphStyleAttributeName : CFStringRef;

external kCTStrokeWidthAttributeName : CFStringRef;

external kCTStrokeColorAttributeName : CFStringRef;

external kCTUnderlineStyleAttributeName : CFStringRef;

external kCTSuperscriptAttributeName : CFStringRef;

external kCTUnderlineColorAttributeName : CFStringRef;

external kCTVerticalFormsAttributeName : CFStringRef;

external kCTGlyphInfoAttributeName : CFStringRef;

external kCTCharacterShapeAttributeName : CFStringRef;

external kCTRunDelegateAttributeName : CFStringRef;

alias kCTUnderlineStyleNone = 0;
alias kCTUnderlineStyleSingle = 1;
alias kCTUnderlineStyleThick = 2;
alias kCTUnderlineStyleDouble = 9;

alias CTUnderlineStyle = Int;

alias kCTUnderlinePatternSolid = 0;
alias kCTUnderlinePatternDot = 256;
alias kCTUnderlinePatternDash = 512;
alias kCTUnderlinePatternDashDot = 768;
alias kCTUnderlinePatternDashDotDot = 1024;

alias CTUnderlineStyleModifiers = Int;

alias CTTextTabRef = OpaquePointer;

external CTTextTabGetTypeID() : CULong;

external kCTTabColumnTerminatorsAttributeName : CFStringRef;

external CTTextTabCreate(
    alignment : CUChar,
    location : Double,
    options : CFDictionaryRef) : CTTextTabRef;

external CTTextTabGetAlignment(
    tab : CTTextTabRef) : CUChar;

external CTTextTabGetLocation(
    tab : CTTextTabRef) : Double;

external CTTextTabGetOptions(
    tab : CTTextTabRef) : CFDictionaryRef;

alias CTRunDelegateRef = OpaquePointer;

external CTRunDelegateGetTypeID() : CULong;

alias CTRunDelegateDeallocateCallback = CCodePointer[[RawPointer],[]];

alias CTRunDelegateGetAscentCallback = CCodePointer[[RawPointer],[Float]];

alias CTRunDelegateGetDescentCallback = CCodePointer[[RawPointer],[Float]];

alias CTRunDelegateGetWidthCallback = CCodePointer[[RawPointer],[Float]];

record UnnamedStruct58 (
    version : CLong,
    dealloc : CTRunDelegateDeallocateCallback,
    getAscent : CTRunDelegateGetAscentCallback,
    getDescent : CTRunDelegateGetDescentCallback,
    getWidth : CTRunDelegateGetWidthCallback,
);

alias CTRunDelegateCallbacks = UnnamedStruct58;

alias kCTRunDelegateVersion1 = 1;
alias kCTRunDelegateCurrentVersion = 1;

external CTRunDelegateCreate(
    callbacks : Pointer[CTRunDelegateCallbacks],
    refCon : RawPointer) : CTRunDelegateRef;

external CTRunDelegateGetRefCon(
    runDelegate : CTRunDelegateRef) : RawPointer;

external CTGetCoreTextVersion() : UInt;
