WWDC2004 Session 425
Transcript
Kind: captions
Language: en
afternoon everyone please welcome from
apple computer manager of text input and
fonts Julia pagalo welcome to section
425 I hope you guys are having an
excellent conference this year when we
were put in the session together we were
wondering what percentage of the
developers attending the session would
be new to the area carbon test and what
percentage would be returning developers
so let me start by asking how many are
new to this area any anybody all right
good how many of you are ready using the
sum of the carbon tax day tea is for
malkinson excellent we have a session
that is packed with information for both
you the new developers so that you can
quickly orient yourself in this area and
for you the developers who have been
using our API is relief after release in
particular I'm going to start by giving
you an overview of the carbon tax ati
landscape and i'm going to talk about
the api for static text as well as the
API for editable text after that I'm
going to turn my attention to the H I
textview api's and the MLP api's for
edit above text and then I'm going to
turn the presentation to Tom Madden one
of the engineers india sua teen and
he'll going to talk to you about Atsui
which are the ati you use for laying out
that so say that a lot of the
applications have a need for static text
either for your labels and your controls
for your text in your dialogues or some
bits and pieces in general of text and
for statistics are basically four
components and play a key role in this
area at the bottom of my diagram is
court they opposed to the drawing engine
which provides beautiful crisp and
clearly of steps on the screen
a client of course is at suing apple
type services for unicode which is the
component responsible for position in
the glyphs correctly on your documents
and also breaking the lines of text
correctly whatever language you use it
are using at the time with these
Japanese Chinese a Roman language as
sweet as the right job the next level up
I either the appearance manager in the
high-level toolbox or TMNT api's which
stands for multilingual text engines in
ninety five percent of the cases ninety
nine percent of the cases the API that
you should use for static text that
would recommend you use is the H I theme
text API however there are situations in
which you need control of the rotated
text in which you need control over your
the comp the graphic context or you need
to use styles other than fonts other
than the ones eh I theme fonts provide
in that case we recommend you look at
the two api's that NLT provides for
static text that not enough you need an
additional control for your static text
then you should look at your 380 eyes
and tom is going to talk to you about
them the second portion of this
presentation the same components they
play a role for static text play a role
for editable text and you see them on
the screen now let's say that you have a
male like application that where you
have some small text fields on the top
of your window say for your recipient or
your subject of the email and some large
text areas for the content of your email
which api's should you use some sort of
the small text fields would recommend
you use the unique or control and those
are being available and the system since
the first version of Mac OS 10 for the
large text area if you have an
application currently running a mac OS
and you are using the system APH you're
probably using MIT directly
which is good however we recommend that
for tigers and Beyond utilization to use
the HR syntax of straight eh I've
textview api's in conjunction with Emily
and I'm going to tell you why in a
second but before I move on I also want
to point out that if you are developing
your own text engine in that case you
may watch you you want to use your thigh
api's directly and again tom is going to
talk to you about that in summary if you
have static text for most cases take a
look at the H ice cream text box ad eyes
if you need additional control over
styles the graphic context or you need
to rotate your text take a look at TX
and draw CF string text box API hand
those are in the MLT heather and if you
need additional control over how your
text is rendered please look at the etsu
api for edited tech foots text field as
i said using Unicode control and that
dat iris is on the screen is the ati
create unicode air attacks control is
the ati you call to create one such text
field and for text areas again for tiger
and beyond we recommend you start using
a chai text view in conjunction with a
melty now I'm hearing some of you back
in there in the room saying i have an
application i'm using the NL ti ti for
my text area they work beautifully why
should i move on and transition to a
chai text you in here at six reasons and
they probably did more in the future so
if you attended a high-level toolbox
sessions during the conference this year
you heard that the high-level toolbox
team is working hard has been working
hard in modernizing the tool the carbon
toolbox and then transition into in a
hierarchical view model
if you use h 8 xu your text areas will
be belong to the hierarchy and the
advantage of that is that then
internally we can take we can use that
information to optimize for the instance
the rendering of the other objects in
addition the order or the carbon events
a well-defined if in age if your text
area is an H I textview also throughout
the conference we been pointed out the
importance of supporting accessibility
so that your application is available to
a wider set of customers if you use H I
text you accessibility is built in in
your text area there is no what that you
need to do in order to make your text
area accessible compositing is also
supported in a chai text view and in
addition is very easy to create an HR 8x
you're using the tools their apple
provides and I'm going to show you how
to do that in a minute last but not
least if you have a text nhi tests you
the MLT object is still is available to
you so that you can extract that object
from the h i text you and you can reuse
all of that code that you already have
in customizing your text area using the
MLT api now let me take a quick detour
for those of you who are new to the area
of carbon Tet and tell you what are the
advantages of using Emily what is the
MLT provide so emily is a full unicode
layout and edited engine and what that
does mean to you is that your text area
are going to support all of the
languages the mac OS and supports you
don't need to worry about they are
upgrades up through the unicode standard
you don't need to worry about learning
about how bi-directional text works that
is there for you in addition because we
leveraged Atsui we had advanced
typography i suggest you go and use the
typography panel
in conjunction with a multi in target to
see how you can take advantage of all
that which features that we have in the
fonts to produce some beautiful text of
course we have antialiased s and memory
also provides built-in support for
multimedia which is important because
this edge is very rare the document that
contains text only another advantage of
a milky ati's is that they provide
support for the basic functionality
without requiring for you to write any
code so for instance you get input text
input from any of the input methods in
the system whether they are corrected
palace keyboard layouts input methods
ink it just work selection drag and drop
are built in and we also added support
for the document axis which are new area
which are new carbon events that were
introduced in center now that is not
enough if you need customization for
your text area MLT provides a simple set
of 80 is that allows you to customize
the text area to your needs and I'm
going to show you how to do that in a
second but most important I think energy
is an evolving and growing side of 80
eyes we've been listening to your
feedback and we really thank you for
that of what are the areas that are
important to you what are the areas
where you need new API is to customize
your text area and so I like to think of
the improvement in MLG into area on the
one hand we have the improvement that we
do under the hood those are the that's
the work that we do at Apple so that
your application provides Richard and
Richard behavior without you making any
changes whatsoever to your code now
going to give you an example of that on
the other hand we have new api's based
on your feedback that allow you to
customize your application and deliver
to your customers the functionality they
need
so let's talk a little bit about what
we've been working on what are the areas
where you can see enhancements in a
multi as there are more and more carbon
and cocoa application in the system we
think it's important that the users get
a consistent behavior as they switch
from one application to the other so
we've been working closely with the
cocoa teams to provide a consistent
behavior this is working progress but
you can notice that there has been some
improvements in this area their
customers are there are more and more
volte lingua so we've been working on
improvement or improving the
multilingual experience in your text
area in particular I want to point out
that we have added support for Guinness
variants in a tiger so that for instance
you can use the typography panel use one
of the phones with the has Cliff
variants built-in and you can choose the
glyphs that you want to represent your
name this is it for the instance is
important to our Japanese users you can
see on this the second line on my screen
is three of the spellings for the last
name Watanabe and the second character
is different in each of the ways they
spell it and that is important to
Japanese users in addition the capoeira
team has been working on improving the
conversion accuracy of the input method
and the way they did that is by
leveraging some new carbon events that
allow the input method to get access to
the context in your text area we added
that support in a multi so that your
text areas get better conversion
accuracy for Japanese there are people
session yesterday we heard that it's
important to many of you improvements in
Arabic support and I wanted to point out
that we've been working on improving our
bi-directional text in a multi for
instance in pan that we improve how the
characters as boundaries between Roman
and Arabic
we're not there yet we know but we are
making progress also if my quest and
involves we've been involved in the
implementation of MLT you heard at the
conference the quick-draw API had been
deprecated we had removed that code path
in a multi so now that you get
absolutely MCG on d in addition we
transition our implementation to use
QuickTime importers so that now you have
a wider set of file formats that you can
import into your and multi text area and
also we've been working on performance
performance performance performance was
our mantra using the Panther release and
what I show you on the screen is some of
the results that if we have between
improvements that we have between 10.2
and 10.3 for instance reading in a text
document the performance of that
operation is 400 times faster scrolling
text is 250 times faster and if you
select all the text in your document and
change the style is 160 times 5 I want
to point out that these improvements are
not only the result of the air for the
MLT team we work closely with the CG and
your soy sauce and the rest of of the
engineers are apples so this is the
result of the combined effort the
performance improvement that you have in
the current tiger deals are very much
comparable to the Panther GM results and
we're still working on that so I do
expect that by the time uShip Tiger
those numbers are going to look even
better now that's it old what's new what
is the new entire so I very happy to
announce that we were able to implement
all of your commonly requested ati's in
a multi for tiger and so let me start
down that list first of all we have a
new group and what an undue group is
basically it's a sequence of actions
that are bracketed be can it be they are
bracketed
to in a beginning and an end api so that
you can give the illusion to your users
when they go and click on the undo item
that all of those actions Adams undone
as a single one and the reason why that
is important to some of you is because
some they are situations in which you
want to initialize your text object with
some text change in style add some
pictures but then you want your users to
undo all of those operations as one take
a look at the API they are in the
headers there are also some related API
that are used for that you can correctly
under the undue menu or that MLT handle
the undo menu correctly let's talk about
scrolling by default MLT you scroll and
some of you love it and some of you hate
it and the reason why some of you don't
like that before behavior is because
it's not suited for your application so
let's say that you have an application
that writes status results to your text
window as it runs one of your users is
looking at the window and is reviewing
the results in the meantime the
applications is adding data to the
bottom of the text area well MLC is
going to score and that might be my via
disconcerting behavior so for tigers we
added some new tasks that you can
control the scroll in behavior the way
you like it you can have it as it is by
default you can make em out TD head like
the terminal in the scrolling behavior
or you can tell them until you don't
scroll at all until I ask you to do so
as I mentioned before if you're using H
i text you you get accessibility support
for free however if you need to continue
your application is to work on back to
panted or for whatever other reason and
you want to continue to use the MLT a TI
we providing you nati to add
accessibility support to your text area
they say the PX on save and the TXN
lady eyes were showing their age they
were all they you do some more data
structures and on the one hand on the
other hand we wanted to add support for
that tfd we added support for at PF
during the Buzzard release in Java we
wanted to extend the support and even
more compatible with the coco start
another PSP support in addition some of
you have been asking for 80 is that
allow them to save and retrieve
information from memory so for tiger we
added to FB i--'s to read and write to
CF data and to API to read and write
from CF URL in addition there is an
auxiliary API that allows you to decide
what is the best file format that you
need to use in order to save your data
without losing and information and and
that is important for instance if you
want to decide whether it's use at PF or
plain text you know another API that we
added actually to ati's we added to set
and get the event target there's been
some confusion in the past where a multi
installed a carbon event handlers and so
although I haven't seen any feedback on
that area recently there was an
outstanding requests for api's that
allow you to set and get the target
event in the targets for the carbon
event cinematic and those are there in
the multi we also added better ways for
you to turn on h high command handling
and i'm going to go in some detail on
the bardo city is in a minute few more
things we added supposed to start
checking and we are the support for the
Fontan so
right now with very few lines of code
stop shaking is working in your text
area and the very few lines of code that
front panel is also working and not only
the main front panel but the color
subpanel the character palette the
typography fun oh and if some of you had
tried to do it that's quite a fair
amount of wood so we have simplified
that in condition all right so two words
of caution one is as Steve mentioned we
are showing you tiger is soon a lot
earlier than other releases so the api's
are they are the basic implementation is
there we're still working on that so the
second word that I want to say is please
give them a try we've been implementing
them response to your request we love to
hear what you have to say and whether
there are things that we need to tweak
all right so what I want now to do is a
more hands-on approach I'm going to show
you how to build a nature textview to
show you the event managers can do it
and how to actually customize it and
then I'm going to move on and give you
some tips and tricks on about
optimization so again can I have the
demo machine please the other dimensions
thank you so I have interfaced yielded
running
all right thank you so I'm going to
create a carbon app with the menu may
with the menu bar and just for the
purpose of this demonstration so that
you can see the contrast between the
background and the text area I'm going
to make it metal and now i'm going to
drag and drop from the carbon palace the
text area i'm going to resize it just
resize it and i'm going to do one more
thing i'm going to give you an egg give
the text view its signature and an ID so
that later on i can retrieve it in my
application and when i give it the
signature text and the ID 0 and right
well so i have nhi to you with an emoji
object inside it and i can type maybe i
can switch to japanese and I can touch
Japanese have right with me no line of
code I can bring up word texts and I can
copy and paste next text so all of that
but just dragging and dropping in a few
clicks so what can I have stage lights
stick so that shows you how to build
your H I Texas but and maybe the basic
functionality is all you need but say
that you need to add some margins you
wanted to retrieve the text you want to
add some tests programmatically then in
that case if you need to customize your
H i text you you want to use the NLT a
tree eyes and if you have been doing so
that you can transition your creation of
the text area to do search i text you
and then take advantage of all the other
code that you already have so this is my
detour for the folks there and need to
be Syria so let me give
give you some basics about Emma to use
very simple MLP represents your text
area your document within a txn object
which is an opaque object if users
object white controls each area called
object controls and EMS you uses the
concept of style attributes that are by
run so for instance you can have your
text is divided in chunks of for offset
0 to have to plan your texts lucida
point size 10 blue from after 11 to
offset 15 is half load test point size
18 green and so on and so forth now
another key concept to a multi is carbon
event and I wanted to say four things
about that so the first one is if you're
using nhi textview MLT is going to
install the carbon event handlers on
your own in view and it's going to
install all of them and creation time
some of them are be going to be turned
on some are now going to be are going to
be off but the important point here is
that all installed at the same time so
that reason why that is important so you
have a good picture of where in the
stack of your carbon events a monkey has
input is on event handlers by default we
turn on the input the text input event
so that you can type in using any of the
input methods and the document access
events which are used by the input
methods as well in addition you can turn
on support for DHI commands weather is
for your edit menu for spell check in on
the fun or for the phone panel but those
are off by default and you can turn it
on for later so that ends my detour now
remember we had our GHI text view and
I'm going to show you how to extract the
MLT object so here it is first of all we
have a constant that allow us to
identify that particular view in our
hierarchy after that I going to call
some standard
high-level toolbox ati's to find the
hood of the hierarchy and extract a
particular view that I'm interested in
this case ehh i text you and once I have
the H I text you I can call hhx you get
TX an object and that gives me the emoji
object now I'm good to go alright so to
show you how to use the MIT api's I'm
going to demonstrate how you can turn on
spell checking and it's going to be very
simple NM LT leverages the H high
command support that we added for tigers
to turn on spell check so let me remind
you what I be a trike man so we have two
flavors of HR commensurate recommend
process events which are the advance
that sent when your users click on a
menu item or set select menu item of
clicks under control and then the rabbit
I try update status events which are the
events are dispatched to your
application when in UI elements needs
updating for instance before your menu
comes up you get one of those events
which you have a chance to update the
information in the look of the items in
your menu we recommend that you handle
all of the H I commands for the menu or
none of them to avoid compatibility
issues in the future and that's actually
the way we did it for a multi so for
Tiger winter we are introducing the TX
and said command event support which
allows you to turn on and off support
for basically three groups of H I common
for editing for stout shaking and for
the fun part and those those three
flavors both for processing and updates
testers I'm not going to go through the
details of that you see on the table but
surface is to say that you have three
options that you can turn on and those
enable
the handling of the H high command's in
a multi so for instance if you decided
you wanna melt you to handle they edit
command processing events and multi will
do so annual handle the undo redo select
all and so on all right now how do we
turn start checking on very simple we
set the options for the HR I commands
that we want the spell checking in this
case and then we call TX and set command
event support with the MLT option and
the options that we set and that's it
from that point on spell checking is
going to work now what is it going to
what is that you're going to see in your
application when you turn start checking
on so if you have new spells they are
going to show up as red dotted underline
in addition we provide a contextual
support for the contextual menu and we
added some api's so that you can modify
the content of that contextual menu if
you choose to so MIT is going to handle
the contextual menu but we're going to
give you a choice modified as you need
and also we provide support for the
spelling panel so if this dead the hy
commands for the spelling finally sent a
multi would react to that and show to
spend in panel so that your user can
select it dictionary learn a new word
spelling and so on if that looks
familiar to you that is because we
implement the same UI is Coco so we were
talking about that consistency between
carbon in cocoa and we wanted to put you
know in breach that so they day you I is
exactly the same you use the same spell
check in ng and the same set of
dictionaries alright so as with that I
show you how to create your H i text you
you how to extract the emoji object how
to customize it now as important is that
to use the API is important also that
you use them correctly and I'm going to
give you some tips that will learn over
the recent months by
working with developers and analyzing
the performance of their application so
the first one is their cases in which is
you don't need all of the rich style
texted MLG supports what you really need
is one of style text in that case would
recommend you use ktx and mono style
text mask when you create your object
that allows us to optimize the brake
line operations because they hyped the
height of the text is constant for tiger
we introduced the KTX and disable layout
and pro tab which is useful when you do
multiple sequential modifications to
your msg object so basically what you
want to do is you want to set the mask
on modify your objects turn it off and
draw and that way MIT will not draw and
brake lines in between operations that
is the same behavior as the KTX and
disability tag used to give you but the
name was really confusing so we decided
to introduce its as it has a name for
what it really does if your text and
with carriage returns then you want to
use the KTX and word wraps data and set
it to nor wrap that way we can avoid
doing unnecessary line breaks which
could be an expensive operation in the
case of Unicode and text as important
that they do teach at the things that
you should not do the model in a multi
nh-8 xu is that a muskie are we asked to
changes to the object by redrawing so in
most cases you don't need you do not
need to call the x and draw one
exception is if you use the TX and
disable a disabled layout and draw up
after you will be enabled laying out and
drawing the test you want to call TX and
draw and that is because I was
implemented long time ago that way and
we didn't want to change it to avoid
performance impact also unless you
really do need it do not use the KTX and
always
rapid view edge mask what that mask does
is keeps your destination rectangle of
your texts pin to the direct of your
window so as you resize your window your
text we're crazily breaking lines and
rejoin your text and that sometimes it's
not the behavior you want so keep an eye
on that if you need it feel free to user
we improve the performance of that
operation quite a bit but if you didn't
need it done said all right and with
that i'm going to give you a quick demo
of then you api's working on tiger let
me clean up some okay so what I have
here is a multi showcase that's an
application that we put together one of
the engineers in the teen road for WWDC
you have it in your SDK feel free to
play with it and give us feedback so
what you see is the large text area is a
nature a text view in Anna multi-object
the small text area on top of that is a
unicode control and we put some radio
buttons to control the behavior because
one of the feedback that we heard is
that did you want to be able to manage
the behavior of your text objects for
any from any kinds of controls not only
for menus so the first thing I'm going
to do is I'm going to turn on spell
check in and I am going to start typing
and I have practice next so while they
cannot make a typing mistake there you
are so as I tried the red dotted
underline comes up and all of the lines
of code that our Dean executed is the
one that I show you we don't have
contextual menus you're working yet in
this application but you will be there
soon and there should okay let me move
on to the front panel and I'm going to
select this paragraph I'm going to
change the font
choose huh flirt text I'm going to hello
yeah thank you they're all right so as
you see I have all of the different
options for changing the style in the
from the front panel working with a
multi object I can even bring up the
color palette and change the color I can
strike through I can underlie so all of
the different palettes just work and
again this is by turning off the H high
command vent support in a multi we have
let them hear a way to show you how the
undo groups work by an on going to have
time to go into that and so let me just
show you the no scrolling in action so
let me copy copy alright nevermind as I
said this is working progress let me
copy the text and let me put my
insertion point at the bottom and i'm
going to paste it and as you see as I
paste the text MLT is going to scroll so
now we're going to turn no scrolling and
i'm going to start pasting nothing
happens as you see this the scroll body
is getting smaller because the size of
my text objects is increasing and
actually the text has been pasted at the
bottom of the of the object but there is
no scrolling action then the next to
write your buttons is going to show you
how to use reading and writing to a CF
URL and you can take a look at that and
again give us feedback and with that I'm
going to end up stay in Matthew session
and I'm going to turn the presentation
to Tom marriage take you how's everybody
doing good conference so my name is Tom
medan I'm a engineer and I've been
working on em Suey for a little while
now well let's get started absolutely is
an acronym that stands for apple type
services for Unicode imaging today I'm
going to cover kind of what it is and
why you should use it I'm going to cover
some basic Atsui construct some things
you would need to know to get started
using up suey I'm gonna cover how to do
some line breaking drawing then I'm
going to cover some advanced features
and I'm going to give you some
performance tips for those of you who
are considering using s3 or have already
adopted it so without further ado what
is that suey well that's two is the low
level unicode layout engine at tsui is
used by all those things that Julia just
showed to actually take the Unicode text
that's used as an input and display it
on the screen absolutely provides layout
services for all those things plus it
provides some services for app get it
provides services for safari and a whole
bunch of other apps so you might be
asking yourself what is layout we've
been using the word lay out the whole
presentation some of you may or may not
know what it is well layout is simply
the process of taking the Unicode text
and converting it to glyphs and
physicians which gets then fed into the
courts rendering engine the glyphs are
and positions are determined by two
things first of all the layout tables
that are embedded in the font Atsui
supports opentype font layout tables
which are the G pause in the G sub table
as well as the AAT font layout tables
it's always supported those in addition
to the layout tables it also requires
character properties unicode has a great
character properties database where it
can find all sorts of information about
the characters so it takes those two
bits of data munches them together and
out come the glyphs and the positions so
besides the standard character to glyph
mapping reordering and stuff like that
that's required by layout absolutely
also does a couple other things the
first is automatic font substitution
automatic font substitution allows that
fooi to substitute a new font
should the fonts that you have selected
not be able to map the characters that
the user has input into Atsui so for
instance let's say you have selected
times new roman and then the user has
input a japanese text times new roman
can't display japanese so x we will go
out and substitute a new font for it
most likely hiiragi know additionally
absolutely provides API for style
management there's an there's an
absolute style object which I'll get to
in to in a minute it provides API for
line breaking which can be pretty tricky
in the case of Unicode and it also
provides API to help you if you had an
editable document so you've seen all the
stuff that julia has you've seen the MLT
ml te you've seen the h i text view you
might be asking yourself why should use
that tsui directly well if you need the
ultimate control over the text you would
use that tsui with that suit you can
control the line breaks you can control
the position the exact position of the
text you can even go into the glyphs and
change their positions directly in
addition at suite provides broader
options for tracking justification
kerning flush pneus and all this other
stuff that you may want to control
directly in addition if you have custom
rendering paths such as you want to go
out to you know say in OpenGL context or
something like that you may want to use
that tsui as well what absolutely will
also get you switching to etsy we
directly is speed in a sense those AP is
that that Julia mentioned and a lot of
the other ati's in the system their
whole purpose is to feed Atsui unicode
techs and to manage their silly objects
for you but if you can do a better job
at doing that then you will get a better
a you will get faster operations because
these objects in some cases were
designed for more general case
so you've decided okay I need to use
that suey so what do you need to know to
get started well the first is you need
to know about unicode the unicode text
buffer that you provide to ETSU II must
be in the utf-16 format Atsui doesn't
accept utf-8 doesn't accept utf-32 only
accepts utf-16 you can get your text
into utf-16 format using CF string or
text encoding converter whatever it just
has to be in u.s. utf-16 format the
second thing that's very important is
that you own the text buffer you can't
free the text buffer out for Matsui if
you do that bad things will happen Atsui
does not retain the text buffer and so
he doesn't do anything like that you
manage it you own it and likewise if you
should change any of the text in that
text buffer you have to notify Atsui so
if you insert text delete text move the
buffer around you have to call an API
which I'll show you in a minute finally
one important note that has tripped up
more than one person is that the
character the glyph mapping is not
necessarily one-to-one even in the case
of simple ASCII English Roman text so
one of the most blatant examples is the
FI ligature you have a F character and
an AI character which combine to form a
single glyph and so if your code makes
assumptions that the there will be one
character for one glyph it will break in
a lot of cases so you have your unicode
text buffer it's in utf-16 it's ready to
go you want to do something with it so
what do you do with it the first thing
you have to do is tell that silly where
it is and you do that by creating an
absolute text layout the absolute text
layout is simply an object that
references your unicode text buffer to
inside that s to text layout you also it
also tracks the style assignments so you
take a range of that buffer and you sign
it to Helvetica you assigned it
time you sign it to two different fonts
or different styles it also tracks the
line breaks it tracks the font fallbacks
which are which allow you to customize
that font substitution behavior that I
talked about earlier and it also tracks
the tab rulers and the tab stops you
modify the fat suit text layout by
setting layout and line controls on it
and there's a there's a couple api's
that allow you to do that and finally
and perhaps most importantly the
absolute text layout will store the
cache lines glyphs and so if you're
constantly creating these things and
throwing them out you're going to get
rid of a lot of work and your
application will run slower because that
whole layout process that I had that
graphic up there for that can be an
expensive process because it has to read
in font tables and interpret the
characters if you throw that work out
and have to recreate it your your
application is doing a lot of extra work
so to create an absolute text loud it's
pretty simple we have an API called as
to create text layout you just call out
to create text layout and you have a
layout it's empty doesn't do anything
yet so you have to assign some text to
it we have an API called absolute set
text pointer location you call that to
set you to assign the buffer to it and
then finally we always recommend that
you call absolute set transient font
matching this will turn on the font
substitution behavior as I described
before it's off by default if you don't
turn this on what will happen is if you
should encounter some text that you're
currently selected font can't render
you'll get ugly little boxes and that's
not pretty so you have your absolute
text layout it's it's kind of boring it
doesn't really do anything yet in fact
if you try and pass it to a draw API or
measurement API you'll get an error
because it doesn't know what to do yet
so to make it much more useful you have
to assign a font to it you have to sign
some style to it and so you do that what
the apps
style object which is simply a
collection of the stylistic attributes
it's the font the color the point size
all this stuff that you want to kind of
style as the text with you take that fu
style and you assign it to a range of
text within that a suit text layout now
an important point is that once it's
assigned to an absolute text layout you
can go ahead and assign it to as many
other etsu text layouts if you want it's
not tied to any specific text layout you
can you can reuse it over and over again
in fact that's recommended because
you'll be creating fewer objects so to
create an absolute textile the first
thing you do is you call as who create
style and that creates a blank style
it's set up with all the defaults in
fact you can use it right away it's just
maybe not what you want i think it's set
up with Helvetica 12 point and a couple
other defaults so to get it more to get
it into a shape that you would want to
be able to use it in you have to set
some attributes to it here i'm setting
the font tag which will set a font a
specific font to that style and a size
tag which will set a specific size to
that style once i have the tag set up i
call lets you set attributes with the
tags and the values and that will set
everything up and it'll be ready to go
so once you have your absolute style set
up you assign it to the text layout to
arrange them the text layout using a
sous cette run style so your text layout
is all ready to go you have the style
set you have all the text in it but
there's one problem it's all one line
and so for some folks that may be okay
but if you have a haven't have an
application that requires line wrapping
a line breaking you need to call Atsui
to do the line breaking for you Atsui
has 29 brittany api's one is called ETSU
batch brake lines and that's
an API that is optimized for breaking
constant with lines and so for instance
if we're breaking inside a rectangle or
if you are breaking down a constant with
barrier you can use that suit batch
brake lines absolute brake line is used
in the situation as could be used for
the situation pictured above where you
would want to vary the line with in this
case we're trying to wrap around an
object so the line with on this side are
a little shorter than the line with
below so that's your batch brake lines
sets multiple brake lines at once and it
requires that you have a constant width
and so here breaking into a box as to
batch brake lines is is used simple the
first thing we recommend is that you set
the width in the object you can specify
a width to the batch brake lines API but
the problem is that with is only used
for line breaking so if you go and apply
a flush nest or a centering or some
other you know AP item to that requires
a with that width won't apply and so you
need you would need to go and set the
width anyway so we recommend you just do
it before so you do as you set layout
controls with that with and then you
simply call a soubrette batch brake
lines and it will go down and set all
the line breaks to that with you've
specified if you need to do non-constant
with breaking if you need to vary align
with if we need to do other things like
that we have the absolute brake line API
and that will let you set the width for
every operation an important thing here
is to let Atsui set the line break once
it's found it at su brake line can be
used in a mode where it can just find
the brake for you which may be what you
want but it's recommended that you let
em sua set the brake once it's found it
and you do that by passing in a
parameter which I'll show you in a
minute this is important because if you
don't let us do we set the brake it will
have to go back and refigure out that
break when you go and set it so you'll
throw out a little bit
work so this code up here does the same
exact code as the batch brake lines
example that I showed you it just uses
the brake line API so like before the
first thing you do is you set the line
with in this case we're using a constant
with the next thing you'll probably want
to do is get the character count so you
know where to stop breaking the lines
you set the brake to start at the
beginning then you call a su brake line
in the loop until it's consumed all the
characters so the next thing you
probably want to do is now that you have
your you're nice as you text layout you
have all the lines broken you have all
the styles of sign is that you probably
want to draw it absolutely has a
function called absolute draw text and
the important point here is it draws one
line at a time so you'll have to draw
those lines individually you should
always specify a CG context and you do
that via a text or a line layout option
or a line or a text layout option in the
absolute text layout you do absolute set
layout attributes with the CG context
and then it'll be set in the text layout
let's say the reason why you do that
because if you don't set a text layout
Atsui has a quick-draw fallback mode and
so if you don't set a CG context it'll
have to go through and look up a CG
context for you from the current
quick-draw port which is a very
expensive operation so if you set that
fiji context beforehand you'll avoid all
that work another important thing to
remember when you draw text is that you
need to flush the CG context if you
don't flush the CG context you probably
won't see anything but you should only
flush at once and so if you're drawing a
whole paragraph worth of text you want
to flush it after you've drawn all the
lines
so some of you have have needs you're
writing a text editor you're writing a
an application that has editable text
you'll need you'll need to use some
editing api's Atsui has hit testing and
cursor handling api's i'm not going to
go through those we have highlighting
api's to handle the highlighting and
unhide aligning text and these are kind
of useful because in unicode techs the
highlighted areas can be discontinuous
depending on the directionality in such
of the text in addition we have three
api's that will be required it should
you ever insert or delete or move text
and there are listed up there on the
screen some advanced features that a
absolutely has that you may be
interested in is we have the absolute
glyph selector to specify a glyph
variant you specify this absolu glyph
selector in the style and that allows
you to do the glyph variant support that
Julia showed you that ml te handles for
you as so we also has the absolute
direct access calls and these allow you
to get exact glyphs and glyph physicians
and all sorts of other information out
of the layout for those of you who want
to do your own positional manipulations
or supply your own metrics as so we also
have some flattening api's for
pasteboard experts exports this will
allow you to take the app to styles that
you've set in the in the layout flatten
them all to a binary format so you can
put them all up on the pace board or
save them to disk and finally absolutely
have some curve access api's and these
are really cool because they allow you
to get at the curves that if tsui is
giving to the graphics engine to draw
the glyphs so some applications such as
motion have used these to actually do
animated text and other cool effects
with those curves so some some folks
have a half first and performance tips
besides some of the ones that have been
given throughout the presentation you
should use the absolute get bliss bounds
API for measuring the text whenever
possible absolutely provides several API
is for measurement and this is the only
one that's guaranteed not to accept
upset any of the cache data some of the
API is require it to do some extra
processing work to get the correct
measurement the measurement that you
requested for this will give you a
typographic bound that's guaranteed to
not upset the cache layout second thing
if you are getting the curves you should
call ETSU get native curve type before
accessing the curve and set up your
curve callbacks according to the result
of that some fonts have curves accepts
and cute or some fonts have curves
stored in cubix some fonts have curves
store in quadratics and if you use the
wrong type Atsui has to convert the
cubes to quads and the quads two cubed
and that's that's not an expensive
process and may give you some
ugly-looking text if you go to draw
those those curves finally if there's
anything that you should take away from
in terms of that silly performance is
that you should maximize the object
lifetimes meaning that you should not
throw away these objects until you're
absolutely done with them keep the text
layout objects around keep the appt su
style objects around following that you
want to minimize the object creation you
want to create as few eps of styles as
possible and you want to create a few
apps and text layouts as your
application requires so that wraps up
the Atsui section of the of the session
and there's a couple things that you
should take away first is that you
should use the hii theme text API for
static text it makes things a lot easier
you can create these things in project
builder second use the unicode control
api
for text fields and these are the small
little text boxes such as password
fields and in little search fields and
stuff like that third use the H I text
view oh and the M LTE API for text to
protect areas these are large you know
document sized or large input areas
fourth you can use that tsui for maximum
or ultimate control on the text layout
and drawing fifth use the use the API
optimally for the best performance that
includes keeping objects around not
throwing them out creating a few objects
as possible turning off visibility on
your M LTE objects when you're doing
lots of hits and stuff like that and
finally you need to file bug reports
should you see anything wrong we're
doing our best to test these things but
every now and then well I shouldn't say
every now and then but everything we get
we get very good bug reports from you
guys from the field and we do fix those
and we do see those problems so with
that I'd like to bring up xavi a for the
wrap-up and the QA thank you
you