Re: How to compute font size ?

"'Chris Barker' via wxPython-dev" <[email protected]> Tue, 1 Jan 2019 09:03:08 -0800
Newsgroups gmane.comp.python.wxpython.devel
Message-ID <CALGmxEJrB41xwUEQiC8SEYFUnnhKD7T5XE6LqEtifyE3ipeDXw@mail.gmail.com>
https://wxpython.org/Phoenix/docs/html/wx.GraphicsContext.html#wx.GraphicsContext.GetFullTextExtent

-CHB


On Fri, Dec 28, 2018 at 2:40 PM Nicolas Pinault <[email protected]> wrote:

> Hi,
>
> In my app, I have a window(a panel) where I write some text as an overlay :
>
>      def _set_overlay(self, win, text, colour=(192, 192, 192)):
>          dc = wx.ClientDC(win)
>          odc = wx.DCOverlay(self.overlay, dc)
>          odc.Clear()
>          ctx = wx.GraphicsContext.Create(dc)
>          col = wx.Colour(*colour, 128)
>          brush = ctx.CreateBrush(wx.Brush(wx.Colour((0,0,0,128))))
>          font = ctx.CreateFont(10, "ARIAL", flags=wx.FONTFLAG_DEFAULT,
> col=col)
>          ctx.SetFont(font)
>          ctx.DrawText(text, 10, 10, brush)
>          del odc
>
> For now, the font size is fixed. I'd like to compute the font size to
> make the text half the width of the window.
> What is the best way to compute the font size ?
>
> Regards,
> Nicolas
>
> --
> You received this message because you are subscribed to the Google Groups
> "wxPython-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>


-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[email protected]

-- 
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.