WWDC2000 Session 156
Transcript
Kind: captions Language: en hello and welcome a line from one of my favorite stories as a child we have so much time and so little to see wait strike that reverse it Willy Wonka from Charlie and the Chocolate Factory let me roll up my sleeves here because we do have a lot to talk about today and I'd like to get started let me give you a brief outline of what the story was basically for the first time in a decade Willy Wonka an eccentric reclusive chocolate maker opens his factory doors to the public five lucky children who find a golden ticket in their wonk of chocolate bars receive a private tour of the factory run by Willy Wonka and his crew of loyal and Palombo workers now I'm not going to tell you who Willy Wonka is at our chocolate factory but consider me your Oompa Loompa guide to the wild and wonderful world of font management on Mac OS the factory doors are open let's begin with a definition of font management from a user's perspective it consists of installing activating and deactivating fronts for use in any number of applications including page layout programs web browsers and even the humble text editor from a developer's standpoint it consists of a programming interface for accessing and modifying a central repository of font data application developers use it to create standard user interface elements like the font panel or the font menu they also use it to to map a user selection to a reference that can be passed to the graphic system to render text on the display or on other graphics devices like the printer now the evolution of thought management on Mac OS has can be divided actually into two distinct periods the first period is marked by a long series of incremental change to a design that has remained fundamentally unchanged since the introduction of the Macintosh in 1984 the second period is characterized by a transition a transition to Apple type services it's a completely new font architecture that was designed from the beginning as a industrial strength font database management system now the key point of this session today is that this transition as of Mac OS 10 is complete what you'll learn are the things as a developer that you'll need to do to take advantage of the features provided by this new font architecture and also what steps you'll need to do to remove dependencies on the old model which has completely gone away on Mac OS 10 traditionally the responsibility for managing fonts resides with the font folder and the finder which in turn depends on the resource manager and the font manager to populate the database and manage that information this design relies heavily on the resource manager which was never intended or designed to handle the data retrieval and storage needs of most professional font collections what third parties and font management utility developers have done is to reverse engineer the underlying implementation they also implement their own auxiliary font management systems all of which has to be synchronized with the central database through system patches undocumented routines and internal data structures of the font manager and resource manager now the existing implementation for managing the font files is a descendant of the original font desk accessory mover which let users manipulate the contents of a monolithic system food case file with the development of true type fonts were no longer to fit Matt fonts that could fit within the system suitcase files they became larger more complex and more numerous as people began to adopt them when the functionality of the mover was integrated with the finder the font manager and the resource manager were modified to create the illusion of a single system suitcase file from a multitude of font files located within the font folder third-party developers again as I mentioned before reverse engineered some of this implementation and figured out what was happening and a lot of it was actually documented openly with an inside Mac and they created system patches that didn't necessarily work together very well they duplicated functionality that was eventually developed within the system itself and we're very fragile to changes within the implementation of the operating system some examples of these font management utilities include Adobe type manager font reserve master juggler and food case these font management utilities really came about because they are designed to address some of the inherent limitations in the system suitcase model first and foremost we have the limitation that all fonts must be referenced to font resources and the font suitcase file an example of how this affects the regular user is Adobe type manager and requirement that post could type 1 fonts even though they stood alone as separate outline files that ATM could render and display on screen required a dummy font suitcase file with at least one bitmap file in there that was never really used to represent each outline font that was available in addition to this only a fixed number of files can be installed in the fonts folder for use by the font management system on Mac OS most thought management utilities work around this limitation by allowing users to activate and deactivate selectively sets the font since these font resources must coexist in the research chain as part of the system suitcase file the font manager and resource manager become involved in resolving conflicts in the font resource identifiers and names these changes these are actually physical changes to the font resources need to be communicated to the font manager through physical changes within the font files themselves if you've ever double clicked on a font suitcase file in the system folder and then took a look at it later you might have noticed that the modification date has actually changed even though you didn't do anything to it even though there's a user interface to actually move files in and out a lot of times what happened was an ID conflict had actually been resolved and your file has changed there are obviously concerns about maintaining the validity of your font data because of this so we want to move to a model where font data is not touched and finally any changes within the fonts folder are often not communicated to applications that are currently running you would have to shut down your applications and restart them to see these changes now beginning with mac OS 8.5 the release of apple type services for unicode imaging that's a mouthful it's Atsui for short or 80s for the underlying subsystem it introduced the text rendering engine and font management model that was designed to handle large collections of fonts and to handle multiple font formats and file packaging models the font manager and quick draw text at that time were rewritten to integrate the 80s glyphs cash a central cache of information related to the fonts and the font file and data management system as an adjunct to the system suitcase model of the resource manager Mac OS 9 point oh we introduced an extent extended set of functions to the font manager that allowed developers for the first time to make use of some of the lower level functionality of atf by the way one thing that i want to make clear is that this extended font manager functionality was available both on mac OS 9.0 straight and in carbon lib the first release of carbon lives on mac OS 10 we've been busy porting 80s to a client server implementation and we've been standardizing the programming interface in coordination with the other component frameworks of the operating system now the main goal of the design of 80s was the replacement of the resource manager with 80s as the principal intermediary to the font database the design also allows us to hide the implementation from third-party developers by providing a programming interface for accessing and modifying the standard font collection by transferring the responsibility for managing the font files parsing the font formats and resolving name and identifier conflicts we've allowed these modifications to be handled dynamically through internal data structures of HS and plot manager rather than through exposed data structures through the resource manager this information is made available to third-party developers through the font axis and data management programming interface of the new extended font manager and 80s another aspect of this design is the font format independence and also for handling different storage models what we've done is we've consolidated the wave fonts get packaged essentially font data may be stored in the standard what you might be familiar with this SS NT is the tag that we use in the research manager in the past a standard SF NT directory and data table model that was developed for truetype and also has been adopted for the open type packaging model from Adobe and Microsoft one last thing is that performance has been improved through the use of data structures and heuristics that are optimized for font management within ATS and this works on multiple platforms and operating systems we have support on Mac OS 9 and on Mac OS 10 in terms of implementing HTS itself at the core of the architecture lies the open font architecture which provides a programming interface and a protocol for communicating with these modular font scalars essentially the font scalars are responsible for parsing and interpreting the font data that's specific to a particular font technology like true type or post groups the font scalars participate in measuring and rendering texts and translating the font data into a canonical format that can be used on different graphic systems the 80s glyphs cache is shared by all clients of a GF and is designed for high throughput of the font data especially in support of large glyph reporters that are used in Asian font the font database uses also references to font files that may be closed as needed in order to conserve valuable system resources and also just to allow you to handle response without keeping them open like they were in the past and the resource manager there's also thanks to this no defined predefined limit to the number of font files that may be open or active in reference through a PS at any single time and finally on Mac OS 10 the clients server implementation of atf allows us to further reduce the load on the system by sharing more of the common data structures and common components now as you can see in this diagram there's no sign of the resource manager in it in this particular implementation this probably represents what you see on Mac OS 10 as of DP for we have applications and utilities linking directly to an ApS client library which then communicates to the AF server which in turn handles the low-level details of the font formats and packaging models on various file systems or even across the network applications and utilities may also linked to a particular graphic system by quick draw which is represented through the font man there's your API or courts to access their font data in a style that's closer to what is used on that graphic system underneath all of this though however these graphic systems also are clients of the 80s server and parts of the 80s client library to make use of font data this abstraction layer allows us to change formats or support formats actually as needed as things come along now a fundamental assumption in 80s is that all font data can be logically contained with within one of these SS NT directory and data table structures this happens to be as I mentioned before the natives storage model for true type and opentype fonts as such each font has a format identifier a directory describing the data tables that are present in the font and a collection of data tables the format support include true types and postscript and within postscript itself there are a multitude of variants we also support classic postscript outline fonts the CFS format fonts which are used in opentype CID keyed to bite font formats or the font format for cid seed funds and other legacy formats in leading the OCS font format that one we're actually working on right now so it's not available in DP for and we're working on open type support also one thing that we've had as a requirement was support for font file formats from other operating systems an example of this is the Microsoft to type ttc or TTFN data fork files this becomes much simpler with the font management model provided by ATF the storage models that we intend to support include although these aren't completely guaranteed of course true type and PostScript fonts suitcases and font resources opentype OTF and true type ttc and pts files as something we are working on and with the emphasis on PDF data structures and file formats within the new quartz graphic system we also are working really hard with the core graphics teams to get PDS embedded font data working properly so that means a PDF with embedded data should work transparently on your Mac os10 system the programming interface to 80s let's application and system developers integrate many of the enhancements that have evolved over time a lot of these features were provided through the font management utilities I described earlier and also have been proposed or have been integrated in part in the finder and fonts folder model now some of these features are actually not available at present time in the finder they include the ability to maintain farms and locations outside of a single directory associated directly with the operating system the fonts folder in the classic world users also like to create and manage sets of fonts customized for different applications this is something that you often do see with font management utilities they also want to be able to open and close fonts while working in the middle of an application and have those fonts immediately available they don't want to have to shut down their applications and finally some utilities also provides ability to share fonts over network which we are actually providing transparently on Mac OS pin through these programs to these AP eyes and the ATF architecture one last thing that we're working on is we're coordinating an effort with a high level toolbox team and the apt-get team to standardize on a user interface for managing fonts this might integrate some of the features within the font panel that you've seen before and the traditional font menu that you're all familiar with at this point I'd like to introduce my fellow comrade in arms from the type team Julio Gonzalez who will demo for you some of the features that 80's makes possible and also some of the features that are actually already implemented in DP for or a plan for the retail release of Mac OS 10 beautiful good evening I want to start by talking and showing you the different locations for the fun directory journalists in the first location the 80s system knows about is the system library fonts location here we have the fonts that are required for the basic operation of the operating system full of some fonts that traditionally with ship with next directory that the 80s system knows about is the local fonts directory this location is the ideal spot for fun collections to get installed into not so the system directory which is exclusive for apple's use the next in Turkey it knows about is a network directory unfortunately i'm not in the network i can show it to you but this is the ideal spot for say a company white font that is used in internal documents the last directory that it knows about is the users font directory basically this ones are only available to the user is currently logged in but the beauty of this directory is that if the home directory resides over the network if you log in on a different machine the fonts go along with you now let me show you some of the new features that we have on OS 10 this is a the current version of simple text that are shipping with the CDs that you all receive it's basically a carbon is applica person of simple text it doesn't do much in as far as using the new API so if we look at the fonts menu this font menu is built using a pen rest menu this is what you're all familiar with it's just the afforded list of fonts are currently installing the system now are taking the same version of simple text and modified it to use some new AP is that were introduced in carbon lip 1.0 that allow you to create a new manual one of the advantages is that you can have a hierarchical menu it's more compact it provides more information so here you see the sub menus which show you the weights and stresses that accompany this font family not so with the old version which in fact if we take a look at barnard modern which has an entry for each one of the stylist or waiting stresses that it can handle so the new menu is more compact and more informative another feature of this menu that is not rarely seen is automatic want activation what do I mean by that typically on mac OS 9 save you wanted to install a font you would install it into the fonts folder any running application would have to quit and and restart for you to be able to see or use it now if i go back here to my disk pick up a font drop it into my users font directory and make sure that it got copied there that's the usage font directory go back to the modified version of simple text and hello oh not the point that i wanted to use but let's pick up a nicer one here yeah sorry about that picked up the one below or but one of us so if we head back Lenny unclutter some of the mess here there it is so we didn't have to put the application in order to see the font and only that of course we can hopefully use it so that's an improvement of over what we've had in or it's not another thing that you can do with this on activation is what Robin talked about is you can activate now fonts anywhere outside of the scope of word the system knows to look at so that gives us a few advantages for example applications that want to ship with their own fonts typically applications have had to install fonts from the font folder or have shipped with the fun suitcases inside of the resource port of the application that second option of course not doable understand because we divorced from the font from the resource manager all together and we no longer look at the resource manager 45 so but you can still install the funds into any of the known locations the user local or network directories which by the way you can you can get at using find folder the same way that you would on the yeah on their mac OS classic mac OS just by calling find folder with some new constants are provided so a better way would be to ship the fonts that the application wishes to use along with the application so that's what I've done with this version of our simple text if I go back to this and show the version of simple text I have a font folder that lives right along it it's got a chest font here that I'm going to demonstrate and the directories just at the same level as the application at that as it launches it looks for this fonts directory in the same spot as it is and activates a font so if i go back here to the modified version of simple text here is that font that has been activated so i can too and use it in queen so that is a cleaner way of doing it but let me just let me just talk about this a little bit more this is not the most clean way of doing it here the finder is showing us a simple text application as an icon that we can double click on in reality this is this is a package a directory structure inside of this structure is a content directory for example and this would be the ideal spot to put your font directory and that way as you copy the finder around moving around to another location your fonts would be copied alongside it so now how about activating all the funds on the system I have a tool here that allows us to do just that let me bring it up it just shows the glyphs that that the current font needs or or have let me also bring up the front panel this is the standard UI under mac OS 10 for the font panel and this or the sponsor are available under it at the moment so i have a menu item here that will allow me to activate any directory that i have on this so i have here a set of a demo direct demo fonts and please watch closely the front panel underneath it as i activate that directory boom here we go we have now a bunch of fonts that we can now use this was a font that was not there it's up you know updates on the background Apple government was also not there so you can imagine you know now we can you can have a user have a set of directories and organize your fonts in whatever way they wish to use them and you as a developer provide at you I that lets them pick any of these any of these folders to activate or deactivate on the fly now for the purpose of this demo when we use the activation routine that Robin is going to talk to you about in a minute you have two options you can activate the font locally so that only these this application fee sit or globally we chose to have to give activated and globally so as we quit this demo application and go back to our simple text application we should be able to see anything here they are for us to see the last thing I want to show you is some of the formats and packaging that Robin talked about that we now support this or some of these are of course work in progress so let me just show you some of the the fonts that we're in that activate demo fonts that I just activated this font right here are windows truetype fonts in fact I downloaded this from the Microsoft website and our standard to type data for font so no resources whatsoever in here as a fan piece you name it this one here is an open type font a Japanese opentype font so I'll go ahead and make use of them Oh before I forget notice also if I go back to my version of simple text this font right here are both of them are PostScript fonts there is no ATM installed on this system this is part of the of the mac OS system now Mac os10 system so let me go back and show you some of these fonts this is the true type font from Microsoft so it does operate so we can see it and now I can go ahead and try that Japanese opentype font excuse my Japanese so for you'll come out right here we go and with that I'll hand it back to Robin and she'll talk some more about all these wonderful api's that i've been using here for the demo thank you thanks Julia so let me reiterate at this point the key point of this session is that on Mac os10 we've completed the transmission to the 80s font architecture as julio mentioned the resource manager is not really in the picture anymore now ApS organizes the font data in a two-tier hierarchy consisting of font families and fonts a font essentially represents a component of a font family that is differentiated by stylistic variation or stress like italic or weight like bold the font family is a reference to a collection of fonts with the same design characteristics this is kind of a definition that most of you are probably familiar with in terms of computing and displaying text on on a computer so this font family reference it's compatible with the routines of the font manager in quick draw text and may be used wherever a standard quick 12 on identifiers from the older days including the text font function that you're familiar with in quick draw and the TX font field within the quick draw graphics port however it cannot be used to access information from a fon V or fond resource handle through the resource manager routines in addition a font family reference does not imply a particular script system nor can it be mapped through some arithmetic magic to a a particular character encoding as was true in the past each component font associated with the font family is identified by an opaque reference to a single object registered with the font database this font reference consists of the individual outline and bitmap fonts that form in combination the font family within the 80s function of programming interface there are also compatibility routines that lets you map one of these newer references or at least the font reference to an old style font family ID and a traditional quick draw style style bit set many of the features that I'll be describing in this section are implemented already in the extended programming interface of the font manager that was introduced with mac OS 9 point 0 and the first release of carbon lib Mac os10 particularly if you're going to be working with within an environment that's based on the courts graphic system like the app kid you have the option of linking directly to the new hgf framework this is where the actual implementation of HS resides on Mac OS 10 now there are four basic tasks that the programming interface needs to provide and this is available again on carbon Liz and Mac OS mine within the font manager and I'm a quest pan through the 80s framework they consist of the ability to enumerate or search for font families and farms accessing information and data contained within the font families and fonts and a set of database related routines the main one being the ability to activate and deactivate fun and finally we have an implementation of a basic font menu as Julio showed you earlier that replaces the append res menu implementation that was very resource manager centric so as for enumeration these routines again allow you to iterate and search for font families and fonts using a model that thread safe and compatible with the pre-emptive multitasking environment of Mac OS 10 for routines are usually provided there's one to create a font or font family iterator object that maintains the state necessary for high-quality data there's a function to iterate to the next item and is one to reset the state of the font object I'm the iterator object and once who disposes the iterator once you're done one additional feature that we provide on the 80s framework is a utility function that's similar to what you see in the core foundation collections library essentially it's the HS font apply function it wraps everything up so you don't have to deal with iterators directly and you can simply pass in a callback routine that's applied or called for each item that's iterated now here's how you create an iterator to step through all of the fonts accessible to your application it's essentially wrapped where they create and dispose function within it there's a inner loop that iterates through all of all of the fonts it returns a font reference that you can use with any of the accessors functions within the library now for the access routines what you want to avoid doing is using the resource manager routines to access the data stored in the traditional font suitcase files these resources include the fonz the fon tisa fonts nfm tees sfn tees and LW sends a whole outfit troupe of resources the resource based semantics of the old font manager will still be available because we didn't blow away the old research manager routines and you'll be able to return some values but it will not be set up the way you're used to with the system resource chain and all the fonts available globally instead what you want to do is use the iterator and the apply functions and also use the atf accessor functions that are also available in a slightly different form within the extended font manager in terms of the interaction between the font manager in the graphic system one thing you should avoid doing is depending on FM swap font and the traditional resource-based font manager data structures to access information such as metrics and other metadata about the fonts an example of this on Mac OS 10 is within the FM output structure there is a font handle field that currently is going to be set to nil in most cases since a lot of this font data is not going to reside within a resource handle there are other data structures that you're probably familiar with that also have similar resource handle pointers or handles to resources that are probably going to be set to nil or will definitely be set to million most all of these cases the way you get around is of course is to use the accessor function that we provide through 80s and through the extended font manager they are set up so that you'll be able to access information that you would normally have gone to a faun directly or to the font handle to retrieve this information and we're currently working with the various graphic systems and the teams for the courts and quick trial graphic systems to integrate these font family and font references into the system as accessors so you won't have to do any sort of conversion back and forth you can just use these natively within those those components I'll say this one more time don't use the research manager for activation and deactivation people in the past have patched the resource manager and font manager to get the work done they have intimate knowledge about the way the resource chain is set up and how fonts are inserted and removed from that chain that will no longer work as of carbon live one point 0 and Mac OS 9 point 0 and on Mac OS 10 we provide functions that makes it so much easier for you you should be using these we have a whole suite of these there's you know not just basic activation and deactivation but also ways to pass in the information whether it's a file or within memory one additional thing that I like to explain is we also provide a mechanism for notification it's very simple in the this first release but essentially consists of a generation seed value it's a global value that stores in the ATF server that gets updated whenever anything happens to change the state of the font database this means any operation that can add delete or even modify the fonts or font families that are stored in the database will trigger a change or an update to this seed value and also any font family or font that happens we touch within a particular transaction will be tagged with the current value of the generation see so there are excessive functions that allow you to retrieve this information and compare it against a cash value that you store within your application to see what happens to the database as time goes on this provides the core functionality for the way the updated font menu has been working so on Mac OS 10 and Julio described earlier you cannot embed a font in the resource fork of your application and assume that it's automatically registered with the font manager when the application is launched instead what you want to do is you want to locate some predefined place if you've actually carbonized your application already and have one of those packages that Julio's show to you one of those apps directories then you can use the CF bundle routines that are available in core foundation to actually locate one of the particular sub folders where you can place your fonts that's carried around with the application whenever user copies it and task that particular piece of information the location as a file spec or a file ref or even a pathname to the 80s routines to activate the fonts contained within it from that with the HTS framework you'll be able to use a opaque container reference to find the fonts that are available or that were registered with the database from within that container or that file or memory location even one thing I should note that Julio mentioned earlier he actually stole some of my thunder was that we have the ability when activate when activating this particular container to determine the context whether it's local to the application or global and system-wide and so that's going to be one of the parameters that you'll be able to pass in the default behavior of course is to make it local to the application and safe so that when an application is normally shut down or crashes even those fonts will be removed from the system the final task that the programming interface provides or enables you to do is a basic font menu I think I'll say this one more time don't use the resource manager base crew teams to do this instead what you'll use are a standard set of functions that were distributed as a carbon with one point o in the menu manager to create this basic font menu and that's actually what coolio was using within his ye simple text that he was demoing so they provide just a few functions that allow you to create and dispose of a standard menu to update it automatically based on this generation feed and the current state of the font database and one key item since the implementation is radically different or it is different anyway from the old append res menu menu we provided a function that allows you to map a user selection to one of these new font family or font references so here's real quick how you'd actually create one of the basic font menus it's almost identical to the old append res menu except for the fact that if you look down below there's a hierarchical font menu option so if you pass that in you'll actually get one of the fancy new hierarchical menus it's not spectacular but it gets the job done if you wanted to you can actually implement your own version of a font menu using the standard access sir and iterator functions now this is what's more interesting so given one of these hierarchical menus which is different from the old attend res menu style where you can simply take the item text and use the quick-draw routine get s none to map it back to an ID that you could pass through the quick trial graphic system instead we provide you this function get font font family from any selection that takes the menu handle in the item that was selected and maps it back to a reference and a standard quick-draw style that then you can use with quick draw so one of the benefits of this is that in the future we could change the implementation so that the menu items are no longer a standard quick draw font name we could actually make it so that they're customizable or we can make it possible to have both a postscript in a truetype version of helvetica presence in the same font menu and allow users to distinguish between them and use them as they want so it's a wrap is up I'll say this one more time don't use the resource manager to do your font management begin developing to the new extended font manager programming interface that's available with carbon also as of DP for you'll be able to preview the programming interface that we have in mind for the 80s framework now this is a caveat on DP for you won't be able to link against these functions and you won't be able to use them just take a look at the header file it's called ACS font H and it's included within the 80s framework itself if you know the structure of the new framework hierarchy basically each of them is a modular package that represents a component in system with headers that are included within that package so again preview those interfaces and see what's up what additional features will be providing and exposing through the 80s architecture here are a couple other sessions that you might be interested in the the text session already happened earlier this morning and a lot of you might have already gone but hopefully I'm not sure about this that they'll have some sort of streaming capability or something to review the lecture there's also the courts session on Friday that you'll be interested in this goes more into the graphic side of things and it's specific to of course the court system and finally on Friday also there's the traditional international and text feedback form that i'll be i'll probably be at and so will my colleagues and you can talk about all kinds of other related topics in the text field on the web you don't want to get up and talking in a meeting here at WWDC you can actually go and take a look at the text and international website for our DTS technical documentation and I'll give a plug to our fellow group in the in the Apple font group which actually creates the fonts that we ship on the system and the tools and utilities that are used to develop them and the final quote from Willy Wonka invention is ninety-three percent perspiration six percent electricity four percent evaporation and two percent butterscotch Ripple think of it this way we've already gone through all the perspiration for you so one additional set of changes to your applications and your utilities will give you that extra magic that you'll see from our chocolate factory thank you very much [Applause]