WWDC2003 Session 406
Transcript
Kind: captions
Language: en
thankies a BA so as love you said my
name is Robin yukawa I'm the manager of
the type engineering team at Apple
computer and i'll be talking to you
today about fonts but not just fun i'm
going to be talking about the font
system architecture and how it works how
it interacts with your application
software and how you can take advantage
of it to make a really really excellent
user interface and user experience for
your customers with regards to font so
why am I talking about fun why are fonts
important well think about it this way
imagine rolling the clock back 20 30
years and think about how fonts work
back then you would have had one font on
the system maybe a green or amber screen
and that's it maybe at best you had a
handful of fonts that you have to deal
with well things just obviously changed
since then we have dozens of fonts that
get installed by default on Mac OS 10
users can install even more fonts on
their systems applications come with
specialized fonts along with them so you
have tons of fonts you get to deal with
even by default another thing that we've
gotten feedback on with Mac os10 has
been that its sponsor complicated you
know people have to deal with a whole
variety of issues with regards to fonts
even with this installing or previewing
them you might have encountered that
with your family members asking well
where do I put these fonts you know
there's like I see a bunch of different
directories with the name font on it
where where does it go and so what we've
tried to do with Panthers is tie into
that whole initiative to put the user at
the center as opposed to having fonts
very computer centric and file centric
we want to make it so that the users can
really take advantage of fonts and
really find it easy and convenient to
use and really take advantage of all the
stuff that thought developers and you
guys have put in
to make these things expressive and
fully functional so what I'll be talking
about today I'm going to be starting off
with a description of the font
architecture you're going to get a
chance to understand what the system
does what it does for you and what all
the different components do and how they
interact with each other the second part
of the session I'll be talking about
what you can do to take advantage of the
system and bring it across to your
applications and really make things
shine so let me just guide straight into
the first section you can think of it
this way I'm going to be lifting up the
hood on the system pulling out the font
engine or the font system and showing
you how all the different pieces work
and right up here I've got a short list
of all the different components related
to the font architecture so let me just
run through them first off we've got the
font database system the font registry
as we call it this keeps track of all
the information related to the fonts and
manages all the fonts that the user can
access secondly we have the font raster
visors this TV spot engine that
basically takes the font data the raw
font data converts it over to data that
can be used by other parts of the system
such as the graphic system or the
printing architecture or even your
application the next level up we've got
the messaging system one thing that you
should understand is that we have
implemented a centralized font server
that keeps track of all of this
information in order for it to
communicate the font data to your
applications and two other processes on
the system it needs to send messages and
these are based on the mock colonel
messaging system another level up we've
got the caching system we've got the
caches to optimize performance so that
you don't have to always hit the lower
levels of the system to get the font
data that you need and then this is the
next level up we've got the programming
interface this is what you've
traditionally heard in the past and what
we've really focused on
what I'm trying to do here is connect
you to the operating system and show you
what the programming interface can do
for you and why we told you to do
certain things as opposed to others and
then finally on top of that as part of
this initiative to put the user at the
center we've implemented and exposed a
number of standard user interface
elements that you could take advantage
of so that your applications really fit
in have a consistent user interface and
take advantage of all the new features
that we've implemented for cancer so
what I've just described is a short list
of all the different components or as a
major components in the font system what
this diagram shows you are how they
interact with each other so over on the
far right you'll see two of the
components those are the components that
reside within the font server or the
80's server as you might have seen it
calls within the system 80s by the way
stands for Apple type services and
that's actually the main component that
my team is responsible for so within the
server centralized for all of the
different processes of available on the
system we've got the font rasterizer and
the font database management system or
the font registry on the left-hand side
of the screen you see everything that
resides mainly within your application
context as opposed to the font server
that includes the user interface whether
you implement it or the system
implemented or some combination between
that we have the programming interface
and we have the caches and in between
the two of them we have messages going
back and forth across to communicate the
font related data that your applications
need and your more importantly what your
users need okay so let me start diving
into the details of this diagram first
off let me work from the very basics
here the font registry itself if is the
central repository of font information
you can also think of it as
interface to the file system that lives
underneath everything else so users for
example might install fonts we track
that information we handle mapping in
all of the file related information and
pull it into the font database the font
registry also tracks all the different
locations that are supported on mac OS
10 for installing fonts and it also
keeps track of the files that are
associated with the fonts within each of
those locations the font registry is
also responsible for managing the
support for access privileges and
multiple users so for example we've done
a considerable amount of work for
Panther to support the new fast user
switching feature that you might have
seen in the keynote another piece of
information that we keep track of with
the fonts has to do with the state and
also the usage of the font part of the
work that we do within the font registry
is we synthesize data and provide a
canonical format for accessing font
related data there's a number of
different pieces of information
including the character mapping
information the past the outline data
the bitmap information the metrics we
handle all of that through the font
registry and other parts of the font
architecture we also keep track of fonts
that somehow get corrupted or actually
bad starting off we can actually tag
those fonts as corrupted or bad or
potentially causing a crash during run
time and prevent other users or other
processes from running into that problem
again and that state information is kept
track of in the font registry one
additional piece of information or one
additional service provided fides
provide the font registry is keeping
track of all of different the multitude
of file formats available for fonts so
for example some fonts are stored in
single files other ones are stored in
multiple files that get associated with
each other in certain ways you know by
file name or maybe something very deep
within the font file another thing we
keep track of is whether or not that
particular font data is stored within
the data for core resource work of a
font of a file
so that covers the basics of what the
font registry does next I'll be
describing what the font wraps the
risers do now you can think of these as
the basic engine these know all the
details about the font data they can
take the font data that's stored on in
the file system run through it and spit
out other forms of data that can be used
by other parts of the system so that
includes graphic data the bitmaps the
path the outlines that get rendered
through the graphic systems we also
provide support for converting data from
what natively stored on disk to the
formats used in for example PDF
documents when you embed fontina within
them also we convert data to the form
used with when downloading fonts to the
printing system generating postscript
forms of the fonts for example the other
thing that we do with the font
rasterizer is very similar to the way
the file registe the font registry
handles different file formats the font
master risers they actually know all the
details about the different formats
available out there so not only can
fonts be stored in different file
formats they can be stored in different
data formats themselves so we've got the
standard technologies that are out there
right now truetype postscript we support
multiple forms of them including the
type one format that you're probably
used to a mac OS Mac OS 9 and older and
we also support the new BFF or contact
font format that's available with the
open type form of the posted font and
also used in PDF document and then last
but not least we support the older or
legacy bitmap only formats that were
available for quick draw based
applications
okay so next let me talk about the
messaging system as I mentioned before
the main thing about messages is that
they are based on the lower level
Colonel messaging system there's the
inter process communication mechanism
for going back and forth between the
font server and your processes and other
processes on the system another key
thing that you can remember from this is
that pretty much any programming
interface related to the font may
ultimately result in a message that goes
from your application out to the server
and potentially back note that this can
take time and I'll be touching on this
subject a little bit later on now
messages can be categorized into
different different classes the one
that's probably most relevant to you is
that when changes occur within the font
registry the font server will actually
broadcast messages out to any clients
that are interested notification about
these changes similarly there's also
supports for your applications to send
notifications messages back to the ATF
server so that you can notify us to do
certain actions or update our font
registry there's one additional flavor
of messages or quark on it that we've
implemented through our API and that
includes support for actually hooking
into the messaging system the way this
works for example is basically since a
number of messages that applications can
send out for querying about missing
fonts let's say you open a document it
doesn't have the fonts you need what
that can often do is trigger a message
across to the font server to ask for a
replacement or to find out whether it's
actually present or not we've provided a
mechanism so that you can hook into that
process intercept that message and
provide your own level of support for
handling that missing font so some new
font utility application vendors have
actually taken advantage of this and
provide a user
or even automatically provides the
appropriate font and activate it within
the system so this shows you some of the
strengths and and benefits of going to a
messaging system the next level are the
caches now as I mentioned before there
is a cost to doing messages and having
this whole font server based
architecture what we try to do with the
caches and what we succeeded actually is
making sure that the most commonly used
functions and the most commonly used
data that you access is available as
fast as possible through this caching
mechanism you'll notice that the key
areas that we're trying to shield you
from are the lower levels in the font
system so for example the font registry
corresponds to the file system usage it
takes time to pull in a font file read
it in and handle it and process it in
fact processing it is the next level up
that we try to reduce the impact
performance wise on your applications it
takes time to run through in fact for
postcard fonts we have to parse through
the entire post Kurtz font program in
order to get even basic data such as the
metrics or one glyph outline and finally
as i mentioned messaging takes time it's
often much faster to just do a simple
function call to access your font data
locally from within a cash than sending
a message off to the font server and
coming back with the data okay so this
is what you're probably most familiar
with and what you deal with on a
day-to-day basis when it comes to font
so as I mentioned earlier 80s Apple type
services we provide a direct API into
the font system through the HTS font API
what this programming interface allows
you to do is modify or manage the
contents of the font registry you can
also query the font registry for
information we also provide support for
accessing data directly from the font
rasterizer
and finally you can hook into the
messaging system and take advantage of
it with your own application software
there are other api's that are available
that are built on top of the underlying
80's API and those include the tech
system available within cocoa or carbon
and also the legacy quick-draw based
font manager is built on top of the 80s
font system now this is the last block
diagram from the architectures that I'll
go over this is a description of all the
features that you might want to have the
user interface with regard to fonts
support for you and your customers first
and foremost you want to be able to
select or change the font and style
information in your document or in any
piece of text you also want to be able
to access glyph specific information
within a font this includes stuff like
what characters does this particular
font support or can I get access to
different variants on character and this
is especially important in the Asian
market where there are different forms
of the Han characters that people use in
for example their last name another
feature of the fonts that you can get
access through the user interface are
the typographic features this includes
support for turning on and off ligatures
or other variant forms within the font
and then finally as I mentioned one
thing that people have really asked us
for in the operating system is a really
easy way to manage the fonts that you
have your collection of fonts this
includes your entire library of fun
they're having
users have asked for ways to install
their fonts much more easily and to be
able to preview their fonts much more
easily and so with panther we try to
make that much more robust much more
simple and also we want to have room for
growing and providing additional
services so with that I'd like to bring
up one of the other engineers on my team
his name is Nathan Taylor and he'll give
you a demonstration of some of the work
we've done for Panther Thank You Robin
as robin said I'm Nathan Taylor I'm an
engineer with the apple type engineering
group and I'm very excited to show you
the new user interface and the user
interfaces that you should implement for
your for a presenting sponsor and
consistent way to your users of the
system we've taken the user centric
approach to heart here and if you saw
the keynote you saw a brief glimpse of
something I am very excited to show you
today so with that I'd like to switch to
demo one please ok you just just bought
a bunch of pawns downloaded some fonts
from the internet doesn't really know
necessarily what they look like and
biggest question like button is where
should we put these fonts you know there
are many font folders which is the best
one to place them in we've tried to tell
it people how to do it in tech notes but
there's a much easier way and let me
show you I'm going to open up the folder
of fonts here and go to one that's not
currently installed in Mac OS 10 the
font that you know and love from Mac OS
9 the type 1 version of it and if user
just double click the font the font book
application comes up and shows a quick
preview of the font where they can
switch between and examine the different
styles and with a single click of a
single button here the font will be
installed in what we considered the
appropriate place at this point in time
that is the user sponsor folder when the
font is installed the main font book
user interface comes up select the font
and they can see that their action is
actually taken effect you know this is a
quick and easy interface to browse the
fonts in the system now with the simple
arrow keys or Mouse actions the users
can look at the various fonts that are
install
get an idea what's available and if
there are some that they don't want or
they're never going to use there's an
option to turn them off I don't speak
Korean I don't read Korean I don't write
Korean I'm never going to use the korean
font to always show up at the font of
the top of the font list well I can
simply select them in font book and
disable them when the one font one spot
book is disabled to font they will no
longer be available and not show up in
the font window in cocoa or carbon
applications then go back it's also
possible to just add a bunch of fun we
have a breakdown of the font library
that shows how fonts our group and
categorized there are the user fonts
that are just my fonts there are the
computer fonts which are shared between
all users of the system network in
classic similarly usually can move on to
round between these directories that
they want to what I'm going to do now is
out a bunch of fonts the rest of the
fonts from that big folder i took
palatino from and just add all the fonts
there i'm going to show you building
collections and searching for fun so all
those fonts has been added is he I've
got a venir bodoni all the ones i just
added are all selected what I can do now
is I know I just installed a bunch of
ITC fonts but I want to group them suck
and easily find them within my
application so we have collection
management and Mac OS tend to do this
and using the new collection management
system provided by as a Coco layer we
can create a new collection maybe at my
ITC fonts and i want to add fonts to
this well just somewhere in this list
right let's find them pi PI DC and I get
all the fonts that match my search
string I can unselect all these fonts
and drag them over to my collection
there
if I switch back to TextEdit now you'll
see that the ITC fonts collection is
available and selecting that collection
shows those fonts I can then simply use
them they are available immediately
likewise there are ways for users to
quickly manipulate collections they can
tweak the collections they can remove
individual faces from them they can
remove families they can also disable
the collections from within the font
panel or from within font book
application say for example I don't like
the heavy faces here can select them and
disable them from this let me do that
again disable them from the ITC
collection rather than the library which
have already showed you and now if I
look at that family Franklin Gothic the
heavy faces are not there any more
easily just we enabling them brings them
back mmm if I don't want to use that
collection of fonts now I can simply
disable the collection and the
collection is hidden from the UI the
fonts are still active for other apps to
use but the collection has been hidden
from the UI while you may ask I want to
group these and disable the fonts as a
whole as optional behavior we do have
the possibility to disable the whole
thing holding down the option key and
disabling this will do like the alert
here it says and to say well all of
those fonts from the library by looking
all fonts here you can see that the ITC
fonts are marked off and they are not
they're no longer in the fonts window so
what do you need to do in your
applications to take advantage of this
new functionality we're providing to the
users we've made it easier for the users
to manipulate their fonts we think this
is going to allow them to do it more
often they don't need to know where
fonts live in the system they can just
launch an application and turn things
off as they wish if your app doesn't
reacts to these changes the user
interface that you presents will not be
consistent across the board and we'd
like this to be user centric so that
everything feels the same in every
application the first thing you can do
and the least we ask you to do is
implement support for ats font
notifications if you have a carbon
application or cocoa application but in
carbon application if you should
implement support for notifications we
will notify you and call back a callback
that you create and in this case I put
up alert to be extremely obvious if we
take a look in the neck defontes menu a
venir bodoni response has been added to
the fonts menu and immediately updated
if i were to disable them they would not
show up next time the font once
activated the fonts on you was opened
this correct the problem of having to
quit the app and we launch the app from
the old days and makes it so much more
consistent but there's one step further
you can go and this is what we really
ask you to do you can implement the
fonts window if you're doing a cocoa
application it's pretty easy it's right
there for you in carbon it's quite
possible but it's not quite as easy but
it's not hard at all and let me give you
an example well let me just show you
real quick I've got another similar
version of simple text here that has a
fox plant window implemented you know
close it bring it back up like the other
one you know I've got the same font and
if I reenable that ITC collection I can
show you that all the support for
collection management and the man user
managed collections are there if you
implement the fonts window subscribing
to acs notifications actually become
unnecessary because the window fonts
window handles that automatically for
you behind the scene so what do you need
to do to do this well
adding notification it's really a piece
of cake first I chose to implement the
standard fonts menu three new function
calls and effectively only three new
lines of code to ads notifications I
just created one call back and made one
function call whenever that notification
came across my callback updated the font
menu and that was it a little more work
to put in the font window but we really
don't think it's that hard if you've
been moving to a carbon event based
application you probably already have a
standard carbon event handler but that's
the first thing you need to do and the
handler I happen here is about 20 lines
of code next I put it in handler
attached to the window to handle the
font window events the font changes the
user made in the fonts panel and that's
about 25 lines of code the last thing
you need to do is update the fonts
window with the user selection with one
new function call well Robin also
mentioned that there were a bunch of
other new features to the fonts window
you see that there's a search fields
here we also have a direct access to
managing font brings up a fonts book
directly and if the user has another
font management application we expect it
to bring that up further we have
typography palette this provides access
to the various fonts features that are
not default and they're very sensible as
FB no is a very pretty font that we
install with mac OS 10 but it has a lot
of features that you can't get to right
on the surface if you implement support
for the press the typography palette you
can get access to specialized ligatures
ornaments
stylistic variants old-style figures
small caps a whole bunch of works
japanese fonts even have a lot more to
offer in this type of gothic palette for
example here ajeno one of the deputy
sponsorship of the system has many
features you can see this is a huge
palette here there's support for
Japanese features like kana wits where
you can have full width half-wits or
performs proportional widths for Connor
characters there's also support for
stylistic variants and other features
that the font may provide the last thing
I want to show you is the character
palette you may have seen this in other
presentations but there's direct access
to get too specific characters and to
see all the characters supported by the
font now unfortunately may have a little
bit more work to do on the character
palette but I think you've seen it
before you'll have a window access to
all the glyphs or all the Unicode points
of the font and the usual how to be able
to see everything that's available we
hope you like the new user centric
approach to managing fonts on Mac OS 10
and we really hope you take two points
home from today's presentation one we
want a user focused approach to do that
we actually do implement one of two
approaches in your application at a
minimum respond to a TS Mont
notifications don't make the user
relaunch your application to see new
font or to even better anywhere you
would use a font menu provide access to
the fonts panel so we can have a
standard user interface for fonts across
the entire system thank you I'd like to
invite Robyn back to stay just finish
the rest of the presentation
[Applause]
Thanks anxious so you've seen some of
the really cool user level features that
we've been working on for Mac OS 10 and
panzer so let me recap this is the
second part of the presentation this is
where i go into what you can do in your
application software to take advantage
of some of the features that we've
implemented and also to implement newer
cooler features in your application so
if there's just two things you're going
to take away from this presentation and
you go back home from WWT and implement
in your application if as Nathan pointed
out the first two items up here one adds
support for the standard user interface
ie the font window or the font panel if
you're old school like me also add
support number two for handling not
fonte nova fond notifications this will
allow you to make sure that your
applications are as responsive as
possible to any changes in the font
registry that the user initiates or
other applications trigger I'll also
cover some lower-level topics that are
of interest to you the third item is
particularly important because people
have asked we have a number of different
font referencing systems in both carbon
and cocoa and I'll go into detail about
how you can interact with the font
system the HTS font system which
underlies everything and take advantage
of those features within those layers
I'll also go into some more detail about
specifics within ATS itself such as
getting access or managing the contents
of the font registry getting access to
information stored within it and
querying the font raster risers for
information specific to glyph
okay so as I said one of two things were
asking you to do is adopt the standard
user interface now if you use cocoa you
get a lot of that for free in fact you
get most of that for free as Nathan
pointed out but with in carbon
applications you still do need to do
some amount of work it's not too bad in
fact if you look up here I've
encapsulated the real the main work that
you need to do in fact the first one so
easy I don't even have to make it slide
for it if you have a standard if you're
using the standard carbon event based
application event handler all you have
to do is add a menu items that triggers
off of that standard command ID which is
to show and hide the font panel once
that's in place you're done any time the
user selects that menu items it will
switch between the two different states
for showing and hiding the font panel
and it will initiate the font panel code
pull it in instantiate it and show it on
screen for you the other three items
I'll go into a little bit more detail in
the next couple of slides but they
include support for handling font
selection events that come from the font
panel to your application so that
includes whenever the user changes the
state as a font panel you get a
notification about that through a
standard carbon event similarly if
somehow the state of your document
changes for example if a user clicks
through and sets the cursor in different
location within your document you want
the pot panel to reflect those changes
and sync up and so there is an API to
allow you to do that and then finally
the font panel as you can tell if
specific to the current user focus so
what you want to do is if a user
switches between different windows you
want to be able to notify the font panel
that something has changed and that it
should pay attention and also notify a
different window or event reference so
first off
handling font selection event is
straightforward and it's built in and
integrated with the carbon event system
all you need to do is handle the
standard font selection event it's of
the event class fonts and we have a
specific event type called font
selection within that event you can pull
out the parameters related to that event
using the standard carbon event call and
we provide information on the current
state of the font panel so originally it
was mainly the typeface family the font
or the typeface and the side that was
important now as you can see we've added
a bunch of additional new features with
panther such as the typography talat and
there's other features that are related
to stylistic effects such as handling
strike throughs and underlines and other
cooler effect states you might not have
been able to get natively within the
font or on previous system so that
information is stored within a
dictionary that gets passed back through
the carbon event that you can also parse
and grab standard pieces of information
so the typography in the information
about the typographic features are
actually stored for example as a
absolute style attribute absolutely
style attribute that you can then pass
through the absolutely text system in
carbon to render appropriately similarly
we've added support for the textile
information such as the strike through
the underline and the other cool
features there's one more thing that's
pretty cool is that we also include
information about multiple maps or
variations so you didn't get a chance to
see it here but if you install a
multiple master font you can use the
typography palette to go through all the
different axes in the multiple master
fonts and take advantage of those cool
features in fact the Apple standard font
mouths Nereus is provided as a multiple
master font so I take advantage of that
person
all the time on my system right now okay
so when you set the font selection
through either changes in the cursor
position or the user uses some other
mechanism in your application to change
the setting of the font in your document
what you need to do is provide
notification back to the font panel that
something has changed the way you do
this is you use the standard a chai
toolbox function to get the target event
graph this is a new data type that's
available this is what's used by the
font panel and in its function to set
the information for the current
selection you pass the target event
rough and an array of data types that
are specific to the text system that
you're currently using so for example
you can pass in an array of absolutely
style objects that correspond to the
current selection of your text it might
actually just be one if it's only a
single style run or it could be multiple
ones once the font panel gets it it
parses through that and it sets the
state accordingly so for example if you
had to style runs ahead like helvetica
is the family but may be bold and
italics you'll see that reflected
accordingly in the font panel where the
family will be set to Helvetica with the
style or typeface information left blank
to indicate multiple selection similarly
we also support passing in quick draw
style or quick draw text information
which consists of the traditional quick
draw a family name and the style bit
array
ok so when users switch between windows
on your application you need to notify
the font panel that that's of the change
and so within York within your event
handler what you want to do is provide
support for the expanded carbon event
that notifies you that the window focus
has changed or that the window focus has
been relinquished and all you have to do
at that point is call that same function
to set the state of the font panel but
just pass it a null eventtarget rush
what that does is it Lee sets the font
panel so it knows it doesn't need to
send events out so that the previous
window anymore and it can clear it state
usually what happens right after that is
the user has selected another window and
you get a a window focus acquired event
when you handle that event you basically
do the same thing you can pull out the
window reference from the event
parameters pull out the target event
rest from that and then pass that
information plus any additional style
information that you have to the font
panels to indicate the new selection
within the new window ok so that was it
that's all you have to do to support the
font window within your carbon
applications so next handling fought
notifications that's the other key thing
I like for you to remember from this
particular session let me go into some
more details on that what handling font
notification does for you is it allows
your applications to be much more
responsive to changes that users do or
other applications due to the state of
the fonts that are in their library so
as Nathan kept pointing out you don't
have to shut down your application or
your users don't have to shut down your
application just to be able to get a new
font that's been dropped into it one of
their fonts folders that's a big thing
and we need your help to be able to do
that secondly and I won't go into much
more detail here today but it's it bears
mentioning you can also send
notifications to the font server if for
example your application install fonts
program
equal using let's say the file manager
calls or standard UNIX file system calls
that pass underneath the radar of the
system we've got hooks into places like
the finders that let us know when
changes occur within the standard font
directory but if your application for
example at launch time installed
application specific fonts this is a key
way to actually notify the font system
that something else has changed and what
we will do is will scan the directory
identify those changes and then do a
broadcast out to all the clients who are
interested and have subscribed for
changes so getting back to the first
point in order to make your applications
more responsive all you have to do is
implement one callback function to
handle the notification what you next to
have to do is basically register it with
the system and you're done all you have
to do is call the standard ATX fonts
notification subscribe function pass in
your callback you can also pass in a
rest con if you want to so you can get
additional data into your callback
function but otherwise that's all it
takes when you want to deregister it's
not required but if you want to get rid
of it before your appt shuts down you
can certainly do that with a similar
function in the 80s font API okay so the
next topic I'll be talking about how to
exchange data back and forth with the
other components in the system first and
foremost the easiest thing to remember
about exchanging data with cocoa and the
underlying court system is that fonts
are uniquely identified by PostScript
name whenever you get a name back from
app kit from within Coco it will be
generally a postscript name similarly if
you want to instantiate an innocent
instance when you're asked for a name
you can query the APS font system for
the post rittany pass it in along with
the side and you can instantiate and
then its font reference
on Panthers we've also implemented
support for a more powerful kind of mega
and as font reference it's the Ennis
font descriptor you could think of it
this way as opposed to just one instance
or one font within the font panel you
can take a whole slice across it and
actually specify a descriptor for that
so here's an example you can actually
specify an init font descriptor just by
the family name and that will include
all the fonts that belong within that
family as one descriptor similarly you
can go off in the other direction get
more detail you can specify a family or
just with the ax font like PostScript
name and that's more like the
traditional and as font or you can go
even further specify a size which gives
you what we traditionally call a strike
it's one specific combination of font
and size within that class there are
other attributes that you can actually
pass in as opposed to passing in a
postscript name or other information
that includes stuff well the way it
works is with the font descriptor class
you can pass in a dictionary of
attributes and the more information you
put in the more specific the descriptor
will be ok so when you work with carbon
that's had a longer history in terms of
the different font references that
available but one key thing to remember
is that both the effluents they support
identifying fonts uniquely by the
traditional quick draw font family name
in style bit array note that a soui is
actually pretty cool in that it actually
handles the core graphics of the court
mechanism also so you can handle those
font references using the post trip name
also one thing that we provide and both
the quick well primarily at the quick
draw layer is conversion functions that
allow you to go back and forth between
the newer HTF font references and the
older font references and font family
references
one of the key reasons we asked you to
do that is that in the future or also
even now there are slight differences
within the data type some are there's
fine differences and there's also size
differences some of the references are
16 bit as opposed to 32 bit or 32 bit
signs what these conversion functions
allow you to do is kind of shield
yourself from any future changes and
also any potential changes that might
happen if you simply assign one of the
older data types to the new or 80s font
one so please avoid typecasting use the
conversion function avoid direct
assignment because you might get
implicit type promotion that causes
problems with the signage use the
conversion function okay so let me get
into some more details about mucking
around with the contents of the font
registry now why would you want to do
this well think of it this way here's a
typical example you've got a font that
you've license with your application you
use you in your user interface but you
don't want to stick it for general
purpose usage out in the standard
library and so what you can do is you
can actually activate that privately
just exactly the same way the file
system or the operating system would do
but just for your fun similarly as
Nathan pointed out we're making a big
effort to kind of integrate the support
for font collections across the system
what I'll be talking about is giving you
a chance to kind of hook into that to
take advantage of that also you're
interested so when you activate and
deactivate fun what we recommend that
you do is pass in a file reference
that's really the easiest way for you to
do it mainly because there's a lot of
information there that we can actually
parse through file types contents to the
files even suffixes on the files figure
out what exact format it is we can take
care of the rest for you so you don't
have to worry about it note that up here
I'm passing in an unspecified format me
because I'm passing in the file
reference another cool thing that you
can take advantage of is if you put
let's say your abscess if
font within your bundle someplace maybe
within the resource folder of the bundle
you can just pass pin a pointer to the
top level of the bundle will trundle
down through it recursively and activate
any fonts that reside in any of the
subdirectory another part of this
example is that I've actually activated
the font locoweed so that it's only
available for my application what you
get back from this function is a
container reference with this container
reference you can later deactivate
exactly the same set of fonts that were
stored in that file or in that directory
using this function to deactivate the
fun there's one thing that's pretty cool
though is that 80's will keep track of
fonts that are activated locally within
your applications so you don't have to
get rid of it yourself when your app
sets down will deactivate the response
for you okay so with cancer we've
provided support for additional api's or
classes that allow you to modify the
contents and remove and add font
collections just as the font book does
in cocoa you simply use the NS font
manager class with a variety of new
api's that are available to do this
similarly we've implemented support in
carbon with see callable wrapper
functions through those same functions
to those same methods that let you do
let you call these functions from within
your carbon applications so far
collections they're identified uniquely
by name what you see up on the font
panel are the unique names for those
fond collections another cool thing is
that font collection go back to those
sponsor scriptures I described earlier
so the same actions that users can do to
kind of grab an instance of a font or
you know a particular font strike drag
it in and set up a font collection entry
you can do the same thing at this level
as long as you define a font descriptor
okay we're almost there I've got
two sections describing how to interact
directly with the ATM font system the
first one if you notice I badges with
the caches entry in the architecture
diagram the reason for this is that
we've implemented a number of high-level
functions that optimize access to this
data through the caching system as much
as possible so we've identified that you
guys tend to use postscript names a lot
especially with my recommendation on
interacting with the cocoa tech system
we've got that out of mind we also have
an optimized function to get at the file
references associated with a particular
font all of this information is cached
so that you don't have to worry about
triggering messages hitting file system
making file system calls and potentially
even triggering font rasterization
efforts now what I'll go into in more
detail in the next two slides are the
lower level functions that bypass those
higher-level easy to use functions and
that includes the function that lets you
kind of go straight to the file system
grab the font data out of those files
and parse it yourself I'll also give you
some information on how to enumerate
every single fonts or font family within
the font registry and do whatever you
want with those entries so when you want
to pull out data related to fonts
directly from the file system we
provided a couple of standard functions
to do that this one happens to be the
one to get the font table think of it
this way the way we've made a standard
format for the font is similar to the
way truetype fonts or opentype fonts are
defined they consist of a directory of
font tables each of which contains
specific class of data so I mentioned
earlier in the presentation that we have
character mapping tables those are sort
in tables that are indicated by the cmap
tag or CM AP we also have support for
accessing the glyph data you can access
any of the fun
data that's available for these fonts
now the convention is you make an
initial call to these functions either
80s fonts get table or the directory
version you pass it into the font dress
and the tag indicating what data you
want and you pass in a null buffer in
return you get back the length of the
data that the function will return to
you and this is what happens in the
second call in the second call you can
actually Malik right then and there a
buffer to hold that database from the
size you got in the first call pass in
the buffer this time and get it filled
in with the data that you need now if
you have any more questions about how to
process this information it's available
in the specs for the opentype font
format and a true type font format so as
you can see this is pretty low level
stuff but for a lot of you out there
this is your meat and potatoes this is
what you want to deal with the other
people in the involved with this usually
use the high level function so if you
have any requests for us we'd be happy
to implement it so please use the the
bug reporter let us know what features
you'd like to have that otherwise you
have to go through the lower levels of
the ATF's font system to get at ok when
you enumerate fonts and font family
there's a similar convention or there's
a standard convention also and they
consist of iterator objects essentially
all you have to do is create an iterator
object based on a bunch of criteria set
up a while loop that calls the iterator
objects for each successive entries and
when it's done it'll give you a status
code back indicating that the iteration
is done and then finally you release the
iterator object to return the system
resources back to the operating system
so some of the different things you can
do with the iterator objects include
filtering them you can pass in any of a
variety of standard predefined filters
such as filtering by font location or by
the generation in which they got
activated so if you want to find out if
there were any fonts that were activated
after you
check the fine the registry you can
check a generation count and in filter
based on that you can also pass in your
own custom filter function to do the
filtering yourself based on whatever
criteria you specify and if you notice
here I'm actually using a similar way to
restrict or actually in this case
totally unrestricted scope of the
iteration I've chosen a global context
with unrestricted scope so I can see
every single font available on the
system for all the processes okay one
last item when you want to access caliph
data this is where you interact directly
with the font rasterizer or in this
particular case the absolutely tech
system eases the burden on you someone
and allows you to mimic exactly what the
soe tech system does but gets you back
this data directly so it has two
functions to access to different flavors
of glyph data format with glyphs path
into different formats essentially the
glist path define the shape of the
glyphs that you can then tap into let's
say the court system or draw yourself
directly on fleeing or manipulate this
as if it were a regular graphics object
now the escapee is take advantage of the
higher levels of the earth Lloyd system
so you can pass the information from a
standard absolutely text layout object
so you can take advantage of how its
specified let's say a run of characters
pass that information in and get just
the glyph information for those
characters in addition they match
exactly the way I see withdrawn so you
can still take advantage of trying to
mimic exactly what actually does but get
into the lower layers of it and directly
access the the font data through these
ap is so usually what you do is you
determine what the native glyph data
format is for a particular font and
there's an API to do that if you don't
do that the function for accessing the
glist path will actually convert the
accordingly to for you so if you ask for
quadratic and you ask to get the glyph
data for a postscript font that's
normally defined in cubic data then it
will converge in a court accordingly the
other thing that you have to do is
implement a series of callback functions
that process the standard standard
operations that define the glyphs shape
so this includes for example let's say
in cubic you have a move to operator a
line to operator a curve to operator and
a closed path operator the line to
operator basically defines a straight
line segments and the curb to defines
any arbitrary curve okay so just to wrap
things up here what I've talked about
today is that there's a lot going on in
the operating system that hides the
complexity of fonts for you we've
implemented a lot of stuff you've seen
how the architecture works and how they
interact and how they touch on api's
that you take advantage of at your level
in your software the other thing I've
covered is that if you go away from WWDC
and implement just these two aspects of
the system you're going to help us push
forward this idea of putting the user at
the center and making it so much easier
to use their fonts and so much powerful
that people will be flocking to your
application so adopt the standard user
interface add support for handling the
fonts window you see how much you'll get
with it the typography palette a
character palette the interaction with
font book and handling support for come
font collection to the very least you
should also support handling font
notifications so that your apps become
much more responsive to changes in the
system there are a couple of related
topics either later on this week or that
you can review after wwf/e includes the
unicode session and the cocoa text
session
our evangelist for this area is zabiela
grill but you can contact him
specifically about some of those bugs or
features or new api's that you like and
something that you guys have been asking
for documentation on this part of the
system well my team has worked really
hard this year to put together the
documentation with the technical
publications people and we've got them
up there so take a look at them they're
really cool there's also related
documentation about the various tech
systems available on Mac os10 including
Atsui cocoa and there's also
documentation for the legacy font
manager API is available in quick draw