[Texas] Changing the font of the Console module

Rage Creation ragecreations at gmail.com
Tue Nov 25 16:04:37 CET 2008


Thanks =)

On Sun, Nov 23, 2008 at 6:08 PM, Walker Hale IV <walker.hale.iv at gmail.com>wrote:

> Short Answer:
>
> Give up. You are so deep into Windows API nastiness that you can't see
> daylight.
>
>
> Long Answer:
>
> You can't do anything in Python that you can't do in C.
>
> Fredrik Lundh's Console module does not support setting the font. This
> module is mostly some C code that accesses a few of the console
> functions in Win32.
>
> http://msdn.microsoft.com/en-us/library/ms682073(VS.85).aspx<http://msdn.microsoft.com/en-us/library/ms682073%28VS.85%29.aspx>
>
> Any deficiencies in this module might be overcome by calling Win32
> functions directly using either the ctypes module or using the pywin32
> library:
>
> http://docs.python.org/library/ctypes.html
>
> http://docs.python.org/using/windows.html
> http://sourceforge.net/projects/pywin32/
> http://docs.activestate.com/activepython/2.6/pywin32/PyWin32.HTML
> http://docs.activestate.com/activepython/2.6/pywin32/win32console.html
>
> In fact you could use either ctypes or pywin32 as a replacement for
> the Console module, but the API wouldn't be as nice.
>
> Now pywin32/win32console does not contain all of the functions in
> Win32. In particular, the one function for dealing with fonts is
> missing...
>
> Microsoft discourages using custom fonts in consoles.
>
> http://blogs.msdn.com/oldnewthing/archive/2007/05/16/2659903.aspx
>
> The only way a font can appear in a console is if that font has been
> added to a magic spot in the registry. This makes the font available
> in the Properties page for the console (when you open the menu in the
> upper-left).
>
>
> http://www.windowsnetworking.com/kbase/WindowsTips/WindowsNT/RegistryTips/Miscellaneous/ConsoleFonts.html
>
> Theoretically, C code can set a console to use one of those specially
> registered fonts, but I haven't found any examples of people
> successfully doing it.
>
>
> Bottom Line:
>
> You are at the beginning of a long, hard road. Python will neither
> help nor hurt you. The problems you face are the same as for a C
> programmer.
>
> If you still want to attempt this you will need to:
>
> * Add your font to the magic spot in the registry, giving it a number.
> * Verify that you can use that font in a standard console window by
> selecting it in the properties dialog.
> * Write special code using ctypes to
> ** create a new console buffer
> ** set the font number for the buffer to the corresponding font number
> in the registry using SetCurrentConsoleFontEx
> ** install the new buffer into your console
>
> Or something like that. And it still might not work!
>
> --
> Walker Hale <walker.hale.iv at gmail.com>
>
> On Fri, Nov 21, 2008 at 9:58 PM, Rage Creation <ragecreations at gmail.com>
> wrote:
> > Using the Console module as described here:
> > http://effbot.org/zone/console-handbook.htm
> > Is there a way to change the system font so that all fonts used within
> the
> > program follow that?
> > Or a way to modify the Console module to adjust what font its using (it
> has
> > to be reading a font from somewhere, right?)
> > Thanks,
> >
> > Anthony
> >
> > On Thu, Nov 20, 2008 at 11:06 AM, Walker Hale IV <
> walker.hale.iv at gmail.com>
> > wrote:
> >>
> >> Are you referring to the console module for Jython or something else?
> >>
> >> In general, adding an attribute that does not already exist to a
> >> module will have no effect.
> >>
> >> --
> >> Walker Hale <walker.hale.iv at gmail.com>
> >>
> >> On Wed, Nov 19, 2008 at 3:20 PM, Rage Creation <ragecreations at gmail.com
> >
> >> wrote:
> >> > Hello everyone, I am a new Python coder using the Console module with
> a
> >> > (hopefully simple) question:
> >> > I want to use a fixed-width font for my program, but the Console
> module
> >> > seems to lack a font attribute. I tried using sys.font = "White
> Rabbit"
> >> > (my
> >> > fixed width font) and it ran with no errors but the output did not
> >> > change. I
> >> > also looked inside of Console.py but there was no setting of a font
> >> > there,
> >> > either.
> >> > Any advice?
>



-- 
http://ragecreations.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/mailman/private/texas/attachments/20081125/d19df352/attachment.htm>


More information about the Texas mailing list