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 Glyphs
Characters 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-glyph
conversion 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 (or
roman) 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 Text
Core 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 a
string that applies attributes to ranges of characters. 



 The attributes can be any key-value pair, but for the purposes of Core Text, they
usually contain style information such as font, color, and indentation.



 It is usually best to use CFMutableAttributedString so you can modify the attributes
of various parts of the string. CFAttributedString requires that all of the string have the
same 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 the
line 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 attributes

and 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 perfectly
adequate. 
•   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 as
drawInRect: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 views
and 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 only
option.
●
    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 so
that 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 You
Presenters:



Ashish Asawa   – ashish.asawa@sourcebits.com
Aditya Sinha   – aditya.sinha@sourcebits.com

More Related Content

PDF
Enhance the Look of Your App With Text Kit
PDF
Text Layout With Core Text
PPTX
HTML5: The Future of Web Development with IE9, IE10 and Windows 8
PDF
Advance text rendering in i os
ZIP
Cocoa text talk.key
PPTX
Text kit ios7
PDF
Dynamic types in iOS
PDF
Hi performance table views with QuartzCore and CoreText
Enhance the Look of Your App With Text Kit
Text Layout With Core Text
HTML5: The Future of Web Development with IE9, IE10 and Windows 8
Advance text rendering in i os
Cocoa text talk.key
Text kit ios7
Dynamic types in iOS
Hi performance table views with QuartzCore and CoreText

Similar to Core text (20)

PPT
Chapter 5 Text
KEY
Intro To Flex Typography 360|Flex
PPTX
What's new in Xamarin.iOS, by Miguel de Icaza
PPT
Web font services: March 2011
PDF
Webtech ’09 – Die Zukunft des Webs beginnt jetzt
PPTX
Unit 2 graphics
PDF
Core What?
PDF
MFF UK - Introduction to iOS
PDF
Beautiful Layouts Through Beautiful Type
PDF
Beautiful Layouts Through Beautiful Type
PDF
FI MUNI 2012 - iOS Basics
KEY
Typography + Text Editing in the Text layout Framework
PDF
Tool twist newsletter 2010
PDF
How to Choose Fonts: A Practical Guide to Web-Optimized Typefaces
PPT
Chapter 04bnbnbbnmbnmbmbmnbmnnbnmbnnm.ppt
ZIP
Between Cocoa and Cocoa Touch: A Comparative Introduction
PDF
Write native iPhone applications using Eclipse CDT
PDF
I pad uicatalog_lesson02
PDF
iOS 5 & Xcode 4: ARC, Stroryboards
Chapter 5 Text
Intro To Flex Typography 360|Flex
What's new in Xamarin.iOS, by Miguel de Icaza
Web font services: March 2011
Webtech ’09 – Die Zukunft des Webs beginnt jetzt
Unit 2 graphics
Core What?
MFF UK - Introduction to iOS
Beautiful Layouts Through Beautiful Type
Beautiful Layouts Through Beautiful Type
FI MUNI 2012 - iOS Basics
Typography + Text Editing in the Text layout Framework
Tool twist newsletter 2010
How to Choose Fonts: A Practical Guide to Web-Optimized Typefaces
Chapter 04bnbnbbnmbnmbmbmnbmnnbnmbnnm.ppt
Between Cocoa and Cocoa Touch: A Comparative Introduction
Write native iPhone applications using Eclipse CDT
I pad uicatalog_lesson02
iOS 5 & Xcode 4: ARC, Stroryboards
Ad

Recently uploaded (20)

PDF
Hybrid model detection and classification of lung cancer
PPT
What is a Computer? Input Devices /output devices
PDF
A review of recent deep learning applications in wood surface defect identifi...
PDF
Zenith AI: Advanced Artificial Intelligence
PPTX
observCloud-Native Containerability and monitoring.pptx
PDF
Getting Started with Data Integration: FME Form 101
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PPTX
Tartificialntelligence_presentation.pptx
PDF
A novel scalable deep ensemble learning framework for big data classification...
PPTX
Chapter 5: Probability Theory and Statistics
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
DOCX
search engine optimization ppt fir known well about this
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PPTX
Benefits of Physical activity for teenagers.pptx
PPTX
Modernising the Digital Integration Hub
Hybrid model detection and classification of lung cancer
What is a Computer? Input Devices /output devices
A review of recent deep learning applications in wood surface defect identifi...
Zenith AI: Advanced Artificial Intelligence
observCloud-Native Containerability and monitoring.pptx
Getting Started with Data Integration: FME Form 101
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Assigned Numbers - 2025 - Bluetooth® Document
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Tartificialntelligence_presentation.pptx
A novel scalable deep ensemble learning framework for big data classification...
Chapter 5: Probability Theory and Statistics
1 - Historical Antecedents, Social Consideration.pdf
Taming the Chaos: How to Turn Unstructured Data into Decisions
search engine optimization ppt fir known well about this
sustainability-14-14877-v2.pddhzftheheeeee
Enhancing emotion recognition model for a student engagement use case through...
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Benefits of Physical activity for teenagers.pptx
Modernising the Digital Integration Hub
Ad

Core text

  • 1. CoreText By: SOURCEBITS Ashish Asawa Aditya Sinha Demo
  • 2. iOS Text Drawing ➢ UIKit ➢ Core Text ➢ Core Graphics
  • 3. UIKit ➢ UILabel ➢ UITextField ➢ UITextView
  • 4. 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. 
  • 5. Characters and Glyphs Characters 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.
  • 6. 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-glyph conversion process. There are any number of glyphs that correspond to a particular character. ✔
  • 7. 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.
  • 8. Italic ✔ True italic type is based on calligraphy and uses different shapes (glyphs) than the regular (or roman) 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.
  • 9. Core Text Core 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. ➢
  • 10. Attributed Strings  The fundamental data type in Core Text is CFAttributedString. An attributed string is a string that applies attributes to ranges of characters.   The attributes can be any key-value pair, but for the purposes of Core Text, they usually contain style information such as font, color, and indentation.  It is usually best to use CFMutableAttributedString so you can modify the attributes of various parts of the string. CFAttributedString requires that all of the string have the same attributes.  Toll free bridge to Cocoa Attributed String (NSAttributed String)
  • 12. CTFrameSetter ● Highest level object in core text layout engine ● Generates text frame by filling path with text ● Applies paragraph styles to the frame text
  • 13. 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 the line objects used to fill a frame
  • 14. 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 attributes and direction ➢Created by typesetter during framesetting operations
  • 15. 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 ?
  • 16. Conclusion •In the vast majority of cases, UIKit views like UILabel, UITextView, UITextFields are perfectly adequate.  • 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 as drawInRect: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 views and Core Text.  • For selectable and editable text, the best option is typically a web view. • Javascript knowledge is required. •
  • 17. 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 only option. ● 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 so that you can swap out the engine later. ● Apple often tries out complicated APIs in its own code before making them public. ● Eg : UIPageViewController, UICollectionView
  • 18. 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
  • 19. ?
  • 20. Thank You Presenters: Ashish Asawa – ashish.asawa@sourcebits.com Aditya Sinha – aditya.sinha@sourcebits.com