├── .gitignore ├── README ├── Tests ├── arcs.m ├── ovals.m ├── test.jpg ├── test.png ├── test.tiff ├── qeb2-draw.m ├── World_Map_1689.jpg ├── World_Map_1689.png ├── shadows.m ├── cocoa.m ├── colorspace.m ├── gradients.m ├── GNUmakefile ├── doublebuffer.m ├── paths.m ├── win32.m ├── bitmaps.m ├── images.m ├── x11.m ├── layers.m └── gstate.m ├── Resources ├── coated_FOGRA39L_argl.icc └── LICENSE ├── Source ├── OpalGraphics │ ├── GNUmakefile.postamble │ ├── CGImageDestination-private.h │ ├── CGImageSource-private.h │ ├── cairo │ │ ├── StandardGlyphNames.h │ │ ├── CairoFontX11.h │ │ ├── CairoFontWin32.h │ │ ├── CairoFont.h │ │ └── CairoFont.m │ ├── CGDataConsumer-private.h │ ├── OPLogging.m │ ├── OPPremultiplyAlpha.h │ ├── CGGradient-private.h │ ├── CGPDFStream.m │ ├── CGPDFObject.m │ ├── CGColor-private.h │ ├── CGPDFString.m │ ├── CGPDFOperatorTable.m │ ├── GNUmakefile │ ├── CGFunction.m │ ├── CGImage-private.h │ ├── CGPattern.m │ ├── opal-win32.m │ ├── CGPSConverter.m │ ├── OPLogging.h │ ├── CGPDFContentStream.m │ ├── OPColorTransformLCMS.h │ ├── CGShading.m │ ├── CGDataProvider-private.h │ ├── CGPDFPage.m │ ├── OPColorSpaceIndexed.h │ ├── CGContext-private.h │ ├── OPPath.h │ ├── CGPDFArray.m │ ├── CGPDFDocument.m │ ├── OPImageConversion.h │ ├── CGPDFDictionary.m │ ├── CGPDFScanner.m │ └── CGAffineTransform.m ├── OpalText │ ├── OPSimpleLayoutEngine.h │ ├── CTLine-private.h │ ├── OPLayoutEngine.h │ ├── CTFontTraits.m │ ├── GNUmakefile │ ├── CTParagraphStyle.m │ ├── CTFrame-private.h │ ├── FreeType │ │ ├── OPFreeTypeFont.h │ │ └── OPFreeTypeUtil.h │ ├── CTRun-private.h │ ├── OPSimpleLayoutEngine.m │ ├── CTStringAttributes.m │ ├── Fontconfig │ │ └── OPFontconfigFontCollection.m │ └── CTTextTab.m └── GNUmakefile ├── .github └── workflows │ └── compile.yaml ├── GNUmakefile └── Headers ├── ImageIO ├── ImageIO.h └── ImageIOBase.h ├── CoreGraphics ├── CGEvent.h ├── CGError.h ├── CGEventType.h ├── CGPDFString.h ├── CGPDFStream.h ├── CGLayer.h ├── OPSVGContext.h ├── OPPostScriptContext.h ├── CGPDFOperatorTable.h ├── CGShading.h ├── CGPDFObject.h ├── CGFunction.h ├── CGGradient.h ├── CGDataConsumer.h ├── CGPDFContentStream.h ├── CGPDFPage.h ├── CoreGraphics.h ├── CGPDFDocument.h ├── CGPattern.h ├── CGPDFArray.h ├── CGBitmapContext.h ├── CGBase.h ├── CGPDFScanner.h ├── CGPDFDictionary.h └── CGColor.h └── CoreText ├── CoreText.h ├── CTFontManagerErrors.h ├── CTTextTab.h ├── CTFramesetter.h ├── CTFrame.h ├── CTTypesetter.h ├── CTStringAttributes.h ├── CTFontCollection.h ├── CTGlyphInfo.h ├── CTFontTraits.h └── CTRun.h /.gitignore: -------------------------------------------------------------------------------- 1 | obj 2 | Source/opal 3 | 4 | *.swp 5 | *.orig 6 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnustep/libs-opal/HEAD/README -------------------------------------------------------------------------------- /Tests/arcs.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnustep/libs-opal/HEAD/Tests/arcs.m -------------------------------------------------------------------------------- /Tests/ovals.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnustep/libs-opal/HEAD/Tests/ovals.m -------------------------------------------------------------------------------- /Tests/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnustep/libs-opal/HEAD/Tests/test.jpg -------------------------------------------------------------------------------- /Tests/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnustep/libs-opal/HEAD/Tests/test.png -------------------------------------------------------------------------------- /Tests/test.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnustep/libs-opal/HEAD/Tests/test.tiff -------------------------------------------------------------------------------- /Tests/qeb2-draw.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnustep/libs-opal/HEAD/Tests/qeb2-draw.m -------------------------------------------------------------------------------- /Tests/World_Map_1689.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnustep/libs-opal/HEAD/Tests/World_Map_1689.jpg -------------------------------------------------------------------------------- /Tests/World_Map_1689.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnustep/libs-opal/HEAD/Tests/World_Map_1689.png -------------------------------------------------------------------------------- /Resources/coated_FOGRA39L_argl.icc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnustep/libs-opal/HEAD/Resources/coated_FOGRA39L_argl.icc -------------------------------------------------------------------------------- /Resources/LICENSE: -------------------------------------------------------------------------------- 1 | coated_FOGRA39L_argl.icc: 2 | Copyright (c) 2008 Kai-Uwe Behrmann - http://www.opensource.org/licenses/zlib-license.php 3 | -------------------------------------------------------------------------------- /Source/OpalGraphics/GNUmakefile.postamble: -------------------------------------------------------------------------------- 1 | # GNUmakefile.postamble 2 | 3 | after-install:: 4 | cp -r ../../Headers/ImageIO $(shell gnustep-config --variable=GNUSTEP_SYSTEM_HEADERS)/ImageIO 5 | cp ../../Headers/CoreGraphics/CGImageSource.h $(shell gnustep-config --variable=GNUSTEP_SYSTEM_HEADERS)/ImageIO 6 | cp ../../Headers/CoreGraphics/CGImageDestination.h $(shell gnustep-config --variable=GNUSTEP_SYSTEM_HEADERS)/ImageIO 7 | -------------------------------------------------------------------------------- /Source/OpalGraphics/CGImageDestination-private.h: -------------------------------------------------------------------------------- 1 | #include "CoreGraphics/CGImageDestination.h" 2 | #import 3 | #import 4 | 5 | @interface CGImageDestination : NSObject 6 | { 7 | } 8 | 9 | + (void) registerDestinationClass: (Class)cls; 10 | + (NSArray*) destinationClasses; 11 | + (Class) destinationClassForType: (NSString*)type; 12 | 13 | + (NSArray *)typeIdentifiers; 14 | - (id) initWithDataConsumer: (CGDataConsumerRef)consumer 15 | type: (CFStringRef)type 16 | count: (size_t)count 17 | options: (CFDictionaryRef)opts; 18 | - (void) setProperties: (CFDictionaryRef)properties; 19 | - (void) addImage: (CGImageRef)img properties: (CFDictionaryRef)properties; 20 | - (bool) finalize; 21 | 22 | @end -------------------------------------------------------------------------------- /.github/workflows/compile.yaml: -------------------------------------------------------------------------------- 1 | name: Run GNUstep tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | test: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v3 10 | - name: Prepare 11 | run: | 12 | sudo apt-get update 13 | - name: Install GNUstep 14 | run: | 15 | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/gnustep/tools-scripts/master/gnustep-web-install)" 16 | - name: Install GNUstep Corebase 17 | run: | 18 | cd gnustep/libs-corebase 19 | ./configure 20 | . /usr/GNUstep/System/Library/Makefiles/GNUstep.sh 21 | sudo PATH=$PATH make install 22 | - name: Compile lib-opal 23 | run: | 24 | . /usr/GNUstep/System/Library/Makefiles/GNUstep.sh 25 | make distclean 26 | make 27 | -------------------------------------------------------------------------------- /GNUmakefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | ifeq ($(GNUSTEP_MAKEFILES),) 4 | GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null) 5 | ifeq ($(GNUSTEP_MAKEFILES),) 6 | $(warning ) 7 | $(warning Unable to obtain GNUSTEP_MAKEFILES setting from gnustep-config!) 8 | $(warning Perhaps gnustep-make is not properly installed,) 9 | $(warning so gnustep-config is not in your PATH.) 10 | $(warning ) 11 | $(warning Your PATH is currently $(PATH)) 12 | $(warning ) 13 | endif 14 | endif 15 | 16 | ifeq ($(GNUSTEP_MAKEFILES),) 17 | $(error You need to set GNUSTEP_MAKEFILES before compiling!) 18 | endif 19 | 20 | include $(GNUSTEP_MAKEFILES)/common.make 21 | 22 | PACKAGE_NAME = opal 23 | SUBPROJECTS = \ 24 | Source \ 25 | Tests 26 | 27 | -include GNUmakefile.preamble 28 | include $(GNUSTEP_MAKEFILES)/aggregate.make 29 | -include GNUmakefile.postamble 30 | -------------------------------------------------------------------------------- /Source/OpalGraphics/CGImageSource-private.h: -------------------------------------------------------------------------------- 1 | #include "CoreGraphics/CGImageSource.h" 2 | #import 3 | #import 4 | 5 | @interface CGImageSource : NSObject 6 | { 7 | } 8 | 9 | + (void) registerSourceClass: (Class)cls; 10 | + (NSArray*) sourceClasses; 11 | 12 | + (NSArray *)typeIdentifiers; 13 | - (id)initWithProvider: (CGDataProviderRef)provider; 14 | - (NSDictionary*)propertiesWithOptions: (NSDictionary*)opts; 15 | - (NSDictionary*)propertiesWithOptions: (NSDictionary*)opts atIndex: (size_t)index; 16 | - (size_t)count; 17 | - (CGImageRef)createImageAtIndex: (size_t)index options: (NSDictionary*)opts; 18 | - (CGImageRef)createThumbnailAtIndex: (size_t)index options: (NSDictionary*)opts; 19 | - (CGImageSourceStatus)status; 20 | - (CGImageSourceStatus)statusAtIndex: (size_t)index; 21 | - (NSString*)type; 22 | - (void)updateDataProvider: (CGDataProviderRef)provider finalUpdate: (bool)finalUpdate; 23 | 24 | @end -------------------------------------------------------------------------------- /Headers/ImageIO/ImageIO.h: -------------------------------------------------------------------------------- 1 | /** ImageIO 2 | 3 | Copyright (C) 2017 Free Software Foundation, Inc. 4 | Author: Daniel Ferreira 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef OPAL_ImageIO_h 22 | #define OPAL_ImageIO_h 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /Tests/shadows.m: -------------------------------------------------------------------------------- 1 | #ifdef __APPLE__ 2 | #include 3 | #else 4 | #include 5 | #endif 6 | 7 | #define pi 3.14159265358979323846 8 | 9 | void draw(CGContextRef ctx, CGRect r) 10 | { 11 | CGContextSetRGBFillColor(ctx, 0, 0, 1, 0.5); 12 | CGContextSetRGBStrokeColor(ctx, 0, 0, 0, 1); 13 | CGContextFillRect(ctx, CGRectMake(10,10,r.size.width - 20, r.size.height - 20)); 14 | CGContextStrokeRect(ctx, CGRectMake(10,10,r.size.width - 20, r.size.height - 20)); 15 | 16 | CGContextSetShadow(ctx, CGSizeMake(3.0,3.0), 2.0); 17 | 18 | // Draw some rotated, shadowed squares 19 | CGContextSetRGBFillColor(ctx, 0, 1, 0.5, 1); 20 | CGContextSaveGState(ctx); 21 | CGContextTranslateCTM(ctx, 225, 125); 22 | int i; 23 | for (i = 0; i < 2; i++) { 24 | CGContextRotateCTM(ctx, 0.4); 25 | CGContextFillRect(ctx, CGRectMake(-50,-50,100,100)); 26 | } 27 | CGContextRestoreGState(ctx); 28 | 29 | CGContextSetRGBFillColor(ctx, 1, 0, 0.5, 1); 30 | CGContextFillRect(ctx, CGRectMake(10, 200, 50, 15)); 31 | CGContextFillRect(ctx, CGRectMake(10, 10, 15, 75)); 32 | CGContextFillRect(ctx, CGRectMake(400, 10, 35, 35)); 33 | } 34 | -------------------------------------------------------------------------------- /Source/OpalGraphics/cairo/StandardGlyphNames.h: -------------------------------------------------------------------------------- 1 | /** StandardGlyphNames 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | /** 26 | * Standatd glyph names 0-257 27 | */ 28 | const char * const StandardGlyphNames[258]; -------------------------------------------------------------------------------- /Source/OpalText/OPSimpleLayoutEngine.h: -------------------------------------------------------------------------------- 1 | /** OPSimpleLayoutEngine 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2011 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Mar 2011 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import "OPLayoutEngine.h" 26 | 27 | @interface OPSimpleLayoutEngine : NSObject 28 | { 29 | } 30 | 31 | @end 32 | 33 | -------------------------------------------------------------------------------- /Source/OpalGraphics/CGDataConsumer-private.h: -------------------------------------------------------------------------------- 1 | /** CGDataConsumer 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June, 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #include "CoreGraphics/CGDataConsumer.h" 26 | 27 | size_t OPDataConsumerPutBytes(CGDataConsumerRef dc, const void *buffer, size_t count); -------------------------------------------------------------------------------- /Source/OpalGraphics/cairo/CairoFontX11.h: -------------------------------------------------------------------------------- 1 | /** CairoFontX11 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2006 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June, 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | 26 | #import "CairoFont.h" 27 | 28 | @interface CairoFontX11 : CairoFont 29 | { 30 | 31 | } 32 | @end 33 | -------------------------------------------------------------------------------- /Source/OpalGraphics/cairo/CairoFontWin32.h: -------------------------------------------------------------------------------- 1 | /** CairoFontWin32 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import "CairoFont.h" 26 | #include 27 | #include 28 | 29 | @interface CairoFontWin32 : CairoFont 30 | { 31 | HFONT hfont; 32 | } 33 | @end 34 | -------------------------------------------------------------------------------- /Source/GNUmakefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | ifeq ($(GNUSTEP_MAKEFILES),) 4 | GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null) 5 | ifeq ($(GNUSTEP_MAKEFILES),) 6 | $(error You need to set GNUSTEP_MAKEFILES before compiling!) 7 | endif 8 | endif 9 | 10 | include $(GNUSTEP_MAKEFILES)/common.make 11 | 12 | PACKAGE_NAME = opal 13 | LIBRARY_NAME = libopal 14 | 15 | ifdef NO_OPALTEXT 16 | libopal_SUBPROJECTS = \ 17 | OpalGraphics 18 | else 19 | libopal_SUBPROJECTS = \ 20 | OpalGraphics\ 21 | OpalText 22 | endif 23 | 24 | ifneq ($(GNUSTEP_TARGET_OS), mingw32) 25 | LIBRARIES_DEPEND_UPON += $(shell pkg-config --libs freetype2) -lfontconfig -lX11 -lXrender -lm 26 | LIBRARIES_DEPEND_UPON += $(shell pkg-config --libs cairo) 27 | else 28 | LIBRARIES_DEPEND_UPON += -lgdi32 -lcairo 29 | endif 30 | 31 | LIBRARIES_DEPEND_UPON += $(shell pkg-config --libs lcms2) 32 | LIBRARIES_DEPEND_UPON += $(shell pkg-config --libs libpng) 33 | LIBRARIES_DEPEND_UPON += -ljpeg -ltiff 34 | 35 | libopal_HAS_RESOURCE_BUNDLE = yes 36 | libopal_RESOURCE_FILES = ../Resources/coated_FOGRA39L_argl.icc 37 | 38 | -include GNUmakefile.preamble 39 | include $(GNUSTEP_MAKEFILES)/aggregate.make 40 | include $(GNUSTEP_MAKEFILES)/library.make 41 | -include GNUmakefile.postamble 42 | -------------------------------------------------------------------------------- /Source/OpalGraphics/OPLogging.m: -------------------------------------------------------------------------------- 1 | /** OPLogging 2 | 3 | C Interface to graphics drawing library 4 | 5 | This just defines a single required storage variable for OPLogging.h. 6 | 7 | Copyright (C) 2013 Free Software Foundation, Inc. 8 | 9 | Author: Ivan Vucica 10 | Date: 2013 11 | 12 | This library is free software; you can redistribute it and/or 13 | modify it under the terms of the GNU Lesser General Public 14 | License as published by the Free Software Foundation; either 15 | version 2.1 of the License, or (at your option) any later version. 16 | 17 | This library is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | Lesser General Public License for more details. 21 | 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with this library; if not, write to the Free Software 24 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 25 | */ 26 | 27 | #import "OPLogging.h" 28 | 29 | #if OPAL_LOG_CALLS 30 | int _opal_loggingEnabled = 1; 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /Source/OpalGraphics/cairo/CairoFont.h: -------------------------------------------------------------------------------- 1 | /** CairoFont 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import "internal/CGFontInternal.h" 26 | #include 27 | 28 | @interface CairoFont : CGFont 29 | { 30 | @public 31 | cairo_scaled_font_t *cairofont; 32 | } 33 | 34 | @end 35 | 36 | -------------------------------------------------------------------------------- /Tests/cocoa.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | void draw(CGContextRef ctx, CGRect r); 4 | 5 | @interface MyView : NSView 6 | @end 7 | @implementation MyView 8 | - (void)drawRect: (NSRect)rect 9 | { 10 | CGRect r = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); 11 | draw([[NSGraphicsContext currentContext] graphicsPort], r); 12 | } 13 | @end 14 | 15 | @interface AppDelegate : NSObject 16 | { 17 | NSWindow *win; 18 | NSView *view; 19 | } 20 | @end 21 | 22 | @implementation AppDelegate 23 | 24 | - (void) applicationDidFinishLaunching: (id)notif 25 | { 26 | NSRect r = NSMakeRect(0,0,640,480); 27 | win = [[NSWindow alloc] initWithContentRect: r 28 | styleMask:NSResizableWindowMask | NSTitledWindowMask | NSClosableWindowMask 29 | backing:NSBackingStoreBuffered 30 | defer:NO]; 31 | view = [[MyView alloc] initWithFrame: r]; 32 | [win setContentView: view]; 33 | [win makeKeyAndOrderFront: nil]; 34 | } 35 | 36 | @end 37 | 38 | 39 | 40 | int main(int argc, char *argv[]) 41 | { 42 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 43 | id delegate = [[AppDelegate alloc] init]; 44 | [[NSApplication sharedApplication] setDelegate: delegate]; 45 | [NSApp run]; 46 | [pool release]; 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /Source/OpalText/CTLine-private.h: -------------------------------------------------------------------------------- 1 | /** CTLine 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2011 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Mar 2011 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #include 26 | #include 27 | 28 | /** 29 | * Container of CTRun objects (glyph runs) 30 | */ 31 | @interface CTLine : NSObject 32 | { 33 | NSArray *_runs; 34 | } 35 | 36 | - (id)initWithRuns: (NSArray*)runs; 37 | 38 | @end -------------------------------------------------------------------------------- /Source/OpalText/OPLayoutEngine.h: -------------------------------------------------------------------------------- 1 | /** OPLayoutEngine 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2011 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Mar 2011 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import 26 | #import 27 | 28 | @protocol OPLayoutEngine 29 | 30 | - (CTRunRef) layoutString: (NSString*)chars 31 | withAttributes: (NSDictionary*)attribs; 32 | 33 | @end 34 | 35 | -------------------------------------------------------------------------------- /Source/OpalGraphics/OPPremultiplyAlpha.h: -------------------------------------------------------------------------------- 1 | /** OPPremultiplyAlpha 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: July, 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import "OPImageConversion.h" 26 | #import "CGColorSpace-private.h" 27 | 28 | void OPPremultiplyAlpha( 29 | unsigned char *row, 30 | size_t pixels, 31 | OPImageFormat format, 32 | bool unPremultiply 33 | ); 34 | -------------------------------------------------------------------------------- /Source/OpalGraphics/CGGradient-private.h: -------------------------------------------------------------------------------- 1 | /** CGGradient 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #include "CoreGraphics/CGGradient.h" 26 | 27 | CGColorSpaceRef OPGradientGetColorSpace(CGGradientRef g); 28 | const CGFloat *OPGradientGetComponents(CGGradientRef g); 29 | const CGFloat *OPGradientGetLocations(CGGradientRef g); 30 | size_t OPGradientGetCount(CGGradientRef g); 31 | -------------------------------------------------------------------------------- /Source/OpalGraphics/CGPDFStream.m: -------------------------------------------------------------------------------- 1 | /** CGPDFStream 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import 26 | #include "CoreGraphics/CGPDFStream.h" 27 | 28 | CGPDFDictionaryRef CGPDFStreamGetDictionary(CGPDFStreamRef stream) 29 | { 30 | return nil; 31 | } 32 | 33 | CFDataRef CGPDFStreamCopyData(CGPDFStreamRef stream, CGPDFDataFormat *format) 34 | { 35 | return nil; 36 | } 37 | -------------------------------------------------------------------------------- /Source/OpalGraphics/CGPDFObject.m: -------------------------------------------------------------------------------- 1 | /** CGPDFObject 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import 26 | #include "CoreGraphics/CGPDFObject.h" 27 | 28 | CGPDFObjectType CGPDFObjectGetType(CGPDFObjectRef object) 29 | { 30 | return kCGPDFObjectTypeNull; 31 | } 32 | 33 | bool CGPDFObjectGetValue(CGPDFObjectRef object, CGPDFObjectType type, void *value) 34 | { 35 | return false; 36 | } -------------------------------------------------------------------------------- /Source/OpalText/CTFontTraits.m: -------------------------------------------------------------------------------- 1 | /** CTFontTraits 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Aug 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #include 26 | 27 | /* Constants */ 28 | 29 | const CFStringRef kCTFontSymbolicTrait = @"kCTFontSymbolicTrait"; 30 | const CFStringRef kCTFontWeightTrait = @"kCTFontWeightTrait"; 31 | const CFStringRef kCTFontWidthTrait = @"kCTFontWidthTrait"; 32 | const CFStringRef kCTFontSlantTrait = @"kCTFontSlantTrait"; 33 | 34 | -------------------------------------------------------------------------------- /Source/OpalText/GNUmakefile: -------------------------------------------------------------------------------- 1 | include $(GNUSTEP_MAKEFILES)/common.make 2 | 3 | PACKAGE_NAME = opal 4 | SUBPROJECT_NAME = OpalText 5 | 6 | $(SUBPROJECT_NAME)_OBJC_FILES = $(wildcard *.m) 7 | 8 | ifneq ($(GNUSTEP_TARGET_OS), mingw32) 9 | $(SUBPROJECT_NAME)_OBJC_FILES += Fontconfig/OPFontconfigFontDescriptor.m 10 | $(SUBPROJECT_NAME)_OBJC_FILES += FreeType/OPFreeTypeFont.m 11 | endif 12 | 13 | $(SUBPROJECT_NAME)_HEADER_FILES_DIR = ../../Headers/CoreText 14 | $(SUBPROJECT_NAME)_INCLUDE_DIRS = -I../../Headers 15 | $(SUBPROJECT_NAME)_HEADER_FILES_INSTALL_DIR = CoreText 16 | $(SUBPROJECT_NAME)_HEADER_FILES = \ 17 | CoreText.h\ 18 | CTFont.h\ 19 | CTFontCollection.h\ 20 | CTFontDescriptor.h\ 21 | CTFontManager.h\ 22 | CTFontManagerErrors.h\ 23 | CTFontTraits.h\ 24 | CTFrame.h\ 25 | CTFramesetter.h\ 26 | CTGlyphInfo.h\ 27 | CTLine.h\ 28 | CTParagraphStyle.h\ 29 | CTRun.h\ 30 | CTStringAttributes.h\ 31 | CTTextTab.h\ 32 | CTTypesetter.h\ 33 | SFNTLayoutTypes.h 34 | 35 | ADDITIONAL_OBJCFLAGS += -Wall -g -O0 -std=gnu99 -DINTERNAL_BUILD_OBJC 36 | ADDITIONAL_CPPFLAGS += $(shell pkg-config --cflags cairo) 37 | 38 | ifneq ($(GNUSTEP_TARGET_OS), mingw32) 39 | ADDITIONAL_CPPFLAGS += $(shell pkg-config --cflags freetype2) 40 | else 41 | ADDITIONAL_CPPFLAGS += -D__MINGW__ 42 | endif 43 | 44 | 45 | -include GNUmakefile.preamble 46 | include $(GNUSTEP_MAKEFILES)/subproject.make 47 | -include GNUmakefile.postamble 48 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGEvent.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | CGEvent.h 4 | 5 | Copyright (C) 2012 Free Software Foundation, Inc. 6 | 7 | Author: Amr Aboelela 8 | Date: January 2012 9 | 10 | This file is part of CoreGraphics. 11 | 12 | This library is free software; you can redistribute it and/or 13 | modify it under the terms of the GNU Lesser General Public 14 | License as published by the Free Software Foundation; either 15 | version 2 of the License, or (at your option) any later version. 16 | 17 | This library is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | Lesser General Public License for more details. 21 | 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with this library; see the file COPYING.LIB. 24 | If not, see or write to the 25 | Free Software Foundation, 51 Franklin Street, Fifth Floor, 26 | Boston, MA 02110-1301, USA. 27 | */ 28 | 29 | #import "CGEventType.h" 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | extern int64_t CGEventGetIntegerValueField(CGEventRef event, CGEventField field); 36 | extern CGEventSourceRef CGEventCreateSourceFromEvent(CGEventRef event); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /Tests/colorspace.m: -------------------------------------------------------------------------------- 1 | #ifdef __APPLE__ 2 | #include 3 | #else 4 | #include 5 | #endif 6 | 7 | #include 8 | 9 | void draw(CGContextRef ctx, CGRect rect) 10 | { 11 | CGContextScaleCTM(ctx, rect.size.width, rect.size.height); 12 | 13 | CGColorSpaceRef AdobeRGB, sRGB; 14 | 15 | AdobeRGB = CGColorSpaceCreateWithName(kCGColorSpaceAdobeRGB1998); 16 | sRGB = CGColorSpaceCreateWithName(kCGColorSpaceSRGB); 17 | 18 | const CGFloat full[4] = {0.0, 1.0, 0.0, 1.0}; 19 | const CGFloat partial[4] = {0.0, 0.75, 0.0, 1.0}; 20 | 21 | CGColorRef adobe1, adobe2, srgb1, srgb2; 22 | adobe1 = CGColorCreate(AdobeRGB, full); 23 | adobe2 = CGColorCreate(AdobeRGB, partial); 24 | srgb1 = CGColorCreate(sRGB, full); 25 | srgb2 = CGColorCreate(sRGB, partial); 26 | 27 | /* AdobeRGB 100% green | sRGB 100% green 28 | --------------------+---------------- 29 | AdobeRGB 75% green | sRGB 75% green */ 30 | 31 | CGContextSetFillColorWithColor(ctx, adobe1); 32 | CGContextFillRect(ctx, CGRectMake(0, 0.5, 0.5, 0.5)); 33 | CGContextSetFillColorWithColor(ctx, srgb1); 34 | CGContextFillRect(ctx, CGRectMake(0.5, 0.5, 0.5, 0.5)); 35 | 36 | CGContextSetFillColorWithColor(ctx, adobe2); 37 | CGContextFillRect(ctx, CGRectMake(0, 0, 0.5, 0.5)); 38 | CGContextSetFillColorWithColor(ctx, srgb2); 39 | CGContextFillRect(ctx, CGRectMake(0.5, 0, 0.5, 0.5)); 40 | } 41 | -------------------------------------------------------------------------------- /Tests/gradients.m: -------------------------------------------------------------------------------- 1 | #ifdef __APPLE__ 2 | #include 3 | #else 4 | #include 5 | #endif 6 | 7 | #include 8 | #include 9 | 10 | 11 | void draw(CGContextRef ctx, CGRect rect) 12 | { 13 | CGContextScaleCTM(ctx, rect.size.width, rect.size.height); 14 | 15 | CGGradientRef myGradient; 16 | CGColorSpaceRef myColorspace; 17 | size_t num_locations = 2; 18 | CGFloat locations[2] = { 0.0, 1.0 }; 19 | CGFloat components[8] = { 1.0, 0.5, 0.4, 1.0, // Start color 20 | 0.8, 0.8, 0.3, 1.0 }; // End color 21 | 22 | myColorspace = CGColorSpaceCreateDeviceRGB(); 23 | myGradient = CGGradientCreateWithColorComponents (myColorspace, components, 24 | locations, num_locations); 25 | 26 | 27 | CGPoint myStartPoint, myEndPoint; 28 | CGFloat myStartRadius, myEndRadius; 29 | myStartPoint.x = 0.15; 30 | myStartPoint.y = 0.15; 31 | myEndPoint.x = 0.5; 32 | myEndPoint.y = 0.5; 33 | myStartRadius = 0.1; 34 | myEndRadius = 0.25; 35 | CGContextDrawRadialGradient (ctx, myGradient, myStartPoint, 36 | myStartRadius, myEndPoint, myEndRadius, 37 | kCGGradientDrawsAfterEndLocation); 38 | { 39 | CGPoint myStartPoint, myEndPoint; 40 | myStartPoint.x = 0.0; 41 | myStartPoint.y = 0.0; 42 | myEndPoint.x = 1.0; 43 | myEndPoint.y = 1.0; 44 | CGContextDrawLinearGradient (ctx, myGradient, myStartPoint, myEndPoint, 0); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGError.h: -------------------------------------------------------------------------------- 1 | 2 | /** CGError 3 | 4 | C Interface to graphics drawing library 5 | 6 | Copyright (C) 2017 Free Software Foundation, Inc. 7 | 8 | Author: Daniel Ferreira 9 | Date: Jun 2017 10 | 11 | This library is free software; you can redistribute it and/or 12 | modify it under the terms of the GNU Lesser General Public 13 | License as published by the Free Software Foundation; either 14 | version 2.1 of the License, or (at your option) any later version. 15 | 16 | This library is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | Lesser General Public License for more details. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with this library; if not, write to the Free Software 23 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 | */ 25 | 26 | enum { 27 | kCGErrorSuccess = 0, 28 | 29 | kCGErrorFailure = 1000, 30 | kCGErrorIllegalArgument = 1001, 31 | kCGErrorInvalidConnection = 1002, 32 | kCGErrorInvalidContext = 1003, 33 | kCGErrorCannotComplete = 1004, 34 | kCGErrorNotImplemented = 1006, 35 | kCGErrorRangeCheck = 1007, 36 | kCGErrorTypeCheck = 1008, 37 | kCGErrorInvalidOperation = 1010, 38 | kCGErrorNoneAvailable = 1011, 39 | }; 40 | typedef int CGError; 41 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGEventType.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | CGEventType.h 4 | 5 | Copyright (C) 2012 Free Software Foundation, Inc. 6 | 7 | Author: Amr Aboelela 8 | Date: January 2012 9 | 10 | This file is part of CoreGraphics. 11 | 12 | This library is free software; you can redistribute it and/or 13 | modify it under the terms of the GNU Lesser General Public 14 | License as published by the Free Software Foundation; either 15 | version 2 of the License, or (at your option) any later version. 16 | 17 | This library is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | Lesser General Public License for more details. 21 | 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with this library; see the file COPYING.LIB. 24 | If not, see or write to the 25 | Free Software Foundation, 51 Franklin Street, Fifth Floor, 26 | Boston, MA 02110-1301, USA. 27 | */ 28 | 29 | typedef struct __CGEvent *CGEventRef; 30 | typedef struct __CGEventSource *CGEventSourceRef; 31 | 32 | enum { 33 | kCGScrollWheelEventIsContinuous = 88, 34 | kCGScrollWheelEventFixedPtDeltaAxis1 = 93, 35 | kCGScrollWheelEventFixedPtDeltaAxis2 = 94, 36 | kCGScrollWheelEventPointDeltaAxis1 = 96, 37 | kCGScrollWheelEventPointDeltaAxis2 = 97 38 | }; 39 | typedef int CGEventField; 40 | -------------------------------------------------------------------------------- /Source/OpalGraphics/CGColor-private.h: -------------------------------------------------------------------------------- 1 | /** CGColor 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2006 Free Software Foundation, Inc. 6 | 7 | Author: BALATON Zoltan 8 | Date: 2006 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #include "CoreGraphics/CGColor.h" 26 | 27 | @interface CGColor : NSObject 28 | { 29 | @public 30 | CGColorSpaceRef cspace; 31 | CGFloat *comps; 32 | CGPatternRef pattern; 33 | } 34 | 35 | - (CGColor*) transformToColorSpace: (CGColorSpaceRef)space withRenderingIntent: (CGColorRenderingIntent)intent; 36 | 37 | @end 38 | 39 | CGColorRef OPColorGetTransformedToSpace(CGColorRef clr, CGColorSpaceRef space, CGColorRenderingIntent intent); 40 | 41 | -------------------------------------------------------------------------------- /Source/OpalGraphics/CGPDFString.m: -------------------------------------------------------------------------------- 1 | /** CGPDFString 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import 26 | #include "CoreGraphics/CGPDFString.h" 27 | 28 | size_t CGPDFStringGetLength(CGPDFStringRef string) 29 | { 30 | return 0; 31 | } 32 | 33 | const unsigned char *CGPDFStringGetBytePtr(CGPDFStringRef string) 34 | { 35 | return NULL; 36 | } 37 | 38 | CFStringRef CGPDFStringCopyTextString(CGPDFStringRef string) 39 | { 40 | return nil; 41 | } 42 | 43 | CFDateRef CGPDFStringCopyDate(CGPDFStringRef string) 44 | { 45 | return nil; 46 | } -------------------------------------------------------------------------------- /Source/OpalGraphics/CGPDFOperatorTable.m: -------------------------------------------------------------------------------- 1 | /** CGPDFOperatorTable 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import 26 | #include "CoreGraphics/CGPDFOperatorTable.h" 27 | 28 | CGPDFOperatorTableRef CGPDFOperatorTableCreate() 29 | { 30 | return nil; 31 | } 32 | 33 | void CGPDFOperatorTableSetCallback( 34 | CGPDFOperatorTableRef table, 35 | const char *name, 36 | CGPDFOperatorCallback callback) 37 | { 38 | 39 | } 40 | 41 | CGPDFOperatorTableRef CGPDFOperatorTableRetain(CGPDFOperatorTableRef table) 42 | { 43 | return nil; 44 | } 45 | 46 | void CGPDFOperatorTableRelease(CGPDFOperatorTableRef table) 47 | { 48 | 49 | } -------------------------------------------------------------------------------- /Tests/GNUmakefile: -------------------------------------------------------------------------------- 1 | include $(GNUSTEP_MAKEFILES)/common.make 2 | 3 | ifdef NO_OPALTEXT 4 | TOOL_NAME = qeb2 shadows shapes layers pdf images gradients colorspace paths bitmaps gstate 5 | else 6 | TOOL_NAME = qeb2 shadows shapes layers texttest textlayout pdf images gradients colorspace paths bitmaps gstate doublebuffer 7 | endif 8 | 9 | ifeq ($(GNUSTEP_TARGET_OS), mingw32) 10 | main_file = win32.m 11 | else 12 | main_file = x11.m 13 | endif 14 | 15 | qeb2_OBJC_FILES = $(main_file) qeb2-draw.m 16 | shadows_OBJC_FILES = $(main_file) shadows.m 17 | shapes_OBJC_FILES = $(main_file) arcs.m ovals.m rects.m shapes.m 18 | paths_OBJC_FILES = $(main_file) paths.m 19 | layers_OBJC_FILES = $(main_file) layers.m 20 | texttest_OBJC_FILES = $(main_file) texttest.m 21 | textlayout_OBJC_FILES = $(main_file) textlayout.m 22 | pdf_OBJC_FILES = pdf.m arcs.m ovals.m rects.m 23 | images_OBJC_FILES = $(main_file) images.m 24 | images_RESOURCE_FILES = test.png test.jpg 25 | gradients_OBJC_FILES = $(main_file) gradients.m 26 | colorspace_OBJC_FILES = $(main_file) colorspace.m 27 | bitmaps_OBJC_FILES = $(main_file) bitmaps.m 28 | gstate_OBJC_FILES = $(main_file) gstate.m 29 | doublebuffer_OBJC_FILES = $(main_file) doublebuffer.m 30 | 31 | ifneq ($(GNUSTEP_TARGET_OS), mingw32) 32 | ADDITIONAL_OBJC_LIBS += -lm -lX11 33 | else 34 | ADDITIONAL_OBJC_LIBS += -lgdi32 35 | endif 36 | 37 | ADDITIONAL_OBJCFLAGS += -Wall -g -O0 -std=gnu99 38 | ADDITIONAL_CFLAGS += -Wall -g -O0 -std=gnu99 39 | ADDITIONAL_LDFLAGS += -L../Source/obj 40 | ADDITIONAL_TOOL_LIBS = -lopal 41 | ADDITIONAL_INCLUDE_DIRS = -I../Headers 42 | 43 | -include GNUmakefile.preamble 44 | include $(GNUSTEP_MAKEFILES)/tool.make 45 | -include GNUmakefile.postamble 46 | -------------------------------------------------------------------------------- /Source/OpalText/CTParagraphStyle.m: -------------------------------------------------------------------------------- 1 | /** CTParagraphStyle 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Aug 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #include 26 | 27 | /* Functions */ 28 | 29 | CFTypeID CTParagraphStyleGetTypeID() 30 | { 31 | return (CFTypeID)nil; 32 | } 33 | 34 | CTParagraphStyleRef CTParagraphStyleCreate( 35 | const CTParagraphStyleSetting* settings, 36 | CFIndex settingCount) 37 | { 38 | return nil; 39 | } 40 | 41 | CTParagraphStyleRef CTParagraphStyleCreateCopy(CTParagraphStyleRef paragraphStyle) 42 | { 43 | return nil; 44 | } 45 | 46 | bool CTParagraphStyleGetValueForSpecifier( 47 | CTParagraphStyleRef paragraphStyle, 48 | CTParagraphStyleSpecifier spec, 49 | size_t valueBufferSize, 50 | void* valueBuffer) 51 | { 52 | return false; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /Source/OpalText/CTFrame-private.h: -------------------------------------------------------------------------------- 1 | /** CTFrame 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2011 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Mar 2011 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #include 26 | 27 | 28 | /** 29 | * Container of CTLine objects 30 | */ 31 | @interface CTFrame : NSObject 32 | { 33 | CGPathRef _path; 34 | NSMutableArray *_lines; 35 | NSRange _stringRange; 36 | NSRange _visibleStringRange; 37 | NSDictionary *_attributes; 38 | } 39 | 40 | - (id) initWithPath: (CGPathRef)aPath 41 | stringRange: (NSRange)aRange 42 | attributes: (NSDictionary*)attribs; 43 | - (void) addLine: (CTLineRef)aLine; 44 | - (CGPathRef)path; 45 | - (NSArray*)lines; 46 | - (NSRange)stringRange; 47 | - (NSRange)visibleStringRange; 48 | - (void)setVisibleStringRange: (NSRange)aRange; 49 | - (NSDictionary*)attributes; 50 | - (void)drawOnContext: (CGContextRef)ctx; 51 | 52 | @end -------------------------------------------------------------------------------- /Headers/CoreText/CoreText.h: -------------------------------------------------------------------------------- 1 | /** CoreText 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Aug 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CoreText_h 26 | #define OPAL_CoreText_h 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /Source/OpalGraphics/GNUmakefile: -------------------------------------------------------------------------------- 1 | include $(GNUSTEP_MAKEFILES)/common.make 2 | 3 | PACKAGE_NAME = opal 4 | SUBPROJECT_NAME = OpalGraphics 5 | 6 | $(SUBPROJECT_NAME)_OBJC_FILES = $(wildcard *.m) 7 | $(SUBPROJECT_NAME)_OBJC_FILES += $(wildcard cairo/*.m) 8 | $(SUBPROJECT_NAME)_OBJC_FILES += $(wildcard image/*.m) 9 | 10 | $(SUBPROJECT_NAME)_HEADER_FILES_DIR = ../../Headers/CoreGraphics 11 | $(SUBPROJECT_NAME)_INCLUDE_DIRS = -I../../Headers 12 | $(SUBPROJECT_NAME)_HEADER_FILES_INSTALL_DIR = CoreGraphics 13 | $(SUBPROJECT_NAME)_HEADER_FILES = \ 14 | CGAffineTransform.h \ 15 | CGBase.h \ 16 | CGBitmapContext.h \ 17 | CGColor.h \ 18 | CGColorSpace.h \ 19 | CGContext.h \ 20 | CGError.h \ 21 | CGDataConsumer.h \ 22 | CGDataProvider.h \ 23 | CGFont.h \ 24 | CGFunction.h \ 25 | CGGeometry.h \ 26 | CGGradient.h \ 27 | CGImage.h \ 28 | CGImageDestination.h \ 29 | CGImageSource.h \ 30 | CGLayer.h \ 31 | CGPath.h \ 32 | CGPattern.h \ 33 | CGPDFArray.h \ 34 | CGPDFContentStream.h \ 35 | CGPDFContext.h \ 36 | CGPDFDictionary.h \ 37 | CGPDFDocument.h \ 38 | CGPDFObject.h \ 39 | CGPDFOperatorTable.h \ 40 | CGPDFPage.h \ 41 | CGPDFScanner.h \ 42 | CGPDFString.h \ 43 | CGPDFStream.h \ 44 | CGPSConverter.h \ 45 | CGShading.h \ 46 | CoreGraphics.h \ 47 | CGEvent.h \ 48 | CGEventType.h \ 49 | 50 | ADDITIONAL_OBJCFLAGS += -Wall -g -O0 -std=gnu99 -DINTERNAL_BUILD_OBJC 51 | ADDITIONAL_CPPFLAGS += $(shell pkg-config --cflags cairo) 52 | ADDITIONAL_CPPFLAGS += $(shell pkg-config --cflags lcms2) 53 | 54 | ifneq ($(GNUSTEP_TARGET_OS), mingw32) 55 | ADDITIONAL_CPPFLAGS += $(shell pkg-config --cflags freetype2) 56 | else 57 | ADDITIONAL_CPPFLAGS += -D__MINGW__ 58 | endif 59 | 60 | 61 | -include GNUmakefile.preamble 62 | include $(GNUSTEP_MAKEFILES)/subproject.make 63 | -include GNUmakefile.postamble 64 | -------------------------------------------------------------------------------- /Source/OpalGraphics/CGFunction.m: -------------------------------------------------------------------------------- 1 | /** CGFunction 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import 26 | #include "CoreGraphics/CGFunction.h" 27 | 28 | @interface CGFunction : NSObject 29 | { 30 | @public 31 | } 32 | 33 | @end 34 | 35 | @implementation CGFunction 36 | 37 | @end 38 | 39 | 40 | CGFunctionRef CGFunctionCreate( 41 | void *info, 42 | size_t domainDimension, 43 | const CGFloat *domain, 44 | size_t rangeDimension, 45 | const CGFloat *range, 46 | const CGFunctionCallbacks *callbacks) 47 | { 48 | CGFunctionRef func = [[CGFunction alloc] init]; 49 | 50 | //FIXME 51 | 52 | return func; 53 | } 54 | 55 | CGFunctionRef CGFunctionRetain(CGFunctionRef function) 56 | { 57 | return [function retain]; 58 | } 59 | 60 | void CGFunctionRelease(CGFunctionRef function) 61 | { 62 | [function release]; 63 | } 64 | -------------------------------------------------------------------------------- /Source/OpalGraphics/CGImage-private.h: -------------------------------------------------------------------------------- 1 | /** CGImage 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010,2016 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June, 2010 9 | Author: BALATON Zoltan 10 | Date: 2006 11 | 12 | This library is free software; you can redistribute it and/or 13 | modify it under the terms of the GNU Lesser General Public 14 | License as published by the Free Software Foundation; either 15 | version 2.1 of the License, or (at your option) any later version. 16 | 17 | This library is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | Lesser General Public License for more details. 21 | 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with this library; if not, write to the Free Software 24 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 25 | */ 26 | 27 | #include "CoreGraphics/CGImage.h" 28 | #include "CGDataProvider-private.h" 29 | #include 30 | 31 | @interface CGImage : NSObject 32 | { 33 | @public 34 | bool ismask; 35 | size_t width; 36 | size_t height; 37 | size_t bitsPerComponent; 38 | size_t bitsPerPixel; 39 | size_t bytesPerRow; 40 | CGDataProviderRef dp; 41 | CGFloat *decode; 42 | bool shouldInterpolate; 43 | /* alphaInfo is always AlphaNone for mask */ 44 | CGBitmapInfo bitmapInfo; 45 | /* cspace and intent are only set for image */ 46 | CGColorSpaceRef cspace; 47 | CGColorRenderingIntent intent; 48 | /* used for CGImageCreateWithImageInRect */ 49 | CGRect crop; 50 | cairo_surface_t *surf; 51 | } 52 | @end 53 | 54 | -------------------------------------------------------------------------------- /Source/OpalGraphics/CGPattern.m: -------------------------------------------------------------------------------- 1 | /** CGPattern 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import 26 | #include "CoreGraphics/CGPattern.h" 27 | 28 | @interface CGPattern : NSObject 29 | { 30 | void *info; 31 | } 32 | @end 33 | @implementation CGPattern 34 | @end 35 | 36 | 37 | CGPatternRef CGPatternCreate( 38 | void *info, 39 | CGRect bounds, 40 | CGAffineTransform matrix, 41 | CGFloat xStep, 42 | CGFloat yStep, 43 | CGPatternTiling tiling, 44 | int isColored, 45 | const CGPatternCallbacks *callbacks) 46 | { 47 | CGPatternRef pattern = nil; 48 | 49 | // FIXME 50 | 51 | return pattern; 52 | } 53 | 54 | CFTypeID CGPatternGetTypeID() 55 | { 56 | return (CFTypeID)[CGPattern class]; 57 | } 58 | 59 | CGPatternRef CGPatternRetain(CGPatternRef pattern) 60 | { 61 | return [pattern retain]; 62 | } 63 | 64 | void CGPatternRelease(CGPatternRef pattern) 65 | { 66 | [pattern release]; 67 | } 68 | 69 | 70 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGPDFString.h: -------------------------------------------------------------------------------- 1 | /** CGPDFString 2 | 3 | C Interface to graphics drawing library 4 | - geometry routines 5 | 6 | Copyright (C) 2010 Free Software Foundation, Inc. 7 | Author: Eric Wasylishen 8 | 9 | This library is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU Lesser General Public 11 | License as published by the Free Software Foundation; either 12 | version 2.1 of the License, or (at your option) any later version. 13 | 14 | This library is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this library; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | 24 | #ifndef OPAL_CGPDFString_h 25 | #define OPAL_CGPDFString_h 26 | 27 | /* Data Types */ 28 | 29 | #ifdef INTERNAL_BUILD_OBJC 30 | @class CGPDFString; 31 | typedef CGPDFString* CGPDFStringRef; 32 | #else 33 | typedef struct CGPDFString* CGPDFStringRef; 34 | #endif 35 | 36 | #include 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /* Functions */ 43 | 44 | size_t CGPDFStringGetLength(CGPDFStringRef string); 45 | 46 | const unsigned char *CGPDFStringGetBytePtr(CGPDFStringRef string); 47 | 48 | CFStringRef CGPDFStringCopyTextString(CGPDFStringRef string); 49 | 50 | CFDateRef CGPDFStringCopyDate(CGPDFStringRef string); 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif /* OPAL_CGPDFString_h */ 57 | -------------------------------------------------------------------------------- /Source/OpalGraphics/opal-win32.m: -------------------------------------------------------------------------------- 1 | /** opal-win32 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: 2010 9 | 10 | This file is part of GNUstep 11 | 12 | This library is free software; you can redistribute it and/or 13 | modify it under the terms of the GNU Library General Public 14 | License as published by the Free Software Foundation; either 15 | version 2 of the License, or (at your option) any later version. 16 | 17 | This library is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | Library General Public License for more details. 21 | 22 | You should have received a copy of the GNU Library General Public 23 | License along with this library; if not, write to the Free 24 | Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. 25 | */ 26 | 27 | #ifdef __MINGW__ 28 | 29 | #include 30 | #include 31 | #include "CoreGraphics/CGContext.h" 32 | #include "CGContext-private.h" 33 | // TODO: add OpalWin32Context class 34 | CGContextRef opal_Win32ContextCreate(HDC hdc) 35 | { 36 | CGContextRef ctx; 37 | cairo_surface_t *target; 38 | RECT r; 39 | 40 | target = cairo_win32_surface_create(hdc); 41 | 42 | GetClipBox(hdc, &r); 43 | 44 | ctx = opal_new_CGContext(target, CGSizeMake(r.right - r.left, r.bottom - r.top)); 45 | 46 | cairo_surface_destroy(target); 47 | 48 | return ctx; 49 | } 50 | // TODO: move to OpalWin32Context class 51 | void opal_surface_flush(cairo_surface_t *target) 52 | { 53 | cairo_surface_flush(target); 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /Headers/ImageIO/ImageIOBase.h: -------------------------------------------------------------------------------- 1 | /** ImageIOBase 2 | 3 | Copyright (C) 2017 Free Software Foundation, Inc. 4 | Author: Daniel Ferreira 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef OPAL_ImageIOBase_h 22 | #define OPAL_ImageIOBase_h 23 | 24 | #include 25 | 26 | #define IMAGEIO_AVAILABLE_STARTING(_mac,_iphone) 27 | #define IMAGEIO_AVAILABLE_BUT_DEPRECATED(_mac,_macDep,_iphone,_iphoneDep) 28 | 29 | #ifndef IMAGEIO_EXTERN 30 | #if defined(__MINGW32__) 31 | 32 | #ifdef __cplusplus 33 | #define IMAGEIO_EXTERN extern "C" __declspec(dllexport) 34 | #else 35 | #define IMAGEIO_EXTERN extern __declspec(dllexport) 36 | #endif 37 | 38 | #else 39 | 40 | #if defined(__cplusplus) 41 | #define IMAGEIO_EXTERN extern "C" 42 | #else 43 | #define IMAGEIO_EXTERN extern 44 | #endif 45 | 46 | #endif 47 | #endif 48 | 49 | #if !defined(IMAGEIO_EXTERN_C_BEGIN) 50 | #ifdef __cplusplus 51 | #define IMAGEIO_EXTERN_C_BEGIN extern "C" { 52 | #define IMAGEIO_EXTERN_C_END } 53 | #else 54 | #define IMAGEIO_EXTERN_C_BEGIN 55 | #define IMAGEIO_EXTERN_C_END 56 | #endif 57 | #endif 58 | 59 | #define IIO_HAS_IOSURFACE 0 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /Headers/CoreText/CTFontManagerErrors.h: -------------------------------------------------------------------------------- 1 | /** CTFontManagerErrors 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Aug 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CTFontManagerErrors_h 26 | #define OPAL_CTFontManagerErrors_h 27 | 28 | #include 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /* Data Types */ 35 | 36 | typedef CFIndex CTFontManagerError; 37 | 38 | /* Constants */ 39 | 40 | extern const CFStringRef kCTFontManagerErrorDomain; 41 | extern const CFStringRef kCTFontManagerErrorFontURLsKey; 42 | 43 | enum { 44 | kCTFontManagerErrorFileNotFound = 101, 45 | kCTFontManagerErrorInsufficientPermissions = 102, 46 | kCTFontManagerErrorUnrecognizedFormat = 103, 47 | kCTFontManagerErrorInvalidFontData = 104, 48 | kCTFontManagerErrorAlreadyRegistered = 105, 49 | }; 50 | 51 | enum { 52 | kCTFontManagerErrorNotRegistered = 201, 53 | kCTFontManagerErrorInUse = 202, 54 | kCTFontManagerErrorSystemRequired = 202, 55 | }; 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /Source/OpalGraphics/CGPSConverter.m: -------------------------------------------------------------------------------- 1 | /** CGPSConverter 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #include "CoreGraphics/CGPSConverter.h" 26 | #include "CoreGraphics/CGPDFContext.h" 27 | 28 | CGPSConverterRef CGPSConverterCreate( 29 | void *info, 30 | const CGPSConverterCallbacks *callbacks, 31 | CFDictionaryRef options) 32 | { 33 | return nil; 34 | } 35 | 36 | bool CGPSConverterConvert( 37 | CGPSConverterRef converter, 38 | CGDataProviderRef provider, 39 | CGDataConsumerRef consumer, 40 | CFDictionaryRef options) 41 | { 42 | //CGContextRef ctx = CGPDFContextCreate(consumer, NULL, NULL); 43 | 44 | // Read postscript from the data provider, and draw on ctx 45 | 46 | return true; 47 | } 48 | 49 | bool CGPSConverterAbort(CGPSConverterRef converter) 50 | { 51 | return false; 52 | } 53 | 54 | bool CGPSConverterIsConverting(CGPSConverterRef converter) 55 | { 56 | return false; 57 | } 58 | 59 | CFTypeID CGPSConverterGetTypeID() 60 | { 61 | return (CFTypeID)nil; 62 | } -------------------------------------------------------------------------------- /Source/OpalGraphics/OPLogging.h: -------------------------------------------------------------------------------- 1 | /** OPLogging 2 | 3 | C Interface to graphics drawing library 4 | 5 | This is a helper header to permit a bit easier logging of as many 6 | Opal calls as possible, to generate easily reproducible test cases 7 | from dynamic drawing code. 8 | 9 | Copyright (C) 2013 Free Software Foundation, Inc. 10 | 11 | Author: Ivan Vucica 12 | Date: 2013 13 | 14 | This library is free software; you can redistribute it and/or 15 | modify it under the terms of the GNU Lesser General Public 16 | License as published by the Free Software Foundation; either 17 | version 2.1 of the License, or (at your option) any later version. 18 | 19 | This library is distributed in the hope that it will be useful, 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | Lesser General Public License for more details. 23 | 24 | You should have received a copy of the GNU Lesser General Public 25 | License along with this library; if not, write to the Free Software 26 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #ifndef OPAL_OPLogging_h 30 | #define OPAL_OPLogging_h 31 | 32 | #define OPAL_LOG_CALLS 1 33 | #if OPAL_LOG_CALLS 34 | 35 | extern int _opal_loggingEnabled; 36 | #define OPLOGCALL(fmt, ...) \ 37 | int oldOpalLoggingEnabled = -1; \ 38 | if(_opal_loggingEnabled) \ 39 | { \ 40 | NSDebugLLog(@"OpalCall", @" opal call: */ %s(" fmt "); /* \n", __FUNCTION__, ##__VA_ARGS__); \ 41 | oldOpalLoggingEnabled = _opal_loggingEnabled; \ 42 | _opal_loggingEnabled = 0; \ 43 | } 44 | 45 | #define OPRESTORELOGGING() \ 46 | if (oldOpalLoggingEnabled != -1) \ 47 | _opal_loggingEnabled = oldOpalLoggingEnabled; 48 | 49 | #else 50 | #define OPLOGCALL(fmt, ...); 51 | #define OPRESTORELOGGING() 52 | #endif 53 | 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /Headers/CoreText/CTTextTab.h: -------------------------------------------------------------------------------- 1 | /** CTTextTab 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Aug 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CTTextTab_h 26 | #define OPAL_CTTextTab_h 27 | 28 | #include 29 | #include 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /* Data Types */ 36 | 37 | #ifdef INTERNAL_BUILD_OBJC 38 | @class CTTextTab; 39 | typedef CTTextTab* CTTextTabRef; 40 | #else 41 | typedef struct CTTextTab* CTTextTabRef; 42 | #endif 43 | 44 | /* Constants */ 45 | 46 | extern const CFStringRef kCTTabColumnTerminatorsAttributeName; 47 | 48 | /* Functions */ 49 | 50 | CFTypeID CTTextTabGetTypeID(); 51 | 52 | CTTextTabRef CTTextTabCreate( 53 | CTTextAlignment alignment, 54 | double location, 55 | CFDictionaryRef options 56 | ); 57 | 58 | CTTextAlignment CTTextTabGetAlignment(CTTextTabRef tab); 59 | 60 | double CTTextTabGetLocation(CTTextTabRef tab); 61 | 62 | CFDictionaryRef CTTextTabGetOptions(CTTextTabRef tab); 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /Source/OpalGraphics/CGPDFContentStream.m: -------------------------------------------------------------------------------- 1 | /** CGPDFContentStream 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import 26 | #include "CoreGraphics/CGPDFContentStream.h" 27 | 28 | CGPDFContentStreamRef CGPDFContentStreamCreateWithPage(CGPDFPageRef page) 29 | { 30 | return nil; 31 | } 32 | 33 | CGPDFContentStreamRef CGPDFContentStreamCreateWithStream( 34 | CGPDFStreamRef stream, 35 | CGPDFDictionaryRef streamResources, 36 | CGPDFContentStreamRef parent) 37 | { 38 | return nil; 39 | } 40 | 41 | CGPDFObjectRef CGPDFContentStreamGetResource( 42 | CGPDFContentStreamRef stream, 43 | const char *category, 44 | const char *name) 45 | { 46 | return nil; 47 | } 48 | 49 | CFArrayRef CGPDFContentStreamGetStreams(CGPDFContentStreamRef stream) 50 | { 51 | return nil; 52 | } 53 | 54 | CGPDFContentStreamRef CGPDFContentStreamRetain(CGPDFContentStreamRef stream) 55 | { 56 | return nil; 57 | } 58 | 59 | void CGPDFContentStreamRelease(CGPDFContentStreamRef stream) 60 | { 61 | 62 | } -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGPDFStream.h: -------------------------------------------------------------------------------- 1 | /** CGPDFStream 2 | 3 | C Interface to graphics drawing library 4 | - geometry routines 5 | 6 | Copyright (C) 2010 Free Software Foundation, Inc. 7 | Author: Eric Wasylishen 8 | 9 | This library is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU Lesser General Public 11 | License as published by the Free Software Foundation; either 12 | version 2.1 of the License, or (at your option) any later version. 13 | 14 | This library is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this library; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | 24 | #ifndef OPAL_CGPDFStream_h 25 | #define OPAL_CGPDFStream_h 26 | 27 | /* Data Types */ 28 | 29 | #ifdef INTERNAL_BUILD_OBJC 30 | @class CGPDFStream; 31 | typedef CGPDFStream* CGPDFStreamRef; 32 | #else 33 | typedef struct CGPDFStream* CGPDFStreamRef; 34 | #endif 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /* Constants */ 44 | 45 | enum { 46 | CGPDFDataFormatRaw = 0, 47 | CGPDFDataFormatJPEGEncoded = 1, 48 | CGPDFDataFormatJPEG2000 = 2 49 | }; 50 | typedef int CGPDFDataFormat; 51 | 52 | /* Functions */ 53 | 54 | CGPDFDictionaryRef CGPDFStreamGetDictionary(CGPDFStreamRef stream); 55 | 56 | CFDataRef CGPDFStreamCopyData(CGPDFStreamRef stream, CGPDFDataFormat *format); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif /* OPAL_CGPDFStream_h */ 63 | -------------------------------------------------------------------------------- /Source/OpalGraphics/OPColorTransformLCMS.h: -------------------------------------------------------------------------------- 1 | /** OPColorTransformLCMS 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: July, 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #include 26 | 27 | #include "CoreGraphics/CGColorSpace.h" 28 | 29 | #import "CGColorSpace-private.h" 30 | #import "OPColorSpaceLCMS.h" 31 | 32 | @interface OPColorTransformLCMS : NSObject 33 | { 34 | cmsHTRANSFORM xform; 35 | OPColorSpaceLCMS *source, *dest; 36 | OPImageFormat sourceFormat, destFormat; 37 | CGColorRenderingIntent renderingIntent; 38 | size_t pixelCount; 39 | unsigned char *tempBuffer1, *tempBuffer2; 40 | } 41 | 42 | - (id) initWithSourceSpace: (OPColorSpaceLCMS *)aSourceSpace 43 | destinationSpace: (OPColorSpaceLCMS *)aDestSpace 44 | sourceFormat: (OPImageFormat)aSourceFormat 45 | destinationFormat: (OPImageFormat)aDestFormat 46 | renderingIntent: (CGColorRenderingIntent)anIntent 47 | pixelCount: (size_t)aPixelCount; 48 | 49 | - (void) transformPixelData: (const unsigned char *)input 50 | output: (unsigned char *)output; 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /Source/OpalGraphics/CGShading.m: -------------------------------------------------------------------------------- 1 | /** CGShading 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import 26 | #include "CoreGraphics/CGShading.h" 27 | 28 | @interface CGShading : NSObject 29 | { 30 | 31 | } 32 | @end 33 | @implementation CGShading 34 | @end 35 | 36 | CGShadingRef CGShadingCreateAxial( 37 | CGColorSpaceRef colorspace, 38 | CGPoint start, 39 | CGPoint end, 40 | CGFunctionRef function, 41 | int extendStart, 42 | int extendEnd) 43 | { 44 | return nil; 45 | } 46 | 47 | CGShadingRef CGShadingCreateRadial( 48 | CGColorSpaceRef colorspace, 49 | CGPoint start, 50 | CGFloat startRadius, 51 | CGPoint end, 52 | CGFloat endRadius, 53 | CGFunctionRef function, 54 | int extendStart, 55 | int extendEnd) 56 | { 57 | return nil; 58 | } 59 | 60 | CFTypeID CGShadingGetTypeID() 61 | { 62 | return (CFTypeID)[CGShading class]; 63 | } 64 | 65 | CGShadingRef CGShadingRetain(CGShadingRef shading) 66 | { 67 | return [shading retain]; 68 | } 69 | 70 | void CGShadingRelease(CGShadingRef shading) 71 | { 72 | [shading release]; 73 | } -------------------------------------------------------------------------------- /Tests/doublebuffer.m: -------------------------------------------------------------------------------- 1 | #ifdef __APPLE__ 2 | #include 3 | #else 4 | #include 5 | #endif 6 | 7 | #include 8 | 9 | /* Taken from GSQuartzCore's CABackingStore */ 10 | static CGContextRef createCGBitmapContext(int pixelsWide, 11 | int pixelsHigh) 12 | { 13 | CGContextRef context = NULL; 14 | CGColorSpaceRef colorSpace; 15 | int bitmapBytesPerRow; 16 | 17 | bitmapBytesPerRow = (pixelsWide * 4); 18 | 19 | colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); 20 | 21 | // Let CGBitmapContextCreate() allocate the memory. 22 | // This should be good under Cocoa too. 23 | context = CGBitmapContextCreate(NULL, 24 | pixelsWide, 25 | pixelsHigh, 26 | 8, // bits per component 27 | bitmapBytesPerRow, 28 | colorSpace, 29 | kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst); 30 | 31 | // Note: our use of premultiplied alpha means that we need to 32 | // do alpha blending using: 33 | // GL_SRC_ALPHA, GL_ONE 34 | 35 | CGColorSpaceRelease(colorSpace); 36 | if (context == NULL) 37 | { 38 | NSLog(@"Context not created!"); 39 | return NULL; 40 | } 41 | return context; 42 | } 43 | 44 | void draw_red(CGContextRef ctx, CGRect rect) 45 | { 46 | const CGFloat r = 0.9; 47 | const CGFloat g = 0.0; 48 | const CGFloat b = 0.0; 49 | const CGFloat a = 0.7; 50 | 51 | 52 | CGContextSetRGBFillColor(ctx, r, g, b, a); 53 | CGContextFillRect(ctx, rect); 54 | 55 | } 56 | 57 | void draw(CGContextRef ctx, CGRect rect) 58 | { 59 | CGContextRef ctx1 = createCGBitmapContext(rect.size.width, 60 | rect.size.height); 61 | draw_red(ctx1, rect); 62 | 63 | CGImageRef backingImage = CGBitmapContextCreateImage(ctx1); 64 | 65 | CGContextDrawImage(ctx, rect, backingImage); 66 | } 67 | 68 | 69 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGLayer.h: -------------------------------------------------------------------------------- 1 | /** CGLayer 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2009 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Dec 2009 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CGLayer_h 26 | #define OPAL_CGLayer_h 27 | 28 | /* Data Types */ 29 | 30 | #ifdef INTERNAL_BUILD_OBJC 31 | @class CGLayer; 32 | typedef CGLayer* CGLayerRef; 33 | #else 34 | typedef struct CGLayer* CGLayerRef; 35 | #endif 36 | 37 | #include 38 | #include 39 | 40 | /* Functions */ 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | CGLayerRef CGLayerCreateWithContext( 47 | CGContextRef referenceCtxt, 48 | CGSize size, 49 | CFDictionaryRef auxInfo 50 | ); 51 | 52 | CGLayerRef CGLayerRetain(CGLayerRef layer); 53 | 54 | void CGLayerRelease(CGLayerRef layer); 55 | 56 | CGSize CGLayerGetSize(CGLayerRef layer); 57 | 58 | CGContextRef CGLayerGetContext(CGLayerRef layer); 59 | 60 | void CGContextDrawLayerInRect( 61 | CGContextRef destCtxt, 62 | CGRect rect, 63 | CGLayerRef layer 64 | ); 65 | 66 | void CGContextDrawLayerAtPoint( 67 | CGContextRef destCtxt, 68 | CGPoint point, 69 | CGLayerRef layer 70 | ); 71 | 72 | CFTypeID CGLayerGetTypeID(); 73 | 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /Source/OpalText/FreeType/OPFreeTypeFont.h: -------------------------------------------------------------------------------- 1 | /** OPFreeTypeFont 2 | 3 | Font Handling Class using FreeType2 4 | 5 | Copyright (C) 2011 Free Software Foundation, Inc. 6 | 7 | Author: Niels Grewe 8 | Date: Feb 2011 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | 26 | #include 27 | #include FT_FREETYPE_H 28 | 29 | #import "../OPFont.h" 30 | #include 31 | @interface OPFreeTypeFont: OPFont 32 | { 33 | FT_Face fontFace; 34 | /** 35 | * OPFont can be used simultaneously by multiple threads, so it is 36 | * necessary to lock before we call FreeType, because an FT_Face 37 | * object may be used by only one thread. 38 | */ 39 | NSLock *fontFaceLock; 40 | BOOL isType1; 41 | NSCache *tableCache; 42 | } 43 | 44 | 45 | /** 46 | * This method is called by the initializer to load additional font metrics 47 | * from an extern file. This will happen when the font is not a TrueType or 48 | * OpenType font but a Type-1 font instead. 49 | */ 50 | - (BOOL)attachMetricsForFontAtPath: (NSString*)path; 51 | 52 | /** 53 | * Obtains the truetype table with the corresponding tag. The object is 54 | * disposable and has been marked as accessed on return from the method. The 55 | * caller is resonsible for calling -endContentAccess on it. 56 | */ 57 | - (NSData*)tableForTag: (uint32_t)tag; 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /Source/OpalGraphics/CGDataProvider-private.h: -------------------------------------------------------------------------------- 1 | /** CGDataProvider 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June, 2010 9 | Author: BALATON Zoltan 10 | Date: 2006 11 | 12 | This library is free software; you can redistribute it and/or 13 | modify it under the terms of the GNU Lesser General Public 14 | License as published by the Free Software Foundation; either 15 | version 2.1 of the License, or (at your option) any later version. 16 | 17 | This library is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | Lesser General Public License for more details. 21 | 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with this library; if not, write to the Free Software 24 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 25 | */ 26 | 27 | #import 28 | #include "CoreGraphics/CGDataProvider.h" 29 | 30 | /** 31 | * These functions provide access to the data in a CGDataProvider. 32 | * Sequential or Direct Access functions can be used regardless of the 33 | * internal type of the data provider. 34 | */ 35 | 36 | /* Sequential Access */ 37 | 38 | size_t OPDataProviderGetBytes(CGDataProviderRef dp, void *buffer, size_t count); 39 | 40 | off_t OPDataProviderSkipForward(CGDataProviderRef dp, off_t count); 41 | 42 | void OPDataProviderRewind(CGDataProviderRef dp); 43 | 44 | /* Direct Access */ 45 | 46 | size_t OPDataProviderGetSize(CGDataProviderRef dp); 47 | 48 | const void *OPDataProviderGetBytePointer(CGDataProviderRef dp); 49 | 50 | void OPDataProviderReleaseBytePointer( 51 | CGDataProviderRef dp, 52 | const void *pointer 53 | ); 54 | 55 | size_t OPDataProviderGetBytesAtPosition( 56 | CGDataProviderRef dp, 57 | void *buffer, 58 | off_t position, 59 | size_t count 60 | ); -------------------------------------------------------------------------------- /Source/OpalGraphics/CGPDFPage.m: -------------------------------------------------------------------------------- 1 | /** CGPDFPage 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import 26 | #include "CoreGraphics/CGPDFPage.h" 27 | 28 | CGPDFDocumentRef CGPDFPageGetDocument(CGPDFPageRef page) 29 | { 30 | return nil; 31 | } 32 | 33 | size_t CGPDFPageGetPageNumber(CGPDFPageRef page) 34 | { 35 | return 0; 36 | } 37 | 38 | CGRect CGPDFPageGetBoxRect(CGPDFPageRef page, CGPDFBox box) 39 | { 40 | return CGRectNull; 41 | } 42 | 43 | int CGPDFPageGetRotationAngle(CGPDFPageRef page) 44 | { 45 | return 0; 46 | } 47 | 48 | CGAffineTransform CGPDFPageGetDrawingTransform( 49 | CGPDFPageRef page, 50 | CGPDFBox box, 51 | CGRect rect, 52 | int rotate, 53 | bool preserveAspectRatio) 54 | { 55 | return CGAffineTransformIdentity; 56 | } 57 | 58 | CGPDFDictionaryRef CGPDFPageGetDictionary(CGPDFPageRef page) 59 | { 60 | return nil; 61 | } 62 | 63 | CFTypeID CGPDFPageGetTypeID(void) 64 | { 65 | return (CFTypeID)nil; 66 | } 67 | 68 | CGPDFPageRef CGPDFPageRetain(CGPDFPageRef page) 69 | { 70 | return nil; 71 | } 72 | 73 | void CGPDFPageRelease(CGPDFPageRef page) 74 | { 75 | 76 | } 77 | -------------------------------------------------------------------------------- /Tests/paths.m: -------------------------------------------------------------------------------- 1 | #ifdef __APPLE__ 2 | #include 3 | #else 4 | #include 5 | #endif 6 | #define pi 3.14159265358979323846 7 | 8 | void draw(CGContextRef ctx, CGRect r) 9 | { 10 | CGAffineTransform matrix0 = CGAffineTransformMakeTranslation(150, 0); 11 | 12 | CGMutablePathRef path = CGPathCreateMutable(); 13 | 14 | CGPathAddArc(path, &matrix0, 100, 100, 25, 0, 2 * pi, YES); 15 | CGPathAddArc(path, &matrix0, 200, 200, 50, 0, 0.8 * pi, NO); 16 | CGPathAddArc(path, &matrix0, 300, 300, 50, 1.7 * pi, 1 * pi, NO); 17 | 18 | CGPathMoveToPoint(path, &matrix0, 300, 50); 19 | 20 | CGPathMoveToPoint(path, &matrix0, 300, 100); 21 | CGPathAddCurveToPoint(path, &matrix0, 300, 600, 350, 100, 350, 150); 22 | CGPathAddCurveToPoint(path, &matrix0, 400, 200, 400, 200, 450, 150); 23 | 24 | CGPathRef path2 = CGPathCreateWithRect(CGRectMake(200, 50, 100, 50), NULL); 25 | 26 | CGAffineTransform matrix = CGAffineTransformMakeTranslation(600, 30); 27 | CGMutablePathRef path3 = CGPathCreateMutableCopyByTransformingPath(path2, &matrix); 28 | CGPathAddArcToPoint(path3, NULL, 600, 100, 100, 300, 100); 29 | CGPathMoveToPoint(path3, NULL, 100, 300); 30 | CGPathAddRoundedRect(path3, NULL, CGRectMake(100, 300, 100, 100), 10, 10); 31 | 32 | CGContextAddPath(ctx, (CGPathRef)path); 33 | CGContextAddPath(ctx, path2); 34 | CGContextAddPath(ctx, path3); 35 | 36 | CGPathRef bounding = CGPathCreateWithRect(CGPathGetPathBoundingBox(path), NULL); 37 | CGContextAddPath(ctx, bounding); 38 | 39 | CGMutablePathRef quadCurve = CGPathCreateMutable(); 40 | CGPathMoveToPoint(quadCurve, NULL, 20, 100); 41 | CGPathAddQuadCurveToPoint(quadCurve, NULL, 80, 300, 120, 100); 42 | CGPathAddQuadCurveToPoint(quadCurve, NULL, 140, 10, 180, 200); 43 | CGContextAddPath(ctx, quadCurve); 44 | 45 | CGPathRef bounding2 = CGPathCreateWithRect(CGPathGetPathBoundingBox(quadCurve), NULL); 46 | CGContextAddPath(ctx, bounding2); 47 | CGPathRef bounding3 = CGPathCreateWithRect(CGPathGetBoundingBox(quadCurve), NULL); 48 | CGContextAddPath(ctx, bounding3); 49 | 50 | CGContextStrokePath(ctx); 51 | } 52 | 53 | -------------------------------------------------------------------------------- /Source/OpalGraphics/cairo/CairoFont.m: -------------------------------------------------------------------------------- 1 | /** CairoFont 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import "CairoFont.h" 26 | 27 | 28 | @implementation CairoFont 29 | 30 | - (void) dealloc 31 | { 32 | cairo_scaled_font_destroy(cairofont); 33 | [super dealloc]; 34 | } 35 | 36 | - (bool) canCreatePostScriptSubset: (CGFontPostScriptFormat)format 37 | { 38 | return false; 39 | } 40 | 41 | - (CFDataRef) createPostScriptSubset: (CFStringRef)name 42 | : (CGFontPostScriptFormat)format 43 | : (const CGGlyph[])glyphs 44 | : (size_t)count 45 | : (const CGGlyph[])encoding 46 | { 47 | return NULL; 48 | } 49 | 50 | + (CGFontRef) createWithDataProvider: (CGDataProviderRef)provider 51 | { 52 | // FIXME: implement 53 | return nil; 54 | } 55 | 56 | #ifdef __MINGW__ // FIXME: proper check for fontconfig 57 | typedef void FcPattern; 58 | #endif 59 | + (CGFontRef) createWithFcPattern: (FcPattern *)pat 60 | { 61 | NSLog(@"%s: not implemented in %@", __PRETTY_FUNCTION__, [self class]); 62 | return nil; 63 | } 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/OPSVGContext.h: -------------------------------------------------------------------------------- 1 | /** OPSVGContext 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2006 Free Software Foundation, Inc. 6 | 7 | Author: BALATON Zoltan 8 | Date: 2006 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_OPSVGContext_h 26 | #define OPAL_OPSVGContext_h 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Constants */ 37 | 38 | /** 39 | * Can used as a key in the auxiliaryInfo dictionary with a value of @"1.2" or 40 | * @"1.1" to restrict to a particular SVG version. 41 | */ 42 | extern const CFStringRef kOPSVGContextSVGVersion; 43 | 44 | /* Functions */ 45 | 46 | void OPSVGContextBeginPage(CGContextRef ctx, CFDictionaryRef pageInfo); 47 | 48 | void OPSVGContextClose(CGContextRef ctx); 49 | 50 | CGContextRef OPSVGContextCreate( 51 | CGDataConsumerRef consumer, 52 | const CGRect *mediaBox, 53 | CFDictionaryRef auxiliaryInfo 54 | ); 55 | 56 | CGContextRef OPSVGContextCreateWithURL( 57 | CFURLRef url, 58 | const CGRect *mediaBox, 59 | CFDictionaryRef auxiliaryInfo 60 | ); 61 | 62 | void OPSVGContextEndPage(CGContextRef ctx); 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif /* OPAL_OPSVGContext_h */ 69 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/OPPostScriptContext.h: -------------------------------------------------------------------------------- 1 | /** OPPostScriptContext 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2006 Free Software Foundation, Inc. 6 | 7 | Author: BALATON Zoltan 8 | Date: 2006 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_OPPostScriptContext_h 26 | #define OPAL_OPPostScriptContext_h 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Constants */ 37 | 38 | extern const CFStringRef kOPPostScriptContextIsEPS; 39 | extern const CFStringRef kOPPostScriptContextLanguageLevel; 40 | 41 | /* Functions */ 42 | 43 | void OPPostScriptContextBeginPage(CGContextRef ctx, CFDictionaryRef pageInfo); 44 | 45 | void OPPostScriptContextClose(CGContextRef ctx); 46 | 47 | CGContextRef OPPostScriptContextCreate( 48 | CGDataConsumerRef consumer, 49 | const CGRect *mediaBox, 50 | CFDictionaryRef auxiliaryInfo /* ignored */ 51 | ); 52 | 53 | CGContextRef OPPostScriptContextCreateWithURL( 54 | CFURLRef url, 55 | const CGRect *mediaBox, 56 | CFDictionaryRef auxiliaryInfo /* ignored */ 57 | ); 58 | 59 | void OPPostScriptContextEndPage(CGContextRef ctx); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif /* OPAL_OPPostScriptContext_h */ 66 | -------------------------------------------------------------------------------- /Source/OpalText/CTRun-private.h: -------------------------------------------------------------------------------- 1 | /** CTRun 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2011 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Mar 2011 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #include 26 | 27 | /** 28 | * Container of adjacent glyphs with the same attributes which have been layed out 29 | */ 30 | @interface CTRun : NSObject 31 | { 32 | size_t _count; 33 | CGGlyph *_glyphs; // pointer to C array of glphs 34 | CGSize *_advances; 35 | CGPoint *_positions; 36 | CFIndex *_stringIndices; 37 | CFRange _stringRange; 38 | NSDictionary *_attributes; 39 | CTRunStatus _status; 40 | CGAffineTransform _matrix; 41 | } 42 | 43 | - (CFIndex)glyphCount; 44 | - (NSDictionary*)attributes; 45 | - (CTRunStatus)status; 46 | - (const CGGlyph *)glyphs; 47 | - (const CGPoint *)positions; 48 | - (const CGSize *)advances; 49 | - (const CFIndex *)stringIndices; 50 | - (CFRange)stringRange; 51 | - (double)typographicBoundsForRange: (CFRange)range 52 | ascent: (CGFloat*)ascent 53 | descent: (CGFloat*)descent 54 | leading: (CGFloat*)leading; 55 | - (CGRect)imageBoundsForRange: (CFRange)range 56 | withContext: (CGContextRef)context; 57 | - (CGAffineTransform)matrix; 58 | - (void)drawRange: (CFRange)range onContext: (CGContextRef)ctx; 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGPDFOperatorTable.h: -------------------------------------------------------------------------------- 1 | /** CGPDFOperatorTable 2 | 3 | C Interface to graphics drawing library 4 | - geometry routines 5 | 6 | Copyright (C) 2010 Free Software Foundation, Inc. 7 | Author: Eric Wasylishen 8 | 9 | This library is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU Lesser General Public 11 | License as published by the Free Software Foundation; either 12 | version 2.1 of the License, or (at your option) any later version. 13 | 14 | This library is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this library; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | 24 | #ifndef OPAL_CGPDFOperatorTable_h 25 | #define OPAL_CGPDFOperatorTable_h 26 | 27 | /* Data Types */ 28 | 29 | #ifdef INTERNAL_BUILD_OBJC 30 | @class CGPDFOperatorTable; 31 | typedef CGPDFOperatorTable* CGPDFOperatorTableRef; 32 | #else 33 | typedef struct CGPDFOperatorTable* CGPDFOperatorTableRef; 34 | #endif 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /* Callbacks */ 44 | 45 | typedef void (*CGPDFOperatorCallback)(CGPDFScannerRef scanner, void *info); 46 | 47 | /* Functions */ 48 | 49 | CGPDFOperatorTableRef CGPDFOperatorTableCreate(); 50 | 51 | void CGPDFOperatorTableSetCallback( 52 | CGPDFOperatorTableRef table, 53 | const char *name, 54 | CGPDFOperatorCallback callback 55 | ); 56 | 57 | CGPDFOperatorTableRef CGPDFOperatorTableRetain(CGPDFOperatorTableRef table); 58 | 59 | void CGPDFOperatorTableRelease(CGPDFOperatorTableRef table); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif /* OPAL_CGPDFOperatorTable_h */ 66 | -------------------------------------------------------------------------------- /Source/OpalGraphics/OPColorSpaceIndexed.h: -------------------------------------------------------------------------------- 1 | /** OPColorSpaceIndexed 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: July, 2010 9 | Author: BALATON Zoltan 10 | Date: 2006 11 | 12 | This library is free software; you can redistribute it and/or 13 | modify it under the terms of the GNU Lesser General Public 14 | License as published by the Free Software Foundation; either 15 | version 2.1 of the License, or (at your option) any later version. 16 | 17 | This library is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | Lesser General Public License for more details. 21 | 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with this library; if not, write to the Free Software 24 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 25 | */ 26 | 27 | #include "CoreGraphics/CGColorSpace.h" 28 | #import "CGColorSpace-private.h" 29 | 30 | @interface OPColorSpaceIndexed : NSObject 31 | { 32 | @public 33 | CGColorSpaceRef base; 34 | size_t lastIndex; 35 | unsigned char *table; 36 | } 37 | 38 | - (id)initWithBaseSpace: (CGColorSpaceRef)aBaseSpace 39 | lastIndex: (size_t)aLastIndex 40 | colorTable: (const unsigned char *)aColorTable; 41 | - (size_t) tableSize; 42 | - (CGColorSpaceRef) baseColorSpace; 43 | - (void) getColorTable: (uint8_t*)tableOut; 44 | - (size_t) colorTableCount; 45 | 46 | - (id) colorTransformTo: (id)otherColor 47 | sourceFormat: (OPImageFormat)sourceFormat 48 | destinationFormat: (OPImageFormat)destFormat; 49 | 50 | @end 51 | 52 | @interface OPColorTransformIndexed : NSObject 53 | { 54 | id baseTransform; 55 | } 56 | 57 | - (void) transformPixelData: (const unsigned char *)input 58 | output: (unsigned char *)output; 59 | 60 | @end 61 | 62 | -------------------------------------------------------------------------------- /Source/OpalText/FreeType/OPFreeTypeUtil.h: -------------------------------------------------------------------------------- 1 | /** OPFreeTypeUtil 2 | 3 | Utility functions for FreeType 4 | 5 | Copyright (C) 2011 Free Software Foundation, Inc. 6 | 7 | Author: Niels Grewe 8 | Date: Feb 2011 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import "CoreGraphics/CoreGraphics.h" 26 | 27 | #include 28 | #include FT_FREETYPE_H 29 | 30 | 31 | static inline CGFloat CGFloatFromFT_Fixed(FT_Fixed f) 32 | { 33 | //FT_Fixed is Q16.16 34 | return (f/65536.0); 35 | } 36 | 37 | static inline FT_Fixed FT_FixedFromCGFloat(CGFloat f) 38 | { 39 | return (FT_Fixed)((f * 65536.0) + 0.5); 40 | 41 | } 42 | 43 | static inline CGFloat CGFloatFromFontUnits(NSInteger units, CGFloat pointSize, NSUInteger unitsPerEm) 44 | { 45 | return (((CGFloat)units * pointSize) / (CGFloat)unitsPerEm); 46 | } 47 | 48 | static inline FT_Matrix FT_MatrixFromCGAffineTransform(CGAffineTransform transform) 49 | { 50 | FT_Matrix theMatrix = {FT_FixedFromCGFloat(transform.a), 51 | FT_FixedFromCGFloat(transform.b), 52 | FT_FixedFromCGFloat(transform.c), 53 | FT_FixedFromCGFloat(transform.d)}; 54 | return theMatrix; 55 | } 56 | 57 | /** 58 | * Creates a Q16.16 fixed point translation vector from an affine transform. 59 | */ 60 | static inline FT_Vector FT_VectorQ1616FromCGAffineTransform(CGAffineTransform transform) 61 | { 62 | FT_Vector theVector = {FT_FixedFromCGFloat(transform.tx), FT_FixedFromCGFloat(transform.ty)}; 63 | return theVector; 64 | } 65 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGShading.h: -------------------------------------------------------------------------------- 1 | /** CGShading 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2006 Free Software Foundation, Inc. 6 | 7 | Author: BALATON Zoltan 8 | Date: 2006 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CGShading_h 26 | #define OPAL_CGShading_h 27 | 28 | /* Data Types */ 29 | 30 | #ifdef INTERNAL_BUILD_OBJC 31 | @class CGShading; 32 | typedef CGShading* CGShadingRef; 33 | #else 34 | typedef struct CGShading* CGShadingRef; 35 | #endif 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /* Functions */ 47 | 48 | CGShadingRef CGShadingCreateAxial( 49 | CGColorSpaceRef colorspace, 50 | CGPoint start, 51 | CGPoint end, 52 | CGFunctionRef function, 53 | int extendStart, 54 | int extendEnd 55 | ); 56 | 57 | CGShadingRef CGShadingCreateRadial( 58 | CGColorSpaceRef colorspace, 59 | CGPoint start, 60 | CGFloat startRadius, 61 | CGPoint end, 62 | CGFloat endRadius, 63 | CGFunctionRef function, 64 | int extendStart, 65 | int extendEnd 66 | ); 67 | 68 | CFTypeID CGShadingGetTypeID(); 69 | 70 | CGShadingRef CGShadingRetain(CGShadingRef shading); 71 | 72 | void CGShadingRelease(CGShadingRef shading); 73 | 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | 78 | #endif /* OPAL_CGShading_h */ 79 | -------------------------------------------------------------------------------- /Source/OpalText/OPSimpleLayoutEngine.m: -------------------------------------------------------------------------------- 1 | /** OPSimpleLayoutEngine 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2011 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Mar 2011 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | 26 | #import "OPSimpleLayoutEngine.h" 27 | #import 28 | #import 29 | 30 | @implementation OPSimpleLayoutEngine 31 | 32 | - (CTRunRef) layoutString: (NSString*)chars 33 | withAttributes: (NSDictionary*)attribs 34 | { 35 | const NSUInteger length = [chars length]; 36 | CGGlyph *glyphs = malloc(sizeof(CGGlyph) * length); 37 | unichar *characters = malloc(sizeof(unichar) * length); 38 | CGSize *advances = malloc(sizeof(CGSize) * length); 39 | 40 | CTFontRef font = [attribs objectForKey: kCTFontAttributeName]; 41 | if (font == nil) 42 | { 43 | NSLog(@"OPSimpleLayoutEngine: Error, layoutString:withAttributes: called without a font"); 44 | } 45 | else 46 | { 47 | bool success = CTFontGetGlyphsForCharacters(font, 48 | characters, 49 | glyphs, 50 | length); 51 | 52 | double total = CTFontGetAdvancesForGlyphs(font, 53 | kCTFontDefaultOrientation, 54 | glyphs, 55 | advances, 56 | length); 57 | } 58 | free(glyphs); 59 | free(characters); 60 | free(advances); 61 | 62 | // FIXME: create a CTRun with the glyphs & advances 63 | return nil; 64 | } 65 | 66 | @end 67 | 68 | -------------------------------------------------------------------------------- /Headers/CoreText/CTFramesetter.h: -------------------------------------------------------------------------------- 1 | /** CTFramesetter 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Aug 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CTFramesetter_h 26 | #define OPAL_CTFramesetter_h 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /* Data Types */ 39 | 40 | #ifdef INTERNAL_BUILD_OBJC 41 | @class CTFramesetter; 42 | typedef CTFramesetter* CTFramesetterRef; 43 | #else 44 | typedef struct CTFramesetter* CTFramesetterRef; 45 | #endif 46 | 47 | /* Functions */ 48 | 49 | CFTypeID CTFramesetterGetTypeID(); 50 | 51 | CTFramesetterRef CTFramesetterCreateWithAttributedString(CFAttributedStringRef string); 52 | 53 | CTFrameRef CTFramesetterCreateFrame( 54 | CTFramesetterRef framesetter, 55 | CFRange stringRange, 56 | CGPathRef path, 57 | CFDictionaryRef attributes 58 | ); 59 | 60 | CTTypesetterRef CTFramesetterGetTypesetter(CTFramesetterRef framesetter); 61 | 62 | CGSize CTFramesetterSuggestFrameSizeWithConstraints( 63 | CTFramesetterRef framesetter, 64 | CFRange stringRange, 65 | CFDictionaryRef attributes, 66 | CGSize constraints, 67 | CFRange* fitRange 68 | ); 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGPDFObject.h: -------------------------------------------------------------------------------- 1 | /** CGPDFObject 2 | 3 | C Interface to graphics drawing library 4 | - geometry routines 5 | 6 | Copyright (C) 2010 Free Software Foundation, Inc. 7 | Author: Eric Wasylishen 8 | 9 | This library is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU Lesser General Public 11 | License as published by the Free Software Foundation; either 12 | version 2.1 of the License, or (at your option) any later version. 13 | 14 | This library is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this library; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | 24 | #ifndef OPAL_CGPDFObject_h 25 | #define OPAL_CGPDFObject_h 26 | 27 | #include 28 | 29 | /* Data Types */ 30 | 31 | typedef unsigned char CGPDFBoolean; 32 | 33 | typedef long int CGPDFInteger; 34 | 35 | typedef CGFloat CGPDFReal; 36 | 37 | #ifdef INTERNAL_BUILD_OBJC 38 | @class CGPDFObject; 39 | typedef CGPDFObject* CGPDFObjectRef; 40 | #else 41 | typedef struct CGPDFObject* CGPDFObjectRef; 42 | #endif 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | /* Constants */ 49 | 50 | enum { 51 | kCGPDFObjectTypeNull = 1, 52 | kCGPDFObjectTypeBoolean = 2, 53 | kCGPDFObjectTypeInteger = 3, 54 | kCGPDFObjectTypeReal = 4, 55 | kCGPDFObjectTypeName = 5, 56 | kCGPDFObjectTypeString = 6, 57 | kCGPDFObjectTypeArray = 7, 58 | kCGPDFObjectTypeDictionary = 8, 59 | kCGPDFObjectTypeStream = 9 60 | }; 61 | typedef int CGPDFObjectType; 62 | 63 | /* Functions */ 64 | 65 | CGPDFObjectType CGPDFObjectGetType(CGPDFObjectRef object); 66 | 67 | bool CGPDFObjectGetValue(CGPDFObjectRef object, CGPDFObjectType type, void *value); 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /* OPAL_CGPDFDictionary_h */ 74 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGFunction.h: -------------------------------------------------------------------------------- 1 | /** CGFunction 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2006 Free Software Foundation, Inc. 6 | 7 | Author: BALATON Zoltan 8 | Date: 2006 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CGFunction_h 26 | #define OPAL_CGFunction_h 27 | 28 | /* Data Types */ 29 | 30 | #ifdef INTERNAL_BUILD_OBJC 31 | @class CGFunction; 32 | typedef CGFunction* CGFunctionRef; 33 | #else 34 | typedef struct CGFunction* CGFunctionRef; 35 | #endif 36 | 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /* Callbacks */ 44 | 45 | typedef void (*CGFunctionEvaluateCallback)( 46 | void *info, 47 | const CGFloat *inData, 48 | CGFloat *outData 49 | ); 50 | 51 | typedef void (*CGFunctionReleaseInfoCallback)(void *info); 52 | 53 | typedef struct CGFunctionCallbacks { 54 | unsigned int version; 55 | CGFunctionEvaluateCallback evaluate; 56 | CGFunctionReleaseInfoCallback releaseInfo; 57 | } CGFunctionCallbacks; 58 | 59 | /* Functions */ 60 | 61 | CGFunctionRef CGFunctionCreate( 62 | void *info, 63 | size_t domainDimension, 64 | const CGFloat *domain, 65 | size_t rangeDimension, 66 | const CGFloat *range, 67 | const CGFunctionCallbacks *callbacks 68 | ); 69 | 70 | CGFunctionRef CGFunctionRetain(CGFunctionRef function); 71 | 72 | void CGFunctionRelease(CGFunctionRef function); 73 | 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | 78 | #endif /* OPAL_CGFunction_h */ 79 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGGradient.h: -------------------------------------------------------------------------------- 1 | /** CGGradient 2 | 3 | C Interface to graphics drawing library 4 | - geometry routines 5 | 6 | Copyright (C) 2010 Free Software Foundation, Inc. 7 | Author: Eric Wasylishen 8 | 9 | This library is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU Lesser General Public 11 | License as published by the Free Software Foundation; either 12 | version 2.1 of the License, or (at your option) any later version. 13 | 14 | This library is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this library; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | 24 | #ifndef OPAL_CGGradient_h 25 | #define OPAL_CGGradient_h 26 | 27 | /* Data Types */ 28 | 29 | #ifdef INTERNAL_BUILD_OBJC 30 | @class CGGradient; 31 | typedef CGGradient* CGGradientRef; 32 | #else 33 | typedef struct CGGradient* CGGradientRef; 34 | #endif 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /* Constants */ 44 | 45 | enum { 46 | kCGGradientDrawsBeforeStartLocation = (1 << 0), 47 | kCGGradientDrawsAfterEndLocation = (1 << 1) 48 | }; 49 | typedef int CGGradientDrawingOptions; 50 | 51 | /* Functions */ 52 | 53 | CGGradientRef CGGradientCreateWithColorComponents( 54 | CGColorSpaceRef cs, 55 | const CGFloat components[], 56 | const CGFloat locations[], 57 | size_t count 58 | ); 59 | 60 | CGGradientRef CGGradientCreateWithColors( 61 | CGColorSpaceRef cs, 62 | CFArrayRef colors, 63 | const CGFloat locations[] 64 | ); 65 | 66 | CFTypeID CGGradientGetTypeID(); 67 | 68 | CGGradientRef CGGradientRetain(CGGradientRef grad); 69 | 70 | void CGGradientRelease(CGGradientRef grad); 71 | 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /Source/OpalText/CTStringAttributes.m: -------------------------------------------------------------------------------- 1 | /** CTStringAttribute 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Aug 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #include 26 | 27 | /* Constants */ 28 | 29 | const CFStringRef kCTFontAttributeName = @"kCTFontAttributeName"; 30 | const CFStringRef kCTForegroundColorFromContextAttributeName = @"kCTForegroundColorFromContextAttributeName"; 31 | const CFStringRef kCTKernAttributeName = @"kCTKernAttributeName"; 32 | const CFStringRef kCTLigatureAttributeName = @"kCTLigatureAttributeName"; 33 | const CFStringRef kCTForegroundColorAttributeName = @"kCTForegroundColorAttributeName"; 34 | const CFStringRef kCTParagraphStyleAttributeName = @"kCTParagraphStyleAttributeName"; 35 | const CFStringRef kCTStrokeWidthAttributeName = @"kCTStrokeWidthAttributeName"; 36 | const CFStringRef kCTStrokeColorAttributeName = @"kCTStrokeColorAttributeName"; 37 | const CFStringRef kCTUnderlineStyleAttributeName = @"kCTUnderlineStyleAttributeName"; 38 | const CFStringRef kCTSuperscriptAttributeName = @"kCTSuperscriptAttributeName"; 39 | const CFStringRef kCTUnderlineColorAttributeName = @"kCTUnderlineColorAttributeName"; 40 | const CFStringRef kCTVerticalFormsAttributeName = @"kCTVerticalFormsAttributeName"; 41 | const CFStringRef kCTGlyphInfoAttributeName = @"kCTGlyphInfoAttributeName"; 42 | const CFStringRef kCTCharacterShapeAttributeName = @"kCTCharacterShapeAttributeName"; 43 | 44 | -------------------------------------------------------------------------------- /Tests/win32.m: -------------------------------------------------------------------------------- 1 | #import 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | 9 | extern CGContextRef opal_Win32ContextCreate(HDC dc); 10 | void draw(CGContextRef ctx, CGRect r); 11 | 12 | LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) 13 | { 14 | switch (msg) 15 | { 16 | case WM_PAINT: 17 | { 18 | PAINTSTRUCT ps; 19 | RECT r; 20 | GetClientRect(hwnd, &r); 21 | HDC hdc = BeginPaint(hwnd, &ps); 22 | 23 | CGContextRef ctx = opal_Win32ContextCreate(hdc); 24 | draw(ctx, CGRectMake(0, 0, r.right - r.left, r.bottom - r.top)); 25 | CGContextRelease(ctx); 26 | 27 | EndPaint(hwnd, &ps); 28 | break; 29 | } 30 | 31 | case WM_DESTROY: 32 | PostQuitMessage(0); 33 | break; 34 | 35 | default: 36 | return DefWindowProc(hwnd, msg, wparam, lparam); 37 | } 38 | return 0; 39 | } 40 | 41 | APIENTRY int WinMain(HINSTANCE hInst, HINSTANCE x, LPSTR y, int nCmdShow) 42 | { 43 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 44 | WNDCLASS wc; 45 | HWND hwnd; 46 | MSG msg; 47 | const char *title = "Opal"; 48 | 49 | wc.style = CS_HREDRAW | CS_VREDRAW; 50 | wc.lpfnWndProc = WindowProc; 51 | wc.cbClsExtra = 0; 52 | wc.cbWndExtra = 0; 53 | wc.hInstance = hInst; 54 | wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); 55 | wc.hCursor = LoadCursor(NULL, IDC_ARROW); 56 | wc.hbrBackground = (HBRUSH)COLOR_WINDOWFRAME; 57 | wc.lpszMenuName = NULL; 58 | wc.lpszClassName = title; 59 | 60 | if (!RegisterClass(&wc)) 61 | return 0; 62 | 63 | hwnd = CreateWindow(title, title, WS_OVERLAPPEDWINDOW, 64 | CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, 65 | NULL, NULL, hInst, NULL); 66 | if (!hwnd) 67 | return 0; 68 | 69 | ShowWindow(hwnd,nCmdShow); 70 | UpdateWindow(hwnd); 71 | 72 | while (GetMessage(&msg, NULL, 0, 0) > 0) 73 | { 74 | NSAutoreleasePool *pool2 = [[NSAutoreleasePool alloc] init]; 75 | TranslateMessage(&msg); 76 | DispatchMessage(&msg); 77 | [pool2 release]; 78 | } 79 | [pool release]; 80 | return 0; 81 | } 82 | -------------------------------------------------------------------------------- /Headers/CoreText/CTFrame.h: -------------------------------------------------------------------------------- 1 | /** CTFrame 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Aug 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CTFrame_h 26 | #define OPAL_CTFrame_h 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Data Types */ 38 | 39 | #ifdef INTERNAL_BUILD_OBJC 40 | @class CTFrame; 41 | typedef CTFrame* CTFrameRef; 42 | #else 43 | typedef struct CTFrame* CTFrameRef; 44 | #endif 45 | 46 | /* Constants */ 47 | 48 | extern const CFStringRef kCTFrameProgressionAttributeName; 49 | 50 | enum { 51 | kCTFrameProgressionTopToBottom = 0, 52 | kCTFrameProgressionRightToLeft = 1 53 | }; 54 | typedef int CTFrameProgression; 55 | 56 | /* Functions */ 57 | 58 | CFTypeID CTFrameGetTypeID(); 59 | 60 | CFRange CTFrameGetStringRange(CTFrameRef frame); 61 | 62 | CFRange CTFrameGetVisibleStringRange(CTFrameRef frame); 63 | 64 | CGPathRef CTFrameGetPath(CTFrameRef frame); 65 | 66 | CFDictionaryRef CTFrameGetFrameAttributes(CTFrameRef frame); 67 | 68 | CFArrayRef CTFrameGetLines(CTFrameRef frame); 69 | 70 | void CTFrameGetLineOrigins( 71 | CTFrameRef frame, 72 | CFRange range, 73 | CGPoint origins[] 74 | ); 75 | 76 | void CTFrameDraw( 77 | CTFrameRef frame, 78 | CGContextRef context 79 | ); 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /Headers/CoreText/CTTypesetter.h: -------------------------------------------------------------------------------- 1 | /** CTTypesetter 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Aug 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CTTypesetter_h 26 | #define OPAL_CTTypesetter_h 27 | 28 | #include 29 | #include 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /* Data Types */ 36 | 37 | #ifdef INTERNAL_BUILD_OBJC 38 | @class CTTypesetter; 39 | typedef CTTypesetter* CTTypesetterRef; 40 | #else 41 | typedef struct CTTypesetter* CTTypesetterRef; 42 | #endif 43 | 44 | /* Constants */ 45 | 46 | extern const CFStringRef kCTTypesetterOptionDisableBidiProcessing; 47 | extern const CFStringRef kCTTypesetterOptionForcedEmbeddingLevel; 48 | 49 | /* Functions */ 50 | 51 | CTTypesetterRef CTTypesetterCreateWithAttributedString(CFAttributedStringRef string); 52 | 53 | CTTypesetterRef CTTypesetterCreateWithAttributedStringAndOptions( 54 | CFAttributedStringRef string, 55 | CFDictionaryRef opts 56 | ); 57 | 58 | CTLineRef CTTypesetterCreateLine( 59 | CTTypesetterRef typesetter, 60 | CFRange range 61 | ); 62 | 63 | CFIndex CTTypesetterSuggestClusterBreak( 64 | CTTypesetterRef typesetter, 65 | CFIndex start, 66 | double width 67 | ); 68 | 69 | CFIndex CTTypesetterSuggestLineBreak( 70 | CTTypesetterRef typesetter, 71 | CFIndex start, 72 | double width 73 | ); 74 | 75 | CFTypeID CTTypesetterGetTypeID(); 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /Source/OpalGraphics/CGContext-private.h: -------------------------------------------------------------------------------- 1 | /** CGContext 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2006 Free Software Foundation, Inc. 6 | 7 | Author: BALATON Zoltan 8 | Date: 2006 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CGContext_private_h 26 | #define OPAL_CGContext_private_h 27 | 28 | #import 29 | 30 | #include "CoreGraphics/CGContext.h" 31 | #include 32 | 33 | typedef struct ct_additions ct_additions; 34 | struct ct_additions 35 | { 36 | ct_additions *next; /* for Save/Restore */ 37 | double alpha; 38 | CGColorRef fill_color; 39 | cairo_pattern_t *fill_cp; 40 | CGColorRef stroke_color; 41 | cairo_pattern_t *stroke_cp; 42 | CGColorRef shadow_color; 43 | cairo_pattern_t *shadow_cp; //FIXME: Don't need this 44 | CGSize shadow_offset; 45 | CGFloat shadow_radius; 46 | CGFontRef font; 47 | CGFloat font_size; 48 | CGFloat char_spacing; 49 | CGTextDrawingMode text_mode; 50 | }; 51 | 52 | @interface CGContext : NSObject 53 | { 54 | @public 55 | cairo_t *ct; /* A Cairo context -- destination of this CGContext */ 56 | ct_additions *add; /* Additional things not in Cairo's gstate */ 57 | CGAffineTransform txtmatrix; 58 | CGFloat scale_factor; 59 | CGSize device_size; 60 | } 61 | - (id) initWithSurface: (cairo_surface_t *)target size: (CGSize)size; 62 | - (void) setSize: (CGSize) size; 63 | @end 64 | 65 | 66 | CGContextRef opal_new_CGContext(cairo_surface_t *target, CGSize device_size); 67 | 68 | void opal_draw_surface_in_rect(CGContextRef ctxt, CGRect dest, cairo_surface_t *src, CGRect srcRect); 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /Source/OpalGraphics/OPPath.h: -------------------------------------------------------------------------------- 1 | /** CGPath 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: August 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import 26 | #include "CoreGraphics/CGPath.h" 27 | 28 | 29 | 30 | typedef struct 31 | { 32 | CGPathElementType type; 33 | CGPoint points[3]; 34 | } OPPathElement; 35 | 36 | @interface CGPath : NSObject 37 | { 38 | NSUInteger _count; 39 | OPPathElement *_elementsArray; 40 | } 41 | - (id) initWithCGPath: (CGPathRef)path; 42 | - (NSUInteger) count; 43 | - (CGPathElementType) elementTypeAtIndex: (NSUInteger)index points: (CGPoint*)outPoints; 44 | - (void) addElementWithType: (CGPathElementType)type points: (CGPoint[])points; 45 | - (BOOL) isEqual:(id)otherObj; 46 | - (BOOL) isRect: (CGRect*)outRect; 47 | 48 | @end 49 | 50 | @interface CGMutablePath : CGPath 51 | { 52 | NSUInteger _capacity; 53 | } 54 | 55 | - (void) addElementWithType: (CGPathElementType)type points: (CGPoint[])points; 56 | 57 | @end 58 | 59 | 60 | /* 61 | * Functions and definitions for approximating arcs through bezier curves. 62 | */ 63 | 64 | #define OPPathArcDefaultTolerance 0.1 65 | 66 | /** 67 | * Calculates the number of segments needed to approximate an arc with the given 68 | * radius after applying the affine transform from m. 69 | * FIXME: Uses fixed tolerance to compute the number of segments needed. 70 | */ 71 | NSUInteger 72 | _OPPathRequiredArcSegments(CGFloat angle, 73 | CGFloat radius, 74 | const CGAffineTransform *m); 75 | 76 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGDataConsumer.h: -------------------------------------------------------------------------------- 1 | /** CGDataConsumer 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2006 Free Software Foundation, Inc. 6 | 7 | Author: BALATON Zoltan 8 | Date: 2006 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CGDataConsumer_h 26 | #define OPAL_CGDataConsumer_h 27 | 28 | /* Data Types */ 29 | 30 | #ifdef INTERNAL_BUILD_OBJC 31 | @class CGDataConsumer; 32 | typedef CGDataConsumer* CGDataConsumerRef; 33 | #else 34 | typedef struct CGDataConsumer* CGDataConsumerRef; 35 | #endif 36 | 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /* Callbacks */ 44 | 45 | typedef size_t (*CGDataConsumerPutBytesCallback)( 46 | void *info, 47 | const void *buffer, 48 | size_t count 49 | ); 50 | 51 | typedef void (*CGDataConsumerReleaseInfoCallback)(void *info); 52 | 53 | typedef struct CGDataConsumerCallbacks 54 | { 55 | CGDataConsumerPutBytesCallback putBytes; 56 | CGDataConsumerReleaseInfoCallback releaseConsumer; 57 | } CGDataConsumerCallbacks; 58 | 59 | /* Functions */ 60 | 61 | CGDataConsumerRef CGDataConsumerCreate( 62 | void *info, 63 | const CGDataConsumerCallbacks *callbacks 64 | ); 65 | 66 | CGDataConsumerRef CGDataConsumerCreateWithCFData(CFMutableDataRef data); 67 | 68 | CGDataConsumerRef CGDataConsumerCreateWithURL(CFURLRef url); 69 | 70 | CFTypeID CGDataConsumerGetTypeID(); 71 | 72 | void CGDataConsumerRelease(CGDataConsumerRef consumer); 73 | 74 | CGDataConsumerRef CGDataConsumerRetain(CGDataConsumerRef consumer); 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif /* OPAL_CGDataConsumer_h */ 81 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGPDFContentStream.h: -------------------------------------------------------------------------------- 1 | /** CGPDFContentStream 2 | 3 | C Interface to graphics drawing library 4 | - geometry routines 5 | 6 | Copyright (C) 2010 Free Software Foundation, Inc. 7 | Author: Eric Wasylishen 8 | 9 | This library is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU Lesser General Public 11 | License as published by the Free Software Foundation; either 12 | version 2.1 of the License, or (at your option) any later version. 13 | 14 | This library is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this library; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | 24 | #ifndef OPAL_CGPDFContentStream_h 25 | #define OPAL_CGPDFContentStream_h 26 | 27 | /* Data Types */ 28 | 29 | #ifdef INTERNAL_BUILD_OBJC 30 | @class CGPDFContentStream; 31 | typedef CGPDFContentStream* CGPDFContentStreamRef; 32 | #else 33 | typedef struct CGPDFContentStream* CGPDFContentStreamRef; 34 | #endif 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | /* Functions */ 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | CGPDFContentStreamRef CGPDFContentStreamCreateWithPage(CGPDFPageRef page); 48 | 49 | CGPDFContentStreamRef CGPDFContentStreamCreateWithStream( 50 | CGPDFStreamRef stream, 51 | CGPDFDictionaryRef streamResources, 52 | CGPDFContentStreamRef parent 53 | ); 54 | 55 | CGPDFObjectRef CGPDFContentStreamGetResource( 56 | CGPDFContentStreamRef stream, 57 | const char *category, 58 | const char *name 59 | ); 60 | 61 | CFArrayRef CGPDFContentStreamGetStreams(CGPDFContentStreamRef stream); 62 | 63 | CGPDFContentStreamRef CGPDFContentStreamRetain(CGPDFContentStreamRef stream); 64 | 65 | void CGPDFContentStreamRelease(CGPDFContentStreamRef stream); 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif /* OPAL_CGPDFContentStream_h */ 72 | -------------------------------------------------------------------------------- /Source/OpalGraphics/CGPDFArray.m: -------------------------------------------------------------------------------- 1 | /** CGPDFArray 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import 26 | #include "CoreGraphics/CGPDFArray.h" 27 | 28 | bool CGPDFArrayGetArray(CGPDFArrayRef array, size_t index, CGPDFArrayRef *value) 29 | { 30 | return false; 31 | } 32 | 33 | bool CGPDFArrayGetBoolean(CGPDFArrayRef array, size_t index, CGPDFBoolean *value) 34 | { 35 | return false; 36 | } 37 | 38 | size_t CGPDFArrayGetCount(CGPDFArrayRef array) 39 | { 40 | return 0; 41 | } 42 | 43 | bool CGPDFArrayGetDictionary(CGPDFArrayRef array, size_t index, CGPDFDictionaryRef *value) 44 | { 45 | return false; 46 | } 47 | 48 | bool CGPDFArrayGetInteger(CGPDFArrayRef array, size_t index, CGPDFInteger *value) 49 | { 50 | return false; 51 | } 52 | 53 | bool CGPDFArrayGetName(CGPDFArrayRef array, size_t index, const char **value) 54 | { 55 | return false; 56 | } 57 | 58 | bool CGPDFArrayGetNull(CGPDFArrayRef array, size_t index) 59 | { 60 | return false; 61 | } 62 | 63 | bool CGPDFArrayGetNumber(CGPDFArrayRef array, size_t index, CGPDFReal *value) 64 | { 65 | return false; 66 | } 67 | 68 | bool CGPDFArrayGetObject(CGPDFArrayRef array, size_t index, CGPDFObjectRef *value) 69 | { 70 | return false; 71 | } 72 | 73 | bool CGPDFArrayGetStream(CGPDFArrayRef array, size_t index, CGPDFStreamRef *value) 74 | { 75 | return false; 76 | } 77 | 78 | bool CGPDFArrayGetString(CGPDFArrayRef array, size_t index, CGPDFStringRef *value) 79 | { 80 | return false; 81 | } -------------------------------------------------------------------------------- /Source/OpalGraphics/CGPDFDocument.m: -------------------------------------------------------------------------------- 1 | /** CGPDFDocument 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import 26 | #include "CoreGraphics/CGPDFDocument.h" 27 | 28 | CGPDFDocumentRef CGPDFDocumentCreateWithProvider(CGDataProviderRef provider) 29 | { 30 | return nil; 31 | } 32 | 33 | CGPDFDocumentRef CGPDFDocumentCreateWithURL(CFURLRef url) 34 | { 35 | return nil; 36 | } 37 | 38 | CGPDFDocumentRef CGPDFDocumentRetain(CGPDFDocumentRef document) 39 | { 40 | return nil; 41 | } 42 | 43 | void CGPDFDocumentRelease(CGPDFDocumentRef document) 44 | { 45 | 46 | } 47 | 48 | int CGPDFDocumentGetNumberOfPages(CGPDFDocumentRef document) 49 | { 50 | return 0; 51 | } 52 | 53 | CGRect CGPDFDocumentGetMediaBox(CGPDFDocumentRef document, int page) 54 | { 55 | return CGRectNull; 56 | } 57 | 58 | CGRect CGPDFDocumentGetCropBox(CGPDFDocumentRef document, int page) 59 | { 60 | return CGRectNull; 61 | } 62 | 63 | CGRect CGPDFDocumentGetBleedBox(CGPDFDocumentRef document, int page) 64 | { 65 | return CGRectNull; 66 | } 67 | 68 | CGRect CGPDFDocumentGetTrimBox(CGPDFDocumentRef document, int page) 69 | { 70 | return CGRectNull; 71 | } 72 | 73 | CGRect CGPDFDocumentGetArtBox(CGPDFDocumentRef document, int page) 74 | { 75 | return CGRectNull; 76 | } 77 | 78 | int CGPDFDocumentGetRotationAngle(CGPDFDocumentRef document, int page) 79 | { 80 | return 0; 81 | } 82 | 83 | CGPDFPageRef CGPDFDocumentGetPage( 84 | CGPDFDocumentRef document, int pageNumber) 85 | { 86 | return NULL; 87 | } 88 | -------------------------------------------------------------------------------- /Tests/bitmaps.m: -------------------------------------------------------------------------------- 1 | #ifdef __APPLE__ 2 | #include 3 | #else 4 | #include 5 | #endif 6 | 7 | #include 8 | 9 | static void assert_close(int expected, int actual) 10 | { 11 | assert(abs(expected - actual) < 10); 12 | } 13 | 14 | void draw(CGContextRef ctx, CGRect rect) 15 | { 16 | CGColorSpaceRef cs = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); 17 | 18 | /* cairo only supports the kCGImageAlphaPremultipliedFirst format */ 19 | CGContextRef bmp = CGBitmapContextCreate(NULL, 2, 2, 8, 8, cs, kCGImageAlphaPremultipliedLast); 20 | CGColorSpaceRelease(cs); 21 | 22 | const double r = 1.0; 23 | const double g = 0.9; 24 | const double b = 0.8; 25 | const double a = 0.7; 26 | 27 | /* fill the bottom-left pixel with a semitransparent cream pastel color */ 28 | CGContextSetRGBFillColor(bmp, r, g, b, a); 29 | CGContextFillRect(bmp, CGRectMake(0, 0, 1, 1)); 30 | 31 | { 32 | unsigned char * bytes = CGBitmapContextGetData(bmp); 33 | 34 | /* top row, left column */ 35 | assert_close(0, bytes[0]); // r * a 36 | assert_close(0, bytes[1]); // g * a 37 | assert_close(0, bytes[2]); // b * a 38 | assert_close(0, bytes[3]); // a 39 | 40 | /* top row, right column */ 41 | assert_close(0, bytes[4]); // r * a 42 | assert_close(0, bytes[5]); // g * a 43 | assert_close(0, bytes[6]); // b * a 44 | assert_close(0, bytes[7]); // a 45 | 46 | /* bottom row, left column */ 47 | assert_close(255 * r * a, bytes[8]); // r * a 48 | assert_close(255 * g * a, bytes[9]); // g * a 49 | assert_close(255 * b * a, bytes[10]); // b * a 50 | assert_close(255 * a, bytes[11]); // a 51 | 52 | /* bottom row, right column */ 53 | assert_close(0, bytes[12]); // r * a 54 | assert_close(0, bytes[13]); // g * a 55 | assert_close(0, bytes[14]); // b * a 56 | assert_close(0, bytes[15]); // a 57 | } 58 | 59 | /* fill the window background with black */ 60 | CGContextSetRGBFillColor(ctx, 0, 0, 0, 1); 61 | CGContextFillRect(ctx, rect); 62 | 63 | CGImageRef img = CGBitmapContextCreateImage(bmp); 64 | CGContextRelease(bmp); 65 | 66 | /* draw the bitmap stretched across the window */ 67 | CGContextDrawImage(ctx, rect, img); 68 | 69 | CGImageRelease(img); 70 | } 71 | -------------------------------------------------------------------------------- /Headers/CoreText/CTStringAttributes.h: -------------------------------------------------------------------------------- 1 | /** CTStringAttribute 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Aug 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CTStringAttributes_h 26 | #define OPAL_CTStringAttributes_h 27 | 28 | #include 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /* Constants */ 35 | 36 | extern const CFStringRef kCTFontAttributeName; 37 | extern const CFStringRef kCTForegroundColorFromContextAttributeName; 38 | extern const CFStringRef kCTKernAttributeName; 39 | extern const CFStringRef kCTLigatureAttributeName; 40 | extern const CFStringRef kCTForegroundColorAttributeName; 41 | extern const CFStringRef kCTParagraphStyleAttributeName; 42 | extern const CFStringRef kCTStrokeWidthAttributeName; 43 | extern const CFStringRef kCTStrokeColorAttributeName; 44 | extern const CFStringRef kCTUnderlineStyleAttributeName; 45 | extern const CFStringRef kCTSuperscriptAttributeName; 46 | extern const CFStringRef kCTUnderlineColorAttributeName; 47 | extern const CFStringRef kCTVerticalFormsAttributeName; 48 | extern const CFStringRef kCTGlyphInfoAttributeName; 49 | extern const CFStringRef kCTCharacterShapeAttributeName; 50 | 51 | enum { 52 | kCTUnderlineStyleNone = 0, 53 | kCTUnderlineStyleSingle = 1, 54 | kCTUnderlineStyleThick = 2, 55 | kCTUnderlineStyleDouble = 9 56 | }; 57 | typedef int CTUnderlineStyle; 58 | 59 | enum { 60 | kCTUnderlinePatternSolid = 0x0000, 61 | kCTUnderlinePatternDot = 0x0100, 62 | kCTUnderlinePatternDash = 0x0200, 63 | kCTUnderlinePatternDashDot = 0x0300, 64 | kCTUnderlinePatternDashDotDot = 0x0400 65 | }; 66 | typedef int CTUnderlineStyleModifiers; 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGPDFPage.h: -------------------------------------------------------------------------------- 1 | /** CGPDFPage 2 | 3 | C Interface to graphics drawing library 4 | - geometry routines 5 | 6 | Copyright (C) 2010 Free Software Foundation, Inc. 7 | Author: Eric Wasylishen 8 | 9 | This library is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU Lesser General Public 11 | License as published by the Free Software Foundation; either 12 | version 2.1 of the License, or (at your option) any later version. 13 | 14 | This library is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this library; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | 24 | #ifndef OPAL_CGPDFPage_h 25 | #define OPAL_CGPDFPage_h 26 | 27 | /* Data Types */ 28 | 29 | #ifdef INTERNAL_BUILD_OBJC 30 | @class CGPDFPage; 31 | typedef CGPDFPage* CGPDFPageRef; 32 | #else 33 | typedef struct CGPDFPage* CGPDFPageRef; 34 | #endif 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /* Constants */ 46 | 47 | enum { 48 | kCGPDFMediaBox = 0, 49 | kCGPDFCropBox = 1, 50 | kCGPDFBleedBox = 2, 51 | kCGPDFTrimBox = 3, 52 | kCGPDFArtBox = 4 53 | }; 54 | typedef int CGPDFBox; 55 | 56 | /* Functions */ 57 | 58 | CGPDFDocumentRef CGPDFPageGetDocument(CGPDFPageRef page); 59 | 60 | size_t CGPDFPageGetPageNumber(CGPDFPageRef page); 61 | 62 | CGRect CGPDFPageGetBoxRect(CGPDFPageRef page, CGPDFBox box); 63 | 64 | int CGPDFPageGetRotationAngle(CGPDFPageRef page); 65 | 66 | CGAffineTransform CGPDFPageGetDrawingTransform( 67 | CGPDFPageRef page, 68 | CGPDFBox box, 69 | CGRect rect, 70 | int rotate, 71 | bool preserveAspectRatio 72 | ); 73 | 74 | CGPDFDictionaryRef CGPDFPageGetDictionary(CGPDFPageRef page); 75 | 76 | CFTypeID CGPDFPageGetTypeID(void); 77 | 78 | CGPDFPageRef CGPDFPageRetain(CGPDFPageRef page); 79 | 80 | void CGPDFPageRelease(CGPDFPageRef page); 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif /* OPAL_CGPDFPage_h */ 87 | -------------------------------------------------------------------------------- /Headers/CoreText/CTFontCollection.h: -------------------------------------------------------------------------------- 1 | /** CTFontCollection 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Aug 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CTFontCollection_h 26 | #define OPAL_CTFontCollection_h 27 | 28 | #include 29 | #include 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /* Data Types */ 36 | 37 | #ifdef INTERNAL_BUILD_OBJC 38 | @class CTFontCollection; 39 | typedef CTFontCollection* CTFontCollectionRef; 40 | #else 41 | typedef struct CTFontCollection* CTFontCollectionRef; 42 | #endif 43 | 44 | /* Callbacks */ 45 | 46 | typedef CFComparisonResult (*CTFontCollectionSortDescriptorsCallback)( 47 | CTFontDescriptorRef a, 48 | CTFontDescriptorRef b, 49 | void *info 50 | ); 51 | 52 | /* Constants */ 53 | 54 | extern const CFStringRef kCTFontCollectionRemoveDuplicatesOption; 55 | 56 | /* Functions */ 57 | 58 | CTFontCollectionRef CTFontCollectionCreateCopyWithFontDescriptors( 59 | CTFontCollectionRef base, 60 | CFArrayRef descriptors, 61 | CFDictionaryRef opts 62 | ); 63 | 64 | CTFontCollectionRef CTFontCollectionCreateFromAvailableFonts(CFDictionaryRef opts); 65 | 66 | CFArrayRef CTFontCollectionCreateMatchingFontDescriptors(CTFontCollectionRef collection); 67 | 68 | CFArrayRef CTFontCollectionCreateMatchingFontDescriptorsSortedWithCallback( 69 | CTFontCollectionRef collection, 70 | CTFontCollectionSortDescriptorsCallback cb, 71 | void *info 72 | ); 73 | 74 | CTFontCollectionRef CTFontCollectionCreateWithFontDescriptors( 75 | CFArrayRef descriptors, 76 | CFDictionaryRef opts 77 | ); 78 | 79 | CFTypeID CTFontCollectionGetTypeID(); 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /Source/OpalGraphics/OPImageConversion.h: -------------------------------------------------------------------------------- 1 | /** CGImage-conversion.h 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: July, 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #include 26 | #include 27 | 28 | /** 29 | * To make the internals sane and fast, we only work with these four pixel components 30 | * internally. They are all native-endian. 31 | */ 32 | typedef enum OPComponentFormat 33 | { 34 | kOPComponentFormat8bpc, 35 | kOPComponentFormat16bpc, 36 | kOPComponentFormat32bpc, 37 | kOPComponentFormatFloat32bpc 38 | } OPComponentFormat; 39 | 40 | typedef struct OPImageFormat 41 | { 42 | OPComponentFormat compFormat; 43 | size_t colorComponents; 44 | bool hasAlpha; 45 | bool isAlphaPremultiplied; 46 | bool isAlphaLast; 47 | bool needs32Swap; 48 | // FIXME: More flags are needed 49 | } OPImageFormat; 50 | 51 | size_t OPComponentNumberOfBytes(OPComponentFormat fmt); 52 | size_t OPPixelTotalComponents(OPImageFormat fmt); 53 | size_t OPPixelNumberOfBytes(OPImageFormat fmt); 54 | 55 | 56 | void OPImageFormatLog(OPImageFormat fmt, NSString *msg); 57 | 58 | void OPImageConvert( 59 | unsigned char *dstData, 60 | const unsigned char *srcData, 61 | size_t width, 62 | size_t height, 63 | size_t dstBitsPerComponent, 64 | size_t srcBitsPerComponent, 65 | size_t dstBitsPerPixel, 66 | size_t srcBitsPerPixel, 67 | size_t dstBytesPerRow, 68 | size_t srcBytesPerRow, 69 | CGBitmapInfo dstBitmapInfo, 70 | CGBitmapInfo srcBitmapInfo, 71 | CGColorSpaceRef dstColorSpace, 72 | CGColorSpaceRef srcColorSpace, 73 | CGColorRenderingIntent intent); 74 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CoreGraphics.h: -------------------------------------------------------------------------------- 1 | /** CoreGraphics 2 | 3 | C Interface to graphics drawing library 4 | - geometry routines 5 | 6 | Copyright (C) 2010 Free Software Foundation, Inc. 7 | Author: Eric Wasylishen 8 | 9 | This library is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU Lesser General Public 11 | License as published by the Free Software Foundation; either 12 | version 2.1 of the License, or (at your option) any later version. 13 | 14 | This library is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this library; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | 24 | #ifndef OPAL_CoreGraphics_h 25 | #define OPAL_CoreGraphics_h 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include 60 | 61 | #endif /* OPAL_CoreGraphics_h */ 62 | -------------------------------------------------------------------------------- /Headers/CoreText/CTGlyphInfo.h: -------------------------------------------------------------------------------- 1 | /** CTGlyphInfo 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Aug 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CTGlyphInfo_h 26 | #define OPAL_CTGlyphInfo_h 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Data Types */ 37 | 38 | #ifdef INTERNAL_BUILD_OBJC 39 | @class CTGlyphInfo; 40 | typedef CTGlyphInfo* CTGlyphInfoRef; 41 | #else 42 | typedef struct CTGlyphInfo* CTGlyphInfoRef; 43 | #endif 44 | 45 | /* Constants */ 46 | 47 | enum { 48 | kCTIdentityMappingCharacterCollection = 0, 49 | kCTAdobeCNS1CharacterCollection = 1, 50 | kCTAdobeGB1CharacterCollection = 2, 51 | kCTAdobeJapan1CharacterCollection = 3, 52 | kCTAdobeJapan2CharacterCollection = 4, 53 | kCTAdobeKorea1CharacterCollection = 5 54 | }; 55 | typedef int CTCharacterCollection; 56 | 57 | /* Functions */ 58 | 59 | CFTypeID CTGlyphInfoGetTypeID(); 60 | 61 | CTGlyphInfoRef CTGlyphInfoCreateWithGlyphName( 62 | CFStringRef glyphName, 63 | CTFontRef font, 64 | CFStringRef baseString 65 | ); 66 | 67 | CTGlyphInfoRef CTGlyphInfoCreateWithGlyph( 68 | CGGlyph glyph, 69 | CTFontRef font, 70 | CFStringRef baseString 71 | ); 72 | 73 | CTGlyphInfoRef CTGlyphInfoCreateWithCharacterIdentifier( 74 | CGFontIndex cid, 75 | CTCharacterCollection collection, 76 | CFStringRef baseString 77 | ); 78 | 79 | CFStringRef CTGlyphInfoGetGlyphName(CTGlyphInfoRef glyphInfo); 80 | 81 | CGFontIndex CTGlyphInfoGetCharacterIdentifier(CTGlyphInfoRef glyphInfo); 82 | 83 | CTCharacterCollection CTGlyphInfoGetCharacterCollection(CTGlyphInfoRef glyphInfo); 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /Source/OpalGraphics/CGPDFDictionary.m: -------------------------------------------------------------------------------- 1 | /** CGPDFDictionary 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import 26 | #include "CoreGraphics/CGPDFDictionary.h" 27 | 28 | 29 | void CGPDFDictionaryApplyFunction(CGPDFDictionaryRef dict, CGPDFDictionaryApplierFunction function, void *info) 30 | { 31 | 32 | } 33 | 34 | size_t CGPDFDictionaryGetCount(CGPDFDictionaryRef dict) 35 | { 36 | return 0; 37 | } 38 | 39 | bool CGPDFDictionaryGetArray(CGPDFDictionaryRef dict, const char *key, CGPDFArrayRef *value) 40 | { 41 | return false; 42 | } 43 | 44 | bool CGPDFDictionaryGetBoolean(CGPDFDictionaryRef dict, const char *key, CGPDFBoolean *value) 45 | { 46 | return false; 47 | } 48 | 49 | bool CGPDFDictionaryGetDictionary(CGPDFDictionaryRef dict, const char *key, CGPDFDictionaryRef *value) 50 | { 51 | return false; 52 | } 53 | 54 | bool CGPDFDictionaryGetInteger(CGPDFDictionaryRef dict, const char *key, CGPDFInteger *value) 55 | { 56 | return false; 57 | } 58 | 59 | bool CGPDFDictionaryGetName(CGPDFDictionaryRef dict, const char *key, const char **value) 60 | { 61 | return false; 62 | } 63 | 64 | bool CGPDFDictionaryGetNumber(CGPDFDictionaryRef dict, const char *key, CGPDFReal *value) 65 | { 66 | return false; 67 | } 68 | 69 | bool CGPDFDictionaryGetObject(CGPDFDictionaryRef dict, const char *key, CGPDFObjectRef *value) 70 | { 71 | return false; 72 | } 73 | 74 | bool CGPDFDictionaryGetStream(CGPDFDictionaryRef dict, const char *key, CGPDFStreamRef *value) 75 | { 76 | return false; 77 | } 78 | 79 | bool CGPDFDictionaryGetString(CGPDFDictionaryRef dict, const char *key, CGPDFStringRef *value) 80 | { 81 | return false; 82 | } 83 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGPDFDocument.h: -------------------------------------------------------------------------------- 1 | /** CGPDFDocument 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2006 Free Software Foundation, Inc. 6 | 7 | Author: BALATON Zoltan 8 | Date: 2006 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CGPDFDocument_h 26 | #define OPAL_CGPDFDocument_h 27 | 28 | /* Data Types */ 29 | 30 | #ifdef INTERNAL_BUILD_OBJC 31 | @class CGPDFDocument; 32 | typedef CGPDFDocument* CGPDFDocumentRef; 33 | #else 34 | typedef struct CGPDFDocument* CGPDFDocumentRef; 35 | #endif 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /* Functions */ 48 | 49 | CGPDFDocumentRef CGPDFDocumentCreateWithProvider(CGDataProviderRef provider); 50 | 51 | CGPDFDocumentRef CGPDFDocumentCreateWithURL(CFURLRef url); 52 | 53 | CGPDFDocumentRef CGPDFDocumentRetain(CGPDFDocumentRef document); 54 | 55 | void CGPDFDocumentRelease(CGPDFDocumentRef document); 56 | 57 | int CGPDFDocumentGetNumberOfPages(CGPDFDocumentRef document); 58 | 59 | CGRect CGPDFDocumentGetMediaBox(CGPDFDocumentRef document, int page); 60 | 61 | CGRect CGPDFDocumentGetCropBox(CGPDFDocumentRef document, int page); 62 | 63 | CGRect CGPDFDocumentGetBleedBox(CGPDFDocumentRef document, int page); 64 | 65 | CGRect CGPDFDocumentGetTrimBox(CGPDFDocumentRef document, int page); 66 | 67 | CGRect CGPDFDocumentGetArtBox(CGPDFDocumentRef document, int page); 68 | 69 | int CGPDFDocumentGetRotationAngle(CGPDFDocumentRef document, int page); 70 | 71 | CGPDFPageRef CGPDFDocumentGetPage( 72 | CGPDFDocumentRef document, int pageNumber); 73 | 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | 78 | #endif /* OPAL_CGPDFDocument_h */ 79 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGPattern.h: -------------------------------------------------------------------------------- 1 | /** CGPattern 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2006 Free Software Foundation, Inc. 6 | 7 | Author: BALATON Zoltan 8 | Date: 2006 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CGPattern_h 26 | #define OPAL_CGPattern_h 27 | 28 | /* Data Types */ 29 | 30 | #ifdef INTERNAL_BUILD_OBJC 31 | @class CGPattern; 32 | typedef CGPattern* CGPatternRef; 33 | #else 34 | typedef struct CGPattern* CGPatternRef; 35 | #endif 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /* Constants */ 47 | 48 | enum 49 | { 50 | kCGPatternTilingNoDistortion = 0, 51 | kCGPatternTilingConstantSpacingMinimalDistortion = 1, 52 | kCGPatternTilingConstantSpacing = 2 53 | }; 54 | typedef int CGPatternTiling; 55 | 56 | /* Callbacks */ 57 | 58 | typedef void(*CGPatternDrawPatternCallback)(void *info, CGContextRef ctx); 59 | 60 | typedef void(*CGPatternReleaseInfoCallback)(void *info); 61 | 62 | typedef struct CGPatternCallbacks { 63 | unsigned int version; 64 | CGPatternDrawPatternCallback drawPattern; 65 | CGPatternReleaseInfoCallback releaseInfo; 66 | } CGPatternCallbacks; 67 | 68 | /* Functions */ 69 | 70 | CGPatternRef CGPatternCreate( 71 | void *info, 72 | CGRect bounds, 73 | CGAffineTransform matrix, 74 | CGFloat xStep, 75 | CGFloat yStep, 76 | CGPatternTiling tiling, 77 | int isColored, 78 | const CGPatternCallbacks *callbacks 79 | ); 80 | 81 | CFTypeID CGPatternGetTypeID(); 82 | 83 | void CGPatternRelease(CGPatternRef pattern); 84 | 85 | CGPatternRef CGPatternRetain(CGPatternRef pattern); 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif /* OPAL_CGPattern_h */ 92 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGPDFArray.h: -------------------------------------------------------------------------------- 1 | /** CGPDFArray 2 | 3 | C Interface to graphics drawing library 4 | - geometry routines 5 | 6 | Copyright (C) 2010 Free Software Foundation, Inc. 7 | Author: Eric Wasylishen 8 | 9 | This library is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU Lesser General Public 11 | License as published by the Free Software Foundation; either 12 | version 2.1 of the License, or (at your option) any later version. 13 | 14 | This library is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this library; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | 24 | #ifndef OPAL_CGPDFArray_h 25 | #define OPAL_CGPDFArray_h 26 | 27 | /* Data Types */ 28 | 29 | #ifdef INTERNAL_BUILD_OBJC 30 | @class CGPDFArray; 31 | typedef CGPDFArray* CGPDFArrayRef; 32 | #else 33 | typedef struct CGPDFArray* CGPDFArrayRef; 34 | #endif 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /* Functions */ 47 | 48 | bool CGPDFArrayGetArray(CGPDFArrayRef array, size_t index, CGPDFArrayRef *value); 49 | 50 | bool CGPDFArrayGetBoolean(CGPDFArrayRef array, size_t index, CGPDFBoolean *value); 51 | 52 | size_t CGPDFArrayGetCount(CGPDFArrayRef array); 53 | 54 | bool CGPDFArrayGetDictionary(CGPDFArrayRef array, size_t index, CGPDFDictionaryRef *value); 55 | 56 | bool CGPDFArrayGetInteger(CGPDFArrayRef array, size_t index, CGPDFInteger *value); 57 | 58 | bool CGPDFArrayGetName(CGPDFArrayRef array, size_t index, const char **value); 59 | 60 | bool CGPDFArrayGetNull(CGPDFArrayRef array, size_t index); 61 | 62 | bool CGPDFArrayGetNumber(CGPDFArrayRef array, size_t index, CGPDFReal *value); 63 | 64 | bool CGPDFArrayGetObject(CGPDFArrayRef array, size_t index, CGPDFObjectRef *value); 65 | 66 | bool CGPDFArrayGetStream(CGPDFArrayRef array, size_t index, CGPDFStreamRef *value); 67 | 68 | bool CGPDFArrayGetString(CGPDFArrayRef array, size_t index, CGPDFStringRef *value); 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | #endif /* OPAL_CGPDFArray_h */ 75 | -------------------------------------------------------------------------------- /Source/OpalText/Fontconfig/OPFontconfigFontCollection.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Collection of font descriptors 3 | */ 4 | @interface CTFontCollection : NSObject 5 | { 6 | NSArray *_descriptors; 7 | } 8 | 9 | - (id)initWithAvailableFontsWithOptions: (NSDictionary*)opts; 10 | - (id)initWithFontDescriptors: (NSArray*)descriptors options: (NSDictionary*)opts; 11 | 12 | - (CTFontCollection*)collectionByAddingFontDescriptors: (NSArray*)descriptors 13 | options: (NSDictionary*)opts; 14 | - (NSArray*)fontDescriptors; 15 | - (NSArray*)fontDescriptorsSortedWithCallback: (CTFontCollectionSortDescriptorsCallback)cb 16 | info: (void*)info; 17 | 18 | @end 19 | 20 | @implementation CTFontCollection 21 | 22 | - (id)initWithAvailableFonts 23 | { 24 | 25 | FcPattern *pat = FcPatternCreate(); 26 | 27 | // Request all of the attributes we are interested in 28 | FcObjectSet *os = FcObjectSetBuild( 29 | FC_FILE, 30 | FC_FAMILY, 31 | FC_FULLNAME, 32 | FC_STYLE, 33 | FC_SLANT, 34 | FC_WEIGHT, 35 | FC_WIDTH, 36 | FC_SPACING, 37 | FC_SIZE, 38 | FC_MATRIX, 39 | FC_CHARSET, 40 | FC_LANG, 41 | FC_VERTICAL_LAYOUT, 42 | FC_OUTLINE, 43 | NULL); 44 | 45 | FcFontSet *fs = FcFontList(NULL, pat, os); 46 | FcPatternDestroy(pat); 47 | FcObjectSetDestroy(os); 48 | 49 | 50 | } 51 | 52 | - (id)initWithFontDescriptors: (NSArray*)descriptors options: (NSDictionary*)opts 53 | { 54 | self = [super init]; 55 | if (nil == self) 56 | { 57 | return nil; 58 | } 59 | 60 | if ([[opts objectForKey: kCTFontCollectionRemoveDuplicatesOption] boolValue]) 61 | { 62 | // FIXME: relies on CTFontDescriptors behaving properly in sets (-hash/-isEqual:) 63 | _descriptors = [[[NSSet setWithArray: descriptors] allObjects] retain]; 64 | } 65 | else 66 | { 67 | _descriptors = [descriptors copy]; 68 | } 69 | return self; 70 | } 71 | - (CTFontCollection*)collectionByAddingFontDescriptors: (NSArray*)descriptors 72 | options: (NSDictionary*)opts 73 | { 74 | NSArray *newDescriptors = [_descriptors arrayByAddingObjectsFromArray: descriptors]; 75 | CTFontCollection *collection = [[CTFontCollection alloc] initWithFontDescriptors: newDescriptors 76 | options: opts]; 77 | return [collection autorelease]; 78 | } 79 | - (NSArray*)fontDescriptors 80 | { 81 | return _descriptors; 82 | } 83 | - (NSArray*)fontDescriptorsSortedWithCallback: (CTFontCollectionSortDescriptorsCallback)cb 84 | info: (void*)info 85 | { 86 | return [_descriptors sortedArrayUsingFunction: cb context: info]; 87 | } 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGBitmapContext.h: -------------------------------------------------------------------------------- 1 | /** CGBitmapContext 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2006 Free Software Foundation, Inc. 6 | 7 | Author: BALATON Zoltan 8 | Date: 2006 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CGBitmapContext_h 26 | #define OPAL_CGBitmapContext_h 27 | 28 | #include 29 | #include 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /* Callbacks */ 36 | 37 | typedef void (*CGBitmapContextReleaseDataCallback)( 38 | void *releaseInfo, 39 | void *data 40 | ); 41 | 42 | /* Functions */ 43 | 44 | CGContextRef CGBitmapContextCreate( 45 | void *data, 46 | size_t width, 47 | size_t height, 48 | size_t bitsPerComponent, 49 | size_t bytesPerRow, 50 | CGColorSpaceRef colorspace, 51 | CGBitmapInfo info 52 | ); 53 | 54 | CGContextRef CGBitmapContextCreateWithData( 55 | void *data, 56 | size_t width, 57 | size_t height, 58 | size_t bitsPerComponent, 59 | size_t bytesPerRow, 60 | CGColorSpaceRef cs, 61 | CGBitmapInfo info, 62 | CGBitmapContextReleaseDataCallback callback, 63 | void *releaseInfo 64 | ); 65 | 66 | CGImageAlphaInfo CGBitmapContextGetAlphaInfo(CGContextRef ctx); 67 | 68 | CGBitmapInfo CGBitmapContextGetBitmapInfo(CGContextRef context); 69 | 70 | size_t CGBitmapContextGetBitsPerComponent (CGContextRef ctx); 71 | 72 | size_t CGBitmapContextGetBitsPerPixel (CGContextRef ctx); 73 | 74 | size_t CGBitmapContextGetBytesPerRow (CGContextRef ctx); 75 | 76 | CGColorSpaceRef CGBitmapContextGetColorSpace(CGContextRef ctx); 77 | 78 | void *CGBitmapContextGetData(CGContextRef ctx); 79 | 80 | size_t CGBitmapContextGetHeight(CGContextRef ctx); 81 | 82 | size_t CGBitmapContextGetWidth(CGContextRef ctx); 83 | 84 | CGImageRef CGBitmapContextCreateImage(CGContextRef ctx); 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif /* OPAL_CGBitmapContext_h */ 91 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGBase.h: -------------------------------------------------------------------------------- 1 | /** CGBase 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Jan 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CGBase_h 26 | #define OPAL_CGBase_h 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | // for off_t 33 | #include 34 | 35 | #import 36 | 37 | // Note: GNUstep Foundation defines CGFloat 38 | #ifdef __OBJC__ 39 | #import 40 | #else 41 | 42 | #ifndef CGFLOAT_DEFINED 43 | #define CGFLOAT_DEFINED 1 44 | 45 | #if INTPTR_MAX == INT64_MAX 46 | #define CGFLOAT_TYPE double 47 | #define CGFLOAT_IS_DOUBLE 1 48 | #define CGFLOAT_MIN DBL_MIN 49 | #define CGFLOAT_MAX DBL_MAX 50 | #else 51 | #define CGFLOAT_TYPE float 52 | #define CGFLOAT_IS_DOUBLE 0 53 | #define CGFLOAT_MIN FLT_MIN 54 | #define CGFLOAT_MAX FLT_MAX 55 | #endif 56 | 57 | typedef CGFLOAT_TYPE CGFloat; 58 | #endif // CGFLOAT_DEFINED 59 | 60 | typedef uintptr_t NSUInteger; 61 | 62 | typedef struct _NSRange NSRange; 63 | struct _NSRange 64 | { 65 | NSUInteger location; 66 | NSUInteger length; 67 | }; 68 | 69 | typedef struct _NSPoint NSPoint; 70 | struct _NSPoint 71 | { 72 | CGFloat x; 73 | CGFloat y; 74 | }; 75 | 76 | typedef struct _NSSize NSSize; 77 | struct _NSSize 78 | { 79 | CGFloat width; 80 | CGFloat height; 81 | }; 82 | 83 | typedef struct _NSRect NSRect; 84 | struct _NSRect 85 | { 86 | NSPoint origin; 87 | NSSize size; 88 | }; 89 | 90 | typedef uint16_t unichar; 91 | typedef NSUInteger NSStringEncoding; 92 | 93 | #endif // __OBJC__ 94 | 95 | #ifndef MAX 96 | #define MAX(a,b) ((a)>(b)?(a):(b)) 97 | #endif 98 | 99 | #ifndef MIN 100 | #define MIN(a,b) ((a)<(b)?(a):(b)) 101 | #endif 102 | 103 | #endif /* OPAL_CGBase_h */ 104 | 105 | -------------------------------------------------------------------------------- /Source/OpalGraphics/CGPDFScanner.m: -------------------------------------------------------------------------------- 1 | /** CGPDFScanner 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: June 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #import 26 | #include "CoreGraphics/CGPDFScanner.h" 27 | 28 | CGPDFScannerRef CGPDFScannerCreate( 29 | CGPDFContentStreamRef cs, 30 | CGPDFOperatorTableRef table, 31 | void *info) 32 | { 33 | return nil; 34 | } 35 | 36 | bool CGPDFScannerScan(CGPDFScannerRef scanner) 37 | { 38 | return false; 39 | } 40 | 41 | CGPDFContentStreamRef CGPDFScannerGetContentStream(CGPDFScannerRef scanner) 42 | { 43 | return nil; 44 | } 45 | 46 | bool CGPDFScannerPopArray(CGPDFScannerRef scanner, CGPDFArrayRef *value) 47 | { 48 | return false; 49 | } 50 | 51 | bool CGPDFScannerPopBoolean(CGPDFScannerRef scanner, CGPDFBoolean *value) 52 | { 53 | return false; 54 | } 55 | 56 | bool CGPDFScannerPopDictionary(CGPDFScannerRef scanner, CGPDFDictionaryRef *value) 57 | { 58 | return false; 59 | } 60 | 61 | bool CGPDFScannerPopInteger(CGPDFScannerRef scanner, CGPDFInteger *value) 62 | { 63 | return false; 64 | } 65 | 66 | bool CGPDFScannerPopName(CGPDFScannerRef scanner, const char **value) 67 | { 68 | return false; 69 | } 70 | 71 | bool CGPDFScannerPopNumber(CGPDFScannerRef scanner, CGPDFReal *value) 72 | { 73 | return false; 74 | } 75 | 76 | bool CGPDFScannerPopObject(CGPDFScannerRef scanner, CGPDFObjectRef *value) 77 | { 78 | return false; 79 | } 80 | 81 | bool CGPDFScannerPopStream(CGPDFScannerRef scanner, CGPDFStreamRef *value) 82 | { 83 | return false; 84 | } 85 | 86 | bool CGPDFScannerPopString(CGPDFScannerRef scanner, CGPDFStringRef *value) 87 | { 88 | return false; 89 | } 90 | 91 | CGPDFScannerRef CGPDFScannerRetain(CGPDFScannerRef scanner) 92 | { 93 | return nil; 94 | } 95 | 96 | void CGPDFScannerRelease(CGPDFScannerRef scanner) 97 | { 98 | 99 | } -------------------------------------------------------------------------------- /Tests/images.m: -------------------------------------------------------------------------------- 1 | #ifdef __APPLE__ 2 | #include 3 | #else 4 | #include 5 | #endif 6 | 7 | #include 8 | 9 | #ifndef MIN 10 | #define MIN(x,y) ((x)<(y)?(x):(y)) 11 | #endif 12 | 13 | static CGImageRef png, jpeg, tiff; 14 | static CGImageRef worldmap; 15 | 16 | void draw(CGContextRef ctx, CGRect rect) 17 | { 18 | CGContextSetRGBFillColor(ctx, 0.45, 0.45, 0.45, 1.0); 19 | CGContextFillRect(ctx, rect); 20 | 21 | // Draw a checkerboard 22 | CGContextSetRGBFillColor(ctx, 0.4, 0.4, 0.4, 1.0); 23 | unsigned int x, y; 24 | for (x=0; xCGPDFScanner 2 | 3 | C Interface to graphics drawing library 4 | - geometry routines 5 | 6 | Copyright (C) 2010 Free Software Foundation, Inc. 7 | Author: Eric Wasylishen 8 | 9 | This library is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU Lesser General Public 11 | License as published by the Free Software Foundation; either 12 | version 2.1 of the License, or (at your option) any later version. 13 | 14 | This library is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this library; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | 24 | #ifndef OPAL_CGPDFScanner_h 25 | #define OPAL_CGPDFScanner_h 26 | 27 | /* Data Types */ 28 | 29 | #ifdef INTERNAL_BUILD_OBJC 30 | @class CGPDFScanner; 31 | typedef CGPDFScanner* CGPDFScannerRef; 32 | #else 33 | typedef struct CGPDFScanner* CGPDFScannerRef; 34 | #endif 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /* Functions */ 48 | 49 | CGPDFScannerRef CGPDFScannerCreate( 50 | CGPDFContentStreamRef cs, 51 | CGPDFOperatorTableRef table, 52 | void *info 53 | ); 54 | 55 | bool CGPDFScannerScan(CGPDFScannerRef scanner); 56 | 57 | CGPDFContentStreamRef CGPDFScannerGetContentStream(CGPDFScannerRef scanner); 58 | 59 | bool CGPDFScannerPopArray(CGPDFScannerRef scanner, CGPDFArrayRef *value); 60 | 61 | bool CGPDFScannerPopBoolean(CGPDFScannerRef scanner, CGPDFBoolean *value); 62 | 63 | bool CGPDFScannerPopDictionary(CGPDFScannerRef scanner, CGPDFDictionaryRef *value); 64 | 65 | bool CGPDFScannerPopInteger(CGPDFScannerRef scanner, CGPDFInteger *value); 66 | 67 | bool CGPDFScannerPopName(CGPDFScannerRef scanner, const char **value); 68 | 69 | bool CGPDFScannerPopNumber(CGPDFScannerRef scanner, CGPDFReal *value); 70 | 71 | bool CGPDFScannerPopObject(CGPDFScannerRef scanner, CGPDFObjectRef *value); 72 | 73 | bool CGPDFScannerPopStream(CGPDFScannerRef scanner, CGPDFStreamRef *value); 74 | 75 | bool CGPDFScannerPopString(CGPDFScannerRef scanner, CGPDFStringRef *value); 76 | 77 | CGPDFScannerRef CGPDFScannerRetain(CGPDFScannerRef scanner); 78 | 79 | void CGPDFScannerRelease(CGPDFScannerRef scanner); 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif /* OPAL_CGPDFScanner_h */ 86 | -------------------------------------------------------------------------------- /Source/OpalText/CTTextTab.m: -------------------------------------------------------------------------------- 1 | /** CTTextTab 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Aug 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #include 26 | 27 | /* Constants */ 28 | 29 | const CFStringRef kCTTabColumnTerminatorsAttributeName = @"kCTTabColumnTerminatorsAttributeName"; 30 | 31 | /* Classes */ 32 | 33 | /** 34 | * Tab 35 | */ 36 | @interface CTTextTab : NSObject 37 | { 38 | CTTextAlignment _alignment; 39 | double _location; 40 | NSDictionary *_options; 41 | } 42 | 43 | - (id)initWithAlignment: (CTTextAlignment)alignment 44 | location: (double)location 45 | options: (NSDictionary*)options; 46 | - (CTTextAlignment)alignment; 47 | - (double)location; 48 | - (NSDictionary*)options; 49 | @end 50 | 51 | @implementation CTTextTab 52 | 53 | - (id)initWithAlignment: (CTTextAlignment)alignment 54 | location: (double)location 55 | options: (NSDictionary*)options 56 | { 57 | self = [super init]; 58 | if (nil == self) 59 | { 60 | return nil; 61 | } 62 | 63 | return self; 64 | } 65 | - (CTTextAlignment)alignment 66 | { 67 | return _alignment; 68 | } 69 | - (double)location 70 | { 71 | return _location; 72 | } 73 | - (NSDictionary*)options 74 | { 75 | return _options; 76 | } 77 | 78 | @end 79 | 80 | 81 | /* Functions */ 82 | 83 | CTTextTabRef CTTextTabCreate( 84 | CTTextAlignment alignment, 85 | double location, 86 | CFDictionaryRef options) 87 | { 88 | return [[CTTextTab alloc] initWithAlignment: alignment 89 | location: location 90 | options: options]; 91 | } 92 | CTTextAlignment CTTextTabGetAlignment(CTTextTabRef tab) 93 | { 94 | return [tab alignment]; 95 | } 96 | double CTTextTabGetLocation(CTTextTabRef tab) 97 | { 98 | return [tab location]; 99 | } 100 | CFDictionaryRef CTTextTabGetOptions(CTTextTabRef tab) 101 | { 102 | return [tab options]; 103 | } 104 | 105 | CFTypeID CTTextTabGetTypeID() 106 | { 107 | return (CFTypeID)[CTTextTab class]; 108 | } 109 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGPDFDictionary.h: -------------------------------------------------------------------------------- 1 | /** CGPDFDictionary 2 | 3 | C Interface to graphics drawing library 4 | - geometry routines 5 | 6 | Copyright (C) 2010 Free Software Foundation, Inc. 7 | Author: Eric Wasylishen 8 | 9 | This library is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU Lesser General Public 11 | License as published by the Free Software Foundation; either 12 | version 2.1 of the License, or (at your option) any later version. 13 | 14 | This library is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this library; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | 24 | #ifndef OPAL_CGPDFDictionary_h 25 | #define OPAL_CGPDFDictionary_h 26 | 27 | /* Data Types */ 28 | 29 | #ifdef INTERNAL_BUILD_OBJC 30 | @class CGPDFDictionary; 31 | typedef CGPDFDictionary* CGPDFDictionaryRef; 32 | #else 33 | typedef struct CGPDFDictionary* CGPDFDictionaryRef; 34 | #endif 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /* Callbacks */ 46 | 47 | typedef void (*CGPDFDictionaryApplierFunction)( 48 | const char *key, 49 | CGPDFObjectRef value, 50 | void *info 51 | ); 52 | 53 | /* Functions */ 54 | 55 | void CGPDFDictionaryApplyFunction(CGPDFDictionaryRef dict, CGPDFDictionaryApplierFunction function, void *info); 56 | 57 | size_t CGPDFDictionaryGetCount(CGPDFDictionaryRef dict); 58 | 59 | bool CGPDFDictionaryGetArray(CGPDFDictionaryRef dict, const char *key, CGPDFArrayRef *value); 60 | 61 | bool CGPDFDictionaryGetBoolean(CGPDFDictionaryRef dict, const char *key, CGPDFBoolean *value); 62 | 63 | bool CGPDFDictionaryGetDictionary(CGPDFDictionaryRef dict, const char *key, CGPDFDictionaryRef *value); 64 | 65 | bool CGPDFDictionaryGetInteger(CGPDFDictionaryRef dict, const char *key, CGPDFInteger *value); 66 | 67 | bool CGPDFDictionaryGetName(CGPDFDictionaryRef dict, const char *key, const char **value); 68 | 69 | bool CGPDFDictionaryGetNumber(CGPDFDictionaryRef dict, const char *key, CGPDFReal *value); 70 | 71 | bool CGPDFDictionaryGetObject(CGPDFDictionaryRef dict, const char *key, CGPDFObjectRef *value); 72 | 73 | bool CGPDFDictionaryGetStream(CGPDFDictionaryRef dict, const char *key, CGPDFStreamRef *value); 74 | 75 | bool CGPDFDictionaryGetString(CGPDFDictionaryRef dict, const char *key, CGPDFStringRef *value); 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif /* OPAL_CGPDFDictionary_h */ 82 | -------------------------------------------------------------------------------- /Headers/CoreText/CTFontTraits.h: -------------------------------------------------------------------------------- 1 | /** CTFontTraits 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Aug 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CTFontTraits_h 26 | #define OPAL_CTFontTraits_h 27 | 28 | #include 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /* Constants */ 35 | 36 | extern const CFStringRef kCTFontSymbolicTrait; 37 | extern const CFStringRef kCTFontWeightTrait; 38 | extern const CFStringRef kCTFontWidthTrait; 39 | extern const CFStringRef kCTFontSlantTrait; 40 | 41 | enum { 42 | kCTFontClassMaskShift = 28 43 | }; 44 | 45 | enum { 46 | kCTFontTraitItalic = (1 << 0), 47 | kCTFontTraitBold = (1 << 1), 48 | kCTFontTraitExpanded = (1 << 5), 49 | kCTFontTraitCondensed = (1 << 6), 50 | kCTFontTraitMonoSpace = (1 << 10), 51 | kCTFontTraitVertical = (1 << 11), 52 | kCTFontTraitUIOptimized = (1 << 12), 53 | kCTFontTraitColorGlyphs = (1 << 13), 54 | kCTFontTraitComposite = (1 << 14), 55 | 56 | kCTFontTraitClassMask = (15U << kCTFontClassMaskShift), 57 | 58 | kCTFontItalicTrait = kCTFontTraitItalic, 59 | kCTFontBoldTrait = kCTFontTraitBold, 60 | kCTFontExpandedTrait = kCTFontTraitExpanded, 61 | kCTFontCondensedTrait = kCTFontTraitCondensed, 62 | kCTFontMonoSpaceTrait = kCTFontTraitMonoSpace, 63 | kCTFontVerticalTrait = kCTFontTraitVertical, 64 | kCTFontUIOptimizedTrait = kCTFontTraitUIOptimized, 65 | kCTFontColorGlyphsTrait = kCTFontTraitColorGlyphs, 66 | kCTFontCompositeTrait = kCTFontTraitComposite, 67 | kCTFontClassMaskTrait = kCTFontTraitClassMask 68 | }; 69 | typedef int CTFontSymbolicTraits; 70 | 71 | enum { 72 | kCTFontUnknownClass = (0 << 28), 73 | kCTFontOldStyleSerifsClass = (1 << 28), 74 | kCTFontTransitionalSerifsClass = (2 << 28), 75 | kCTFontModernSerifsClass = (3 << 28), 76 | kCTFontClarendonSerifsClass = (4 << 28), 77 | kCTFontSlabSerifsClass = (5 << 28), 78 | kCTFontFreeformSerifsClass = (7 << 28), 79 | kCTFontSansSerifClass = (8 << 28), 80 | kCTFontOrnamentalsClass = (9 << 28), 81 | kCTFontScriptsClass = (10 << 28), 82 | kCTFontSymbolicClass = (12 << 28) 83 | }; 84 | typedef int CTFontStylisticClass; 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /Headers/CoreGraphics/CGColor.h: -------------------------------------------------------------------------------- 1 | /** CGColor 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2006 Free Software Foundation, Inc. 6 | 7 | Author: BALATON Zoltan 8 | Date: 2006 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CGColor_h 26 | #define OPAL_CGColor_h 27 | 28 | /* Data Types */ 29 | 30 | #ifdef INTERNAL_BUILD_OBJC 31 | @class CGColor; 32 | typedef CGColor* CGColorRef; 33 | #else 34 | typedef struct CGColor* CGColorRef; 35 | #endif 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /* Constants */ 46 | 47 | const extern CFStringRef kCGColorWhite; 48 | const extern CFStringRef kCGColorBlack; 49 | const extern CFStringRef kCGColorClear; 50 | 51 | /* Functions */ 52 | 53 | extern CGColorRef CGColorCreate(CGColorSpaceRef colorspace, const CGFloat components[]); 54 | CGColorRef CGColorCreateCopy(CGColorRef clr); 55 | 56 | CGColorRef CGColorCreateCopyWithAlpha(CGColorRef clr, CGFloat alpha); 57 | 58 | CGColorRef CGColorCreateGenericCMYK( 59 | CGFloat cyan, 60 | CGFloat magenta, 61 | CGFloat yellow, 62 | CGFloat black, 63 | CGFloat alpha 64 | ); 65 | 66 | CGColorRef CGColorCreateGenericGray(CGFloat gray, CGFloat alpha); 67 | 68 | CGColorRef CGColorCreateGenericRGB( 69 | CGFloat red, 70 | CGFloat green, 71 | CGFloat blue, 72 | CGFloat alpha 73 | ); 74 | 75 | CGColorRef CGColorCreateWithPattern( 76 | CGColorSpaceRef colorspace, 77 | CGPatternRef pattern, 78 | const CGFloat components[] 79 | ); 80 | 81 | bool CGColorEqualToColor(CGColorRef color1, CGColorRef color2); 82 | 83 | CGFloat CGColorGetAlpha(CGColorRef clr); 84 | 85 | CGColorSpaceRef CGColorGetColorSpace(CGColorRef clr); 86 | 87 | const CGFloat *CGColorGetComponents(CGColorRef clr); 88 | 89 | CGColorRef CGColorGetConstantColor(CFStringRef name); 90 | 91 | size_t CGColorGetNumberOfComponents(CGColorRef clr); 92 | 93 | CGPatternRef CGColorGetPattern(CGColorRef clr); 94 | 95 | CFTypeID CGColorGetTypeID(); 96 | 97 | void CGColorRelease(CGColorRef clr); 98 | 99 | CGColorRef CGColorRetain(CGColorRef clr); 100 | 101 | #ifdef __cplusplus 102 | } 103 | #endif 104 | 105 | #endif /* OPAL_CGColor_h */ 106 | -------------------------------------------------------------------------------- /Tests/x11.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #import 6 | 7 | extern CGContextRef OPX11ContextCreate(Display *d, Window w); 8 | 9 | void draw(CGContextRef ctx, CGRect r); 10 | 11 | int main(int argc, char **argv) 12 | { 13 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 14 | int ret; 15 | CGRect cr; 16 | CGContextRef ctx; 17 | XSetWindowAttributes wa; 18 | XEvent e; 19 | Display *d; 20 | Window win; 21 | 22 | d = XOpenDisplay(NULL); 23 | if (!d) 24 | { 25 | fprintf(stderr,"Cannot open display: %s\n", XDisplayName(NULL)); 26 | exit(EXIT_FAILURE); 27 | } 28 | printf("Opened display %s\n", DisplayString(d)); 29 | 30 | cr = CGRectMake(0,0,640,480); 31 | wa.background_pixel = WhitePixel(d, DefaultScreen(d)); 32 | wa.event_mask = ExposureMask | ButtonReleaseMask; 33 | 34 | /* Create a window */ 35 | win = XCreateWindow(d, /* Display */ 36 | DefaultRootWindow(d), /* Parent */ 37 | cr.origin.x, cr.origin.y, /* x, y */ 38 | cr.size.width, cr.size.height, /* width, height */ 39 | 0, /* border_width */ 40 | CopyFromParent, /* depth */ 41 | InputOutput, /* class */ 42 | CopyFromParent, /* visual */ 43 | CWBackPixel | CWEventMask, /* valuemask */ 44 | &wa); /* attributes */ 45 | printf("XCreateWindow returned: %lx\n", win); 46 | XSelectInput(d, win, ExposureMask | StructureNotifyMask | ButtonReleaseMask ); 47 | /* Map the window */ 48 | ret = XMapRaised(d, win); 49 | printf("XMapRaised returned: %x\n", ret); 50 | 51 | /* Create a CGContext */ 52 | ctx = OPX11ContextCreate(d, win); 53 | if (!ctx) { 54 | fprintf(stderr,"Cannot create context\n"); 55 | exit(EXIT_FAILURE); 56 | } 57 | printf("Created context\n"); 58 | 59 | while(1) 60 | { 61 | NSAutoreleasePool *pool2 = [[NSAutoreleasePool alloc] init]; 62 | XNextEvent(d,&e); 63 | switch(e.type) 64 | { 65 | case Expose: 66 | /* Dispose multiple events */ 67 | while (XCheckTypedEvent(d, Expose, &e)); 68 | 69 | /* Draw window contents */ 70 | if(e.xexpose.count == 0) { 71 | CGContextSaveGState(ctx); 72 | XClearWindow(d, win); 73 | draw(ctx, cr); 74 | CGContextRestoreGState(ctx); 75 | } 76 | break; 77 | case ConfigureNotify: 78 | { 79 | if (cr.size.width != e.xconfigure.width || cr.size.height != e.xconfigure.height) 80 | { 81 | cr.size.width = e.xconfigure.width; 82 | cr.size.height = e.xconfigure.height; 83 | NSLog(@"New rect: %f x %f", (float)cr.size.width, (float)cr.size.height); 84 | OPContextSetSize(ctx, cr.size); 85 | } 86 | } 87 | break; 88 | case ButtonRelease: 89 | /* Finish program */ 90 | CGContextRelease(ctx); 91 | XCloseDisplay(d); 92 | exit(EXIT_SUCCESS); 93 | break; 94 | } 95 | [pool2 release]; 96 | } 97 | [pool release]; 98 | return EXIT_SUCCESS; 99 | } 100 | 101 | -------------------------------------------------------------------------------- /Tests/layers.m: -------------------------------------------------------------------------------- 1 | #ifdef __APPLE__ 2 | #include 3 | #else 4 | #include 5 | #endif 6 | 7 | #include 8 | 9 | #define pi 3.14159265358979323846 10 | 11 | CGLayerRef makeSampleLayer(CGContextRef ctx){ 12 | CGRect layerBounds = CGRectMake(0,0,50, 50); 13 | CGLayerRef layer = CGLayerCreateWithContext(ctx, layerBounds.size, NULL); 14 | CGContextRef layerCtx = CGLayerGetContext(layer); 15 | 16 | CGContextSetRGBFillColor(layerCtx, 1, 1, 0, 0.5); 17 | CGContextFillRect(layerCtx, layerBounds); 18 | 19 | CGContextSetRGBStrokeColor(layerCtx, 0, 0, 0, 0.7); 20 | CGContextStrokeRect(layerCtx, layerBounds); 21 | 22 | 23 | // Draw a smiley 24 | CGContextBeginPath(layerCtx); 25 | printf("%d", CGContextIsPathEmpty(layerCtx)); 26 | CGContextMoveToPoint(layerCtx, 14, 35); CGContextAddArc(layerCtx, 10, 35, 4, 0, 2 * pi, 0); CGContextClosePath(layerCtx); 27 | CGContextMoveToPoint(layerCtx, 44, 35); CGContextAddArc(layerCtx, 40, 35, 4, 0, 2 * pi, 0); CGContextClosePath(layerCtx); 28 | CGContextMoveToPoint(layerCtx, 16, 15); CGContextAddArc(layerCtx, 12, 15, 4, 0, 2 * pi, 0); CGContextClosePath(layerCtx); 29 | CGContextMoveToPoint(layerCtx, 23, 10); CGContextAddArc(layerCtx, 19, 10, 4, 0, 2 * pi, 0); CGContextClosePath(layerCtx); 30 | CGContextMoveToPoint(layerCtx, 29, 8); CGContextAddArc(layerCtx, 25, 8, 4, 0, 2 * pi, 0); CGContextClosePath(layerCtx); 31 | CGContextMoveToPoint(layerCtx, 35, 10); CGContextAddArc(layerCtx, 31, 10, 4, 0, 2 * pi, 0); CGContextClosePath(layerCtx); 32 | CGContextMoveToPoint(layerCtx, 42, 15); CGContextAddArc(layerCtx, 38, 15, 4, 0, 2 * pi, 0); CGContextClosePath(layerCtx); 33 | 34 | CGContextSetRGBFillColor(layerCtx, 1, 0, 0, 0.5); 35 | CGContextSetRGBStrokeColor(layerCtx, 0, 0, 0, 1); 36 | CGContextDrawPath(layerCtx, kCGPathFillStroke); 37 | 38 | 39 | return layer; 40 | } 41 | 42 | void draw(CGContextRef ctx, CGRect r) 43 | { 44 | CGContextSetRGBFillColor(ctx, 0, 0, 1, 0.5); 45 | CGContextSetRGBStrokeColor(ctx, 0, 0, 0, 1); 46 | CGContextFillRect(ctx, CGRectMake(10,10,r.size.width - 20, r.size.height - 20)); 47 | CGContextStrokeRect(ctx, CGRectMake(10,10,r.size.width - 20, r.size.height - 20)); 48 | 49 | // Draw some copies of a layer 50 | CGLayerRef layer = makeSampleLayer(ctx); 51 | 52 | // Draw some rotated faces 53 | CGContextSaveGState(ctx); 54 | CGContextTranslateCTM(ctx, 225, 125); 55 | int i; 56 | for (i = 0; i < 3; i++) { 57 | CGContextRotateCTM(ctx, 0.06); 58 | CGContextDrawLayerInRect(ctx, CGRectMake(-145,-110,290,220), layer); 59 | } 60 | CGContextRestoreGState(ctx); 61 | 62 | 63 | 64 | CGContextDrawLayerInRect(ctx, CGRectMake(80,15,290,220), layer); 65 | 66 | CGContextDrawLayerAtPoint(ctx, CGPointMake(100, 170), layer); 67 | CGContextDrawLayerAtPoint(ctx, CGPointMake(300, 170), layer); 68 | 69 | CGContextDrawLayerAtPoint(ctx, CGPointMake(100, 60), layer); 70 | CGContextDrawLayerAtPoint(ctx, CGPointMake(150, 16), layer); 71 | CGContextDrawLayerAtPoint(ctx, CGPointMake(200, 10), layer); 72 | CGContextDrawLayerAtPoint(ctx, CGPointMake(250, 16), layer); 73 | CGContextDrawLayerAtPoint(ctx, CGPointMake(300, 60), layer); 74 | CGLayerRelease(layer); 75 | } 76 | 77 | -------------------------------------------------------------------------------- /Headers/CoreText/CTRun.h: -------------------------------------------------------------------------------- 1 | /** CTRun 2 | 3 | C Interface to text layout library 4 | 5 | Copyright (C) 2010 Free Software Foundation, Inc. 6 | 7 | Author: Eric Wasylishen 8 | Date: Aug 2010 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef OPAL_CTRun_h 26 | #define OPAL_CTRun_h 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Data Types */ 38 | 39 | #ifdef INTERNAL_BUILD_OBJC 40 | @class CTRun; 41 | typedef CTRun* CTRunRef; 42 | #else 43 | typedef struct CTRun* CTRunRef; 44 | #endif 45 | 46 | /* Constants */ 47 | 48 | enum { 49 | kCTRunStatusNoStatus = 0, 50 | kCTRunStatusRightToLeft = (1 << 0), 51 | kCTRunStatusNonMonotonic = (1 << 1), 52 | kCTRunStatusHasNonIdentityMatrix = (1 << 2) 53 | }; 54 | typedef int CTRunStatus; 55 | 56 | /* Functions */ 57 | 58 | CFIndex CTRunGetGlyphCount(CTRunRef run); 59 | 60 | CFDictionaryRef CTRunGetAttributes(CTRunRef run); 61 | 62 | CTRunStatus CTRunGetStatus(CTRunRef run); 63 | 64 | const CGGlyph* CTRunGetGlyphsPtr(CTRunRef run); 65 | 66 | void CTRunGetGlyphs( 67 | CTRunRef run, 68 | CFRange range, 69 | CGGlyph buffer[] 70 | ); 71 | 72 | const CGPoint* CTRunGetPositionsPtr(CTRunRef run); 73 | 74 | void CTRunGetPositions( 75 | CTRunRef run, 76 | CFRange range, 77 | CGPoint buffer[] 78 | ); 79 | 80 | const CGSize* CTRunGetAdvancesPtr(CTRunRef run); 81 | 82 | void CTRunGetAdvances( 83 | CTRunRef run, 84 | CFRange range, 85 | CGSize buffer[] 86 | ); 87 | 88 | const CFIndex *CTRunGetStringIndicesPtr(CTRunRef run); 89 | 90 | void CTRunGetStringIndices( 91 | CTRunRef run, 92 | CFRange range, 93 | CFIndex buffer[] 94 | ); 95 | 96 | CFRange CTRunGetStringRange(CTRunRef run); 97 | 98 | double CTRunGetTypographicBounds( 99 | CTRunRef run, 100 | CFRange range, 101 | CGFloat *ascent, 102 | CGFloat *descent, 103 | CGFloat *leading 104 | ); 105 | 106 | CGRect CTRunGetImageBounds( 107 | CTRunRef run, 108 | CGContextRef ctx, 109 | CFRange range 110 | ); 111 | 112 | CGAffineTransform CTRunGetTextMatrix(CTRunRef run); 113 | 114 | void CTRunDraw( 115 | CTRunRef run, 116 | CGContextRef ctx, 117 | CFRange range 118 | ); 119 | 120 | CFTypeID CTRunGetTypeID(); 121 | 122 | #ifdef __cplusplus 123 | } 124 | #endif 125 | 126 | #endif 127 | -------------------------------------------------------------------------------- /Source/OpalGraphics/CGAffineTransform.m: -------------------------------------------------------------------------------- 1 | /** CGAffineTransform 2 | 3 | C Interface to graphics drawing library 4 | 5 | Copyright (C) 2006 Free Software Foundation, Inc. 6 | 7 | Author: BALATON Zoltan 8 | Date: 2006 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with this library; if not, write to the Free Software 22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #define IN_CGAFFINETRANSFORM_C 26 | #include "CoreGraphics/CGAffineTransform.h" 27 | #undef IN_CGAFFINETRANSFORM_C 28 | 29 | #import 30 | #include 31 | 32 | const CGAffineTransform CGAffineTransformIdentity = {1,0,0,1,0,0}; 33 | 34 | CGAffineTransform CGAffineTransformMakeRotation(CGFloat angle) 35 | { 36 | CGAffineTransform matrix; 37 | CGFloat cosa = cos(angle); 38 | CGFloat sina = sin(angle); 39 | 40 | matrix.a = matrix.d = cosa; 41 | matrix.b = sina; 42 | matrix.c = -sina; 43 | matrix.tx = matrix.ty = 0; 44 | 45 | return matrix; 46 | } 47 | 48 | CGAffineTransform CGAffineTransformInvert(CGAffineTransform t) 49 | { 50 | CGAffineTransform inv; 51 | CGFloat det; 52 | 53 | det = t.a * t.d - t.b *t.c; 54 | if (det == 0) { 55 | NSLog(@"CGAffineTransformInvert: Cannot invert matrix, determinant is 0"); 56 | return t; 57 | } 58 | 59 | inv.a = t.d / det; 60 | inv.b = -t.b / det; 61 | inv.c = -t.c / det; 62 | inv.d = t.a / det; 63 | inv.tx = (t.c * t.ty - t.d * t.tx) / det; 64 | inv.ty = (t.b * t.tx - t.a * t.ty) / det; 65 | 66 | return inv; 67 | } 68 | 69 | /** 70 | * Returns the smallest rectangle which contains the four supplied points. 71 | */ 72 | static CGRect make_bounding_rect(CGPoint p1, CGPoint p2, CGPoint p3, CGPoint p4) 73 | { 74 | CGFloat minX = MIN(p1.x, MIN(p2.x, MIN(p3.x, p4.x))); 75 | CGFloat minY = MIN(p1.y, MIN(p2.y, MIN(p3.y, p4.y))); 76 | CGFloat maxX = MAX(p1.x, MAX(p2.x, MAX(p3.x, p4.x))); 77 | CGFloat maxY = MAX(p1.y, MAX(p2.y, MAX(p3.y, p4.y))); 78 | 79 | return CGRectMake(minX, minY, (maxX - minX), (maxY - minY)); 80 | } 81 | 82 | CGRect CGRectApplyAffineTransform(CGRect rect, CGAffineTransform t) 83 | { 84 | 85 | CGPoint p1 = CGPointMake(CGRectGetMinX(rect), CGRectGetMinY(rect)); 86 | CGPoint p2 = CGPointMake(CGRectGetMaxX(rect), CGRectGetMinY(rect)); 87 | CGPoint p3 = CGPointMake(CGRectGetMinX(rect), CGRectGetMaxY(rect)); 88 | CGPoint p4 = CGPointMake(CGRectGetMaxX(rect), CGRectGetMaxY(rect)); 89 | 90 | p1 = CGPointApplyAffineTransform(p1, t); 91 | p2 = CGPointApplyAffineTransform(p2, t); 92 | p3 = CGPointApplyAffineTransform(p3, t); 93 | p4 = CGPointApplyAffineTransform(p4, t); 94 | 95 | return make_bounding_rect(p1, p2, p3, p4); 96 | } 97 | -------------------------------------------------------------------------------- /Tests/gstate.m: -------------------------------------------------------------------------------- 1 | #ifdef __APPLE__ 2 | #include 3 | #else 4 | #include 5 | #endif 6 | 7 | #include 8 | 9 | // This test is intended to verify the consistency of gstate after various 10 | // operations, as well as results of matrix operations, etc. 11 | 12 | // It could slowly grow over time. 13 | 14 | NSString * affineTransformRepr(CGAffineTransform at) 15 | { 16 | return [NSString stringWithFormat: @"((%g %g), (%g %g), (%g %g))", 17 | at.a, at.b, 18 | at.c, at.d, 19 | at.tx, at.ty]; 20 | } 21 | 22 | void draw(CGContextRef ctx, CGRect rect) 23 | { 24 | // Test 1: 25 | // Setting and restoring CTM. Uses Opal-specific methods. 26 | 27 | NSLog(@" Test 1"); 28 | #if GNUSTEP 29 | { 30 | CGAffineTransform ctm; 31 | CGAffineTransform oldctm = CGContextGetCTM(ctx); 32 | 33 | CGContextSaveGState(ctx); 34 | OPContextSetIdentityCTM(ctx); 35 | ctm = CGContextGetCTM(ctx); 36 | if (ctm.a == 1.0 && ctm.b == 0.0 && 37 | ctm.c == 0.0 && ctm.d == 1.0 && 38 | ctm.tx == 0.0 && ctm.ty == 0.0) 39 | { 40 | NSLog(@"+ Setting identity CTM ok"); 41 | } 42 | else 43 | { 44 | NSLog(@"- Setting identity CTM failed - is %@", affineTransformRepr(ctm)); 45 | } 46 | 47 | if (CGAffineTransformEqualToTransform(ctm, CGAffineTransformIdentity)) 48 | { 49 | NSLog(@"+ CTM is CGAffineTransformIdentity"); 50 | } 51 | else 52 | { 53 | NSLog(@"- CTM differs from CGAffineTransformIdentity - is %@", affineTransformRepr(ctm)); 54 | } 55 | 56 | CGAffineTransform matrix1 = { 57 | .a = 1.0, .b = 0.0, 58 | .c = 0.0, .d = 1.0, 59 | .tx = 2.0, .ty = 3.0 60 | }; 61 | CGContextConcatCTM(ctx, matrix1); 62 | ctm = CGContextGetCTM(ctx); 63 | if (CGAffineTransformEqualToTransform(ctm, matrix1)) 64 | { 65 | NSLog(@"+ Concatenating matrix1 ok"); 66 | } 67 | else 68 | { 69 | NSLog(@"- Concatenating matrix1 failed - expected %@, got %@", affineTransformRepr(matrix1), affineTransformRepr(ctm)); 70 | } 71 | 72 | CGAffineTransform matrix2 = { 73 | .a = 2.0, .b = 0.0, 74 | .c = 0.0, .d = 2.0, 75 | .tx = 2.0, .ty = 3.0 76 | }; 77 | OPContextSetIdentityCTM(ctx); 78 | CGContextConcatCTM(ctx, matrix2); 79 | ctm = CGContextGetCTM(ctx); 80 | if (CGAffineTransformEqualToTransform(ctm, matrix2)) 81 | { 82 | NSLog(@"+ Concatenating matrix2 ok"); 83 | } 84 | else 85 | { 86 | NSLog(@"- Concatenating matrix2 failed - expected %@, got %@", affineTransformRepr(matrix2), affineTransformRepr(ctm)); 87 | } 88 | 89 | CGContextRestoreGState(ctx); 90 | 91 | ctm = CGContextGetCTM(ctx); 92 | if (CGAffineTransformEqualToTransform(ctm, oldctm)) 93 | { 94 | NSLog(@"+ CTM correctly restored"); 95 | } 96 | else 97 | { 98 | NSLog(@"- CTM not the same as before - expected %@, got %@", affineTransformRepr(oldctm), affineTransformRepr(ctm)); 99 | } 100 | } 101 | #else 102 | NSLog(@"Skipped under OS X"); 103 | #endif 104 | 105 | } 106 | --------------------------------------------------------------------------------