FontDescription and TextAttributes and CharacterAttributes, oh my!

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

FontDescription and TextAttributes and CharacterAttributes, oh my!

Charles Adams
I'm in trouble. I did something in VW 2.5 to install as the default font an Arial font of size 12. I built up the FontDescription and TextAttributes myself, but something in these definitions was not right. It did not bold the text when required. In fact, it had no bolding capability at all.  I have to reproduce this "feature" in VW 7.1 and I do not know how. I don't know what I did to create this aberrant font and I don't know how to recreate it now.
 
This is what I did in VW 2.5:
 
 | charAtt vsta |
 charAtt := VariableCharacterAttributes newWithDefaultAttributes.
 charAtt setDefaultQuery: (FontDescription new family: (Array with: 'Arial' with: '*');
        manufacturer: #('adobe' '*');
        fixedWidth: false;
        serif: false;
        italic: false;
        boldness: 0.5;
        pixelSize: 12).
 vsta := VariableSizeTextAttributes new.
 vsta setCharacterAttributes: charAtt.
 vsta install.
 vsta scalingFactor: 1.
 vsta gridForFont: nil withTopLead: 0 bottomLead: 0.
 vsta updateLineGridding.
 VariableSizeTextAttributes styleNamed: #default put: vsta.
In VW 2.5, this produces a font without any bolding ability. If you look at the masks in the FontDescription, it certainly seems to support boldness. Maybe that is not meaningful.
 
I can run this same code in VW 7.1 and it seems as though the font is fully capable of bolding when necessary.
 
I guess I do not understand the relationship of FontDescription, (VariableSized)TextAttributes, (Variable)CharacterAttributes and whatever else is in play here.
 
Charlie Adams   
Adventa Control Technologies, Inc.
3001 E. Plano Parkway, #100 
Plano, TX 75074-7422 
Office: 972.543.1688
FAX: 972.633.9317
http://www.adventact.com
[hidden email]
 
Reply | Threaded
Open this post in threaded view
|

RE: FontDescription and TextAttributes and CharacterAttributes, oh my!

Steven Kelly
Message
Charlie,
 
Maybe I'm barking up the wrong tree, but I think I recall that at least in older versions of VW there was some code that prevented Labels being bolded in the UI on Windows only. I forget how this was done, but if you're talking specifically about Labels, rather than text used in other places (list views, text views etc.), that might be related.
 
To prevent bolding with the CharacterAttributes you give, you could try building a subclass of FontDescription (or whichever class actually handles bolding) that ignores bolding, and use that just for this font. Another way that comes to my hacker's mind is to copy arial.ttf over arialbd.ttf (obviously only sensible on single-purpose workstations, which may or may not fit with Adventa's deployment environments, and indeed may or may not work :->).
 
HTH,
Steve
-----Original Message-----
From: Charlie Adams [mailto:[hidden email]]
Sent: 25 January 2006 19:06
To: [hidden email]
Subject: FontDescription and TextAttributes and CharacterAttributes, oh my!

I'm in trouble. I did something in VW 2.5 to install as the default font an Arial font of size 12. I built up the FontDescription and TextAttributes myself, but something in these definitions was not right. It did not bold the text when required. In fact, it had no bolding capability at all.  I have to reproduce this "feature" in VW 7.1 and I do not know how. I don't know what I did to create this aberrant font and I don't know how to recreate it now.
 
This is what I did in VW 2.5:
 
 | charAtt vsta |
 charAtt := VariableCharacterAttributes newWithDefaultAttributes.
 charAtt setDefaultQuery: (FontDescription new family: (Array with: 'Arial' with: '*');
        manufacturer: #('adobe' '*');
        fixedWidth: false;
        serif: false;
        italic: false;
        boldness: 0.5;
        pixelSize: 12).
 vsta := VariableSizeTextAttributes new.
 vsta setCharacterAttributes: charAtt.
 vsta install.
 vsta scalingFactor: 1.
 vsta gridForFont: nil withTopLead: 0 bottomLead: 0.
 vsta updateLineGridding.
 VariableSizeTextAttributes styleNamed: #default put: vsta.
In VW 2.5, this produces a font without any bolding ability. If you look at the masks in the FontDescription, it certainly seems to support boldness. Maybe that is not meaningful.
 
I can run this same code in VW 7.1 and it seems as though the font is fully capable of bolding when necessary.
 
I guess I do not understand the relationship of FontDescription, (VariableSized)TextAttributes, (Variable)CharacterAttributes and whatever else is in play here.
 
Charlie Adams   
Adventa Control Technologies, Inc.
3001 E. Plano Parkway, #100 
Plano, TX 75074-7422 
Office: 972.543.1688
FAX: 972.633.9317
http://www.adventact.com
[hidden email]
 
Reply | Threaded
Open this post in threaded view
|

Re: FontDescription and TextAttributes and CharacterAttributes, oh my!

kobetic
In reply to this post by Charles Adams
Try adding

        charAtt at: #bold put: [:query | ].

HTH,

Martin


Charlie Adams wrote:

>  | charAtt vsta |
>  charAtt := VariableCharacterAttributes newWithDefaultAttributes.
>  charAtt setDefaultQuery: (FontDescription new family: (Array with: 'Arial' with: '*');
>         manufacturer: #('adobe' '*');
>         fixedWidth: false;
>         serif: false;
>         italic: false;
>         boldness: 0.5;
>         pixelSize: 12).
>  vsta := VariableSizeTextAttributes new.
>  vsta setCharacterAttributes: charAtt.
>  vsta install.
>  vsta scalingFactor: 1.
>  vsta gridForFont: nil withTopLead: 0 bottomLead: 0.
>  vsta updateLineGridding.
>  VariableSizeTextAttributes styleNamed: #default put: vsta.

Reply | Threaded
Open this post in threaded view
|

Re: FontDescription and TextAttributes and CharacterAttributes, oh my!

Charles Adams
Martin: Thank you. That looks terrible -- and it produced the exact results
I needed.

Steven Kelly: Yes, I need a global solution, but I like the way you think.

----- Original Message -----
From: "Martin Kobetic" <[hidden email]>
To: "Charlie Adams" <[hidden email]>
Cc: <[hidden email]>
Sent: Wednesday, January 25, 2006 1:29 PM
Subject: Re: FontDescription and TextAttributes and CharacterAttributes, oh
my!


> Try adding
>
> charAtt at: #bold put: [:query | ].
>
> HTH,
>
> Martin
>
>
> Charlie Adams wrote:
>>  | charAtt vsta |
>>  charAtt := VariableCharacterAttributes newWithDefaultAttributes.
>>  charAtt setDefaultQuery: (FontDescription new family: (Array with:
>> 'Arial' with: '*');
>>         manufacturer: #('adobe' '*');
>>         fixedWidth: false;
>>         serif: false;
>>         italic: false;
>>         boldness: 0.5;
>>         pixelSize: 12).
>>  vsta := VariableSizeTextAttributes new.
>>  vsta setCharacterAttributes: charAtt.
>>  vsta install.
>>  vsta scalingFactor: 1.
>>  vsta gridForFont: nil withTopLead: 0 bottomLead: 0.
>>  vsta updateLineGridding.
>>  VariableSizeTextAttributes styleNamed: #default put: vsta.
>
>

Reply | Threaded
Open this post in threaded view
|

Re: FontDescription and TextAttributes and CharacterAttributes, oh my!

kobetic
Charlie Adams wrote:
> Martin: Thank you. That looks terrible -- and it produced the exact
> results I needed.

:-). It's not all that complicated actually. Text emphasis symbols
(#bold, #italic, ...) are interpreted by these "attribute" blocks, which
define how to modify the default font description to achieve the desired
effect. If you look into CharacterAttributes
class>>newWithDefaultAttributes, you can find the default definition of
#bold as

        at: #bold put: [:query | query boldness: 0.7].

So my proposed fix simply turns it into a noop.

HTH,

Martin

Reply | Threaded
Open this post in threaded view
|

Re: FontDescription and TextAttributes and CharacterAttributes, oh my!

Charles Adams
Yes, I had tried

at: #bold put: [:query | query]

but this didn't work. Or maybe I didn't do something right. At any rate, I
didn't think to merely noop the block. Doh.

My customer appreciates your quick response and solution. I had left this
problem languishing too long.

----- Original Message -----
From: "Martin Kobetic" <[hidden email]>
To: "Charlie Adams" <[hidden email]>
Cc: "Martin Kobetic" <[hidden email]>; <[hidden email]>
Sent: Wednesday, January 25, 2006 2:01 PM
Subject: Re: FontDescription and TextAttributes and CharacterAttributes, oh
my!


> Charlie Adams wrote:
>> Martin: Thank you. That looks terrible -- and it produced the exact
>> results I needed.
>
> :-). It's not all that complicated actually. Text emphasis symbols (#bold,
> #italic, ...) are interpreted by these "attribute" blocks, which define
> how to modify the default font description to achieve the desired effect.
> If you look into CharacterAttributes class>>newWithDefaultAttributes, you
> can find the default definition of #bold as
>
> at: #bold put: [:query | query boldness: 0.7].
>
> So my proposed fix simply turns it into a noop.
>
> HTH,
>
> Martin
>
>