Serialization of font object

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

Serialization of font object

gerard alis

Regards

I see in Pharo a few ways for create a font, StrikeFont, LogicalFont...  I need generate dinamically code in Smalltalk for build UIs, and my problem now is when I have serialize the font of a widget. Which could be the best way for do that? In other objects like arrays, points, associations is possible get that calling #printString method. Exists some equivalence for that in fonts, or is needed implement that mechanism of zero?

Thanks for answers
Reply | Threaded
Open this post in threaded view
|

Re: Serialization of font object

Henrik Sperre Johansen
On Apr 23, 2010, at 4:01 48PM, nullPointer wrote:

>
>
> Regards
>
> I see in Pharo a few ways for create a font, StrikeFont, LogicalFont...  I
> need generate dinamically code in Smalltalk for build UIs, and my problem
> now is when I have serialize the font of a widget. Which could be the best
> way for do that? In other objects like arrays, points, associations is
> possible get that calling #printString method. Exists some equivalence for
> that in fonts, or is needed implement that mechanism of zero?
>
> Thanks for answers

I would store the the name/boldness/size etc., then use (LogicalFont familyName: pointSize: stretchValue:weightValue: slantValue: ) realFont
 to discover the closest font available when loading the morph into an image again.

Cheers,
Henry
_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Serialization of font object

Stéphane Ducasse
may be using the storeOn: aStream and readFrom: mechanism?


On Apr 23, 2010, at 4:28 PM, Henrik Johansen wrote:

> On Apr 23, 2010, at 4:01 48PM, nullPointer wrote:
>
>>
>>
>> Regards
>>
>> I see in Pharo a few ways for create a font, StrikeFont, LogicalFont...  I
>> need generate dinamically code in Smalltalk for build UIs, and my problem
>> now is when I have serialize the font of a widget. Which could be the best
>> way for do that? In other objects like arrays, points, associations is
>> possible get that calling #printString method. Exists some equivalence for
>> that in fonts, or is needed implement that mechanism of zero?
>>
>> Thanks for answers
>
> I would store the the name/boldness/size etc., then use (LogicalFont familyName: pointSize: stretchValue:weightValue: slantValue: ) realFont
> to discover the closest font available when loading the morph into an image again.
>
> Cheers,
> Henry
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Serialization of font object

Henrik Sperre Johansen

On Apr 23, 2010, at 7:37 33PM, Stéphane Ducasse wrote:

> may be using the storeOn: aStream and readFrom: mechanism?
>
I doubt it would work for FreeType fonts, which hold external handles.
For StrikeFonts, it may, but even if it did, you'd probably end up importing a new Font instance (complete with an XX KB bitmap), for each Morph...

Cheers,
Henry

>
> On Apr 23, 2010, at 4:28 PM, Henrik Johansen wrote:
>
>> On Apr 23, 2010, at 4:01 48PM, nullPointer wrote:
>>
>>>
>>>
>>> Regards
>>>
>>> I see in Pharo a few ways for create a font, StrikeFont, LogicalFont...  I
>>> need generate dinamically code in Smalltalk for build UIs, and my problem
>>> now is when I have serialize the font of a widget. Which could be the best
>>> way for do that? In other objects like arrays, points, associations is
>>> possible get that calling #printString method. Exists some equivalence for
>>> that in fonts, or is needed implement that mechanism of zero?
>>>
>>> Thanks for answers
>>
>> I would store the the name/boldness/size etc., then use (LogicalFont familyName: pointSize: stretchValue:weightValue: slantValue: ) realFont
>> to discover the closest font available when loading the morph into an image again.
>>
>> Cheers,
>> Henry
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Serialization of font object

Stéphane Ducasse
I was thinking more as a simple mechanism to serialize the info you gave than to serialize the objects since
after you may not have the fonts in your system but should guess a substitution.

Stef
On Apr 23, 2010, at 9:22 PM, Henrik Johansen wrote:

>
> On Apr 23, 2010, at 7:37 33PM, Stéphane Ducasse wrote:
>
>> may be using the storeOn: aStream and readFrom: mechanism?
>>
> I doubt it would work for FreeType fonts, which hold external handles.
> For StrikeFonts, it may, but even if it did, you'd probably end up importing a new Font instance (complete with an XX KB bitmap), for each Morph...
>
> Cheers,
> Henry
>
>>
>> On Apr 23, 2010, at 4:28 PM, Henrik Johansen wrote:
>>
>>> On Apr 23, 2010, at 4:01 48PM, nullPointer wrote:
>>>
>>>>
>>>>
>>>> Regards
>>>>
>>>> I see in Pharo a few ways for create a font, StrikeFont, LogicalFont...  I
>>>> need generate dinamically code in Smalltalk for build UIs, and my problem
>>>> now is when I have serialize the font of a widget. Which could be the best
>>>> way for do that? In other objects like arrays, points, associations is
>>>> possible get that calling #printString method. Exists some equivalence for
>>>> that in fonts, or is needed implement that mechanism of zero?
>>>>
>>>> Thanks for answers
>>>
>>> I would store the the name/boldness/size etc., then use (LogicalFont familyName: pointSize: stretchValue:weightValue: slantValue: ) realFont
>>> to discover the closest font available when loading the morph into an image again.
>>>
>>> Cheers,
>>> Henry
>>> _______________________________________________
>>> Pharo-project mailing list
>>> [hidden email]
>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Serialization of font object

Mariano Martinez Peck
In reply to this post by Henrik Sperre Johansen


On Fri, Apr 23, 2010 at 9:22 PM, Henrik Johansen <[hidden email]> wrote:

On Apr 23, 2010, at 7:37 33PM, Stéphane Ducasse wrote:

> may be using the storeOn: aStream and readFrom: mechanism?
>
I doubt it would work for FreeType fonts, which hold external handles.

mmmmm but do you want also to serialize external handles ?  what are you going to do with them when you load the objects again to memory ?

 
For StrikeFonts, it may, but even if it did, you'd probably end up importing a new Font instance (complete with an XX KB bitmap), for each Morph...

Cheers,
Henry

>
> On Apr 23, 2010, at 4:28 PM, Henrik Johansen wrote:
>
>> On Apr 23, 2010, at 4:01 48PM, nullPointer wrote:
>>
>>>
>>>
>>> Regards
>>>
>>> I see in Pharo a few ways for create a font, StrikeFont, LogicalFont...  I
>>> need generate dinamically code in Smalltalk for build UIs, and my problem
>>> now is when I have serialize the font of a widget. Which could be the best
>>> way for do that? In other objects like arrays, points, associations is
>>> possible get that calling #printString method. Exists some equivalence for
>>> that in fonts, or is needed implement that mechanism of zero?
>>>
>>> Thanks for answers
>>
>> I would store the the name/boldness/size etc., then use (LogicalFont familyName: pointSize: stretchValue:weightValue: slantValue: ) realFont
>> to discover the closest font available when loading the morph into an image again.
>>
>> Cheers,
>> Henry
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Serialization of font object

Henrik Sperre Johansen
On 25.04.2010 17:08, Mariano Martinez Peck wrote:


On Fri, Apr 23, 2010 at 9:22 PM, Henrik Johansen <[hidden email]> wrote:

On Apr 23, 2010, at 7:37 33PM, Stéphane Ducasse wrote:

> may be using the storeOn: aStream and readFrom: mechanism?
>
I doubt it would work for FreeType fonts, which hold external handles.

mmmmm but do you want also to serialize external handles ?  what are you going to do with them when you load the objects again to memory ?

That was my point exactly, read Object>storeOn: (which Fonts currently use), I thought Steph's suggestion was to use that method to serialize fonts.

However, I think I misunderstood, and Steph meant to write the logic for storing attributes you'd need to rebuild a Font instance in store/writeOn: and readFrom: methods. (storeOn: is usually reserved for writing an executable expression which will yield the instance, so it's probably a bad idea to use it paired with readFrom:)
Which is an option of course, but the usual convention in image readFrom: methods seem to be having them instance-side.
That wouldn't make sense if you want to return an already-existing, closest fitting to the saved attributes, Font instance.

Cheers,
Henry
 
For StrikeFonts, it may, but even if it did, you'd probably end up importing a new Font instance (complete with an XX KB bitmap), for each Morph...

Cheers,
Henry

>
> On Apr 23, 2010, at 4:28 PM, Henrik Johansen wrote:
>
>> On Apr 23, 2010, at 4:01 48PM, nullPointer wrote:
>>
>>>
>>>
>>> Regards
>>>
>>> I see in Pharo a few ways for create a font, StrikeFont, LogicalFont...  I
>>> need generate dinamically code in Smalltalk for build UIs, and my problem
>>> now is when I have serialize the font of a widget. Which could be the best
>>> way for do that? In other objects like arrays, points, associations is
>>> possible get that calling #printString method. Exists some equivalence for
>>> that in fonts, or is needed implement that mechanism of zero?
>>>
>>> Thanks for answers
>>
>> I would store the the name/boldness/size etc., then use (LogicalFont familyName: pointSize: stretchValue:weightValue: slantValue: ) realFont
>> to discover the closest font available when loading the morph into an image again.
>>
>> Cheers,
>> Henry
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

_______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project