Implementing TTF/true-type-font in a wx control, using the .ttf file?

I have the .ttf true-type-font file for rendering braille characters, sort of graphically, and was just wondering, if slapped together a wx-based GUI interface, how easy would it be to get something like a static label to render it’s text output using that font, without having it installed on the target windows machine?

TIA

Jacob Kruger
Blind Biker
Skype: BlindZA
“Roger Wilco wants to welcome you…to the space janitor’s closet…”

Ok, little bit of online research, and seems font would need to be installed on this windows machine, but, how do I then implement a wx.Font object, since seems like needs you to specify something like a font base name at initiation? Just not sure what counts as base name for this file - if use the name windows refers to it as, am not sure it’s really implementing it etc., and when then instantiating an instance of wx.StaticText, would I just pass the wx.Font object to it as an argument?

TIA

Jacob Kruger
Blind Biker
Skype: BlindZA
“Roger Wilco wants to welcome you…to the space janitor’s closet…”

···

----- Original Message -----

From:
Jacob Kruger

To: wxpython-users@googlegroupscom

Sent: Friday, May 08, 2015 11:20 AM

Subject: [wxPython-users] Implementing TTF/true-type-font in a wx control, using the .ttf file?

I have the .ttf true-type-font file for rendering braille characters, sort of graphically, and was just wondering, if slapped together a wx-based GUI interface, how easy would it be to get something like a static label to render it’s text output using that font, without having it installed on the target windows machine?

TIA

Jacob Kruger
Blind Biker
Skype: BlindZA
“Roger Wilco wants to welcome you…to the space janitor’s closet…”


You received this message because you are subscribed to the Google Groups “wxPython-users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Installing a font is a very operating system-specific task. I’m not
sure there is any abstraction available.
On Windows, you can use the AddFontResource API to add a temporary
font that will last only until the next reboot. To make it
permanent, you need to copy the file into C:\Windows\Fonts.

···

Jacob Kruger wrote:

      I have the .ttf true-type-font

file for rendering braille characters, sort of graphically,
and was just wondering, if slapped together a wx-based GUI
interface, how easy would it be to get something like a static
label to render it’s text output using that font, without
having it installed on the target windows machine?

-- Tim Roberts, Providenza & Boekelheide, Inc.

timr@probo.com

From:
Tim Roberts

To: wxpython-users@googlegroupscom

Sent: Friday, May 08, 2015 7:23 PM

Subject: Re: [wxPython-users] Implementing TTF/true-type-font in a wx control, using the .ttf file?

Installing a font is a very operating system-specific task. I’m not sure there is > any abstraction available.

On Windows, you can use the AddFontResource API to add a temporary font > that will last only until the next reboot. To make it permanent, you need to

copy the file into C:\Windows\Fonts.
The installation of the font is not really an issue, but, now trying to figure out how to then make use of that font-face when rendering the wx.StaticText element?

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
“Roger Wilco wants to welcome you…to the space janitor’s closet…”

···

----- Original Message -----

installed font, and you can then pass that font to where you want it used.

http://docs.wxwidgets.org/3.0/overview_font.html

You want to set the faceName

The trick may be to figure out what to call it! -- but look on the overview
page under Native Font Information -- it looks like you can us a Font
Dialog to grab the font -- then you should be able to store the native font
info (which I think is a string).

- Good luck.

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

Chris.Barker@noaa.gov

···

On Fri, May 8, 2015 at 12:15 PM, Jacob Kruger <jacob@blindza.co.za> wrote:

  The installation of the font is not really an issue, but, now trying to
figure out how to then make use of that font-face when rendering the
wx.StaticText element?

what have you tried? wx should be able to create a wxFont object from any

From:
Chris Barker

To: wxpython-users

Sent: Friday, May 08, 2015 10:53 PM

Subject: Re: [wxPython-users] Implementing TTF/true-type-font in a wx control, using the .ttf file?

what have you tried? wx should be able to create a wxFont object from any

installed font, and you can then pass that font to where you want it used.

http://docs.wxwidgets.org/3.0/overview_font.html

You want to set the faceName

The trick may be to figure out what to call it! – but look on the overview page

under Native Font Information – it looks like you can us a Font Dialog to grab

the font – then you should be able to store the native font info (which I think is > a string).

Ok, if I invoke wx.GetFontFromUser, I can select it from the list of fonts, choose font size, colour, effects, etc., and then have the wx.Font instance returned from the dialogue, and then .GetFaceName() returns “gh Braille Nemeth One”.

However, for example, if I just try implementing a new font using that string value, it doesn’t immediately notify me about any errors/issues, but I then get all sorts of errors relating to init of parent class not having been called if I then try doing much with the object/instance thereafter - the one returned from dialogue works fine/alright.

Also tried then pickling the returned .Font object to then reinvoke it later, but, there, it again just tells me init hasn’t been called.

So, for now, think will have to just use the font selection dialogue on startup, just because - not major, but, still just wondering.

Thanks for pointer

Jacob Kruger
Blind Biker
Skype: BlindZA
“Roger Wilco wants to welcome you…to the space janitor’s closet…”

···

----- Original Message -----

  Ok, if I invoke wx.GetFontFromUser, I can select it from the list of
fonts, choose font size, colour, effects, etc., and then have the wx.Font
instance returned from the dialogue, and then .GetFaceName() returns "gh
Braille Nemeth One".

However, for example, if I just try implementing a new font using that
string value, it doesn't immediately notify me about any errors/issues, but
I then get all sorts of errors relating to __init__ of parent class not
having been called if I then try doing much with the object/instance
thereafter - the one returned from dialogue works fine/alright.

darn -- you'd think that would work. But maybe this will:

"""
Instead, you should store the value returned by
wxFont::GetNativeFontInfoDesc and pass it to wxFont::SetNativeFontInfo later
to recreate exactly the same font.
"""

I _think_ the NativeFontInfo is a string, so you can save and restore it
easily enough.

-Chris

···

On Sat, May 9, 2015 at 1:00 AM, Jacob Kruger <jacob@blindza.co.za> wrote:

Also tried then pickling the returned .Font object to then reinvoke it
later, but, there, it again just tells me __init__ hasn't been called.

So, for now, think will have to just use the font selection dialogue on
startup, just because - not major, but, still just wondering.

Thanks for pointer

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
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

Chris.Barker@noaa.gov

From:
Chris Barker

To: wxpython-users

Sent: Monday, May 11, 2015 8:48 PM

Subject: Re: [wxPython-users] Implementing TTF/true-type-font in a wx control, using the .ttf file?

Instead, you should store the value returned by

wxFont::GetNativeFontInfoDesc and pass it to

wxFont::SetNativeFontInfo later to recreate exactly the same font.

Ok, that works fine - thanks again.

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
“Roger Wilco wants to welcome you…to the space janitor’s closet…”

···

----- Original Message -----

-Chris

···

On Mon, May 11, 2015 at 11:06 PM, Jacob Kruger <jacob@blindza.co.za> wrote:

*From:* Chris Barker <chris.barker@noaa.gov>

> Instead, you should store the value returned by
> wxFont::GetNativeFontInfoDesc and pass it to
> wxFont::SetNativeFontInfo later to recreate exactly the same font.
Ok, that works fine - thanks again.

cool -- glad you got it figured out.

--

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

Chris.Barker@noaa.gov