You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by Miguel Ferreira <mi...@hotmail.com> on 2013/06/27 16:30:18 UTC

Text flow underline

Hi guys,
i have a question :)
Can we set the padding between letter and the underline?
maybe 2 questions!
Can we set the thickness of the underline?

Thanks! 		 	   		  

Re: Text flow underline

Posted by Alex Harui <ah...@adobe.com>.
Yeah, there doesn't appear to be a connection between the TLF
configuration and FontMetrics.  I haven't proven it in the debugger, but
it appears that underlines are handled in TLF in FlowLeafElement.as.
There is a method in there called getComputedFontMetrics.  You could try
monkey patching that.

If you don't like monkey-patching and are using embedded fonts, there
might be a way to intercept in the swfContext API.

-Alex 

On 6/28/13 8:29 AM, "Miguel Ferreira" <mi...@hotmail.com>
wrote:

>Hi Alex,
>Is truly rich, is a web to print solution Enterprise application that i
>join on the last 5 months.
>Why i wish a solution like this:To make what the user see on the web  and
>get it on the PDF.The PDF creator uses SVG embebed fonts and when the
>user set underline we have different results.
>I could draw the lines with the example of justin from the post:
>--------------------------------------------------------------------------
>------------From inside createTextLinesFromTextBlock method in
>FTETextField.                    // FTE doesn't render underlines,
>            // but it can tell us where to draw them.
>// You can't draw in a TextLine but it can have children,
>   // so we create a child Shape to draw them in.
>               var fontMetrics:FontMetrics;                    if
>(fontContext)                        fontMetrics =
>fontContext.callInContext(elementFormat.getFontMetrics, elementFormat,
>[]);                    else                        fontMetrics =
>elementFormat.getFontMetrics();
>var shape:Shape = new Shape();                    var g:Graphics =
>shape.graphics;   
>g.lineStyle(fontMetrics.underlineThickness,
>elementFormat.color, elementFormat.alpha);                    g.moveTo(0,
>fontMetrics.underlineOffset);
>g.lineTo(textLine.textWidth, fontMetrics.underlineOffset);
>--------------------------------------------------------------------------
>------------
>but i don't know on the RTE where i can override the TextBlock that
>creates the textlines/underline.
>In on component RTE all the text is underline i dont have parcial text
>underline.
>
>I have my extended RTE with just textValidation (if font have glyph) and
>font face validation.
>
>What looks easy to underline gap and thickness is not so easy i tough
>that i could add this to TLF configuration but not.What i read is that
>FontMetrics have the metrics of the embebed fonts as i said i tried to
>fake this class but also with no success..(maybe the wrong
>solution/perspective).
>
>
>
>
>> From: aharui@adobe.com
>> To: users@flex.apache.org
>> Date: Fri, 28 Jun 2013 08:14:11 -0700
>> Subject: Re: Text flow underline
>> 
>> Hi Miguel,
>> 
>> I think RET uses TLF to draw the underlines which relies on FontMetrics.
>> Is this text truly "rich" (different font families, sizes and styles) or
>> single font?
>> 
>> -Alex
>> 
>> On 6/28/13 7:57 AM, "Miguel Ferreira" <mi...@hotmail.com>
>> wrote:
>> 
>> >Hi Justin and Alex,
>> >I am using RichEditableText. (When i enter on this project that option
>> >was already taken).I tried to convince them to use a smaller component
>>to
>> >present the text and use a heavy one for edition, but without success.
>> >@Justin: i am checking now that link.
>> >If i have some good solution i will try to post it here.
>> >
>> >> From: aharui@adobe.com
>> >> To: users@flex.apache.org
>> >> Date: Fri, 28 Jun 2013 07:38:25 -0700
>> >> Subject: Re: Text flow underline
>> >> 
>> >> Are you using a Flex component like RichText or Label?  Or are you
>>just
>> >> using TLF or FTE directly?
>> >> 
>> >> On 6/28/13 4:10 AM, "Miguel Ferreira"
>><mi...@hotmail.com>
>> >> wrote:
>> >> 
>> >> >Hi Alex,
>> >> >Thank you for the help... you always have time to say something..
>>that
>> >>is
>> >> >admirable!
>> >> >The FontMetrics class have all the information about of the font on
>> >>this
>> >> >case:- underlineOffset- underlineThickness
>> >> >I tried to fake it (maybe wrongly)!
>> >> >I create a class with the same name and same package on the src,
>>hoping
>> >> >that the compiler will use my class instead the one on the sdk, with
>> >>this
>> >> >constructor, code example:
>> >> >public function FontMetrics(emBox:Rectangle,
>> >>strikethroughOffset:Number,
>> >> >strikethroughThickness:Number, underlineOffset:Number,
>> >> >underlineThickness:Number, subscriptOffset:Number,
>> >>subscriptScale:Number,
>> >> >superscriptOffset:Number, superscriptScale:Number) 		{			this.emBox
>>=
>> >> >emBox;						this.strikethroughOffset =
>> >> >strikethroughOffset;			this.strikethroughThickness =
>> >> >strikethroughThickness;						this.subscriptOffset =
>> >> >subscriptOffset;			this.subscriptScale =
>> >> >subscriptScale;						this.superscriptOffset =
>> >> >superscriptOffset;			this.superscriptScale =
>> >> >superscriptScale;						this.underlineOffset =
>> >> >0;			this.underlineThickness = 10;		}
>> >> >
>> >> >but when i trace the the underline properties i never the 0 and 10.
>> >> >Even if the compiler get the project class instead of the SDK i also
>> >> >don't know if the text line engine will use this values...
>> >> >If someone have some idea... they are welcome!
>> >> >Thank you,Miguel
>> >> >
>> >> >> From: aharui@adobe.com
>> >> >> To: users@flex.apache.org
>> >> >> Date: Thu, 27 Jun 2013 13:04:43 -0700
>> >> >> Subject: Re: Text flow underline
>> >> >> 
>> >> >> I don't know for sure, but you can try manipulating the
>>fontMetrics.
>> >> >>See
>> >> >> flash.text.engine.FontMetrics
>> >> >> 
>> >> >> On 6/27/13 7:30 AM, "Miguel Ferreira"
>> >><mi...@hotmail.com>
>> >> >> wrote:
>> >> >> 
>> >> >> >Hi guys,
>> >> >> >i have a question :)
>> >> >> >Can we set the padding between letter and the underline?
>> >> >> >maybe 2 questions!
>> >> >> >Can we set the thickness of the underline?
>> >> >> >
>> >> >> >Thanks! 		 	   		
>> >> >> 
>> >> > 		 	   		  
>> >> 
>> > 		 	   		  
>> 
> 		 	   		  


RE: Text flow underline

Posted by Miguel Ferreira <mi...@hotmail.com>.
Hi Alex,
Is truly rich, is a web to print solution Enterprise application that i join on the last 5 months.
Why i wish a solution like this:To make what the user see on the web  and get it on the PDF.The PDF creator uses SVG embebed fonts and when the user set underline we have different results.
I could draw the lines with the example of justin from the post:
--------------------------------------------------------------------------------------From inside createTextLinesFromTextBlock method in FTETextField.                    // FTE doesn't render underlines,                    // but it can tell us where to draw them.                    // You can't draw in a TextLine but it can have children,                    // so we create a child Shape to draw them in.                                        var fontMetrics:FontMetrics;                    if (fontContext)                        fontMetrics = fontContext.callInContext(elementFormat.getFontMetrics, elementFormat, []);                    else                        fontMetrics = elementFormat.getFontMetrics();                                        var shape:Shape = new Shape();                    var g:Graphics = shape.graphics;                    g.lineStyle(fontMetrics.underlineThickness,                         elementFormat.color, elementFormat.alpha);                    g.moveTo(0, fontMetrics.underlineOffset);                    g.lineTo(textLine.textWidth, fontMetrics.underlineOffset);
--------------------------------------------------------------------------------------
but i don't know on the RTE where i can override the TextBlock that creates the textlines/underline.
In on component RTE all the text is underline i dont have parcial text underline.

I have my extended RTE with just textValidation (if font have glyph) and font face validation.

What looks easy to underline gap and thickness is not so easy i tough that i could add this to TLF configuration but not.What i read is that FontMetrics have the metrics of the embebed fonts as i said i tried to fake this class but also with no success..(maybe the wrong solution/perspective).




> From: aharui@adobe.com
> To: users@flex.apache.org
> Date: Fri, 28 Jun 2013 08:14:11 -0700
> Subject: Re: Text flow underline
> 
> Hi Miguel,
> 
> I think RET uses TLF to draw the underlines which relies on FontMetrics.
> Is this text truly "rich" (different font families, sizes and styles) or
> single font?
> 
> -Alex
> 
> On 6/28/13 7:57 AM, "Miguel Ferreira" <mi...@hotmail.com>
> wrote:
> 
> >Hi Justin and Alex,
> >I am using RichEditableText. (When i enter on this project that option
> >was already taken).I tried to convince them to use a smaller component to
> >present the text and use a heavy one for edition, but without success.
> >@Justin: i am checking now that link.
> >If i have some good solution i will try to post it here.
> >
> >> From: aharui@adobe.com
> >> To: users@flex.apache.org
> >> Date: Fri, 28 Jun 2013 07:38:25 -0700
> >> Subject: Re: Text flow underline
> >> 
> >> Are you using a Flex component like RichText or Label?  Or are you just
> >> using TLF or FTE directly?
> >> 
> >> On 6/28/13 4:10 AM, "Miguel Ferreira" <mi...@hotmail.com>
> >> wrote:
> >> 
> >> >Hi Alex,
> >> >Thank you for the help... you always have time to say something.. that
> >>is
> >> >admirable!
> >> >The FontMetrics class have all the information about of the font on
> >>this
> >> >case:- underlineOffset- underlineThickness
> >> >I tried to fake it (maybe wrongly)!
> >> >I create a class with the same name and same package on the src, hoping
> >> >that the compiler will use my class instead the one on the sdk, with
> >>this
> >> >constructor, code example:
> >> >public function FontMetrics(emBox:Rectangle,
> >>strikethroughOffset:Number,
> >> >strikethroughThickness:Number, underlineOffset:Number,
> >> >underlineThickness:Number, subscriptOffset:Number,
> >>subscriptScale:Number,
> >> >superscriptOffset:Number, superscriptScale:Number) 		{			this.emBox =
> >> >emBox;						this.strikethroughOffset =
> >> >strikethroughOffset;			this.strikethroughThickness =
> >> >strikethroughThickness;						this.subscriptOffset =
> >> >subscriptOffset;			this.subscriptScale =
> >> >subscriptScale;						this.superscriptOffset =
> >> >superscriptOffset;			this.superscriptScale =
> >> >superscriptScale;						this.underlineOffset =
> >> >0;			this.underlineThickness = 10;		}
> >> >
> >> >but when i trace the the underline properties i never the 0 and 10.
> >> >Even if the compiler get the project class instead of the SDK i also
> >> >don't know if the text line engine will use this values...
> >> >If someone have some idea... they are welcome!
> >> >Thank you,Miguel
> >> >
> >> >> From: aharui@adobe.com
> >> >> To: users@flex.apache.org
> >> >> Date: Thu, 27 Jun 2013 13:04:43 -0700
> >> >> Subject: Re: Text flow underline
> >> >> 
> >> >> I don't know for sure, but you can try manipulating the fontMetrics.
> >> >>See
> >> >> flash.text.engine.FontMetrics
> >> >> 
> >> >> On 6/27/13 7:30 AM, "Miguel Ferreira"
> >><mi...@hotmail.com>
> >> >> wrote:
> >> >> 
> >> >> >Hi guys,
> >> >> >i have a question :)
> >> >> >Can we set the padding between letter and the underline?
> >> >> >maybe 2 questions!
> >> >> >Can we set the thickness of the underline?
> >> >> >
> >> >> >Thanks! 		 	   		
> >> >> 
> >> > 		 	   		  
> >> 
> > 		 	   		  
> 
 		 	   		  

Re: Text flow underline

Posted by Alex Harui <ah...@adobe.com>.
Hi Miguel,

I think RET uses TLF to draw the underlines which relies on FontMetrics.
Is this text truly "rich" (different font families, sizes and styles) or
single font?

-Alex

On 6/28/13 7:57 AM, "Miguel Ferreira" <mi...@hotmail.com>
wrote:

>Hi Justin and Alex,
>I am using RichEditableText. (When i enter on this project that option
>was already taken).I tried to convince them to use a smaller component to
>present the text and use a heavy one for edition, but without success.
>@Justin: i am checking now that link.
>If i have some good solution i will try to post it here.
>
>> From: aharui@adobe.com
>> To: users@flex.apache.org
>> Date: Fri, 28 Jun 2013 07:38:25 -0700
>> Subject: Re: Text flow underline
>> 
>> Are you using a Flex component like RichText or Label?  Or are you just
>> using TLF or FTE directly?
>> 
>> On 6/28/13 4:10 AM, "Miguel Ferreira" <mi...@hotmail.com>
>> wrote:
>> 
>> >Hi Alex,
>> >Thank you for the help... you always have time to say something.. that
>>is
>> >admirable!
>> >The FontMetrics class have all the information about of the font on
>>this
>> >case:- underlineOffset- underlineThickness
>> >I tried to fake it (maybe wrongly)!
>> >I create a class with the same name and same package on the src, hoping
>> >that the compiler will use my class instead the one on the sdk, with
>>this
>> >constructor, code example:
>> >public function FontMetrics(emBox:Rectangle,
>>strikethroughOffset:Number,
>> >strikethroughThickness:Number, underlineOffset:Number,
>> >underlineThickness:Number, subscriptOffset:Number,
>>subscriptScale:Number,
>> >superscriptOffset:Number, superscriptScale:Number) 		{			this.emBox =
>> >emBox;						this.strikethroughOffset =
>> >strikethroughOffset;			this.strikethroughThickness =
>> >strikethroughThickness;						this.subscriptOffset =
>> >subscriptOffset;			this.subscriptScale =
>> >subscriptScale;						this.superscriptOffset =
>> >superscriptOffset;			this.superscriptScale =
>> >superscriptScale;						this.underlineOffset =
>> >0;			this.underlineThickness = 10;		}
>> >
>> >but when i trace the the underline properties i never the 0 and 10.
>> >Even if the compiler get the project class instead of the SDK i also
>> >don't know if the text line engine will use this values...
>> >If someone have some idea... they are welcome!
>> >Thank you,Miguel
>> >
>> >> From: aharui@adobe.com
>> >> To: users@flex.apache.org
>> >> Date: Thu, 27 Jun 2013 13:04:43 -0700
>> >> Subject: Re: Text flow underline
>> >> 
>> >> I don't know for sure, but you can try manipulating the fontMetrics.
>> >>See
>> >> flash.text.engine.FontMetrics
>> >> 
>> >> On 6/27/13 7:30 AM, "Miguel Ferreira"
>><mi...@hotmail.com>
>> >> wrote:
>> >> 
>> >> >Hi guys,
>> >> >i have a question :)
>> >> >Can we set the padding between letter and the underline?
>> >> >maybe 2 questions!
>> >> >Can we set the thickness of the underline?
>> >> >
>> >> >Thanks! 		 	   		
>> >> 
>> > 		 	   		  
>> 
> 		 	   		  


RE: Text flow underline

Posted by Miguel Ferreira <mi...@hotmail.com>.
Hi Justin and Alex,
I am using RichEditableText. (When i enter on this project that option was already taken).I tried to convince them to use a smaller component to present the text and use a heavy one for edition, but without success.
@Justin: i am checking now that link.
If i have some good solution i will try to post it here.

> From: aharui@adobe.com
> To: users@flex.apache.org
> Date: Fri, 28 Jun 2013 07:38:25 -0700
> Subject: Re: Text flow underline
> 
> Are you using a Flex component like RichText or Label?  Or are you just
> using TLF or FTE directly?
> 
> On 6/28/13 4:10 AM, "Miguel Ferreira" <mi...@hotmail.com>
> wrote:
> 
> >Hi Alex,
> >Thank you for the help... you always have time to say something.. that is
> >admirable!
> >The FontMetrics class have all the information about of the font on this
> >case:- underlineOffset- underlineThickness
> >I tried to fake it (maybe wrongly)!
> >I create a class with the same name and same package on the src, hoping
> >that the compiler will use my class instead the one on the sdk, with this
> >constructor, code example:
> >public function FontMetrics(emBox:Rectangle, strikethroughOffset:Number,
> >strikethroughThickness:Number, underlineOffset:Number,
> >underlineThickness:Number, subscriptOffset:Number, subscriptScale:Number,
> >superscriptOffset:Number, superscriptScale:Number) 		{			this.emBox =
> >emBox;						this.strikethroughOffset =
> >strikethroughOffset;			this.strikethroughThickness =
> >strikethroughThickness;						this.subscriptOffset =
> >subscriptOffset;			this.subscriptScale =
> >subscriptScale;						this.superscriptOffset =
> >superscriptOffset;			this.superscriptScale =
> >superscriptScale;						this.underlineOffset =
> >0;			this.underlineThickness = 10;		}
> >
> >but when i trace the the underline properties i never the 0 and 10.
> >Even if the compiler get the project class instead of the SDK i also
> >don't know if the text line engine will use this values...
> >If someone have some idea... they are welcome!
> >Thank you,Miguel
> >
> >> From: aharui@adobe.com
> >> To: users@flex.apache.org
> >> Date: Thu, 27 Jun 2013 13:04:43 -0700
> >> Subject: Re: Text flow underline
> >> 
> >> I don't know for sure, but you can try manipulating the fontMetrics.
> >>See
> >> flash.text.engine.FontMetrics
> >> 
> >> On 6/27/13 7:30 AM, "Miguel Ferreira" <mi...@hotmail.com>
> >> wrote:
> >> 
> >> >Hi guys,
> >> >i have a question :)
> >> >Can we set the padding between letter and the underline?
> >> >maybe 2 questions!
> >> >Can we set the thickness of the underline?
> >> >
> >> >Thanks! 		 	   		
> >> 
> > 		 	   		  
> 
 		 	   		  

Re: Text flow underline

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

Some text fields don't really support underlines but just pretend by drawing a line. Might need some minor code adjustments???

https://issues.apache.org/jira/browse/FLEX-33561

Justin

Re: Text flow underline

Posted by Alex Harui <ah...@adobe.com>.
Are you using a Flex component like RichText or Label?  Or are you just
using TLF or FTE directly?

On 6/28/13 4:10 AM, "Miguel Ferreira" <mi...@hotmail.com>
wrote:

>Hi Alex,
>Thank you for the help... you always have time to say something.. that is
>admirable!
>The FontMetrics class have all the information about of the font on this
>case:- underlineOffset- underlineThickness
>I tried to fake it (maybe wrongly)!
>I create a class with the same name and same package on the src, hoping
>that the compiler will use my class instead the one on the sdk, with this
>constructor, code example:
>public function FontMetrics(emBox:Rectangle, strikethroughOffset:Number,
>strikethroughThickness:Number, underlineOffset:Number,
>underlineThickness:Number, subscriptOffset:Number, subscriptScale:Number,
>superscriptOffset:Number, superscriptScale:Number) 		{			this.emBox =
>emBox;						this.strikethroughOffset =
>strikethroughOffset;			this.strikethroughThickness =
>strikethroughThickness;						this.subscriptOffset =
>subscriptOffset;			this.subscriptScale =
>subscriptScale;						this.superscriptOffset =
>superscriptOffset;			this.superscriptScale =
>superscriptScale;						this.underlineOffset =
>0;			this.underlineThickness = 10;		}
>
>but when i trace the the underline properties i never the 0 and 10.
>Even if the compiler get the project class instead of the SDK i also
>don't know if the text line engine will use this values...
>If someone have some idea... they are welcome!
>Thank you,Miguel
>
>> From: aharui@adobe.com
>> To: users@flex.apache.org
>> Date: Thu, 27 Jun 2013 13:04:43 -0700
>> Subject: Re: Text flow underline
>> 
>> I don't know for sure, but you can try manipulating the fontMetrics.
>>See
>> flash.text.engine.FontMetrics
>> 
>> On 6/27/13 7:30 AM, "Miguel Ferreira" <mi...@hotmail.com>
>> wrote:
>> 
>> >Hi guys,
>> >i have a question :)
>> >Can we set the padding between letter and the underline?
>> >maybe 2 questions!
>> >Can we set the thickness of the underline?
>> >
>> >Thanks! 		 	   		
>> 
> 		 	   		  


RE: Text flow underline

Posted by Miguel Ferreira <mi...@hotmail.com>.
Hi Alex,
Thank you for the help... you always have time to say something.. that is admirable!
The FontMetrics class have all the information about of the font on this case:- underlineOffset- underlineThickness
I tried to fake it (maybe wrongly)!
I create a class with the same name and same package on the src, hoping that the compiler will use my class instead the one on the sdk, with this constructor, code example:
public function FontMetrics(emBox:Rectangle, strikethroughOffset:Number, strikethroughThickness:Number, underlineOffset:Number, underlineThickness:Number, subscriptOffset:Number, subscriptScale:Number, superscriptOffset:Number, superscriptScale:Number) 		{			this.emBox = emBox;						this.strikethroughOffset = strikethroughOffset;			this.strikethroughThickness = strikethroughThickness;						this.subscriptOffset = subscriptOffset;			this.subscriptScale = subscriptScale;						this.superscriptOffset = superscriptOffset;			this.superscriptScale = superscriptScale;						this.underlineOffset = 0;			this.underlineThickness = 10;		}

but when i trace the the underline properties i never the 0 and 10.
Even if the compiler get the project class instead of the SDK i also don't know if the text line engine will use this values...
If someone have some idea... they are welcome!
Thank you,Miguel

> From: aharui@adobe.com
> To: users@flex.apache.org
> Date: Thu, 27 Jun 2013 13:04:43 -0700
> Subject: Re: Text flow underline
> 
> I don't know for sure, but you can try manipulating the fontMetrics.  See
> flash.text.engine.FontMetrics
> 
> On 6/27/13 7:30 AM, "Miguel Ferreira" <mi...@hotmail.com>
> wrote:
> 
> >Hi guys,
> >i have a question :)
> >Can we set the padding between letter and the underline?
> >maybe 2 questions!
> >Can we set the thickness of the underline?
> >
> >Thanks! 		 	   		  
> 
 		 	   		  

Re: Text flow underline

Posted by Alex Harui <ah...@adobe.com>.
I don't know for sure, but you can try manipulating the fontMetrics.  See
flash.text.engine.FontMetrics

On 6/27/13 7:30 AM, "Miguel Ferreira" <mi...@hotmail.com>
wrote:

>Hi guys,
>i have a question :)
>Can we set the padding between letter and the underline?
>maybe 2 questions!
>Can we set the thickness of the underline?
>
>Thanks!