Fonts with non-standard sizes?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Fonts with non-standard sizes?

Simon Guest-2
Hi,

I've made a morph which contains some text, and the font size should
depend on the size of the morph.

However, if I just try to set the font using
StrikeFont class>>familyName:pointSize: or TTCFont class>>family:size:, it only
gives me fonts in certain predefined sizes.

I know I can choose my own size using StrikeFont class>>fromUser, but
what's the best way to do this in my code, non-interactively?

Oh, and should I prefer TTCFont or StrikeFont, or does it not matter?

And what should I use for the font family, for maximum portability?
Can I assume BitstreamVeraSans is always available?  What's better
than assuming that?

cheers,
Simon
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Fonts with non-standard sizes?

Yoshiki Ohshima-2
  Simon,

  What version of Squeak are you using?

> I know I can choose my own size using StrikeFont class>>fromUser, but
> what's the best way to do this in my code, non-interactively?

  This is a good starting point. StrikeFont class>fromUser calls:
StrikeFont class>fromUser:allowKeyboard:, and down in the method, you
find lines like:

  ptMenu add: 'new size'
      target ... #addNewFontSizeDialog: ...

This suggests that for the 'new size' menu item, a message whose
selector is addNewFontSizeDialog: is sent to an object.  And if you
look at the implementors of the method, it is TextStyle.

  So, if you evaluate:

  (TextStyle named: 'BitstreamVeraSans') addNewFontSize: 120.

you can add the new size.

> Oh, and should I prefer TTCFont or StrikeFont, or does it not
> matter?

  StrikeFont is pixel font and not good for making new size
programatically.  Your safe bet is on TTCFont.

> And what should I use for the font family, for maximum portability?
> Can I assume BitstreamVeraSans is always available?  What's better
> than assuming that?

  Nobody would lobby to remove it but you could do:

        TTFontDescription default name

to figure out the "default TrueType font" in the current system.

-- Yoshiki
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Fonts with non-standard sizes?

Simon Guest-2
At Wed, 12 Dec 2007 18:22:13 -0800,
Yoshiki Ohshima wrote:
>
>   Simon,
>
>   What version of Squeak are you using?

Yoshiki,

I'm dithering around between different versions for different uses, 3.10
and OLPC developer image, hoping that at the level I am working, my
code will work on both.

Thanks for your reply, it was really useful.

cheers,
Simon
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners