[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] font.get_fonts and OS X



Hi,

What I did was find a listing of default fonts distributed with Windows XP and made a list from that. So if a known font file is found an entry is made for it. Registry entries take precedent. Scanning the fonts directory first was the simplest way to implement it. But originally the directory search followed the registry lookup. So initsysfont_darwin could first call initsysfont_unix, then scan the OS X fonts directory for overlooked entries.

Lenard

René Dudfield wrote:
hi,

yeah, it looks like it is sharing fonts. It returns some fonts in the X11 dirs, and some from the /Fonts/ dirs.

I could try and create something like: XP_default_font_files, but remove the X11 files from that list... if fc-list isn't there? Then use a method similar to the one you used for xp.

cu,


On Fri, May 22, 2009 at 4:19 PM, Lenard Lindstrom <len-l@xxxxxxxxx <mailto:len-l@xxxxxxxxx>> wrote:

    So for OS X and X11, is sysfont.py picking up the right fonts? Or
    does X11 on OS X share the Aqua fonts.

    Lenard

    René Dudfield wrote:

        hi,

        looks like the fix you committed is passing tests now :)
         http://thorbrian.com/pygame/builds.php

        Now to figure out a way to get it to pass on OSX 10.4 and
        below.  The tests pass on 10.5 and 10.4 with the optional X11
        installed.

        cu,



        On Fri, May 22, 2009 at 3:21 AM, Lenard Lindstrom
        <len-l@xxxxxxxxx <mailto:len-l@xxxxxxxxx>
        <mailto:len-l@xxxxxxxxx <mailto:len-l@xxxxxxxxx>>> wrote:

           EnumFontFamilies does not map font characteristic to an actual
           TrueType file, so is of no use here.

           Lenard


           Lenard Lindstrom wrote:


               Of course ctypes is used by pygame -m pygame.tests on
        Windows.
               So requiring it for sysfont as well is reasonable.

               Lenard

               Lenard Lindstrom wrote:


                   Hi René,

                   win32gui creates a win32api dependency. This could
        be done
                   with ctypes, but now Python 2.4 support will be
                   compromised. Personally, I don't care if general Python
                   2.4 support is dropped.

                   Lenard

                   René Dudfield wrote:

                       Hi,

                       two things I found out...

                       maybe this key works?
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows[NT]\CurrentVersion\Fonts"



                       Also there is an function called EnumFontFamilies,
                       that is there from win95 to get font information.


                       Here's some code I found using the win32gui
        module...

                       import win32gui
                       hdc=win32gui.CreateDC('DISPLAY','Display',None)
                       fonts=[]
                       def callback(font, tm, fonttype, fonts):
                          fonts.append(font)
                          #print font.lfFaceName
                          #print fonttype
                          return True
                       win32gui.EnumFontFamilies(hdc, None, callback,
        fonts)

                       #print fonts

                       f = fonts[0]

                       print dir(fonts[0])






                       On Thu, May 21, 2009 at 6:59 AM, Lenard Lindstrom
                       <len-l@xxxxxxxxx <mailto:len-l@xxxxxxxxx>
        <mailto:len-l@xxxxxxxxx <mailto:len-l@xxxxxxxxx>>
                       <mailto:len-l@xxxxxxxxx
        <mailto:len-l@xxxxxxxxx> <mailto:len-l@xxxxxxxxx
        <mailto:len-l@xxxxxxxxx>>>> wrote:

                          Hi,

                          I see there are problems with Windows XP.
                       Apparently the default
                          fonts aren't showing up in the usual
        registry place:

                          HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
                       NT\CurrentVersion\Fonts

                          I guess that is just for additional fonts, which
                       Brian's build
                          machine apparently does not have. Would there be
                       any other places
                          in the registry to search? Or must one start
        with a
                       list of
                          default Windows fonts then check for each in the
                       \windows\fonts
                          directory?

                          Lenard


                          René Dudfield wrote:

                              hi,

                              the tests pass on 10.5.7... which just
        uses the
                       unix
                              function... (which uses fc-list).

                              I think it should be easier to figure
        out what
                       to do for when
                              fc-list isn't there (pre 10.5.x machines)...
                        by looking at
                              the out put that the fc-list using
        function uses.

                              cu,



                              On Wed, May 20, 2009 at 3:33 PM, Lenard
        Lindstrom
                              <len-l@xxxxxxxxx
        <mailto:len-l@xxxxxxxxx> <mailto:len-l@xxxxxxxxx
        <mailto:len-l@xxxxxxxxx>>
                       <mailto:len-l@xxxxxxxxx
        <mailto:len-l@xxxxxxxxx> <mailto:len-l@xxxxxxxxx
        <mailto:len-l@xxxxxxxxx>>>
                              <mailto:len-l@xxxxxxxxx
        <mailto:len-l@xxxxxxxxx>
                       <mailto:len-l@xxxxxxxxx
        <mailto:len-l@xxxxxxxxx>> <mailto:len-l@xxxxxxxxx
        <mailto:len-l@xxxxxxxxx>
                       <mailto:len-l@xxxxxxxxx
        <mailto:len-l@xxxxxxxxx>>>>> wrote:

                                 I committed what I have so far. If OS
        X has
                       an fc-list
                              equivalent
                                 take a look at the updates I made to the
                       Unix section of
                                 sysfont.py for Python 3 and unicode.
        Some of
                       it may be
                              relevant.

                                 Lenard



                                 René Dudfield wrote:

                                     hello,

                                     ah, nice catch!   That's
        annoying... all
                       this time and it
                                     hasn't been
                                     working on OSX.

                                     Can you commit your tests?

                                     I can have a go at it... unless Brian
                       you want to have
                              a go?


                                     Here are the main font paths...
        the X11
                       one isn't there
                              on most
                                     installs for 10.4.x ... but should be
                       there on most 10.5.x
                                     installs.
                                     The last path is where OS9 used to
                       install fonts, and
                              some people
                                     still use that directory apparently.

                                     ~/Library/Fonts/
                                     /Library/Fonts/
                                     /System/Library/Fonts/
                                     /usr/X11/lib/X11/fonts/TTF/
                                     /Network/Library/Fonts/
                                     /System Folder/Fonts/


                                     cheers,




                                     On Wed, May 20, 2009 at 7:55 AM,
        Lenard
                       Lindstrom
                                     <len-l@xxxxxxxxx
        <mailto:len-l@xxxxxxxxx>
                       <mailto:len-l@xxxxxxxxx
        <mailto:len-l@xxxxxxxxx>> <mailto:len-l@xxxxxxxxx
        <mailto:len-l@xxxxxxxxx>
                       <mailto:len-l@xxxxxxxxx <mailto:len-l@xxxxxxxxx>>>
                              <mailto:len-l@xxxxxxxxx
        <mailto:len-l@xxxxxxxxx>
                       <mailto:len-l@xxxxxxxxx
        <mailto:len-l@xxxxxxxxx>> <mailto:len-l@xxxxxxxxx
        <mailto:len-l@xxxxxxxxx>
                       <mailto:len-l@xxxxxxxxx
        <mailto:len-l@xxxxxxxxx>>>>> wrote:
                                                        Currently I am
                       filling in the font unit tests. For
                              OS X I
                                         noticed that
                                         sysfont.py does not hunt down
                       installed fonts. The
                                         relevant function is a
                                         stub. I have no OS X access, so
                       can't write it
                              myself. Is
                                         someone else
                                         willing to take care of it.
                       Otherwise when I commit the
                                         completed unit tests
                                         they will fail for OS X.

                                         Lenard


-- Lenard Lindstrom
                          <len-l@xxxxxxxxx <mailto:len-l@xxxxxxxxx>
        <mailto:len-l@xxxxxxxxx <mailto:len-l@xxxxxxxxx>>
                       <mailto:len-l@xxxxxxxxx
        <mailto:len-l@xxxxxxxxx> <mailto:len-l@xxxxxxxxx
        <mailto:len-l@xxxxxxxxx>>>>








-- Lenard Lindstrom
    <len-l@xxxxxxxxx <mailto:len-l@xxxxxxxxx>>