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

Dan Norton dnorton at mindspring.com
Mon Apr 10 17:14:19 UTC 2017


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 <hannes.hirzel at gmail.com> 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
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners



More information about the Beginners mailing list