Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Core Text

From Wikipedia, the free encyclopedia

icon
This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Core Text" – news ·newspapers ·books ·scholar ·JSTOR
(September 2007) (Learn how and when to remove this message)

Core Text is aCore Foundation styleAPI inmacOS, first introduced inMac OS X 10.4 Tiger, made public inMac OS X 10.5 Leopard, and introduced for theiPad with iPhone SDK 3.2. Exposing aCAPI, it replaces the text rendering abilities of the now-deprecatedQuickDraw andATSUI frameworks in previous versions of Mac OS X. According to Apple, Core Text is "designed for high performance and ease of use" and its layout API is "simple, consistent, and tightly integrated with Core Foundation, Core Graphics, and Cocoa."[1]

Features

[edit]

Core Text provides the following opaque types:

  • CTFramesetter - creates CTFrame objects from given attributed string object and CGPath object using CTTypesetter.
  • CTTypesetter - performs line layouts; e.g., line breaking
  • CTFrame - represents an array of lines (i.e., CTLine objects).
  • CTLine - represents an array of glyph runs.
  • CTRun - an ordered collection of glyphs sharing the same attribute.
  • CTFont - represents a font.

Example

[edit]

The following code displays the text "Hello, World!" to the given graphics context inObjective-C.

// Prepare fontCTFontReffont=CTFontCreateWithName(CFSTR("Times"),48,NULL);// Create an attributed stringCFStringRefkeys[]={kCTFontAttributeName};CFTypeRefvalues[]={font};CFDictionaryRefattr=CFDictionaryCreate(NULL,(constvoid**)&keys,(constvoid**)&values,sizeof(keys)/sizeof(keys[0]),&kCFTypeDictionaryKeyCallBacks,&kCFTypeDictionaryValueCallBacks);CFAttributedStringRefattrString=CFAttributedStringCreate(NULL,CFSTR("Hello, World!"),attr);CFRelease(attr);// Draw the stringCTLineRefline=CTLineCreateWithAttributedString(attrString);CGContextSetTextMatrix(context,CGAffineTransformIdentity);//Use this one when using standard view coordinates//CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1.0, -1.0)); //Use this one if the view's coordinates are flippedCGContextSetTextPosition(context,10,20);CTLineDraw(line,context);// Clean upCFRelease(line);CFRelease(attrString);CFRelease(font);

References

[edit]
  1. ^Core Text Programming Guide: Core Text Overview

External links

[edit]
Products
Hardware
Mac
iPod
iPhone
iPad
Other
Software
Operating
systems
Services
Financial
Media
Communication
Retail
Support
Other
Companies
Subsidiaries
Acquisitions
Partnerships
Design andmarketing
Legal issues and
labour relations
Related
People
CEOs
Board chairs
Other
executives
Current
Former
Founders
  • Italics indicate discontinued products, services, or defunct companies.
  • Category
Versions
Mac OS X
OS X
macOS
Predecessors
Applications
Core
applications
Developer
Tools
Xcode
Former
Former
Utilities
Discontinued
Technologies,
user interface
Deprecated
Discontinued
  • Italics denote upcoming products.
  •  Category
Stub icon

This Macintosh-related article is astub. You can help Wikipedia byexpanding it.

Retrieved from "https://en.wikipedia.org/w/index.php?title=Core_Text&oldid=1203363981"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp