2007-02-13 03:41:55 +00:00
|
|
|
/* Copyright (c) 2007 Christopher J. W. Lloyd
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
|
2010-03-31 14:36:14 +00:00
|
|
|
#import <Onyx2D/O2Context.h>
|
|
|
|
#import <Onyx2D/O2BitmapContext.h>
|
|
|
|
#import <Onyx2D/O2GraphicsState.h>
|
|
|
|
#import <Onyx2D/O2Color.h>
|
|
|
|
#import <Onyx2D/O2ColorSpace.h>
|
|
|
|
#import <Onyx2D/O2MutablePath.h>
|
|
|
|
#import <Onyx2D/O2Layer.h>
|
|
|
|
#import <Onyx2D/O2PDFPage.h>
|
|
|
|
#import <Onyx2D/O2ClipPhase.h>
|
|
|
|
#import <Onyx2D/O2Exceptions.h>
|
2019-04-15 20:32:12 +00:00
|
|
|
#import <Onyx2D/O2Encoding.h>
|
|
|
|
#import <Onyx2D/O2PDFCharWidths.h>
|
2008-04-17 16:59:58 +00:00
|
|
|
#import <Foundation/NSBundle.h>
|
|
|
|
#import <Foundation/NSArray.h>
|
2010-10-22 15:57:22 +00:00
|
|
|
|
2018-09-02 20:14:39 +00:00
|
|
|
void O2ContextDefaultShowText(O2ContextRef self,const char *text, NSUInteger length);
|
2007-02-13 03:41:55 +00:00
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
@implementation O2Context
|
2007-02-13 03:41:55 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
-initWithBytes:(void *)bytes width:(size_t)width height:(size_t)height bitsPerComponent:(size_t)bitsPerComponent bytesPerRow:(size_t)bytesPerRow colorSpace:(O2ColorSpaceRef)colorSpace bitmapInfo:(O2BitmapInfo)bitmapInfo releaseCallback:(O2BitmapContextReleaseDataCallback)releaseCallback releaseInfo:(void *)releaseInfo {
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
- Issue #84 fix in NSDocumentController, NSDocumentController was referring to a NSMenu's itemArray while the array was changing due to KVC & -[NSMenu _setItemArray:]
- Added NSIntegerMapKeyCallBacks
- Added variety of CGBitmapContext, CGImage, CGDataProvider, CGGeometry, CGPath, CGPattern, CGColor C interfaces to the .h's in ApplicationServices and underlying implementation in AppKit.
- Consolidated KGPath/VGPath more. Consolidated KGImage/KGSurface(VGImage) more into read-only and read-write images.
- Moved some KG classes from SWRender to AppKit
- SWRender overhaul to use the whole KG interface (context,color,path,etc.) directly using the C CoreGraphics interface and a common test template for both CG and KG using the C interface.
2008-04-23 17:52:06 +00:00
|
|
|
+(BOOL)canInitBitmap {
|
2008-02-29 17:56:38 +00:00
|
|
|
return NO;
|
2008-01-02 03:31:21 +00:00
|
|
|
}
|
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
-initWithGraphicsState:(O2GState *)state {
|
2010-03-03 15:13:26 +00:00
|
|
|
_userToDeviceTransform=state->_deviceSpaceTransform;
|
2007-03-11 19:28:02 +00:00
|
|
|
_layerStack=[NSMutableArray new];
|
|
|
|
_stateStack=[NSMutableArray new];
|
|
|
|
[_stateStack addObject:state];
|
2010-10-22 15:57:22 +00:00
|
|
|
_currentState=state;
|
2009-08-03 20:52:42 +00:00
|
|
|
_path=[[O2MutablePath alloc] init];
|
2007-03-11 19:28:02 +00:00
|
|
|
_allowsAntialiasing=YES;
|
2010-10-22 15:57:22 +00:00
|
|
|
_textMatrix=O2AffineTransformIdentity;
|
|
|
|
_showTextFunction=O2ContextDefaultShowText;
|
2010-10-28 06:53:25 +00:00
|
|
|
_showGlyphsFunction=(O2ContextShowGlyphsFunction)[self methodForSelector:@selector(showGlyphs:advances:count:)];
|
2007-03-11 19:28:02 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2007-10-15 18:08:57 +00:00
|
|
|
-init {
|
2009-10-06 16:02:46 +00:00
|
|
|
return [self initWithGraphicsState:[[[O2GState alloc] init] autorelease]];
|
2007-10-15 18:08:57 +00:00
|
|
|
}
|
|
|
|
|
2007-03-11 19:28:02 +00:00
|
|
|
-(void)dealloc {
|
|
|
|
[_layerStack release];
|
|
|
|
[_stateStack release];
|
|
|
|
[_path release];
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
-(O2Surface *)surface {
|
2008-06-27 17:35:48 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
-(O2Surface *)createSurfaceWithWidth:(size_t)width height:(size_t)height {
|
2008-06-27 17:35:48 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2007-03-11 19:28:02 +00:00
|
|
|
-(void)beginTransparencyLayerWithInfo:(NSDictionary *)unused {
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)endTransparencyLayer {
|
|
|
|
}
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2ColorRef O2ContextStrokeColor(O2ContextRef self) {
|
|
|
|
return O2GStateStrokeColor(O2ContextCurrentGState(self));
|
2009-11-02 16:23:34 +00:00
|
|
|
}
|
|
|
|
|
2010-03-03 15:13:26 +00:00
|
|
|
O2ColorRef O2ContextFillColor(O2ContextRef self) {
|
2010-10-22 15:57:22 +00:00
|
|
|
return O2GStateFillColor(O2ContextCurrentGState(self));
|
2009-11-02 16:23:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setStrokeAlpha:(O2Float)alpha {
|
2010-10-22 15:57:22 +00:00
|
|
|
O2ColorRef color=O2ColorCreateCopyWithAlpha(O2ContextStrokeColor(self),alpha);
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSetStrokeColorWithColor(self,color);
|
|
|
|
O2ColorRelease(color);
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setGrayStrokeColor:(O2Float)gray {
|
2010-10-22 15:57:22 +00:00
|
|
|
O2Float alpha=O2ColorGetAlpha(O2ContextStrokeColor(self));
|
2009-11-02 16:23:34 +00:00
|
|
|
|
|
|
|
O2ContextSetGrayStrokeColor(self,gray,alpha);
|
|
|
|
}
|
|
|
|
|
2013-08-04 05:53:06 +00:00
|
|
|
-(void)setStrokeColorRed:(O2Float)r green:(O2Float)g blue:(O2Float)b {
|
2010-10-22 15:57:22 +00:00
|
|
|
O2Float alpha=O2ColorGetAlpha(O2ContextStrokeColor(self));
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSetRGBStrokeColor(self,r,g,b,alpha);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2013-08-04 05:53:06 +00:00
|
|
|
-(void)setStrokeColorC:(O2Float)c m:(O2Float)m y:(O2Float)y k:(O2Float)k {
|
2010-10-22 15:57:22 +00:00
|
|
|
O2Float alpha=O2ColorGetAlpha(O2ContextStrokeColor(self));
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSetCMYKStrokeColor(self,c,m,y,k,alpha);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
-(void)setFillAlpha:(O2Float)alpha {
|
2010-03-03 15:13:26 +00:00
|
|
|
O2ColorRef color=O2ColorCreateCopyWithAlpha(O2ContextFillColor(self),alpha);
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSetFillColorWithColor(self,color);
|
|
|
|
O2ColorRelease(color);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
-(void)setGrayFillColor:(O2Float)gray {
|
2010-03-03 15:13:26 +00:00
|
|
|
O2Float alpha=O2ColorGetAlpha(O2ContextFillColor(self));
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSetGrayFillColor(self,gray,alpha);
|
|
|
|
}
|
|
|
|
|
2013-08-04 05:53:06 +00:00
|
|
|
-(void)setFillColorRed:(O2Float)r green:(O2Float)g blue:(O2Float)b {
|
2010-03-03 15:13:26 +00:00
|
|
|
O2Float alpha=O2ColorGetAlpha(O2ContextFillColor(self));
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSetRGBFillColor(self,r,g,b,alpha);
|
|
|
|
}
|
|
|
|
|
2013-08-04 05:53:06 +00:00
|
|
|
-(void)setFillColorC:(O2Float)c m:(O2Float)m y:(O2Float)y k:(O2Float)k {
|
2010-03-03 15:13:26 +00:00
|
|
|
O2Float alpha=O2ColorGetAlpha(O2ContextFillColor(self));
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSetCMYKFillColor(self,c,m,y,k,alpha);
|
|
|
|
}
|
|
|
|
|
2018-06-15 14:47:11 +00:00
|
|
|
-(void)setAlpha:(O2Float)alpha
|
2011-06-22 16:17:01 +00:00
|
|
|
{
|
|
|
|
O2GStateSetAlpha(O2ContextCurrentGState(self), alpha);
|
|
|
|
if ([self supportsGlobalAlpha] == NO) {
|
|
|
|
[self setStrokeAlpha:alpha];
|
|
|
|
[self setFillAlpha:alpha];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-22 16:27:48 +00:00
|
|
|
-(BOOL)supportsGlobalAlpha
|
2011-06-22 16:17:01 +00:00
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2013-10-30 11:42:33 +00:00
|
|
|
-(BOOL)isBitmapContext
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
-(void)drawPath:(O2PathDrawingMode)pathMode {
|
2009-11-18 04:48:58 +00:00
|
|
|
O2InvalidAbstractInvocation();
|
2009-11-02 16:23:34 +00:00
|
|
|
// reset path in subclass
|
|
|
|
}
|
|
|
|
|
2011-10-27 14:21:46 +00:00
|
|
|
-(void)replacePathWithStrokedPath {
|
|
|
|
O2UnimplementedFunction();
|
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
-(void)drawShading:(O2Shading *)shading {
|
2009-11-18 04:48:58 +00:00
|
|
|
O2InvalidAbstractInvocation();
|
2009-11-02 16:23:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)drawImage:(O2Image *)image inRect:(O2Rect)rect {
|
2009-11-18 04:48:58 +00:00
|
|
|
O2InvalidAbstractInvocation();
|
2009-11-02 16:23:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)drawLayer:(O2LayerRef)layer inRect:(O2Rect)rect {
|
2009-11-18 04:48:58 +00:00
|
|
|
O2InvalidAbstractInvocation();
|
2009-11-02 16:23:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)flush {
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)synchronize {
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
2009-12-16 19:27:00 +00:00
|
|
|
-(BOOL)resizeWithNewSize:(O2Size)size {
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
-(void)beginPage:(const O2Rect *)mediaBox {
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)endPage {
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)close {
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
-(O2Size)size {
|
|
|
|
return O2SizeMake(0,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
-(O2ContextRef)createCompatibleContextWithSize:(O2Size)size unused:(NSDictionary *)unused {
|
2017-12-17 13:11:05 +00:00
|
|
|
return [[[self class] alloc] initWithSize:size context:self];
|
2009-11-02 16:23:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(BOOL)getImageableRect:(O2Rect *)rect {
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
// temporary
|
|
|
|
|
|
|
|
-(void)setAntialiasingQuality:(int)value {
|
2010-10-22 15:57:22 +00:00
|
|
|
[O2ContextCurrentGState(self) setAntialiasingQuality:value];
|
2009-11-02 16:23:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)copyBitsInRect:(O2Rect)rect toPoint:(O2Point)point gState:(int)gState {
|
2009-11-18 04:48:58 +00:00
|
|
|
O2InvalidAbstractInvocation();
|
2009-11-02 16:23:34 +00:00
|
|
|
}
|
|
|
|
|
2011-02-20 20:23:36 +00:00
|
|
|
-(NSData *)captureBitmapInRect:(NSRect)rect {
|
|
|
|
O2InvalidAbstractInvocation();
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
/*
|
|
|
|
Notes: OSX generates a clip mask at fill time using the current aliasing setting. Once the fill is complete the clip mask persists with the next clip/fill. This means you can turn off AA, create a clip path, fill, turn on AA, create another clip path, fill, and edges from the first path will be aliased, and ones from the second will not. PDF does not dictate aliasing behavior, so while this is not really expected behavior, it is not a bug.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
-(void)clipToState:(O2ClipState *)clipState {
|
|
|
|
O2InvalidAbstractInvocation();
|
2009-11-02 16:23:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
O2ContextRef O2ContextRetain(O2ContextRef self) {
|
2009-12-01 22:27:05 +00:00
|
|
|
return (self!=NULL)?(O2ContextRef)CFRetain(self):NULL;
|
2009-11-02 16:23:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void O2ContextRelease(O2ContextRef self) {
|
2009-12-01 22:27:05 +00:00
|
|
|
if(self!=NULL)
|
|
|
|
CFRelease(self);
|
2009-11-02 16:23:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// context state
|
|
|
|
void O2ContextSetAllowsAntialiasing(O2ContextRef self,BOOL yesOrNo) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
self->_allowsAntialiasing=yesOrNo;
|
|
|
|
}
|
|
|
|
|
|
|
|
// layers
|
|
|
|
void O2ContextBeginTransparencyLayer(O2ContextRef self,NSDictionary *unused) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
[self beginTransparencyLayerWithInfo:unused];
|
|
|
|
}
|
|
|
|
|
|
|
|
void O2ContextEndTransparencyLayer(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
[self endTransparencyLayer];
|
|
|
|
}
|
|
|
|
|
|
|
|
// path
|
|
|
|
BOOL O2ContextIsPathEmpty(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return YES;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
return (self->_path==nil)?YES:O2PathIsEmpty(self->_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
O2Point O2ContextGetPathCurrentPoint(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return O2PointZero;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
return (self->_path==nil)?O2PointZero:O2PathGetCurrentPoint(self->_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
O2Rect O2ContextGetPathBoundingBox(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return O2RectZero;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
return (self->_path==nil)?O2RectZero:O2PathGetBoundingBox(self->_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL O2ContextPathContainsPoint(O2ContextRef self,O2Point point,O2PathDrawingMode pathMode) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return NO;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2AffineTransform ctm=O2ContextCurrentGState(self)->_deviceSpaceTransform;
|
2007-03-11 19:28:02 +00:00
|
|
|
|
|
|
|
// FIX evenOdd
|
2009-11-02 16:23:34 +00:00
|
|
|
return O2PathContainsPoint(self->_path,&ctm,point,NO);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextBeginPath(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2PathReset(self->_path);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextClosePath(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2PathCloseSubpath(self->_path);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-07-08 15:59:34 +00:00
|
|
|
/* Path building is affected by the CTM, we transform them here into base coordinates (first quadrant, no transformation)
|
|
|
|
|
|
|
|
A backend can then convert them to where it needs them, base, current, or device space.
|
|
|
|
*/
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextMoveToPoint(O2ContextRef self,O2Float x,O2Float y) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2AffineTransform ctm=O2GStateUserSpaceTransform(O2ContextCurrentGState(self));
|
2008-06-30 16:18:49 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2PathMoveToPoint(self->_path,&ctm,x,y);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextAddLineToPoint(O2ContextRef self,O2Float x,O2Float y) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2AffineTransform ctm=O2GStateUserSpaceTransform(O2ContextCurrentGState(self));
|
2008-06-30 16:18:49 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2PathAddLineToPoint(self->_path,&ctm,x,y);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextAddCurveToPoint(O2ContextRef self,O2Float cx1,O2Float cy1,O2Float cx2,O2Float cy2,O2Float x,O2Float y) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2AffineTransform ctm=O2GStateUserSpaceTransform(O2ContextCurrentGState(self));
|
2008-06-30 16:18:49 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2PathAddCurveToPoint(self->_path,&ctm,cx1,cy1,cx2,cy2,x,y);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextAddQuadCurveToPoint(O2ContextRef self,O2Float cx1,O2Float cy1,O2Float x,O2Float y) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2AffineTransform ctm=O2GStateUserSpaceTransform(O2ContextCurrentGState(self));
|
2008-06-30 16:18:49 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2PathAddQuadCurveToPoint(self->_path,&ctm,cx1,cy1,x,y);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2018-09-02 20:14:39 +00:00
|
|
|
void O2ContextAddLines(O2ContextRef self,const O2Point *points, NSUInteger count) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2AffineTransform ctm=O2GStateUserSpaceTransform(O2ContextCurrentGState(self));
|
2008-06-30 16:18:49 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2PathAddLines(self->_path,&ctm,points,count);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextAddRect(O2ContextRef self,O2Rect rect) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2AffineTransform ctm=O2GStateUserSpaceTransform(O2ContextCurrentGState(self));
|
2009-08-03 20:52:42 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2PathAddRect(self->_path,&ctm,rect);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2018-09-02 20:14:39 +00:00
|
|
|
void O2ContextAddRects(O2ContextRef self,const O2Rect *rects, NSUInteger count) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2AffineTransform ctm=O2GStateUserSpaceTransform(O2ContextCurrentGState(self));
|
2008-06-30 16:18:49 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2PathAddRects(self->_path,&ctm,rects,count);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextAddArc(O2ContextRef self,O2Float x,O2Float y,O2Float radius,O2Float startRadian,O2Float endRadian,BOOL clockwise) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2AffineTransform ctm=O2GStateUserSpaceTransform(O2ContextCurrentGState(self));
|
2008-06-30 16:18:49 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2PathAddArc(self->_path,&ctm,x,y,radius,startRadian,endRadian,clockwise);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextAddArcToPoint(O2ContextRef self,O2Float x1,O2Float y1,O2Float x2,O2Float y2,O2Float radius) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2AffineTransform ctm=O2GStateUserSpaceTransform(O2ContextCurrentGState(self));
|
2008-06-30 16:18:49 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2PathAddArcToPoint(self->_path,&ctm,x1,y1,x2,y2,radius);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextAddEllipseInRect(O2ContextRef self,O2Rect rect) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2AffineTransform ctm=O2GStateUserSpaceTransform(O2ContextCurrentGState(self));
|
2008-06-30 16:18:49 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2PathAddEllipseInRect(self->_path,&ctm,rect);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextAddPath(O2ContextRef self,O2PathRef path) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2AffineTransform ctm=O2GStateUserSpaceTransform(O2ContextCurrentGState(self));
|
2008-06-30 16:18:49 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2PathAddPath(self->_path,&ctm,path);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextReplacePathWithStrokedPath(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2011-10-27 14:21:46 +00:00
|
|
|
[self replacePathWithStrokedPath];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2013-09-16 17:15:19 +00:00
|
|
|
O2Path* O2ContextCopyPath(O2ContextRef self) {
|
|
|
|
if(self==nil)
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
return [self->_path copy];
|
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
// gstate
|
2008-02-29 17:56:38 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSaveGState(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GState *current=O2ContextCurrentGState(self),*next;
|
2007-03-11 19:28:02 +00:00
|
|
|
|
2010-03-03 15:13:26 +00:00
|
|
|
next=O2GStateCopyWithZone(current,NULL);
|
2009-11-02 16:23:34 +00:00
|
|
|
[self->_stateStack addObject:next];
|
2010-10-22 15:57:22 +00:00
|
|
|
self->_currentState=next;
|
2007-03-11 19:28:02 +00:00
|
|
|
[next release];
|
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextRestoreGState(O2ContextRef self) {
|
2010-03-03 15:13:26 +00:00
|
|
|
if(self==nil){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
[self->_stateStack removeLastObject];
|
2010-10-22 15:57:22 +00:00
|
|
|
self->_currentState=[self->_stateStack lastObject];
|
2008-02-29 17:56:38 +00:00
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GState *gState=O2ContextCurrentGState(self);
|
2009-11-02 16:23:34 +00:00
|
|
|
|
|
|
|
// FIXME, this could be conditional by comparing to previous font
|
|
|
|
gState->_fontIsDirty=YES;
|
2010-10-22 15:57:22 +00:00
|
|
|
gState->_fillColorIsDirty=YES;
|
2009-11-02 16:23:34 +00:00
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
[self clipToState:O2GStateClipState(gState)];
|
2008-02-29 17:56:38 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2AffineTransform O2ContextGetUserSpaceToDeviceSpaceTransform(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return O2AffineTransformIdentity;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
return O2ContextCurrentGState(self)->_deviceSpaceTransform;
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2AffineTransform O2ContextGetCTM(O2ContextRef self){
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return O2AffineTransformIdentity;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
return O2GStateUserSpaceTransform(O2ContextCurrentGState(self));
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2Rect O2ContextGetClipBoundingBox(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return O2RectZero;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
return [O2ContextCurrentGState(self) clipBoundingBox];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2AffineTransform O2ContextGetTextMatrix(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return O2AffineTransformIdentity;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
return self->_textMatrix;
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2InterpolationQuality O2ContextGetInterpolationQuality(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return 0;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
return [O2ContextCurrentGState(self) interpolationQuality];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2Point O2ContextGetTextPosition(O2ContextRef self){
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return O2PointZero;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2Point result={self->_textMatrix.tx,self->_textMatrix.ty};
|
|
|
|
return result;
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2Point O2ContextConvertPointToDeviceSpace(O2ContextRef self,O2Point point) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return O2PointZero;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
return [O2ContextCurrentGState(self) convertPointToDeviceSpace:point];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2Point O2ContextConvertPointToUserSpace(O2ContextRef self,O2Point point) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return O2PointZero;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
return [O2ContextCurrentGState(self) convertPointToUserSpace:point];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2Size O2ContextConvertSizeToDeviceSpace(O2ContextRef self,O2Size size) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return O2SizeZero;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
return [O2ContextCurrentGState(self) convertSizeToDeviceSpace:size];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2Size O2ContextConvertSizeToUserSpace(O2ContextRef self,O2Size size) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return O2SizeZero;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
return [O2ContextCurrentGState(self) convertSizeToUserSpace:size];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2Rect O2ContextConvertRectToDeviceSpace(O2ContextRef self,O2Rect rect) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return O2RectZero;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
return [O2ContextCurrentGState(self) convertRectToDeviceSpace:rect];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2Rect O2ContextConvertRectToUserSpace(O2ContextRef self,O2Rect rect) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return O2RectZero;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
return [O2ContextCurrentGState(self) convertRectToUserSpace:rect];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextConcatCTM(O2ContextRef self,O2AffineTransform matrix) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GStateConcatCTM(O2ContextCurrentGState(self),matrix);
|
2007-11-08 15:58:54 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextTranslateCTM(O2ContextRef self,O2Float translatex,O2Float translatey) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextConcatCTM(self,O2AffineTransformMakeTranslation(translatex,translatey));
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextScaleCTM(O2ContextRef self,O2Float scalex,O2Float scaley) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextConcatCTM(self,O2AffineTransformMakeScale(scalex,scaley));
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextRotateCTM(O2ContextRef self,O2Float radians) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextConcatCTM(self,O2AffineTransformMakeRotation(radians));
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextClip(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
if(O2PathIsEmpty(self->_path))
|
2007-07-11 23:27:46 +00:00
|
|
|
return;
|
2008-02-29 17:56:38 +00:00
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GState *gState=O2ContextCurrentGState(self);
|
|
|
|
|
|
|
|
O2PathApplyTransform(self->_path,O2AffineTransformInvert(gState->_userSpaceTransform));
|
|
|
|
O2PathApplyTransform(self->_path,gState->_deviceSpaceTransform);
|
|
|
|
|
|
|
|
O2GStateAddClipToPath(gState,self->_path);
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2PathReset(self->_path);
|
2010-10-22 15:57:22 +00:00
|
|
|
|
|
|
|
[self clipToState:O2GStateClipState(gState)];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextEOClip(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
if(O2PathIsEmpty(self->_path))
|
2007-07-11 23:27:46 +00:00
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GState *gState=O2ContextCurrentGState(self);
|
|
|
|
|
|
|
|
O2PathApplyTransform(self->_path,O2AffineTransformInvert(gState->_userSpaceTransform));
|
|
|
|
O2PathApplyTransform(self->_path,gState->_deviceSpaceTransform);
|
|
|
|
|
|
|
|
O2GStateAddEvenOddClipToPath(gState,self->_path);
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2PathReset(self->_path);
|
2010-10-22 15:57:22 +00:00
|
|
|
|
|
|
|
[self clipToState:O2GStateClipState(gState)];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextClipToMask(O2ContextRef self,O2Rect rect,O2ImageRef image) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GState *gState=O2ContextCurrentGState(self);
|
|
|
|
|
|
|
|
O2GStateAddClipToMask(gState,image,rect);
|
|
|
|
|
|
|
|
[self clipToState:O2GStateClipState(gState)];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextClipToRect(O2ContextRef self,O2Rect rect) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2AffineTransform ctm=O2GStateUserSpaceTransform(O2ContextCurrentGState(self));
|
2008-06-30 16:18:49 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2PathReset(self->_path);
|
|
|
|
O2PathAddRect(self->_path,&ctm,rect);
|
|
|
|
O2ContextClip(self);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2018-09-02 20:14:39 +00:00
|
|
|
void O2ContextClipToRects(O2ContextRef self,const O2Rect *rects, NSUInteger count) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2AffineTransform ctm=O2GStateUserSpaceTransform(O2ContextCurrentGState(self));
|
2007-06-23 04:08:45 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2PathReset(self->_path);
|
|
|
|
O2PathAddRects(self->_path,&ctm,rects,count);
|
|
|
|
O2ContextClip(self);
|
2007-06-23 04:08:45 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetStrokeColorSpace(O2ContextRef self,O2ColorSpaceRef colorSpace) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
int i,length=O2ColorSpaceGetNumberOfComponents(colorSpace);
|
|
|
|
O2Float components[length+1];
|
2009-09-04 16:36:13 +00:00
|
|
|
|
|
|
|
for(i=0;i<length;i++)
|
|
|
|
components[i]=0;
|
|
|
|
components[i]=1;
|
|
|
|
|
2009-12-01 22:27:05 +00:00
|
|
|
O2ColorRef color=O2ColorCreate(colorSpace,components);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSetStrokeColorWithColor(self,color);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ColorRelease(color);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetFillColorSpace(O2ContextRef self,O2ColorSpaceRef colorSpace) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
int i,length=O2ColorSpaceGetNumberOfComponents(colorSpace);
|
|
|
|
O2Float components[length+1];
|
2009-09-04 16:36:13 +00:00
|
|
|
|
|
|
|
for(i=0;i<length;i++)
|
|
|
|
components[i]=0;
|
|
|
|
components[i]=1;
|
|
|
|
|
2009-12-01 22:27:05 +00:00
|
|
|
O2ColorRef color=O2ColorCreate(colorSpace,components);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSetFillColorWithColor(self,color);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ColorRelease(color);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetStrokeColor(O2ContextRef self,const O2Float *components) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2ColorSpaceRef colorSpace=O2ColorGetColorSpace(O2ContextStrokeColor(self));
|
2009-12-01 22:27:05 +00:00
|
|
|
O2ColorRef color=O2ColorCreate(colorSpace,components);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSetStrokeColorWithColor(self,color);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ColorRelease(color);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetStrokeColorWithColor(O2ContextRef self,O2ColorRef color) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GStateSetStrokeColor(O2ContextCurrentGState(self),color);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetGrayStrokeColor(O2ContextRef self,O2Float gray,O2Float alpha) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ColorSpaceRef colorSpace=O2ColorSpaceCreateDeviceGray();
|
|
|
|
O2Float components[2]={gray,alpha};
|
2009-12-01 22:27:05 +00:00
|
|
|
O2ColorRef color=O2ColorCreate(colorSpace,components);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSetStrokeColorWithColor(self,color);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ColorRelease(color);
|
|
|
|
O2ColorSpaceRelease(colorSpace);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetRGBStrokeColor(O2ContextRef self,O2Float r,O2Float g,O2Float b,O2Float alpha) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ColorSpaceRef colorSpace=O2ColorSpaceCreateDeviceRGB();
|
|
|
|
O2Float components[4]={r,g,b,alpha};
|
2009-12-01 22:27:05 +00:00
|
|
|
O2ColorRef color=O2ColorCreate(colorSpace,components);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSetStrokeColorWithColor(self,color);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ColorRelease(color);
|
|
|
|
O2ColorSpaceRelease(colorSpace);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetCMYKStrokeColor(O2ContextRef self,O2Float c,O2Float m,O2Float y,O2Float k,O2Float alpha) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ColorSpaceRef colorSpace=O2ColorSpaceCreateDeviceCMYK();
|
|
|
|
O2Float components[5]={c,m,y,k,alpha};
|
2009-12-01 22:27:05 +00:00
|
|
|
O2ColorRef color=O2ColorCreate(colorSpace,components);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSetStrokeColorWithColor(self,color);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ColorRelease(color);
|
|
|
|
O2ColorSpaceRelease(colorSpace);
|
|
|
|
}
|
|
|
|
|
|
|
|
void O2ContextSetFillColor(O2ContextRef self,const O2Float *components) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-03-03 15:13:26 +00:00
|
|
|
O2ColorSpaceRef colorSpace=O2ColorGetColorSpace(O2ContextFillColor(self));
|
2009-12-01 22:27:05 +00:00
|
|
|
O2ColorRef color=O2ColorCreate(colorSpace,components);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSetFillColorWithColor(self,color);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ColorRelease(color);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetFillColorWithColor(O2ContextRef self,O2ColorRef color) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GStateSetFillColor(O2ContextCurrentGState(self),color);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetGrayFillColor(O2ContextRef self,O2Float gray,O2Float alpha) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ColorSpaceRef colorSpace=O2ColorSpaceCreateDeviceGray();
|
|
|
|
O2Float components[2]={gray,alpha};
|
2009-12-01 22:27:05 +00:00
|
|
|
O2ColorRef color=O2ColorCreate(colorSpace,components);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSetFillColorWithColor(self,color);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ColorRelease(color);
|
|
|
|
O2ColorSpaceRelease(colorSpace);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetRGBFillColor(O2ContextRef self,O2Float r,O2Float g,O2Float b,O2Float alpha) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ColorSpaceRef colorSpace=O2ColorSpaceCreateDeviceRGB();
|
|
|
|
O2Float components[4]={r,g,b,alpha};
|
2009-12-01 22:27:05 +00:00
|
|
|
O2ColorRef color=O2ColorCreate(colorSpace,components);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSetFillColorWithColor(self,color);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ColorRelease(color);
|
|
|
|
O2ColorSpaceRelease(colorSpace);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetCMYKFillColor(O2ContextRef self,O2Float c,O2Float m,O2Float y,O2Float k,O2Float alpha) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ColorSpaceRef colorSpace=O2ColorSpaceCreateDeviceCMYK();
|
|
|
|
O2Float components[5]={c,m,y,k,alpha};
|
2009-12-01 22:27:05 +00:00
|
|
|
O2ColorRef color=O2ColorCreate(colorSpace,components);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSetFillColorWithColor(self,color);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ColorRelease(color);
|
|
|
|
O2ColorSpaceRelease(colorSpace);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetAlpha(O2ContextRef self,O2Float alpha) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2011-06-22 16:17:01 +00:00
|
|
|
[self setAlpha:alpha];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetPatternPhase(O2ContextRef self,O2Size phase) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GStateSetPatternPhase(O2ContextCurrentGState(self),phase);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetStrokePattern(O2ContextRef self,O2PatternRef pattern,const O2Float *components) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
[O2ContextCurrentGState(self) setStrokePattern:pattern components:components];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetFillPattern(O2ContextRef self,O2PatternRef pattern,const O2Float *components) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
[O2ContextCurrentGState(self) setFillPattern:pattern components:components];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetTextMatrix(O2ContextRef self,O2AffineTransform matrix) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
self->_textMatrix=matrix;
|
|
|
|
O2ContextCurrentGState(self)->_fontIsDirty=YES;
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetTextPosition(O2ContextRef self,O2Float x,O2Float y) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
self->_textMatrix.tx=x;
|
|
|
|
self->_textMatrix.ty=y;
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetCharacterSpacing(O2ContextRef self,O2Float spacing) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GStateSetCharacterSpacing(O2ContextCurrentGState(self),spacing);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetTextDrawingMode(O2ContextRef self,O2TextDrawingMode textMode) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
[O2ContextCurrentGState(self) setTextDrawingMode:textMode];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetFont(O2ContextRef self,O2FontRef font) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GStateSetFont(O2ContextCurrentGState(self),font);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetFontSize(O2ContextRef self,O2Float size) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GStateSetFontSize(O2ContextCurrentGState(self),size);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSelectFont(O2ContextRef self,const char *name,O2Float size,O2TextEncoding encoding) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
[O2ContextCurrentGState(self) selectFontWithName:name size:size encoding:encoding];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetShouldSmoothFonts(O2ContextRef self,BOOL yesOrNo) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
[O2ContextCurrentGState(self) setShouldSmoothFonts:yesOrNo];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetLineWidth(O2ContextRef self,O2Float width) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GStateSetLineWidth(O2ContextCurrentGState(self),width);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetLineCap(O2ContextRef self,O2LineCap lineCap) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GStateSetLineCap(O2ContextCurrentGState(self),lineCap);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetLineJoin(O2ContextRef self,O2LineJoin lineJoin) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GStateSetLineJoin(O2ContextCurrentGState(self),lineJoin);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetMiterLimit(O2ContextRef self,O2Float miterLimit) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GStateSetMiterLimit(O2ContextCurrentGState(self),miterLimit);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2018-09-02 20:14:39 +00:00
|
|
|
void O2ContextSetLineDash(O2ContextRef self,O2Float phase,const O2Float *lengths, NSUInteger count) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GStateSetLineDash(O2ContextCurrentGState(self),phase,lengths,count);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetRenderingIntent(O2ContextRef self,O2ColorRenderingIntent renderingIntent) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
[O2ContextCurrentGState(self) setRenderingIntent:renderingIntent];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetBlendMode(O2ContextRef self,O2BlendMode blendMode) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GStateSetBlendMode(O2ContextCurrentGState(self),blendMode);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetFlatness(O2ContextRef self,O2Float flatness) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
[O2ContextCurrentGState(self) setFlatness:flatness];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetInterpolationQuality(O2ContextRef self,O2InterpolationQuality quality) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
[O2ContextCurrentGState(self) setInterpolationQuality:quality];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetShadowWithColor(O2ContextRef self,O2Size offset,O2Float blur,O2ColorRef color) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
[O2ContextCurrentGState(self) setShadowOffset:offset blur:blur color:color];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetShadow(O2ContextRef self,O2Size offset,O2Float blur) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
[O2ContextCurrentGState(self) setShadowOffset:offset blur:blur];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetShouldAntialias(O2ContextRef self,BOOL yesOrNo) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
[O2ContextCurrentGState(self) setShouldAntialias:yesOrNo];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
// drawing
|
2018-09-02 20:14:39 +00:00
|
|
|
void O2ContextStrokeLineSegments(O2ContextRef self,const O2Point *points, NSUInteger count) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2007-10-15 18:08:57 +00:00
|
|
|
int i;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextBeginPath(self);
|
2007-10-15 18:08:57 +00:00
|
|
|
for(i=0;i<count;i+=2){
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextMoveToPoint(self,points[i].x,points[i].y);
|
|
|
|
O2ContextAddLineToPoint(self,points[i+1].x,points[i+1].y);
|
2007-10-15 18:08:57 +00:00
|
|
|
}
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextStrokePath(self);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextStrokeRect(O2ContextRef self,O2Rect rect) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextBeginPath(self);
|
|
|
|
O2ContextAddRect(self,rect);
|
|
|
|
O2ContextStrokePath(self);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextStrokeRectWithWidth(O2ContextRef self,O2Rect rect,O2Float width) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSaveGState(self);
|
|
|
|
O2ContextSetLineWidth(self,width);
|
|
|
|
O2ContextBeginPath(self);
|
|
|
|
O2ContextAddRect(self,rect);
|
|
|
|
O2ContextStrokePath(self);
|
|
|
|
O2ContextRestoreGState(self);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextStrokeEllipseInRect(O2ContextRef self,O2Rect rect) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextBeginPath(self);
|
|
|
|
O2ContextAddEllipseInRect(self,rect);
|
|
|
|
O2ContextStrokePath(self);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextFillRect(O2ContextRef self,O2Rect rect) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextFillRects(self,&rect,1);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2018-09-02 20:14:39 +00:00
|
|
|
void O2ContextFillRects(O2ContextRef self,const O2Rect *rects, NSUInteger count) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextBeginPath(self);
|
|
|
|
O2ContextAddRects(self,rects,count);
|
|
|
|
O2ContextFillPath(self);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextFillEllipseInRect(O2ContextRef self,O2Rect rect) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextBeginPath(self);
|
|
|
|
O2ContextAddEllipseInRect(self,rect);
|
|
|
|
O2ContextFillPath(self);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextDrawPath(O2ContextRef self,O2PathDrawingMode pathMode) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
[self drawPath:pathMode];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextStrokePath(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextDrawPath(self,kO2PathStroke);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextFillPath(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextDrawPath(self,kO2PathFill);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextEOFillPath(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextDrawPath(self,kO2PathEOFill);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextClearRect(O2ContextRef self,O2Rect rect) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
// doc.s are not clear. tests say O2ContextClearRect resets the path and does not affect gstate color
|
|
|
|
O2ContextSaveGState(self);
|
|
|
|
O2ContextSetBlendMode(self,kO2BlendModeCopy); // does it set the blend mode?
|
|
|
|
O2ContextSetGrayFillColor(self,0,0);
|
|
|
|
O2ContextFillRect(self,rect);
|
|
|
|
O2ContextRestoreGState(self);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2018-09-02 20:14:39 +00:00
|
|
|
void O2ContextShowGlyphs(O2ContextRef self,const O2Glyph *glyphs, NSUInteger count) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
self->_showGlyphsFunction(self,NULL,glyphs,NULL,count);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2018-09-02 20:14:39 +00:00
|
|
|
void O2ContextShowGlyphsAtPoint(O2ContextRef self,O2Float x,O2Float y,const O2Glyph *glyphs, NSUInteger count) {
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSetTextPosition(self,x,y);
|
|
|
|
O2ContextShowGlyphs(self,glyphs,count);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2018-09-02 20:14:39 +00:00
|
|
|
-(void)showGlyphs:(const O2Glyph *)glyphs advances:(const O2Size *)advances count:(NSUInteger)count {
|
2010-10-22 15:57:22 +00:00
|
|
|
#if 1
|
|
|
|
O2InvalidAbstractInvocation();
|
|
|
|
#else
|
|
|
|
O2AffineTransform textMatrix=O2ContextGetTextMatrix(self);
|
2009-11-02 16:23:34 +00:00
|
|
|
O2Float x=textMatrix.tx;
|
|
|
|
O2Float y=textMatrix.ty;
|
2007-10-15 18:08:57 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0;i<count;i++){
|
|
|
|
[self showGlyphs:glyphs+i count:1];
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2Size advance=O2SizeApplyAffineTransform(advances[i],textMatrix);
|
|
|
|
|
|
|
|
x+=advance.width;
|
|
|
|
y+=advance.height;
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSetTextPosition(self,x,y);
|
2007-10-15 18:08:57 +00:00
|
|
|
}
|
2010-10-22 15:57:22 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-09-02 20:14:39 +00:00
|
|
|
void O2ContextShowGlyphsWithAdvances(O2ContextRef self,const O2Glyph *glyphs,const O2Size *advances, NSUInteger count) {
|
2010-10-22 15:57:22 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
|
|
|
self->_showGlyphsFunction(self,NULL,glyphs,advances,count);
|
|
|
|
}
|
|
|
|
|
2018-09-02 20:14:39 +00:00
|
|
|
void O2ContextDefaultShowText(O2ContextRef self,const char *text, NSUInteger length) {
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GState *gState=O2ContextCurrentGState(self);
|
|
|
|
O2Encoding *encoding=O2GStateEncoding(gState);
|
|
|
|
O2PDFCharWidths *widths=O2GStateCharWidths(gState);
|
|
|
|
O2Glyph glyphs[length];
|
|
|
|
|
2012-05-15 05:05:28 +00:00
|
|
|
O2EncodingGetGlyphsForBytes(encoding,glyphs,(const uint8_t *)text,length);
|
2010-10-22 15:57:22 +00:00
|
|
|
if(widths==nil && gState->_characterSpacing==0)
|
|
|
|
self->_showGlyphsFunction(self,NULL,glyphs,NULL,length);
|
|
|
|
else {
|
|
|
|
O2Size advances[length];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if(widths!=nil)
|
2012-05-15 05:05:28 +00:00
|
|
|
O2PDFCharWidthsGetAdvances(widths,advances,(const uint8_t *)text,length);
|
2010-10-22 15:57:22 +00:00
|
|
|
else
|
|
|
|
O2ContextGetDefaultAdvances(self,glyphs,advances,length);
|
|
|
|
|
|
|
|
for(i=0;i<length;i++){
|
|
|
|
advances[i].width+=gState->_characterSpacing;
|
|
|
|
}
|
|
|
|
|
|
|
|
self->_showGlyphsFunction(self,NULL,glyphs,advances,length);
|
|
|
|
}
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
|
2018-09-02 20:14:39 +00:00
|
|
|
void O2ContextShowText(O2ContextRef self,const char *text, NSUInteger length) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
self->_showTextFunction(self,text,length);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2018-09-02 20:14:39 +00:00
|
|
|
void O2ContextShowTextAtPoint(O2ContextRef self,O2Float x,O2Float y,const char *text, NSUInteger count) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextSetTextPosition(self,x,y);
|
|
|
|
O2ContextShowText(self,text,count);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextDrawShading(O2ContextRef self,O2ShadingRef shading) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
[self drawShading:shading];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextDrawImage(O2ContextRef self,O2Rect rect,O2ImageRef image) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
[self drawImage:image inRect:rect];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextDrawLayerAtPoint(O2ContextRef self,O2Point point,O2LayerRef layer) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2Size size=O2LayerGetSize(layer);
|
|
|
|
O2Rect rect={point,size};
|
2007-03-11 19:28:02 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2ContextDrawLayerInRect(self,rect,layer);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextDrawLayerInRect(O2ContextRef self,O2Rect rect,O2LayerRef layer) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
[self drawLayer:layer inRect:rect];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextDrawPDFPage(O2ContextRef self,O2PDFPageRef page) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
// Per doc.s, these are initialized at the beginning of each page only
|
|
|
|
|
|
|
|
O2ContextSetCharacterSpacing(self,0);
|
|
|
|
O2ContextSetWordSpacing(self,0);
|
|
|
|
O2ContextSetTextHorizontalScaling(self,100);
|
|
|
|
O2ContextSetTextLeading(self,0);
|
|
|
|
O2ContextSetTextDrawingMode(self,0);
|
|
|
|
O2ContextSetTextRise(self,0);
|
|
|
|
|
2007-03-11 19:28:02 +00:00
|
|
|
[page drawInContext:self];
|
2010-10-22 15:57:22 +00:00
|
|
|
|
|
|
|
O2ContextSetTextLineMatrix(self,O2AffineTransformIdentity);
|
|
|
|
O2ContextSetTextMatrix(self,O2AffineTransformIdentity);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
2007-10-15 18:08:57 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextFlush(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
[self flush];
|
2007-10-15 18:08:57 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSynchronize(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
[self synchronize];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
// pagination
|
- Issue #84 fix in NSDocumentController, NSDocumentController was referring to a NSMenu's itemArray while the array was changing due to KVC & -[NSMenu _setItemArray:]
- Added NSIntegerMapKeyCallBacks
- Added variety of CGBitmapContext, CGImage, CGDataProvider, CGGeometry, CGPath, CGPattern, CGColor C interfaces to the .h's in ApplicationServices and underlying implementation in AppKit.
- Consolidated KGPath/VGPath more. Consolidated KGImage/KGSurface(VGImage) more into read-only and read-write images.
- Moved some KG classes from SWRender to AppKit
- SWRender overhaul to use the whole KG interface (context,color,path,etc.) directly using the C CoreGraphics interface and a common test template for both CG and KG using the C interface.
2008-04-23 17:52:06 +00:00
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextBeginPage(O2ContextRef self,const O2Rect *mediaBox) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
[self beginPage:mediaBox];
|
- Issue #84 fix in NSDocumentController, NSDocumentController was referring to a NSMenu's itemArray while the array was changing due to KVC & -[NSMenu _setItemArray:]
- Added NSIntegerMapKeyCallBacks
- Added variety of CGBitmapContext, CGImage, CGDataProvider, CGGeometry, CGPath, CGPattern, CGColor C interfaces to the .h's in ApplicationServices and underlying implementation in AppKit.
- Consolidated KGPath/VGPath more. Consolidated KGImage/KGSurface(VGImage) more into read-only and read-write images.
- Moved some KG classes from SWRender to AppKit
- SWRender overhaul to use the whole KG interface (context,color,path,etc.) directly using the C CoreGraphics interface and a common test template for both CG and KG using the C interface.
2008-04-23 17:52:06 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextEndPage(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
[self endPage];
|
- Issue #84 fix in NSDocumentController, NSDocumentController was referring to a NSMenu's itemArray while the array was changing due to KVC & -[NSMenu _setItemArray:]
- Added NSIntegerMapKeyCallBacks
- Added variety of CGBitmapContext, CGImage, CGDataProvider, CGGeometry, CGPath, CGPattern, CGColor C interfaces to the .h's in ApplicationServices and underlying implementation in AppKit.
- Consolidated KGPath/VGPath more. Consolidated KGImage/KGSurface(VGImage) more into read-only and read-write images.
- Moved some KG classes from SWRender to AppKit
- SWRender overhaul to use the whole KG interface (context,color,path,etc.) directly using the C CoreGraphics interface and a common test template for both CG and KG using the C interface.
2008-04-23 17:52:06 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
// **PRIVATE** These are private in Apple's implementation as well as ours.
|
- Issue #84 fix in NSDocumentController, NSDocumentController was referring to a NSMenu's itemArray while the array was changing due to KVC & -[NSMenu _setItemArray:]
- Added NSIntegerMapKeyCallBacks
- Added variety of CGBitmapContext, CGImage, CGDataProvider, CGGeometry, CGPath, CGPattern, CGColor C interfaces to the .h's in ApplicationServices and underlying implementation in AppKit.
- Consolidated KGPath/VGPath more. Consolidated KGImage/KGSurface(VGImage) more into read-only and read-write images.
- Moved some KG classes from SWRender to AppKit
- SWRender overhaul to use the whole KG interface (context,color,path,etc.) directly using the C CoreGraphics interface and a common test template for both CG and KG using the C interface.
2008-04-23 17:52:06 +00:00
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
void O2ContextSetTextLineMatrix(O2ContextRef self,O2AffineTransform matrix) {
|
|
|
|
self->_textLineMatrix=matrix;
|
|
|
|
}
|
|
|
|
|
|
|
|
O2AffineTransform O2ContextGetTextLineMatrix(O2ContextRef self) {
|
|
|
|
return self->_textLineMatrix;
|
|
|
|
}
|
|
|
|
|
|
|
|
O2Float O2ContextGetTextLeading(O2ContextRef self) {
|
|
|
|
return O2GStateTextLeading(O2ContextCurrentGState(self));
|
|
|
|
}
|
|
|
|
|
|
|
|
void O2ContextSetTextLeading(O2ContextRef self,O2Float value) {
|
|
|
|
O2GStateSetTextLeading(O2ContextCurrentGState(self),value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void O2ContextSetWordSpacing(O2ContextRef self,O2Float value) {
|
|
|
|
O2GStateSetWordSpacing(O2ContextCurrentGState(self),value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void O2ContextSetTextRise(O2ContextRef self,O2Float value) {
|
|
|
|
O2GStateSetTextRise(O2ContextCurrentGState(self),value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void O2ContextSetTextHorizontalScaling(O2ContextRef self,O2Float value) {
|
|
|
|
O2GStateSetTextHorizontalScaling(O2ContextCurrentGState(self),value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void O2ContextSetEncoding(O2ContextRef self,O2Encoding *value) {
|
|
|
|
O2GStateSetFontEncoding(O2ContextCurrentGState(self),value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void O2ContextSetPDFCharWidths(O2ContextRef self,O2PDFCharWidths *value) {
|
|
|
|
[O2ContextCurrentGState(self) setPDFCharWidths:value];
|
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextSetCTM(O2ContextRef self,O2AffineTransform matrix) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
O2AffineTransform deviceTransform=self->_userToDeviceTransform;
|
|
|
|
|
|
|
|
deviceTransform=O2AffineTransformConcat(matrix,deviceTransform);
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GStateSetDeviceSpaceCTM(O2ContextCurrentGState(self),deviceTransform);
|
2007-03-11 19:28:02 +00:00
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GStateSetUserSpaceCTM(O2ContextCurrentGState(self),matrix);
|
2008-01-02 03:31:21 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextResetClip(O2ContextRef self) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GState *gState=O2ContextCurrentGState(self);
|
|
|
|
|
|
|
|
O2GStateResetClip(gState);
|
|
|
|
|
|
|
|
[self clipToState:O2GStateClipState(gState)];
|
2007-06-26 03:07:44 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2AffineTransform O2ContextGetTextRenderingMatrix(O2ContextRef self) {
|
|
|
|
O2GState *gState=O2ContextCurrentGState(self);
|
2008-06-23 18:58:30 +00:00
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2AffineTransform transformToDevice=gState->_deviceSpaceTransform;
|
|
|
|
O2AffineTransform Tm=self->_textMatrix;
|
|
|
|
|
2011-09-28 17:55:47 +00:00
|
|
|
return O2AffineTransformConcat(Tm,transformToDevice);
|
2010-10-22 15:57:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void O2ContextGetDefaultAdvances(O2ContextRef self,const O2Glyph *glyphs,O2Size *advances,size_t count) {
|
|
|
|
O2GState *gState=O2ContextCurrentGState(self);
|
|
|
|
O2Font *font=O2GStateFont(gState);
|
2018-09-08 11:06:56 +00:00
|
|
|
int intAdvances[count];
|
2010-10-22 15:57:22 +00:00
|
|
|
O2Float unitsPerEm=O2FontGetUnitsPerEm(font);
|
|
|
|
O2Float pointSize=O2GStatePointSize(gState);
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
O2FontGetGlyphAdvances(font,glyphs,count,intAdvances);
|
|
|
|
|
2018-09-02 20:14:39 +00:00
|
|
|
O2Float scale = [font nativeSizeForSize:pointSize]/unitsPerEm;
|
2013-12-09 17:03:21 +00:00
|
|
|
for(i=0;i<count;i++){
|
|
|
|
advances[i].width=intAdvances[i]*scale;
|
2010-10-22 15:57:22 +00:00
|
|
|
advances[i].height=0;
|
|
|
|
}
|
|
|
|
}
|
2010-05-11 15:28:47 +00:00
|
|
|
|
2010-10-22 20:32:04 +00:00
|
|
|
void O2ContextConcatAdvancesToTextMatrix(O2ContextRef self,const O2Size *advances,size_t count){
|
2010-10-22 15:57:22 +00:00
|
|
|
O2AffineTransform Tm=self->_textMatrix;
|
|
|
|
O2Size totalAdvance=O2SizeMake(0,0);
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for(i=0;i<count;i++){
|
|
|
|
O2Size advance=O2SizeApplyAffineTransform(advances[i],Tm);
|
|
|
|
|
|
|
|
totalAdvance.width+=advance.width;
|
|
|
|
totalAdvance.height+=advance.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
self->_textMatrix.tx+=totalAdvance.width;
|
|
|
|
self->_textMatrix.ty+=totalAdvance.height;
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 15:57:22 +00:00
|
|
|
O2GState *O2ContextCurrentGState(O2ContextRef self) {
|
|
|
|
return self->_currentState;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Temporary hacks
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
void O2ContextCopyBits(O2ContextRef self,O2Rect rect,O2Point point,int gState) {
|
2010-05-11 15:28:47 +00:00
|
|
|
if(self==nil)
|
|
|
|
return;
|
|
|
|
|
2009-11-02 16:23:34 +00:00
|
|
|
[self copyBitsInRect:rect toPoint:point gState:gState];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2011-06-22 16:46:35 +00:00
|
|
|
bool O2ContextSupportsGlobalAlpha(O2ContextRef self)
|
|
|
|
{
|
|
|
|
return [self supportsGlobalAlpha];
|
|
|
|
}
|
2013-10-30 11:42:33 +00:00
|
|
|
|
2011-02-20 20:23:36 +00:00
|
|
|
NSData *O2ContextCaptureBitmap(O2ContextRef self,O2Rect rect) {
|
|
|
|
return [self captureBitmapInRect:rect];
|
|
|
|
}
|
2008-02-29 17:56:38 +00:00
|
|
|
|
2013-10-30 11:42:33 +00:00
|
|
|
bool O2ContextIsBitmapContext(O2ContextRef self)
|
|
|
|
{
|
|
|
|
return [self isBitmapContext];
|
|
|
|
}
|
2019-08-14 01:55:33 +00:00
|
|
|
|
|
|
|
void O2ContextSetAllowsFontSmoothing(O2ContextRef self, BOOL allowsFontSmoothing)
|
|
|
|
{
|
|
|
|
self->_allowsFontSmoothing = allowsFontSmoothing;
|
|
|
|
}
|
|
|
|
|
|
|
|
void O2ContextSetAllowsFontSubpixelQuantization(O2ContextRef self, BOOL allowsFontSubpixelQuantization)
|
|
|
|
{
|
|
|
|
self->_allowsFontSubpixelQuantization = allowsFontSubpixelQuantization;
|
|
|
|
}
|
|
|
|
|
|
|
|
void O2ContextSetShouldSubpixelQuantizeFonts(O2ContextRef self, BOOL shouldSubpixelQuantizeFonts)
|
|
|
|
{
|
|
|
|
self->_shouldSubpixelQuantizeFonts = shouldSubpixelQuantizeFonts;
|
|
|
|
}
|
|
|
|
|
|
|
|
void O2ContextSetAllowsFontSubpixelPositioning(O2ContextRef self, BOOL allowsFontSubpixelPositioning)
|
|
|
|
{
|
|
|
|
self->_allowsFontSubpixelPositioning = allowsFontSubpixelPositioning;
|
|
|
|
}
|
|
|
|
|
|
|
|
void O2ContextSetShouldSubpixelPositionFonts(O2ContextRef self, BOOL shouldSubpixelPositionFonts)
|
|
|
|
{
|
|
|
|
self->_shouldSubpixelPositionFonts = shouldSubpixelPositionFonts;
|
|
|
|
}
|
|
|
|
|
2007-02-13 03:41:55 +00:00
|
|
|
@end
|