This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) drawText: (NSRect) theRect { | |
const CTFramesetterRef framesetter = | |
CTFramesetterCreateWithAttributedString((CFAttributedStringRef)_text); | |
// Initialize a rectangular path. | |
const CGMutablePathRef path = CGPathCreateMutable(); | |
const CGRect rect = CGRectInset(NSRectToCGRect([self bounds]), 5.0, 5.0); | |
CGPathAddRect(path, NULL, rect); | |
// Create the frame and draw it into the graphics context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <ApplicationServices/ApplicationServices.h> | |
CTFontRef font = CTFontCreateWithName(CFSTR("LucidaGrande"), 11.0, NULL); | |
CFTypeRef keys[] = { kCTFontAttributeName }; | |
CFTypeRef values[] = { font }; | |
CFDictionaryRef attributes = | |
CFDictionaryCreate(kCFAllocatorDefault, | |
(const void**)keys, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ast | |
import sys | |
import pprint | |
import re | |
type_lookup = { | |
ast.Module: 'Module', | |
ast.FunctionDef: 'Function', | |
ast.ClassDef: 'Class' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface AClass (ACategory) | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Core Graphics method | |
CGDataProviderRef provider = CGDataProviderCreateWithURL((__bridge CFURLRef)fontURL); | |
CGFontRef graphicsFont = CGFontCreateWithDataProvider(provider); | |
CTFontRef coreTextFont = CTFontCreateWithGraphicsFont(graphicsFont, fontSize, /*matrix*/ NULL, /*attributes*/ NULL); | |
if (coreTextFont) { | |
NSFont *font = (__bridge NSFont *)coreTextFont; | |
[fonts addObject:font]; | |
CFRelease(coreTextFont); | |
} | |
CGFontRelease(graphicsFont); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <ApplicationServices/ApplicationServices.h> | |
#import <Foundation/Foundation.h> | |
int main(int argc, char *argv[]) | |
{ | |
if (argc != 2) | |
return 0; | |
NSAutoreleasePool *pool = [NSAutoreleasePool new]; | |
CFStringRef name = (CFStringRef) [NSString stringWithUTF8String: argv[1]]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static CGRect clipRectToPath(CGRect rect, CGPathRef path) | |
{ | |
size_t width = floorf(rect.size.width); | |
size_t height = floorf(rect.size.height); | |
uint8_t *points = calloc(width * height, sizeof(*points)); | |
CGContextRef bitmapContext = CGBitmapContextCreate(points, width, height, sizeof(*points) * 8, width, NULL, kCGImageAlphaOnly); | |
BOOL atStart = NO; | |
NSRange range = NSMakeRange(0, 0); | |
NSUInteger x = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CTTest.c | |
#include <ApplicationServices/ApplicationServices.h> | |
CFDictionaryRef findFeatureByName(CFArrayRef features, const char *name) | |
{ | |
CFDictionaryRef feature = NULL; | |
CFStringRef featureName = CFStringCreateWithCString(NULL, name, kCFStringEncodingUTF8); | |
CFIndex i; | |
for (i = 0; i < CFArrayGetCount(features); i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A small chunk of it. | |
- (void)tapGestureAction:(UITapGestureRecognizer *)gesture | |
{ | |
CGPoint location = [gesture locationInView:self]; | |
_linkLocation = location; | |
location.y += (ARTICLE_BODY_FONT_SIZE / lineHeightFactor); | |
CFArrayRef lines = CTFrameGetLines(_frame); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://stackoverflow.com/questions/7979592/is-it-possible-to-select-the-text-rendered-by-core-text-in-iphone |
OlderNewer