font installer & free type fonts

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

font installer & free type fonts

Tudor Girba-2
Hi,

To ease the transition to Athens, we need to get free type fonts in the image. I researched a bit, and found a couple of font families that are nicely free and open-source: DejaVu, Source Code Pro, Source Sans Pro, and LinLibertine.

I put together a little tool that imports a TTF file and installs it in a dedicated class. You can find a library of already imported fonts on SmalltalkHub:
http://www.smalltalkhub.com/#!/~girba/FreeFonts/

More details about this library can be found at:
http://www.tudorgirba.com/blog/free-font-collection-for-pharo

For example, you can use the SourceCodeProRegular font as a code font like:
Gofer new
   smalltalkhubUser: 'girba' project: 'FreeFonts';
   package: 'SourceCodeProRegular';
   load.
(Smalltalk at: #SourceCodeProRegular) new install.
FreeTypeSystemSettings loadFt2Library: true.
StandardFonts codeFont: (LogicalFont familyName: 'Source Code Pro' pointSize: 10).

The Moose image already comes with a convenience method to set a complete free type font set:
MooseImageSetupCommandLineHandler new installFonts.

Cheers,
Doru


--
www.tudorgirba.com

"Be rather willing to give than demanding to get."

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: font installer & free type fonts

stephane ducasse
Hi doru

How do you use SourceCodeProSemibold for example 
StandardFonts codeFont: (LogicalFont
familyName: 'Source Code Pro'
pointSize: 10).

Because there is no family name for semi bold

Stef



On May 11, 2013, at 12:21 AM, Tudor Girba <[hidden email]> wrote:

Hi,

To ease the transition to Athens, we need to get free type fonts in the image. I researched a bit, and found a couple of font families that are nicely free and open-source: DejaVu, Source Code Pro, Source Sans Pro, and LinLibertine.

I put together a little tool that imports a TTF file and installs it in a dedicated class. You can find a library of already imported fonts on SmalltalkHub:
http://www.smalltalkhub.com/#!/~girba/FreeFonts/

More details about this library can be found at:
http://www.tudorgirba.com/blog/free-font-collection-for-pharo

For example, you can use the SourceCodeProRegular font as a code font like:
Gofer new
  smalltalkhubUser: 'girba' project: 'FreeFonts';
  package: 'SourceCodeProRegular';
  load.
(Smalltalk at: #SourceCodeProRegular) new install.
FreeTypeSystemSettings loadFt2Library: true.
StandardFonts codeFont: (LogicalFont familyName: 'Source Code Pro' pointSize: 10).

The Moose image already comes with a convenience method to set a complete free type font set:
MooseImageSetupCommandLineHandler new installFonts.

Cheers,
Doru


--
www.tudorgirba.com

"Be rather willing to give than demanding to get."

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: font installer & free type fonts

Tudor Girba-2
Hi,

The fonts-related code is a bit too complex for my mind.

Semi bold is indeed not a FreeTypeFontFamily, but a FreeTypeFontFamilyMember.

After loading the font, you can inspect it via:
(LogicalFontManager current allFamilies
        detect: [:each | each familyName = 'Source Code Pro' ])
                members detect: [ :each | each styleName = 'Semibold' ].

You will see that it has a couple of integer values for: stretch, weight and slant. The only way I could set a LogicalFont from outside was via these values explicitly:

StandardFonts codeFont: (LogicalFont
                        familyName: 'Source Code Pro'
                        pointSize: 10
                        stretchValue: 5
                        weightValue: 600
                        slantValue: 0).

I guess we need to review this part of Pharo.

Cheers,
Doru


On May 11, 2013, at 5:39 PM, stephane ducasse <[hidden email]> wrote:

> Hi doru
>
> How do you use SourceCodeProSemibold for example
> StandardFonts codeFont: (LogicalFont
>                          familyName: 'Source Code Pro'
>                          pointSize: 10).
>
> Because there is no family name for semi bold
>
> Stef
>
>
>
> On May 11, 2013, at 12:21 AM, Tudor Girba <[hidden email]> wrote:
>
>> Hi,
>>
>> To ease the transition to Athens, we need to get free type fonts in the image. I researched a bit, and found a couple of font families that are nicely free and open-source: DejaVu, Source Code Pro, Source Sans Pro, and LinLibertine.
>>
>> I put together a little tool that imports a TTF file and installs it in a dedicated class. You can find a library of already imported fonts on SmalltalkHub:
>> http://www.smalltalkhub.com/#!/~girba/FreeFonts/
>>
>> More details about this library can be found at:
>> http://www.tudorgirba.com/blog/free-font-collection-for-pharo
>>
>> For example, you can use the SourceCodeProRegular font as a code font like:
>> Gofer new
>>   smalltalkhubUser: 'girba' project: 'FreeFonts';
>>   package: 'SourceCodeProRegular';
>>   load.
>> (Smalltalk at: #SourceCodeProRegular) new install.
>> FreeTypeSystemSettings loadFt2Library: true.
>> StandardFonts codeFont: (LogicalFont familyName: 'Source Code Pro' pointSize: 10).
>>
>> The Moose image already comes with a convenience method to set a complete free type font set:
>> MooseImageSetupCommandLineHandler new installFonts.
>>
>> Cheers,
>> Doru
>>
>>
>> --
>> www.tudorgirba.com
>>
>> "Be rather willing to give than demanding to get."
>>
>> _______________________________________________
>> Moose-dev mailing list
>> [hidden email]
>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev

--
www.tudorgirba.com

"If you can't say why something is relevant,
it probably isn't."


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: font installer & free type fonts

stephane ducasse

On May 12, 2013, at 8:18 AM, Tudor Girba <[hidden email]> wrote:

> Hi,
>
> The fonts-related code is a bit too complex for my mind.

for mine too :)

>
> Semi bold is indeed not a FreeTypeFontFamily, but a FreeTypeFontFamilyMember.
>
> After loading the font, you can inspect it via:
> (LogicalFontManager current allFamilies
> detect: [:each | each familyName = 'Source Code Pro' ])
> members detect: [ :each | each styleName = 'Semibold' ].
>
> You will see that it has a couple of integer values for: stretch, weight and slant. The only way I could set a LogicalFont from outside was via these values explicitly:
>
> StandardFonts codeFont: (LogicalFont
> familyName: 'Source Code Pro'
> pointSize: 10
> stretchValue: 5
> weightValue: 600
> slantValue: 0).
>
> I guess we need to review this part of Pharo.
>
> Cheers,
> Doru
>
>
> On May 11, 2013, at 5:39 PM, stephane ducasse <[hidden email]> wrote:
>
>> Hi doru
>>
>> How do you use SourceCodeProSemibold for example
>> StandardFonts codeFont: (LogicalFont
>>                         familyName: 'Source Code Pro'
>>                         pointSize: 10).
>>
>> Because there is no family name for semi bold
>>
>> Stef
>>
>>
>>
>> On May 11, 2013, at 12:21 AM, Tudor Girba <[hidden email]> wrote:
>>
>>> Hi,
>>>
>>> To ease the transition to Athens, we need to get free type fonts in the image. I researched a bit, and found a couple of font families that are nicely free and open-source: DejaVu, Source Code Pro, Source Sans Pro, and LinLibertine.
>>>
>>> I put together a little tool that imports a TTF file and installs it in a dedicated class. You can find a library of already imported fonts on SmalltalkHub:
>>> http://www.smalltalkhub.com/#!/~girba/FreeFonts/
>>>
>>> More details about this library can be found at:
>>> http://www.tudorgirba.com/blog/free-font-collection-for-pharo
>>>
>>> For example, you can use the SourceCodeProRegular font as a code font like:
>>> Gofer new
>>>  smalltalkhubUser: 'girba' project: 'FreeFonts';
>>>  package: 'SourceCodeProRegular';
>>>  load.
>>> (Smalltalk at: #SourceCodeProRegular) new install.
>>> FreeTypeSystemSettings loadFt2Library: true.
>>> StandardFonts codeFont: (LogicalFont familyName: 'Source Code Pro' pointSize: 10).
>>>
>>> The Moose image already comes with a convenience method to set a complete free type font set:
>>> MooseImageSetupCommandLineHandler new installFonts.
>>>
>>> Cheers,
>>> Doru
>>>
>>>
>>> --
>>> www.tudorgirba.com
>>>
>>> "Be rather willing to give than demanding to get."
>>>
>>> _______________________________________________
>>> Moose-dev mailing list
>>> [hidden email]
>>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>
>> _______________________________________________
>> Moose-dev mailing list
>> [hidden email]
>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>
> --
> www.tudorgirba.com
>
> "If you can't say why something is relevant,
> it probably isn't."
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-project] font installer & free type fonts

Igor Stasenko
In reply to this post by stephane ducasse
Hi , Doru

i have only one question: why you put font binary data into compiled method?
That means that in object memory it will be contained 3 times:
 - 1 as source code
 - 2 as big literal array
 - 3 in freetype memory buffer

imo, #fontContents should be

fontContents
  ^ self url getContents ".. or whatever.. url is key here"


... or you can download the binaray data and put it into class var
(lazy-initialized etc)..
but do not hold binary data as source code.. this is really awful idea as to me.
unless you worry that longevity of your file copy @ smalltalk-hub will
be higher than
longevity on site where you downloaded it from.

--
Best regards,
Igor Stasenko.
_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-project] font installer & free type fonts

Igor Stasenko
On 15 May 2013 00:57, Igor Stasenko <[hidden email]> wrote:

> Hi , Doru
>
> i have only one question: why you put font binary data into compiled method?
> That means that in object memory it will be contained 3 times:
>  - 1 as source code
>  - 2 as big literal array
>  - 3 in freetype memory buffer
>
> imo, #fontContents should be
>
> fontContents
>   ^ self url getContents ".. or whatever.. url is key here"
>
>
> ... or you can download the binaray data and put it into class var
> (lazy-initialized etc)..
> but do not hold binary data as source code.. this is really awful idea as to me.
> unless you worry that longevity of your file copy @ smalltalk-hub will
> be higher than
> longevity on site where you downloaded it from.
>
or even better,
at class #initialize you forcefully downloading font from its original
web site and put it into
some class var.
Since package is also downloaded from internet, there's no worry that
font will be unavailable
during installation (unless the site where it located changes file location).
Like that, the package will contain just minimum necessary bits to
install the font.
And also, having url available, makes it easier for users to add own
fonts by simply overriding it,
without need of figuring out how to turn a binary file into method's
source code.

> --
> Best regards,
> Igor Stasenko.



--
Best regards,
Igor Stasenko.
_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-project] font installer & free type fonts

stephane ducasse

On May 15, 2013, at 1:11 AM, Igor Stasenko <[hidden email]> wrote:

> On 15 May 2013 00:57, Igor Stasenko <[hidden email]> wrote:
>> Hi , Doru
>>
>> i have only one question: why you put font binary data into compiled method?
>> That means that in object memory it will be contained 3 times:
>> - 1 as source code
>> - 2 as big literal array
>> - 3 in freetype memory buffer
>>
>> imo, #fontContents should be
>>
>> fontContents
>>  ^ self url getContents ".. or whatever.. url is key here"
>>
>>
>> ... or you can download the binaray data and put it into class var
>> (lazy-initialized etc)..
>> but do not hold binary data as source code.. this is really awful idea as to me.
>> unless you worry that longevity of your file copy @ smalltalk-hub will
>> be higher than
>> longevity on site where you downloaded it from.
>>
> or even better,
> at class #initialize you forcefully downloading font from its original
> web site and put it into
> some class var.

Do you care? Because I like the idea to have self contained package.
We can do the inverse: remove the method once the fonts are installed?

I do not want to rely on a web connection to get the system working.


> Since package is also downloaded from internet, there's no worry that
> font will be unavailable
> during installation (unless the site where it located changes file location).
> Like that, the package will contain just minimum necessary bits to
> install the font.
> And also, having url available, makes it easier for users to add own
> fonts by simply overriding it,
> without need of figuring out how to turn a binary file into method's
> source code.

I would provide a helper method that compile the contents into a method.

>
>> --
>> Best regards,
>> Igor Stasenko.
>
>
>
> --
> Best regards,
> Igor Stasenko.
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-project] font installer & free type fonts

Tudor Girba-2
Hi,

The reason I took this path was because this is how we are dealing with pictures as well. Furthermore, the fonts are downloaded from sourceforge and that is neither the fastest nor the most reliable site. As Stef said, if we are worried about the size, we can easily unload the package after installing. So, for me, the current solution is simple and as reliable as any other Pharo code. In other words, if SmalltalkHub fails, many other things will fail before the fonts become an issue.

Nevertheless, it could be interesting to create an index class that can build fonts on the fly based on a url. For this, we would need a repository somewhere reliable :).

About the easiness of compiling the binary file, there already exists a utility documented on my blog post:

Gofer new
   smalltalkhubUser: 'girba' project: 'FreeFonts';
   package: 'FontInstaller';
   load.

fontDirectory := FileSystem workingDirectory / 'Fonts' / 
                 'SourceCodePro_FontsOnly-1.017'.
FontInstaller new
   installFromDirectory: fontDirectory / 'TTF'
   license: ((fontDirectory / 'LICENSE.txt') readStreamDo: #contents).


Cheers,
Doru



On Wed, May 15, 2013 at 9:42 AM, stephane ducasse <[hidden email]> wrote:

On May 15, 2013, at 1:11 AM, Igor Stasenko <[hidden email]> wrote:

> On 15 May 2013 00:57, Igor Stasenko <[hidden email]> wrote:
>> Hi , Doru
>>
>> i have only one question: why you put font binary data into compiled method?
>> That means that in object memory it will be contained 3 times:
>> - 1 as source code
>> - 2 as big literal array
>> - 3 in freetype memory buffer
>>
>> imo, #fontContents should be
>>
>> fontContents
>>  ^ self url getContents ".. or whatever.. url is key here"
>>
>>
>> ... or you can download the binaray data and put it into class var
>> (lazy-initialized etc)..
>> but do not hold binary data as source code.. this is really awful idea as to me.
>> unless you worry that longevity of your file copy @ smalltalk-hub will
>> be higher than
>> longevity on site where you downloaded it from.
>>
> or even better,
> at class #initialize you forcefully downloading font from its original
> web site and put it into
> some class var.

Do you care? Because I like the idea to have self contained package.
We can do the inverse: remove the method once the fonts are installed?

I do not want to rely on a web connection to get the system working.


> Since package is also downloaded from internet, there's no worry that
> font will be unavailable
> during installation (unless the site where it located changes file location).
> Like that, the package will contain just minimum necessary bits to
> install the font.
> And also, having url available, makes it easier for users to add own
> fonts by simply overriding it,
> without need of figuring out how to turn a binary file into method's
> source code.

I would provide a helper method that compile the contents into a method.

>
>> --
>> Best regards,
>> Igor Stasenko.
>
>
>
> --
> Best regards,
> Igor Stasenko.
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev



--

"Every thing has its own flow"

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev