Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!cbmvax!peter From: peter@cbmvax.commodore.com (Peter Cherna) Newsgroups: comp.sys.amiga.programmer Subject: Re: 2.0 Compatibility Message-ID: <21163@cbmvax.commodore.com> Date: 2 May 91 15:45:29 GMT References: <4766@orbit.cts.com> <1991May1.213904.338@neon.Stanford.EDU> Reply-To: peter@cbmvax.commodore.com (Peter Cherna) Organization: Commodore-Amiga, Inc. West Chester, PA. Lines: 114 In article <1991May1.213904.338@neon.Stanford.EDU> espie@flamingo.Stanford.EDU (Marc Espie) writes: >About that font change problem, I think this is THE biggest loophole in specs. >HOW WHERE PROGRAMMERS SUPPOSED TO DEDUCE FROM THE ROM KERNEL MANUAL THAT >THERE WOULD BE *TWO* DISTINCT SYSTEM FONTS ? A great many applications could not handle proportional fonts, so it became clear that GfxBase->DefaultFont had to be a monospace font. However, Intuition was quite capable of handling proportional fonts for things like screen titles, and they look much better. It would have sucked to force the titlebar font to be monospace. That is how the screen font came to be defined as "the user's preferred font", and GfxBase->DefaultFont came to be defined as "the user's preferred monospace font". >Myself, not being a professionnal developper, and having the RKM1.3, was >having a hard time figuring that out. Knowing you can rely on preferences fonts >is rather elusive, where do you find the font information ? The system has to grow. Often that means mild compatibility glitches when the system is in a "new" state. Compatibility can be returned by restoring default preferences (eg. font, screen-mode, overscan). >The system font is to be found in GfxBase->DefaultFont, the screen >font is to be found in the screen you want to open: screen->Font. If you're opening on someone else's screen (usually the Workbench), then the screen's font is not necessarily the same as the user's preferred screen font. You could open a public screen with Helvetica 27 as its font, if you like. >One bad thing about these is that one speaks graphics (struct TextFont), >and the other one speaks intuition (struct TextAttr). It's exceptionally straightforward to build a TextAttr out of a TextFont. Incidentally, both structures are graphics.library concepts. Think of a TextAttr as a font request, like a NewWindow structure is. A TextFont is an actual instance of a font, like a Window structure. >Other interesting detail, the screen font is not necessarily fixed-width, >the system font is... As I mentioned above, that's _the_ crucial detail. >To get to that screen (for instance workbench), you can either open a window in >it, or lock IBase and look for it... the big problem is, if you don't have >a window opened, preferences is free to change its fonts... so you had better >get to it with a probe window (LockPubScreen is of course another solution, >which doesn't run under 1.3). It's easy to call LockPubScreen() if you're running V36 or higher. LockPubScreen() ensures that nobody can close the screen you're trying to open on, while you make enquiries of it. If you're going to open a window based on things you've learned through LockPubScreen(), then you MUST use the {WA_PubScreen, pubsc} tag-item, to ensure that you'll open on the intended screen. Note that by setting NW_EXTENDED, you can call (old-style) OpenWindow() and still pass a tag-list, that 1.3 will ignore. >(side-question to 2.0 developpers: is there a way to get notified when >preferences wants to change its fonts, so that you can do as the workbench, >close all your windows, wait for font change, and reopen them ?) You can wait on notification for the files that cause Workbench to be reset: overscan, screenmode, screenfont. However, it's almost certainly not worth the bother, since in real use, the user isn't constantly switching these. The user typically plays with them for fun or to decide what he likes, then eventually they're not changed any more. It can end up being a fair amount of coding to be able to shut down your window, and re-open it with the previous context. Actually, now that I think about it, there's no easy way to know when the Workbench screen has re-opened! (We did consider supporting this, but it's far harder than it seems. Some of the most frightening synchronization problems I've ever seen were in this area. We used to have cases where Workbench failed to re-open when you made a change under certain rare conditions. It would have been a tremendous amount of work to get a robust, functional mechanism working for general use. Remember that with just Workbench, Intuition has only one customer to worry about, and we control the code that's in it...) >Other compatibility problems: window borders and window title. The simplest >way I've found around this one is the following (since GZZ windows are >inefficient): >- open a window as though it had no borders. >- adjust all your gadget and display stuff to the window border. >- resize the window, simply: >Size(window, window->BorderRight + window->BorderLeft, window->BorderTop + >window->BorderBottom); >(for more dynamic sizing, you can compute open the window with say, >xstart and ystart as a size, compute the size you need (borders not included), >say xmax, ymax, and Size(w, w->BorderRight + window->BorderLeft + xmax - xstart, >...). You can save yourself a lot of trouble by noting that the titlebar height can be predicted as: screen->WBorTop + screen->Font->ta_YSize + 1 The other border dimensions are compatible with the values used in 1.3, and are constant. They only vary if you stuff larger border gadgets into them. I expect that if such dimensions will ever have to change, that there will be a compatibility flag you set to request it. It really is a question of yield vs. cost. Getting the screen font into the title bar makes the system look _amazing_. Tweaking things like the height of the sizing gadget (which would be nice for interlaced screens, for example) is lower yield. > Marc (espie@flamingo.stanford.edu) Peter -- Peter Cherna, Operating Systems Development Group, Commodore-Amiga, Inc. {uunet|rutgers}!cbmvax!peter peter@cbmvax.commodore.com My opinions do not necessarily represent the opinions of my employer. "If all you have is a hammer, everything looks like a nail."