What is the regular way to create a StringMorph with a particular font size?

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

What is the regular way to create a StringMorph with a particular font size?

Hannes Hirzel
Hello

I am wondering how a short version of constructing a StringMorph with
a particular TextStyle looks like.

The version which is attached works fine.

The question is mainly

How do I replace

     (TextConstants at: #LiberationSans) fontArray at: 7

with something which directly refers to the point size?

And as a second question how do I get from the number of desired
screen pixels to the closest font size?

Regards
Hannes

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

LiberationSans60point.png (28K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: What is the regular way to create a StringMorph with a particular font size?

Hannes Hirzel
P.S.

I had changed

 TTCFont pointSizes

  "The default sizes that are created when a TextStyle is created.
    You can add new sizes by the new-size feature."
        ^ #(9 12 15 24 36).

in my image _before_ importing a TrueType font.




TTCFont pointSizes

is now

pointSizes

        "The default sizes that are created when a TextStyle is created.  You
can add new sizes by the new-size feature."
        ^ #(9 12 15 24 36 48 60).


And the font loaded is LiberationSans

https://pagure.io/liberation-fonts

The Liberation Fonts are intended to be replacements
for the three most commonly used fonts on Microsoft systems:
- Times New Roman,
- Arial and
- Courier \ New.

On 4/10/17, H. Hirzel <[hidden email]> wrote:

> Hello
>
> I am wondering how a short version of constructing a StringMorph with
> a particular TextStyle looks like.
>
> The version which is attached works fine.
>
> The question is mainly
>
> How do I replace
>
>      (TextConstants at: #LiberationSans) fontArray at: 7
>
> with something which directly refers to the point size?
>
> And as a second question how do I get from the number of desired
> screen pixels to the closest font size?
>
> Regards
> Hannes
>
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: What is the regular way to create a StringMorph with a particular font size?

Dan Norton
Hi Hannes,


On 04/10/2017 07:11 AM, H. Hirzel wrote:

> P.S.
>
> I had changed
>
>   TTCFont pointSizes
>
>    "The default sizes that are created when a TextStyle is created.
>      You can add new sizes by the new-size feature."
> ^ #(9 12 15 24 36).
>
> in my image _before_ importing a TrueType font.
>
>
>
>
> TTCFont pointSizes
>
> is now
>
> pointSizes
>
>          "The default sizes that are created when a TextStyle is created.  You
> can add new sizes by the new-size feature."
>          ^ #(9 12 15 24 36 48 60).
>
>
> And the font loaded is LiberationSans
>
> https://pagure.io/liberation-fonts
>
> The Liberation Fonts are intended to be replacements
> for the three most commonly used fonts on Microsoft systems:
> - Times New Roman,
> - Arial and
> - Courier \ New.
>
> On 4/10/17, H. Hirzel <[hidden email]> wrote:
>> Hello
>>
>> I am wondering how a short version of constructing a StringMorph with
>> a particular TextStyle looks like.

With Cuis, if you have the font in the 'AdditionalFontData' directory,
maybe the following?

| w nam |
nam := 'LiberationSans'.
w := AbstractFont familyName: nam aroundPointSize: 10.
(StringMorph contents: 'Some text in "', nam, '" font.' font: w) openInHand.

I don't have your TrueType font, but the above works for the DejaVu Sans
Mono font. This example appears in Terse Guide.

  - Dan

>>
>> The version which is attached works fine.
>>
>> The question is mainly
>>
>> How do I replace
>>
>>       (TextConstants at: #LiberationSans) fontArray at: 7
>>
>> with something which directly refers to the point size?
>>
>> And as a second question how do I get from the number of desired
>> screen pixels to the closest font size?
>>
>> Regards
>> Hannes
>>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

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