How to set different fonts (question answered)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to set different fonts (question answered)

BGreen
I would like to be able to use a LaTeX math mode-like font for some plots. (I'm running Octave 5.1.0 on Windows 10.) The documentation at
suggests using the fontname property for this, but its instructions do not specify

Two suggestions came up when I searched. The first was just to use a font name, like
set(gca,"This Is A Font","defaulttextfontname","Helvetica")
This works, which is great.

The second was to give the directory and file like this:
title("This Is A Font","fontname","C:\Windows\Fonts\cambria.ttc")
While this doesn't return an error, it just prints the title with the default font.

In the end, all I had to do was
title("This Is A Font","fontname","Cambria Math")
and it worked. I had forgotten that I had not tried the simple string ("Cambria Math" here) with the property "fontname" intead of "defaulttextfontname".

I was surprised and impressed that I didn't need to specify a directory for an external font. Kudos to everyone who worked on this, and on Octave in general!

Though I was able to answer my question in the end, I wanted to submit this to the mailing list archives in case it could help someone else in the future.

- Brett Green


Reply | Threaded
Open this post in threaded view
|

Re: How to set different fonts (question answered)

nrjank
Assuming there might be users after you with similar questions, do you have a suggestion for revised documentation text that would have made this more clear/useful? 

On Fri, Aug 30, 2019 at 10:20 AM Brett Green <[hidden email]> wrote:
I would like to be able to use a LaTeX math mode-like font for some plots. (I'm running Octave 5.1.0 on Windows 10.) The documentation at
suggests using the fontname property for this, but its instructions do not specify

Two suggestions came up when I searched. The first was just to use a font name, like
set(gca,"This Is A Font","defaulttextfontname","Helvetica")
This works, which is great.

The second was to give the directory and file like this:
title("This Is A Font","fontname","C:\Windows\Fonts\cambria.ttc")
While this doesn't return an error, it just prints the title with the default font.

In the end, all I had to do was
title("This Is A Font","fontname","Cambria Math")
and it worked. I had forgotten that I had not tried the simple string ("Cambria Math" here) with the property "fontname" intead of "defaulttextfontname".

I was surprised and impressed that I didn't need to specify a directory for an external font. Kudos to everyone who worked on this, and on Octave in general!

Though I was able to answer my question in the end, I wanted to submit this to the mailing list archives in case it could help someone else in the future.

- Brett Green



Reply | Threaded
Open this post in threaded view
|

Re: How to set different fonts (question answered)

BGreen
The documentation in < https://octave.org/doc/interpreter/Text-Properties.html > is fairly clear. I think the only possible benefit would be a few possible options as examples. For instance, we have the fontunits entry:
fontunits: "centimeters" | "inches" | "normalized" | "pixels" | {"points"}

fontname's entry is:
fontname: string, def. "*"

What about something like this?
fontname: string, def. "*", other options e.g.  "Helvetica" | "Courier New" | ...

Mostly, the reason I had trouble using this property was that I had trouble finding it. My go-to is the "walk-through" part of the documentation, e.g. here: < https://octave.org/doc/interpreter/Plot-Annotations.html >. Though they are treasure troves of functionality, properties lists like < https://octave.org/doc/interpreter/Text-Properties.html > are less easy to find and to learn from. Perhaps that's only a fault of mine, though.

- Brett Green


On Fri, Aug 30, 2019 at 10:33 AM Nicholas Jankowski <[hidden email]> wrote:
Assuming there might be users after you with similar questions, do you have a suggestion for revised documentation text that would have made this more clear/useful? 

On Fri, Aug 30, 2019 at 10:20 AM Brett Green <[hidden email]> wrote:
I would like to be able to use a LaTeX math mode-like font for some plots. (I'm running Octave 5.1.0 on Windows 10.) The documentation at
suggests using the fontname property for this, but its instructions do not specify

Two suggestions came up when I searched. The first was just to use a font name, like
set(gca,"This Is A Font","defaulttextfontname","Helvetica")
This works, which is great.

The second was to give the directory and file like this:
title("This Is A Font","fontname","C:\Windows\Fonts\cambria.ttc")
While this doesn't return an error, it just prints the title with the default font.

In the end, all I had to do was
title("This Is A Font","fontname","Cambria Math")
and it worked. I had forgotten that I had not tried the simple string ("Cambria Math" here) with the property "fontname" intead of "defaulttextfontname".

I was surprised and impressed that I didn't need to specify a directory for an external font. Kudos to everyone who worked on this, and on Octave in general!

Though I was able to answer my question in the end, I wanted to submit this to the mailing list archives in case it could help someone else in the future.

- Brett Green



Reply | Threaded
Open this post in threaded view
|

Re: How to set different fonts (question answered)

nrjank

Mostly, the reason I had trouble using this property was that I had trouble finding it. My go-to is the "walk-through" part of the documentation, e.g. here: < https://octave.org/doc/interpreter/Plot-Annotations.html >. Though they are treasure troves of functionality, properties lists like < https://octave.org/doc/interpreter/Text-Properties.html > are less easy to find and to learn from. Perhaps that's only a fault of mine, though.


this did come up  before (see the discussion at https://savannah.gnu.org/bugs/?50247) because there was an issues linking to pages with spaces in the names. that bug has an outstanding task of identifying which functions would benefit from document link updates now that the underlying issue is fixed.  maybe you could help identify other places where a simple link to follow would have made the search easier?


Reply | Threaded
Open this post in threaded view
|

Re: How to set different fonts (question answered)

BGreen
Interesting; I'd never seen that discussion. While off the top of my head I don't remember any, I'll certainly keep that in mind for when I remember or next time I see things where a link could help. Thank you for sharing!

- Brett Green


On Fri, Aug 30, 2019 at 1:01 PM Nicholas Jankowski <[hidden email]> wrote:

Mostly, the reason I had trouble using this property was that I had trouble finding it. My go-to is the "walk-through" part of the documentation, e.g. here: < https://octave.org/doc/interpreter/Plot-Annotations.html >. Though they are treasure troves of functionality, properties lists like < https://octave.org/doc/interpreter/Text-Properties.html > are less easy to find and to learn from. Perhaps that's only a fault of mine, though.


this did come up  before (see the discussion at https://savannah.gnu.org/bugs/?50247) because there was an issues linking to pages with spaces in the names. that bug has an outstanding task of identifying which functions would benefit from document link updates now that the underlying issue is fixed.  maybe you could help identify other places where a simple link to follow would have made the search easier?