diff --git a/Headers/CoreGraphics/CGContext.h b/Headers/CoreGraphics/CGContext.h index 131445e..b30b382 100644 --- a/Headers/CoreGraphics/CGContext.h +++ b/Headers/CoreGraphics/CGContext.h @@ -138,6 +138,22 @@ enum { }; typedef int CGTextEncoding; +// NOTE: This `typedef enum` in opposition to defining enum constants and +// their types as integers is here to maintain compatibility with the original +// CoreGraphics API, although this is *NOT* an ideal way to define these types. +typedef enum { + kCGContextTypeUnknown, + kCGContextTypePDF, + kCGContextTypePostScript, + kCGContextTypeWindow, + kCGContextTypeBitmap, + kCGContextTypeGL, + kCGContextTypeDisplayList, + kCGContextTypeKSeparation, + kCGContextTypeIOSurface, + kCGContextTypeCount +} CGContextType; + /* Functions */ /* Managing Graphics Contexts */ @@ -562,6 +578,31 @@ CGRect CGContextConvertRectToDeviceSpace(CGContextRef ctx, CGRect rect); CGRect CGContextConvertRectToUserSpace(CGContextRef ctx, CGRect rect); +bool CGContextPathContainsPoint(CGContextRef c, + CGPoint point, CGPathDrawingMode mode); + +/* CoreGraphics Private APIs */ + +bool CGContextGetShouldSmoothFonts(CGContextRef ctx); + +bool CGContextGetShouldAntialias(CGContextRef ctx); + +CGContextType CGContextGetType(CGContextRef ctx); + +void CGContextSetCTM(CGContextRef ctx, CGAffineTransform m); + +CGAffineTransform CGContextGetBaseCTM(CGContextRef); + +void CGContextSetBaseCTM(CGContextRef, CGAffineTransform); + +CGColorSpaceRef CGContextCopyDeviceColorSpace(CGContextRef); + +void CGContextSetShouldAntialiasFonts(CGContextRef, bool shouldAntialiasFonts); + +bool CGDisplayUsesInvertedPolarity(void); + +bool CGDisplayUsesForceToGray(void); + /* Opal Extensions */ // FIXME: Move extensions to a separate header? @@ -583,9 +624,6 @@ OPGStateRef OPContextCopyGState(CGContextRef ctx); void OPContextSetGState(CGContextRef ctx, OPGStateRef gstate); -bool CGContextPathContainsPoint(CGContextRef c, - CGPoint point, CGPathDrawingMode mode); - #ifdef __cplusplus } #endif diff --git a/Headers/CoreGraphics/CGFont.h b/Headers/CoreGraphics/CGFont.h index 7824a58..7677bbb 100644 --- a/Headers/CoreGraphics/CGFont.h +++ b/Headers/CoreGraphics/CGFont.h @@ -35,6 +35,7 @@ typedef struct CGFont* CGFontRef; #endif #include +#include #include #include @@ -154,6 +155,16 @@ CGFontRef CGFontRetain(CGFontRef font); void CGFontRelease(CGFontRef font); +/* Private Functions */ + +bool CGFontGetGlyphAdvancesForStyle( + CGFontRef, + const CGAffineTransform*, + int, + const CGGlyph[], + size_t count, + CGSize advances[]); + /* Extensions */ #ifndef __MINGW__ // FIXME: proper check for fontconfig diff --git a/Headers/CoreGraphics/CGImageSource.h b/Headers/CoreGraphics/CGImageSource.h index 9a4ad24..3937a1e 100644 --- a/Headers/CoreGraphics/CGImageSource.h +++ b/Headers/CoreGraphics/CGImageSource.h @@ -50,6 +50,11 @@ const extern CFStringRef kCGImageSourceCreateThumbnailFromImageAlways; const extern CFStringRef kCGImageSourceThumbnailMaxPixelSize; const extern CFStringRef kCGImageSourceCreateThumbnailWithTransform; +const extern CFStringRef kCGImageSourceShouldPreferRGB32; +const extern CFStringRef kCGImageSourceSkipMetadata; +const extern CFStringRef kCGImageSourceSubsampleFactor; +const extern CFStringRef kCGImageSourceShouldCacheImmediately; + /* Data Types */ #ifdef INTERNAL_BUILD_OBJC @@ -139,6 +144,10 @@ void CGImageSourceUpdateDataProvider( CFTypeID CGImageSourceGetTypeID(); +/* Private APIs */ + +CFStringRef CGImageSourceGetTypeWithData(CFDataRef, CFStringRef, bool*); + #ifdef __cplusplus } #endif diff --git a/Headers/CoreText/CTFont.h b/Headers/CoreText/CTFont.h index 9725176..8d8f837 100644 --- a/Headers/CoreText/CTFont.h +++ b/Headers/CoreText/CTFont.h @@ -486,6 +486,37 @@ CFTypeID CTFontGetTypeID(); CTFontDescriptorRef CTFontManagerCreateFontDescriptorFromData( CFDataRef data); +/* Private APIs */ + +bool CTFontGetVerticalGlyphsForCharacters( + CTFontRef, + const UniChar characters[], + CGGlyph glyphs[], + CFIndex count); + +bool CTFontTransformGlyphs( + CTFontRef, + CGGlyph glyphs[], + CGSize advances[], + CFIndex count, + int); + +CTFontRef CTFontCreateForCSS( + CFStringRef name, + uint16_t weight, + CTFontSymbolicTraits, + CGFloat size); + +CTFontRef CTFontCreateForCharactersWithLanguage( + CTFontRef currentFont, + const UTF16Char *characters, + CFIndex length, + CFStringRef language, CFIndex *coveredLength); + +extern const CFStringRef kCTFontReferenceURLAttribute; +extern const CFStringRef kCTFontOpticalSizeAttribute; +extern const CFStringRef kCTFontPostScriptNameAttribute; + #ifdef __cplusplus } #endif diff --git a/Headers/CoreText/CTFontDescriptor.h b/Headers/CoreText/CTFontDescriptor.h index 95d65f3..859d161 100644 --- a/Headers/CoreText/CTFontDescriptor.h +++ b/Headers/CoreText/CTFontDescriptor.h @@ -152,6 +152,8 @@ CFTypeRef CTFontDescriptorCopyLocalizedAttribute( CFTypeID CTFontDescriptorGetTypeID(); +bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef); + #ifdef __cplusplus } #endif diff --git a/Headers/CoreText/CTLine.h b/Headers/CoreText/CTLine.h index ea9c6dc..51f4b65 100644 --- a/Headers/CoreText/CTLine.h +++ b/Headers/CoreText/CTLine.h @@ -125,6 +125,20 @@ CGRect CTLineGetBoundsWithOptions( CTLineRef line, CTLineBoundsOptions options); +/* Private APIs */ + +typedef const UniChar* (*CTUniCharProviderCallback)( + CFIndex stringIndex, + CFIndex* charCount, + CFDictionaryRef* attributes, + void* refCon); +typedef void (*CTUniCharDisposeCallback)(const UniChar* chars, void* refCon); + +CTLineRef CTLineCreateWithUniCharProvider( + CTUniCharProviderCallback provide, + CTUniCharDisposeCallback dispose, + void* refCon); + #ifdef __cplusplus } #endif diff --git a/Headers/CoreText/CTRun.h b/Headers/CoreText/CTRun.h index 27cf886..647e530 100644 --- a/Headers/CoreText/CTRun.h +++ b/Headers/CoreText/CTRun.h @@ -119,6 +119,16 @@ void CTRunDraw( CFTypeID CTRunGetTypeID(); +/* Private APIs */ + +CGSize CTRunGetInitialAdvance(CTRunRef run); + +void CTRunGetBaseAdvancesAndOrigins( + CTRunRef, + CFRange, + CGSize baseAdvances[], + CGPoint origins[]); + #ifdef __cplusplus } #endif diff --git a/Headers/CoreText/CTTypesetter.h b/Headers/CoreText/CTTypesetter.h index 72044a0..6aec39b 100644 --- a/Headers/CoreText/CTTypesetter.h +++ b/Headers/CoreText/CTTypesetter.h @@ -74,6 +74,12 @@ CFIndex CTTypesetterSuggestLineBreak( CFTypeID CTTypesetterGetTypeID(); +CTTypesetterRef CTTypesetterCreateWithUniCharProviderAndOptions( + CTUniCharProviderCallback provide, + CTUniCharDisposeCallback dispose, + void* refCon, + CFDictionaryRef options); + #ifdef __cplusplus } #endif diff --git a/Source/OpalGraphics/CGContext.m b/Source/OpalGraphics/CGContext.m index 7ae42ed..97955f5 100644 --- a/Source/OpalGraphics/CGContext.m +++ b/Source/OpalGraphics/CGContext.m @@ -290,6 +290,16 @@ CGAffineTransform CGContextGetCTM(CGContextRef ctx) return CGAffineTransformMake(result.xx, result.yx, result.xy, result.yy, result.x0, result.y0); } +void CGContextSetCTM(CGContextRef ctx, CGAffineTransform m) +{ + // FIXME: it looks like we do not need to do anything related to the + // flip transformation here like in GetCTM() above, but we may be wrong + // here. + cairo_matrix_t cairoMatrix; + cairo_matrix_init(&cairoMatrix, m.a, m.b, m.c, m.d, m.tx, m.ty); + cairo_set_matrix(ctx->ct, &cairoMatrix); +} + void OPContextSetCairoDeviceOffset(CGContextRef ctx, CGFloat x, CGFloat y) { OPLOGCALL("ctx /*%p*/, %g, %g", ctx, x, y) @@ -377,6 +387,11 @@ void CGContextSetShouldAntialias(CGContextRef ctx, int shouldAntialias) OPRESTORELOGGING() } +bool CGContextGetShouldAntialias(CGContextRef ctx) +{ + return cairo_get_antialias(ctx->ct) != CAIRO_ANTIALIAS_NONE; +} + void CGContextSetLineWidth(CGContextRef ctx, CGFloat width) { OPLOGCALL("ctx /*%p*/, %g", ctx, width) @@ -480,6 +495,11 @@ void CGContextSetShouldSmoothFonts(CGContextRef ctx, int shouldSmoothFonts) OPRESTORELOGGING() } +bool CGContextGetShouldSmoothFonts(CGContextRef ctx) +{ + return false; +} + void CGContextSetAllowsFontSmoothing(CGContextRef ctx, bool allowsFontSmoothing) { OPLOGCALL("ctx /*%p*/, %s", ctx, allowsFontSmoothing ? "true" : "false") @@ -772,7 +792,11 @@ void CGContextAddPath(CGContextRef ctx, CGPathRef path) void CGContextAddEllipseInRect(CGContextRef ctx, CGRect rect) { OPLOGCALL("ctx /*%p*/, CGRectMake(%g, %g, %g, %g)", ctx, rect.origin.x, rect.origin.y, - rect.size.width, rect.size.height) + rect.size.width, rect.size.height); + CGPathRef path = CGPathCreateMutable(); + CGPathAddEllipseInRect(path, NULL, rect); + CGContextAddPath(ctx, path); + CGPathRelease(path); OPRESTORELOGGING() } @@ -953,6 +977,20 @@ void CGContextClearRect(CGContextRef ctx, CGRect rect) OPRESTORELOGGING() } +void CGContextFillEllipseInRect(CGContextRef ctx, CGRect rect) +{ + CGContextBeginPath(ctx); + CGContextAddEllipseInRect(ctx, rect); + CGContextFillPath(ctx); +} + +void CGContextStrokeEllipseInRect(CGContextRef ctx, CGRect rect) +{ + CGContextBeginPath(ctx); + CGContextAddEllipseInRect(ctx, rect); + CGContextStrokePath(ctx); +} + void CGContextStrokeLineSegments( CGContextRef ctx, const CGPoint points[], @@ -1526,8 +1564,11 @@ void CGContextDrawRadialGradient( void CGContextDrawShading( CGContextRef ctx, - CGShadingRef shading -); + CGShadingRef shading) +{ + // FIXME: unimplemented + return; +} void CGContextSetFont(CGContextRef ctx, CGFontRef font) { @@ -1956,6 +1997,47 @@ CGRect CGContextConvertRectToUserSpace(CGContextRef ctx, CGRect rect) CGAffineTransformInvert(CGContextGetUserSpaceToDeviceSpaceTransform(ctx))); } +CGContextType CGContextGetType(CGContextRef ctx) +{ + // NOTE: This is not wrong, since Opal does not currently seem to support + // any other context type. + return kCGContextTypeBitmap; +} + +CGAffineTransform CGContextGetBaseCTM(CGContextRef ctx) +{ + // FIXME: unimplemented + return (CGAffineTransform){0, 0, 0, 0, 0, 0}; +} + +void CGContextSetBaseCTM(CGContextRef ctx, CGAffineTransform m) +{ + // FIXME: unimplemented +} + +CGColorSpaceRef CGContextCopyDeviceColorSpace(CGContextRef ctx) +{ + // FIXME: unimplemented + return NULL; +} + +void CGContextSetShouldAntialiasFonts(CGContextRef ctx, bool shouldAntialiasFonts) +{ + // FIXME: unimplemented +} + +bool CGDisplayUsesInvertedPolarity(void) +{ + // FIXME: unimplemented + return false; +} + +bool CGDisplayUsesForceToGray(void) +{ + // FIXME: unimplemented + return false; +} + void OpalContextSetScaleFactor(CGContextRef ctx, CGFloat scale) { if (scale == 0) diff --git a/Source/OpalGraphics/CGFont.m b/Source/OpalGraphics/CGFont.m index ac67927..59d6aa7 100644 --- a/Source/OpalGraphics/CGFont.m +++ b/Source/OpalGraphics/CGFont.m @@ -351,3 +351,15 @@ CGGlyph OPFontGetGlyphWithCharacter(CGFontRef font, unichar character) { return [font glyphWithCharacter: character]; } + +bool CGFontGetGlyphAdvancesForStyle( + CGFontRef font, + const CGAffineTransform *m, + int renderingStyle, + const CGGlyph glyphs[], + size_t count, + CGSize advances[]) +{ + // FIXME: unimplemented + return false; +} diff --git a/Source/OpalGraphics/CGImageSource.m b/Source/OpalGraphics/CGImageSource.m index 10849ee..839ceff 100644 --- a/Source/OpalGraphics/CGImageSource.m +++ b/Source/OpalGraphics/CGImageSource.m @@ -38,6 +38,15 @@ const CFStringRef kCGImageSourceThumbnailMaxPixelSize = @"kCGImageSourceThumbnailMaxPixelSize"; const CFStringRef kCGImageSourceCreateThumbnailWithTransform = @"kCGImageSourceCreateThumbnailWithTransform"; +const CFStringRef kCGImageSourceShouldPreferRGB32 = + @"kCGImageSourceShouldPreferRGB32"; +const CFStringRef kCGImageSourceSkipMetadata = + @"kCGImageSourceSkipMetadata"; +const CFStringRef kCGImageSourceSubsampleFactor = + @"kCGImageSourceSubsampleFactor"; +const CFStringRef kCGImageSourceShouldCacheImmediately = + @"kCGImageSourceShouldCacheImmediately"; + static NSMutableArray *sourceClasses = nil; @@ -354,6 +363,15 @@ CFStringRef CGImageSourceGetType(CGImageSourceRef source) return [source type]; } +CFStringRef CGImageSourceGetTypeWithData( + CFDataRef data, + CFStringRef string, + bool* result) +{ + // FIXME: unimplemented + return NULL; +} + void CGImageSourceUpdateData( CGImageSourceRef source, CFDataRef data, diff --git a/Source/OpalText/CTFont.m b/Source/OpalText/CTFont.m index 9905d82..e718c73 100644 --- a/Source/OpalText/CTFont.m +++ b/Source/OpalText/CTFont.m @@ -66,6 +66,13 @@ const CFStringRef kCTFontOpenTypeFeatureTag = (CFStringRef)@"kCTFontOpenTypeFeatureTag"; const CFStringRef kCTFontOpenTypeFeatureValue = (CFStringRef)@"kCTFontOpenTypeFeatureValue"; +const CFStringRef kCTFontReferenceURLAttribute = + @"kCTFontReferenceURLAttribute"; +const CFStringRef kCTFontOpticalSizeAttribute = + @"kCTFontOpticalSizeAttribute"; +const CFStringRef kCTFontPostScriptNameAttribute = + @"kCTFontPostScriptNameAttribute"; + /* Classes */ @@ -552,3 +559,45 @@ CTFontDescriptorRef CTFontManagerCreateFontDescriptorFromData( // FIXME: unimplemented return NULL; } + +bool CTFontGetVerticalGlyphsForCharacters( + CTFontRef font, + const UniChar characters[], + CGGlyph glyphs[], + CFIndex count) +{ + // FIXME: unimplemented + return false; +} + +bool CTFontTransformGlyphs( + CTFontRef font, + CGGlyph glyphs[], + CGSize advances[], + CFIndex count, + int options) +{ + // FIXME: unimplemented + return false; +} + +CTFontRef CTFontCreateForCSS( + CFStringRef name, + uint16_t weight, + CTFontSymbolicTraits traits, + CGFloat size) +{ + // FIXME: unimplemented + return NULL; +} + +CTFontRef CTFontCreateForCharactersWithLanguage( + CTFontRef currentFont, + const UTF16Char *characters, + CFIndex length, + CFStringRef language, + CFIndex *coveredLength) +{ + // FIXME: unimplemented + return NULL; +} diff --git a/Source/OpalText/CTFontDescriptor.m b/Source/OpalText/CTFontDescriptor.m index 983265c..55b23a2 100644 --- a/Source/OpalText/CTFontDescriptor.m +++ b/Source/OpalText/CTFontDescriptor.m @@ -177,3 +177,8 @@ CFTypeID CTFontDescriptorGetTypeID() return (CFTypeID)[OPFontDescriptor class]; } +bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef desc) +{ + // FIXME: unimplemented + return false; +} diff --git a/Source/OpalText/CTLine.m b/Source/OpalText/CTLine.m index 0e8b051..7c9e6c9 100644 --- a/Source/OpalText/CTLine.m +++ b/Source/OpalText/CTLine.m @@ -191,3 +191,11 @@ CGRect CTLineGetBoundsWithOptions( { return CGRectZero; } + +CTLineRef CTLineCreateWithUniCharProvider( + CTUniCharProviderCallback provide, + CTUniCharDisposeCallback dispose, + void* refCon) +{ + return NULL; +} diff --git a/Source/OpalText/CTRun.m b/Source/OpalText/CTRun.m index 2f30170..67624d5 100644 --- a/Source/OpalText/CTRun.m +++ b/Source/OpalText/CTRun.m @@ -223,3 +223,17 @@ CFTypeID CTRunGetTypeID() return (CFTypeID)[CTRun class]; } +CGSize CTRunGetInitialAdvance(CTRunRef run) +{ + // FIXME: unimplemented + return CGSizeZero; +} + +void CTRunGetBaseAdvancesAndOrigins( + CTRunRef run, + CFRange range, + CGSize baseAdvances[], + CGPoint origins[]) +{ + // FIXME: unimplemented +} diff --git a/Source/OpalText/CTTypesetter.m b/Source/OpalText/CTTypesetter.m index eb9d047..fa39d10 100644 --- a/Source/OpalText/CTTypesetter.m +++ b/Source/OpalText/CTTypesetter.m @@ -143,3 +143,12 @@ CFTypeID CTTypesetterGetTypeID() return (CFTypeID)[CTTypesetter class]; } +CTTypesetterRef CTTypesetterCreateWithUniCharProviderAndOptions( + CTUniCharProviderCallback provide, + CTUniCharDisposeCallback dispose, + void* refCon, + CFDictionaryRef options) +{ + // FIXME: unimplemented + return NULL; +}