SlideShare une entreprise Scribd logo
1  sur  20
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

Contenu connexe

Similaire à Core text

Swift programming language
Swift programming languageSwift programming language
Swift programming languageNijo Job
 
Indian Language App.Development Framework for Android
Indian Language App.Development Framework for AndroidIndian Language App.Development Framework for Android
Indian Language App.Development Framework for AndroidSiji Sunny
 
358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1sumitbardhan
 
UCSY CS Club Week2
UCSY CS Club Week2UCSY CS Club Week2
UCSY CS Club Week2Ye Linn Wai
 
Programming languages and concepts by vivek parihar
Programming languages and concepts by vivek pariharProgramming languages and concepts by vivek parihar
Programming languages and concepts by vivek pariharVivek Parihar
 
Benefits of Typescript.pptx
Benefits of Typescript.pptxBenefits of Typescript.pptx
Benefits of Typescript.pptxAmitGupta440280
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design BasicsAkhil Kaushik
 
Bonding with Pango
Bonding with PangoBonding with Pango
Bonding with PangoESUG
 
Compiler Design Introduction
Compiler Design Introduction Compiler Design Introduction
Compiler Design Introduction Thapar Institute
 
HTML5, CSS, JavaScript Style guide and coding conventions
HTML5, CSS, JavaScript Style guide and coding conventionsHTML5, CSS, JavaScript Style guide and coding conventions
HTML5, CSS, JavaScript Style guide and coding conventionsKnoldus Inc.
 
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxUnit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxMalla Reddy University
 
c# usage,applications and advantages
c# usage,applications and advantages c# usage,applications and advantages
c# usage,applications and advantages mohamed drahem
 
Bringing a Design Language to Life in Sketch and React
Bringing a Design Language to Life in Sketch and ReactBringing a Design Language to Life in Sketch and React
Bringing a Design Language to Life in Sketch and ReactGrace Kwan
 
aditya malkani compiler.pptx
aditya malkani compiler.pptxaditya malkani compiler.pptx
aditya malkani compiler.pptxWildVenomOP
 
The Spoofax Language Workbench (SPLASH 2010)
The Spoofax Language Workbench (SPLASH 2010)The Spoofax Language Workbench (SPLASH 2010)
The Spoofax Language Workbench (SPLASH 2010)lennartkats
 
English de lenguaje de programacion
English de lenguaje de programacionEnglish de lenguaje de programacion
English de lenguaje de programacionVillalba Griselda
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design BasicsAkhil Kaushik
 

Similaire à Core text (20)

SPC Unit 2
SPC Unit 2SPC Unit 2
SPC Unit 2
 
Swift programming language
Swift programming languageSwift programming language
Swift programming language
 
Indian Language App.Development Framework for Android
Indian Language App.Development Framework for AndroidIndian Language App.Development Framework for Android
Indian Language App.Development Framework for Android
 
358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1
 
UCSY CS Club Week2
UCSY CS Club Week2UCSY CS Club Week2
UCSY CS Club Week2
 
Programming languages and concepts by vivek parihar
Programming languages and concepts by vivek pariharProgramming languages and concepts by vivek parihar
Programming languages and concepts by vivek parihar
 
Benefits of Typescript.pptx
Benefits of Typescript.pptxBenefits of Typescript.pptx
Benefits of Typescript.pptx
 
Text
TextText
Text
 
Julie Strawson
Julie StrawsonJulie Strawson
Julie Strawson
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
Bonding with Pango
Bonding with PangoBonding with Pango
Bonding with Pango
 
Compiler Design Introduction
Compiler Design Introduction Compiler Design Introduction
Compiler Design Introduction
 
HTML5, CSS, JavaScript Style guide and coding conventions
HTML5, CSS, JavaScript Style guide and coding conventionsHTML5, CSS, JavaScript Style guide and coding conventions
HTML5, CSS, JavaScript Style guide and coding conventions
 
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxUnit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
 
c# usage,applications and advantages
c# usage,applications and advantages c# usage,applications and advantages
c# usage,applications and advantages
 
Bringing a Design Language to Life in Sketch and React
Bringing a Design Language to Life in Sketch and ReactBringing a Design Language to Life in Sketch and React
Bringing a Design Language to Life in Sketch and React
 
aditya malkani compiler.pptx
aditya malkani compiler.pptxaditya malkani compiler.pptx
aditya malkani compiler.pptx
 
The Spoofax Language Workbench (SPLASH 2010)
The Spoofax Language Workbench (SPLASH 2010)The Spoofax Language Workbench (SPLASH 2010)
The Spoofax Language Workbench (SPLASH 2010)
 
English de lenguaje de programacion
English de lenguaje de programacionEnglish de lenguaje de programacion
English de lenguaje de programacion
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 

Dernier

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 

Dernier (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

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