• Save
Core text
Upcoming SlideShare
Loading in...5
×
 

Core text

on

  • 1,160 views

Core Text is an iOS framework that supports improved text rendering in various layouts you can think of. More about it here : http://goo.gl/CCeJe

Core Text is an iOS framework that supports improved text rendering in various layouts you can think of. More about it here : http://goo.gl/CCeJe

Statistics

Views

Total Views
1,160
Views on SlideShare
1,158
Embed Views
2

Actions

Likes
2
Downloads
0
Comments
0

2 Embeds 2

http://www.docseek.net 1
https://twitter.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Core text Core text Presentation Transcript

  • CoreText By: SOURCEBITS Ashish Asawa Aditya Sinha Demo
  • iOS Text Drawing➢ UIKit➢ Core Text➢ Core Graphics
  • UIKit➢ UILabel➢ UITextField➢ UITextView
  • Common Problems with UIKit Y can apply a font to the text, but the same font is used for the entire view. ou UITextView cannot display rich text from an NSAttributedString. There is no Apple- provided view that can do that.➢ UIWebView• Not ideal for displaying rich text.• Requires HTML. • The native rich-text data structure  -> NSAttributedString• Slow, and it provides no easy access to its current contents. 
  • Characters and GlyphsCharacters are essentially numbers representing code points in a character set or encoding scheme.OSX✔ Unicode✔ Provide unique number for every character✔ Independent of programming language, platform.
  • Glyphs continued.. A glyph is a graphic shape used to depict a character.numeric codes✔ glyph codes✔ Glyphs are selected during composition and layout processing by the character-to-glyphconversion process.There are any number of glyphs that correspond to a particular character.✔
  • Understanding bold, Italics and Underline✔ Three most common rich-text attributes.✔ Presented to the user as simple attributes, ✔ But they are quite different from each other.✔ In typography, you do not “bold” a font by drawing it with thicker lines.  ✔ Font designer -> variation. ✔ In iOS the Helvetica font has a variation called Helvetica-Bold. ✔ While these fonts are related, they are completely different.✔ To find font variations, you use CTFontCreateCopyWithSymbolicTraits.
  • Italic✔ True italic type is based on calligraphy and uses different shapes (glyphs) than the regular (orroman) font.✔  Some fonts do not have a true italic variation -> roman type -> oblique.✔ When users request italic,  Either italic or oblique.  ✔✔ kCTFontItalicTrait to CTFontCreateCopyWithSymbolicTraits ✔ It returns the best font that matches this looser definition.✔  Text with both bold and italic requires yet another font variation such as Georgia-BoldItalic.✔ Underline is a decoration like color or shadow.  ✔ You do not change font when you add decorations.
  • Core TextCore Text is a C-based API that uses Core Foundation naming and memory management.Low-level text layout and font-handling engine.➢Extremely fast and powerful. ➢Can handle complex layouts➢Multicolumn text ➢Curved text.➢
  • Attributed Strings The fundamental data type in Core Text is CFAttributedString. An attributed string is astring that applies attributes to ranges of characters.  The attributes can be any key-value pair, but for the purposes of Core Text, theyusually contain style information such as font, color, and indentation. It is usually best to use CFMutableAttributedString so you can modify the attributesof various parts of the string. CFAttributedString requires that all of the string have thesame attributes. Toll free bridge to Cocoa Attributed String (NSAttributed String)
  • CoreText Objects➢CTFramesetter➢Typesetters➢Lines and Glyph Runs
  • CTFrameSetter● Highest level object in core text layout engine● Generates text frame by filling path with text● Applies paragraph styles to the frame text
  • Typesetters➢ Performs the fundamental text layout operations of character-to-glyph conversion➢ Positioning of glyphs into lines.➢ Suggests line breaks.➢ CTFramesetter instantiates a typesetter and uses it to create theline objects used to fill a frame
  • Lines and Glyph Runs➢CTLine : CoreText Object that represents a line➢Contains an array of glyph runs➢Glyph run is a set of consecutive glyphs sharing the same attributesand direction➢Created by typesetter during framesetting operations
  • CoreText: Things NOT Covered➢ CTFont➢ Run Delegate - to attach pic, movie in the middle of document ➢➢ Presenting Big Document➢ Writing CT to pdf➢ NSAttributed String and Core Text - ios6➢ Mixing Different Languages.➢ CT Editor ?
  • Conclusion•In the vast majority of cases, UIKit views like UILabel, UITextView, UITextFields are perfectlyadequate. • If you need a just few stylized words, you can break the sentence into multiple UILabel views.• For complex styles, UIKit views are insufficient.•The next tool you should consider is custom view drawing with NSString methods such asdrawInRect:withFont:. This approach is very good for static text.•If you need to draw highly stylized, dynamic text, then you basically have two options: web viewsand Core Text. • For selectable and editable text, the best option is typically a web view. • Javascript knowledge is required.•
  • Conclusion continued..● If you don’t need to edit your rich text, then Core Text is a good choice. ● If you need to perform very complex layout, such as drawing along curves, Core Text may be your onlyoption.● Core Text does not include any capability for text selection, or copy and paste. ● If you use Core Text, to get good performance use as much as foundation classes.● If the user needs to select text, you need to implement that by hand.● Whichever option you choose, try to keep your text rendering isolated to a small number of classes sothat you can swap out the engine later.● Apple often tries out complicated APIs in its own code before making them public.● Eg : UIPageViewController, UICollectionView
  • References●Core Text Programming Guide●Quartz 2D Programming Guide.  "Text"●String Programming Guide. “Drawing Strings”●Text, Web, and Editing Programming Guide●WWDC 2011 videos.   "Session 511 – Rich Text Editing in Safari on iOS"●WWDC 2010 videos. "Session 110 - Advanced Text Handling for iPhone OS"●http://www.planetclegg.com/projects/WarpingTextToSplines.html
  • ?
  • Thank YouPresenters:Ashish Asawa – ashish.asawa@sourcebits.comAditya Sinha – aditya.sinha@sourcebits.com