WWDC2004 Session 402
Transcript
Kind: captions Language: en please welcome from Apple computer Robin Mikawa all right so let's get started my name is Robin mikela I'm the manager of the type engineering team that Apple computer and I'm going to be here talking to you today about the bon epi on Mac OS pin but before I get started let me give you some background and an explanation why are we all here today why are fonts so important so first and foremost the thing to remember about fonts is that they're inextricably tied together with text so if you're working with text you are working with fonts that's really the thing to remember even if you're developing let's say a simple application terminal emulator that only uses one font at a time even nowadays we provide the option for users to set your set your preferences so in that case you'll have to deal with fonts in and being able to list it and allow your users to select the fonts now second fonts have a long history they've evolved over time you've got all these different formats available and users can and have sound and frustrating or difficult to use they're tricky some have multiple files that you have to carry across you know others well they're all different formats they're all different styles so what we've done on the system is made it a lot easier for both the users and you as developers to take advantage of all these technologies and have consistent reliable results make it really simple to work with fonts and so what you're going to get out of today's session is how to hook into the operating system and really make your applications shine take up to the front of the pack you know become leaders in the world of thought so just to give you a short overview of what the presentation is I'm going to be talking about just how to get started we're going to go right into the meat of the matter we're going to show you programming techniques tips and tricks hints stuff you shouldn't do and along the way you're going to get some glimpses into the future what we're feet what we're working on for tiger as well as the roadmap for longer term beyond tiger so let's get started alright as developers and I know exactly how you feel one of the first questions maybe not the first one but at least maybe the second the third one is what api's are available and how should I use them what I've shown you here is not only the layering but also what each component or API set is really tailored for so to get started up at the upper left we've got Coco that is the application framework for Mac OS 10 so if you're starting from scratch or you have the option to switch over to the coco framework great you're going to get a lot of the support for free now if you want to do user interface text you've got a chai toolbox that is d engine for drawing user interface text as well as measuring it and then handling all the fonts support underneath it such as substituting the appropriate fonts for different languages now underlying that is the multilingual text engine what that does is it handles the text editing and static text behavior in a chai toolbox itself there's also support for handling a document based model as well as doing a font user interface and so all of that allows you to build essentially a very basic text editing application just by using em LTE now underlying all of this is absolutely you've got Apple type services for Unicode imaging people have asked me that before that's the official name what it is is the text layout engine for Mac OS 10 it provides support for positioning text in the right places handling the fonts the graphics all of that stuff is abstracted out from underneath you it also handles things like justification font features a lot of details that you don't need to worry about but that can cocaine at that layer if you just want to take advantage of some parts of the system services now of course we've got the graphic system you've all heard about it it's court in addition to providing basic support for rendering text what's really more interesting for you also is that you can hook into the printing architecture and the imaging model based on PDF with that you can take advantage of support for the way it handles fonts and then underlying all of that is ATF itself that's Apple type services and that's the core font system on Mac OS 10 and so what that gives you is a way to hook into the way fonts are tracked detailed information about the fonts such as the metrics and it's really what serves all the fun information up to the other parts of the system now you'll notice there's one component I've mentioned in the past that isn't up here and that's quick draw quick draw as a tiger has been deprecated now don't panic it's not going away it's just we've marked it in the interfaces and allowed you to or let you know that we're recommending that you move on to other technologies such as quartz we made sure there's additional support in there to at least match or parallel the functionality that you become used to there's going to be a discussion about it later in the week at the graphics session and you can listen in on those at that point in time alright so next up as opposed to you as developers where do you your users get started where they're going to see the user interface how do they get at the fonts that they want where the commands how do they process the fonts and so one of the things we noticed that Apple was that there really hasn't been any guidelines for providing a consistent user interface for font think of this way you've got the file menu most of you know it's like okay we've got a couple commands in there that should be in there edit menus in a similar way we're recommending that you move to this model for your font menu now the key thing to remember here is that first command up there show fonts that's really where we're going to focus all of our new features our development or ease of use on the font panel that command shows and hides the font panel now we've made it really easy by building in the support in interface builder you can just drag in the font menu the other items the other commands in there if you don't want to support them you can simply grade them out in the menu but you probably already have commands like they spread out somewhere in your menu structure the idea is so that users know exactly where to go for at least they're really basic commands for dealing with fonts now going along with quick-draw being deprecated we're highly recommending that you're moving you move away from the old font and style menus that you used to see in quit your application one of the key things is that users have found it confusing sometimes they wouldn't even use the style menu because they couldn't get at exactly the fonts that they wanted and so we've been working on ways to make sure that that's much more easy to do with the font panel all right so that's the basics I just covered how to get started and let's just dive into the rest of the presentation and i'll give you another engineer on my team nathan taylor to talk about them Thank You Robin hi I'm Nathan Taylor I'm a software engineer with the pipe engineering team and my responsibilities include many of the API is that we're going to show you today so what I'm here to talk about are some of the basic programming techniques that you can implement in your applications to bring it to the head of the pack as robin said there are three basic items we want you to take from this one and foremost adopt the font panel in your application the font panel is the common interface that we have provided for accessing fonts it's also a lot of the previous problems with font menus and adds new functionality for the users it's also important to consider this in providing a consistent user interface for accessing fonts throughout the app throughout the system via your application the second item is to handle font notifications in your application these notifications are provided to you so that you can respond to changes to the font registry that a user may enact and the third item up here store font references how should you store font references in your document in their user documents now and going forward with the system and I'll cover that a bit later before I show you how to do this let me give you a brief demo of what these things will provide for your application all right I'm going to do is fire up a simple app here this is your basic hello world application written with the carbon frameworks and I what I have here is a basic window with some pretty plain text so now I'm going to bring up the font panel and as you can see we have the font panel implemented through a pretty standard fonts menu according to the H I guidelines now one of the first things your application is going to need to do when they use or changes of font its respond to that and actually change the font in the document so let me pick another font here he'll float x 96 point and you can see that I've implemented basic font changing within this application so besides just the basic support for the font panel which you can see right here there's also functional functionality that the font pound provides and you can choose to implement this is some nice features such as font effects you can see I just implemented this panel bar right here these effects provide things like shadow colors underline and strike through things that go above and beyond what the font itself actually provides this information is provided to your application through the same mechanism that a lot of the font panel information is in addition to the font effects there are also typographic features that the user can access through the typography panel as you can see hafla text has a bunch of features here and you know these include things like ligature control this allows the user to have extra control were the font to support these features so they can turn off and/or turn on some of the special pictures that I thought might have for example art is that female font has this cool ligature that when you type it out p no it makes one single glyph for the whole name of the font now the other thing to worry about when implementing support for the font panel is handling user focus the most common user focus changes you need to be worried about and that you won't probably forget it's tracking the users position through a body of text and through different style runs but one that is often forgotten is tracking the change between windows so I just brought up a second window here with another greeting and let me set the font on that real quick now you see I have push air selected here if I change windows I've been plugged in here tracking of the user focus between windows when I switch to the other window hafler text is selected let me do that again so you can see now it's back to close down finally I mentioned font notifications and so let me turn on notifications of my application I'm going to subscribe to them now the demo app is listening for these and I'm going to be a user and I'm going to disable a font using font book let me go right after cloche and there and turn it off a high spot book you'll see that the demo application has received a notification this is gratuitous you don't need to do this in your application but the alert is here to illustrate the point and as you can see this text has now changed it is now you know using a substitute font and I handled that substitution in my notification call back so that the text didn't disappear in my simple text engine here and that about covers it for the basic demo so let's go back to the slides and dive right into how you can implement this in your application so first let's look at how to adopt the font panel the first thing you need to do is how do you get this font panel in your application as Robin mentioned use interface builder for arvin or cocoa and drag the font menu into your menu bar in cocoa once you've done that it's pretty much free for all the basic view classes and carbon there's a little bit more work and so let me go into that there are three basic steps once you've put the font panel in your application you need to show and hide the font panel on demand you need to handle user selection events and you need to handle user focus so showing and hiding the font panel is pretty straightforward it's supported through the standard event handler and if you create a show fonts menu item and give it that s hfp tag i have here the standard command identifier for the show/hide font panel you will get much of the show it you know much of the support to hide and show the font panel with the selection through the standard event handler you can also handle that adventure self if you choose to again font selection events are important because that's where the user interacts with your application through the font panel they'll select the font a size and you should be able to handle it and show it in the current selection that they have and finally as i showed user focus tracking between windows is important there's also another stage of user focus tracking that's important when the user has close all windows or just interim between switching windows you want to be able to clear the state of the font panel and so i'll go into when i show you the code there's a simple steps to do that so handling font selection is pretty straightforward the first thing you're going to do is you're going to receive font selection events from the font panel these events contain information about the user selection the first thing your polygon want to pull out of here is the typeface you know that can be provided by family by PI space directly and will probably also include size information as I mentioned the demo additional information such as typographic features text effects and even variation instance information could be provided through the event mechanism we've had much many requests for support for variation instances and it's now available through the typographic features panel so let's take a look at how to implement font selection in your application this is a really simple event handler here now what I've got is I look for the basic class of the event then I check to make sure the CSA font selection event at which point i select and extract the parameters from the event that i need in this case i'm pulling out the add some fonts ID and the accident font size I'll then pass this on to my text engine apply them to the users current selection and then move on here's the point where you would also want to pull out the extra parameters such as the type of X typographic features and anything else you might want from this event now handling user focus is another simple thing to do and let's take a look at it try that again alright so this first block of code shows how they handle user focus when a window focus acquired Dementors comes through the same code would be used when you're switching between users selections the basic flow here is you extract your target this is where you want your events to be sent then you extract the current text style from that target finally calling set font info for selection you pass in the style and the target and that caused the font panel to select the current style within the window window focus from the window is relinquished by the event window focus relinquishes you could call set font info for selection here it's important to note you just passed a null for the target and the style and that clears the state of the font panel additionally that instructs the font panel to discontinue sending notifications to the previous target alright the next item we have to cover is handling font notifications font notifications are pretty simple to do but they provide a lot of functionality for you and let's look at what you can get and how you can and what you can do with them the first thing to do with notifications is you need to subscribe and do this by creating a callback and using the appropriate API subscribe that callback to notifications in your callback it's important that you do the work that you need to do this could involve updating documents like i did in the demo with custom font substitution or if you have a standard font menu or font list updating that it's really important to main track your notifications so that a user doesn't have to quit and relaunch your application to see changes they made to the font system other things you can do with want notifications or you can notify the system of changes you make the font directories or the registry there's a simple API to notify the system of changes and you'll want to do this if you're installing fonts from an installer application or some installer block in your code that drops fonts in the standard directory and finally a little bit more interesting often you can do and it interacts with some of the other font management api's that we have available is to batch your processing events things like 80's font activate and deactivate are lengthy operations and they trigger automatic notifications to anybody who subscribed if you're doing a lot of these in sequence you'll generate a lot of events center anybody subscribing to notifications which could be a performance issue what you can do is back your operation by passing the do not notify flag to those api's and at the end of your bags operation call the same 80s want notify API to tell everybody that you're done and that something has changed so let's see how to do a basic subscription to font notifications what I've done here is I have a very simple call back within the braces you would put the code that you want to run and for brevity I kind of left mine out then register it with the system using you can register your notification with the system using the API 80s font notifications subscribe and you passing your callback and you get back a notification reference it's possible to register notifications and you would want to hang on to the references especially if you want to unsubscribe them like I do at the bottom when unsubscribing you pass in the notification reference and then you no longer will receive notifications for the callback that's attached to that reference this you can do this in the case where you've got multiple functionality but only some of it needs to be maintained through a certain time period you know so you set up set up a bunch of callbacks turn one off when you no longer need it anything else you have when your application terminates will automatically be unsubscribed all right the last item I have to cover is how to store font references in your document client references are important because a user wants to open their documents that they previously saved and see it coming back just as they saved it with the correct fonts and the correct style information so what are the best ways for you to store font references I've got three here and one of them is new for tiger so let's start with that one use the NS font descriptor class available from cocoa if you can this provides extended functionality for specifying fonts it allows you to specify fonts more precisely if you desire and also allows us to be more flexible with providing fonts for your request there are three simple steps to using these first you would create a font descriptor with some font attributes could be as simple as a font name then to save it you'll extract the attributes from the font descriptor which returns a dictionary which you can flatten and save into your document using the standard methods finally upon opening the document you'll create the NS font from this font descriptor and display it and your usual will be happy the other methods that you've seen before if you've been inundated previous sessions are use the postscript name if you can't adopt sponsor scripters the postscript name is the next best thing it's the standard reference mechanism in cocoa and quartz up to this point for referencing fonts if you happen to have a quick-draw based application you may still need to store the family name and style information all right so let's take a look at some quick code snippets for handling font descriptors alright I've got three blocks here the first block I create a font descriptor by a create with name this name is simply the PostScript name then in the second block I extract the font attributes this returns as you can see an nsdictionary I then can save that to my file and then bring it back and create a font after an archiving the dictionary creating a descriptor from that dictionary and then creating an NS font with fonts with descriptor and size at this point the document is ready to display and the users happy all right that about wraps it up for me so I'll have Robin come back on stage to give you some more advanced programming techniques to customize your application thank you alright so I'm back essentially you can see what i'm going to talk about for the rest of the session which is even more programming techniques so hang in there i'm going to try and make this as fun as possible now one of the key things i thought about when i was looking over this session was what are the sorts of things i want to hear about if i were just a generic developer who did something with fonts and here's something that's really important for you is in addition to the basic stuff we just described up above what you can get out of the system is hooking into it at the right level and customizing the way font handling works in your application so again we're giving you recommendations and guidelines but if you want to do your own custom support or if you want to make something slightly different that makes things even better for your users you can do it and so that includes things like the user interface looking at fonts in detail so you can implement let's say your own custom text engines handling font management in your own way or implementing a font utility just like font book you can also hook into the graphic system or the way fonts are processed either for printing or for rendering on screen and then finally there's a new feature that I'll go into later that I'm pretty excited about you'll probably notice it later is scripting for font management and that lets your users customize the way fonts work for them on the on the operating system so before I do that let me go in and give you a quick demo that shows you how you might want to customize some of these features alright so I'll bring up font book here and I've implemented a really simple basic application that shows you how you can customize the user interface so like we said we recommend using the font panel but if you want to do something different let's say a thought menu that does pretty much exactly the same thing as the font panel then I've done it fear if you look at this you can see that it's got all the standard collections in there within them they've got all the contents that you would get in a carbon or cocoa application that's adopted the font panel these are all the standard collections in fact I've shown it on the side with folks so you can see that they're actually exactly the same now another thing that we've done on tiger that's new that takes advantage of the font system and extract information out of it and puts it up on screen in a slightly different way is Apple system profiler and then you blow the stuff a little bit so you can see it and what we've done is we've added a fonts plugin for system profiler that essentially lists all the fonts available on your system extracts different bits of information about the font and then splashes it up on screen or in the system profiler app so you can actually see and get a lot of interesting information that's in the fonts themselves so you can see this is that fee know I've got you know where it's located whether or not it's enabled and in all kinds of information about the font itself that's actually available to you as developers okay so that's my demo reel quick and short and moving back to the presentation what I'm going to go over next is all of these items now go through and real quick you can tell i can speak pretty quickly i'll try and make sure I don't run everything together and a lot of other so you can understand me but essentially customizing to use their interface first off I'm going to talk about cocoa and then I'm going to talk about another component ml te so with cocoa what we've got here is it parallels the implementation or the additional work you might need to do that Nathan describes for carbon and this is important if you're writing a custom view all of the standard text views the text fields they handle the front panel automatically but let's say you're writing a no subclass of the table view or the outline view which don't inherently support the font panel this is how you go about doing it and it says two slides worth of steps it's really easy but first of all in cocoa just a general thing if you're dealing with fonts most likely you're going to have to get an instance of the shared font manager this is the hub of getting all your font services now once you've got your hands on that you can send a notification whenever your current selection in your text object your view changes or when you become first responders those are the two places where you'd actually want to do it and so you simply send this command and indicate the font and whether or not it's a multiple selection that's one part of the communication the second half is just about a simple so what happened here is that like I said standard text views automatically do this for you but if you want you can respond to changes in the font panel or the font user interface in the font menu the font manager will send a notification up the responder chain all you have to do is listen to the default message in this case I've implemented a basic delegate method change font is the message or the action message that you need to respond to within that function all you need to do is pull out your current selection I've got a really simple example here it's only one font for the object but you can do something more complex can imagine I pull that out my old font I send it back the to the bot manager to modify it and make that match exactly what the user has selected whatever actions the user has done in the font panel at the font menu it sends me back a new instance of an N and spawn object which then I can apply to my text field that's it so you notice it's actually in parallel with what Nathan describes you listen in to the messages and you send notifications out to communicate the information to the font panel now in ml te in the past you have to do what Nathan describes as with any carbon application but new for tiger we've made it even simpler all you have to do now is one line of code or in my case four lines of code essentially there's a new API available to enable support in a text ention which is the old name for MLT text objects and so in essence I've created text object it could be either a document or a text field indicate that you want it to listen and support the standard font command that's it you're done all of that communication back and forth updating the text object itself all of that handled automatically for you on tiger so that was a pretty boring slide but it's really simple all right so next up when you really want to get some detailed information about the fonts what do you do where do you go and what ap is or how do you go about doing it now I've got some sample code here but let me give you just a real quick hint when you're dealing with fonts you want to get information there's api's available but that's pretty much all the layers that I described earlier Coco absolutely ATS in all of those the recommendation is whichever one you've chosen to work at primarily let's say you're a Coco application a lot of the AP is there support the same level of support for accessing find information try and use it at that level if you need to you can dip down lower into the deeper layers as you need to so at the very bottom of course you've got a TS and in this case what i've done is i want to get access to every single thought on the system in the registry actually let me strike that every single font my app can see that I'll talk about this next there's some options you can set to define the context and the scope of an enumeration or a listing so in this case I create an iterator object I pass that iterator object to a function ap has spawned iterator next that basically steps through every single font on the system that matches my criteria returns a standard font rest that I can then use later to access information and I'll go into that in a little bit more detail later once I'm done with the iteration or the enumeration I'll release the iterator object and I can move on fact that's exactly what I'll do next all right so i mentioned context and scope a lot of people tend to ask this question what the heck is that there's two options I gotta mess with it simplest way to look at it is in this diagram you'll see the local unregistered unrestricted combination of options really matches what i just described it's really all the fonts that your apps should be able to use in speed now within that step you've got more restricted steps one is the local restricted local context which is really your local applications restricted to just those fonts that your application owns and manages and has entered into the system so they're like application-specific fonts global restricted is the global space it's all the shared fonts and those fonts managed by the system itself put those together and you get all the fonts that you can see in use within your app there's one more combination the fourth one which is global unrestricted which we don't recommend you use mainly because you take this image duplicated essentially with all the processes or the all the applications in the system it'll give you all those fonts every single fonts and so the key thing here to remember is you might get your hands on some fonts that you don't have you know you can't use basically they're owned by somebody else all right so once you get your hands on a font ref what can you do with it here's one example there's support its various layers and its font has the support ats also has the support you can ask this metrics information about the fonts and also in some cases information about individual glyphs within the font and so you've got the advanced you've got line information bounding wrecks and additional information including like the italic angle so again the recommendation is use those AP is at the same level as the other AP eyes you're using in your application now another thing okay so customizing font management is the next section what's that means well let me give you a little background font management when I talk about it we're talking about component wise it's the shared font registry on the system it's the support available for Mac OS 10 that goes out and finds all the fonts it tracks information such as you know what users can see the fonts what processes can use and see the fonts and access privileges as well as where the fonts are located this font database or fonts registries handles the standard file system domain orderings this is all the different locations so just to go through it real quickly first off the system will look in the user domain or your home directories font library next up the local domain which is the library fonts that shared across the particular computer between different users as well as different applications you've got the network fonts and then the system critical fonts that you're not supposed to touch and then finally it's not a standard vows with some domain but we supported the classic environment which doesn't need to be running by the way all you have to do is register it with system preferences we'll look inside its system folder and give you back all those fonts also so the way you can take advantage of this is you can add fonts or remove fonts in that registry you can modify the content the way you would do it is using this function 80s fond activates from file specification is one example it uses a standard file spec this is obviously an older API pointed at your font or your direct response indicate now this is why we had different contexts and scope options we we use that one so you can register the fonts locally within your application I've also specified that I don't know what the format is so please figure it out for me and that's a really good example with a system you can leverage it and still provide custom support because it handles all of the details of the different formats and activates them accordingly you get a container objects back whenever you want to you can remove those fonts from the system using that container that's it all right now this is something really cool it's new in the past we've told you if you have an application specific font you need to do that stuff in the previous slide well now on tiger all you have to do is stuff your fonts somewhere in your application bundle put a pointer to it in the info.plist file and then you're done everything else is taken care of for you so the system will automatically register those fonts with itself when your application is launched and then remove those fonts when your application ships down and again the key that you'll want to use is right up there ATS application fonts path now another thing is in the demo I showed you I access the system support for collections and the way this works just a quick review is it lets users filter down the font list to something more manageable and so when you do that we actually the way you can support it is hooking into cocoa we also have C callable equivalents for getting at this support what we have here right now is the first block of code is just getting a list of all the collections available it's essentially an array of NF string from that you can actually modify or add additional collections you can add and remove them I don't show it here but I do show how you can modify the contents one or create a new one on your own and so there's a thought geek in my group I won't mention their names but I happen to install my fonts and group them according to different styles and categories historically venetian ghiroli are two different subclasses of or subgroups of the seraphs old style categories so what I want to do here in this example is essentially take all the descriptors side note every collection consists of quanta scriptures as nation nation mentioned earlier these are essentially a way to describe or criteria that describe one or more fonts together so again my collection I extract all the descriptors out of it stick it in an array then I stuff in some more I pull them out of the garage collection stuff them into that array and then I add all of those fought descriptors to my new collections that I referenced by is the name serif old cell simple as that and again there's see callable equivalents that you can use in the carbon frame work all right so we got font processing what does that mean for you I think I mentioned it earlier they're essentially a way for you to hook into the graphic system or the printing system what the rasterizer is do they're actually modular components on the system they take the raw font data they run through it and they spit out graphics or print related data that includes the bitmap the outlines it also converts the font data from what you see on disk that can be embedded within a postscript document or PDF file in fact that's exactly what the printing system on Mac os10 uses it uses this level of support so if you want to hook into it you can take advantage of that now the rasterizer is also hide all of the details of different formats for you so we've got truetype in all its variants open types is actually a new format package that is supported by microsoft in Adobe and Mac os10 we also handle PostScript both the type 1 and the open type flavors so all of that details hidden away from you so you don't have to worry about it but still take advantage of the general features now here's one example of doing that I'm going to give you 2 i'll touch on printing next but in this case i'm using the text layout system itself i'm using its character to glyph conversion support in initial block essentially i'm using this API ok I'll let you read it out loud by the way I've done worse than my history essentially it takes a text layout object that stores the text stream the text information it takes those character codes converts them over to a list of glyphs records I've got a glyph data array and account one thing to note is that character codes don't necessarily map the glyph IDs which are actually the representation of the actual shapes within a font so a good example of this is a ligature if you have F let's say f & L in your character stream when you apply to a font or apply a font to it it might get merged into one ligature one glyph that's the SL ligature itself and so you can take advantage of the text system to do that conversion for you in a standard way now the second block of code shows you how you can actually get that graphics paid i mentioned one of the things you can use it for is let's say you got some text you want to turn it into graphics data that you want to send to a straight to the printer you want to modify it you want a more fit into a different graphic shape you know put polka dots on it for all I know so in order to do this you go through those with records one by one grab the relevant information in this case the style object and the glyph ID and what's really interesting here is that by the way I'm converting this to cubic data cubic path you can also convert it to another form quadratic curve but in this case I've got four standard operations that define the shape of the glyph and so one would be moving to a particular point another one would be drawing a straight line segments another one might be drawing a curve and the fast last one is drawing or indicating the end of the path and so all of these functions you can define pass it into the absolute get cubic glyphs path function it will basically record or playback those glyphs allow you to record that information in a buffer and process it however you want you can send it straight down to a disk whatever you choose to all right so i mentioned printing support essentially this is this is a new feature in tiger now we still highly recommend you let the printing system do as much of the work as possible but if you were using instead of let's say the PDF rendering path which is recommended you're using the old laserwriter eight compatibility print support to do postscript rendering or postscript downloads this lets you take advantage of newer support to actually just get that font data to do it to manipulate in your own way and so we allow you to generate font subsets from a standard courts font reference using the function well cg fonts create PostScript subsets you can indicate what the output format should be and then an array of glyphs cg glyph ids these are just the same as those goodbye these i mentioned earlier in the absolutely example if you pass the null for the array it will just give you every single glyph in the font or you can indicate specific lists as you choose once you've done that it will return all that data back in a CF package foundation data package which then you can use the standard functions and core foundation to parse and process however you want including spending it to a disk or downloading it straight to a printer okay so at this layer when you're working on it you have to be more aware of performance and so here are some tips and hints when you're working in that silly try and we use objects as much as possible specifically for fonts pre-allocate and reuse the abscess style objects this this allows you to use the caching system available in that sweet and it basically minimizes the amount of memory allocations and reuse of system resources also use the courts graphics context as much as possible when you're working directly with a sooty this is because actually has been optimized for courts if you're using an older let's say quick draw graphics port there's some conversion that's needed that slows things down potentially now when you're working in court the same principles tend to apply try and we use the CG font reps as much as possible the courts font references the reason for this is even though you might have the same font reference pointing at the same font let's say x if it's reused in the PDF document those would actually be treated as two different fonts completely the caching system also works in a similar way now higher level components actually hide those details from you but at this layer if you're working directly you can end up let's say if you were doing PDF support you might end up embedding two different sets of font taters that are essentially the same font all right so I mentioned I was excited about this well it's really cool it's new and let me show you instead of actually talking about it first with an example of what we've done on Mac OS 10 for tiger so right now I've got font book showing if you didn't notice earlier take a look here I've got a Anders Apple script menu now available I'll just open up the scripts folder and I've got two scripts they're available in fact let me just pull up one using script editor to show you that it is actually applescript alright so one of the key things to remember here you can manipulate any object that font book itself can see and handle so in this particular case I'm just showing you the codes we get expensive yeah this is real code but just a quick summary of it is it's creating a new collection named bulbs and then it's asking all the typefaces in font book for every entry in there that might match the name bold pull those out and stuff them into the new collection i just created called bulbs now instead of running it from within script editor let me run it straight from fonte books now the thing to remember is watch the collections pane on the left hand side you're going to see a new collection show up there pretty much instantaneously call bulb it contains entries that only have a bold typeface in it not vice if I done this myself it would have taken me a little bit longer than that you know snaps one second thing now another thing that I've done is actually I've implemented another applescript it's really cool I actually hugged the engineer when he showed me this mainly because I'll let it run I used to do have to do this by hand okay so I go in and I'd have to test it i said create the samples I hated it well it's done well yes it's done now so essentially i created a document with 87 different families 183 typefaces all using Apple scripts and the key thing to remember here is that not only is font book itself Apple scripted but you can interact or your users can interact with other applications that support apple script this is easily okay so that's the demo reel and getting back to the presentation here's this the final summary of what the scripting support that's new for Tiger consists of it's a standard apple apple script dictionary in font book it has a number of classes and elements that you can take advantage of including the domains I described earlier collections themselves as well as containers and you can also manipulate or look at the thought families and tight spaces within those each of them has a bunch of different properties that you can check out but the name is definitely one of them whether or not that font or collection is enabled and then you can manipulate them using the standard apple script commands like add and remove to remove items from a container object let's say fonts from a collection you can also do eat objects wholesale so that's new for tiger it's really exciting I know some of you have asked us in the password and we got it done all right so that wraps up the presentation let me just give you an overall summary essentially adopt the font panel if anything please try to do that let the system do the work for you that's really the key message here that's where we're going to put a lot of support in you can take advantage of this by just doing that now if you want to customize support you can do it like I described there's a bunch of different things you can do with the operating system a bunch of different API is available you can customize the wave fonts work within your application to match your users needs now if you have any questions you can contact our evangelist xavi a liberal and you can also refer to the documentation on the Apple Developer connection website and this just touches on a couple of the items i discussed today I kind of went everywhere