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" <[email protected]> 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: [email protected] >> To: [email protected] >> 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" <[email protected]> >> 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: [email protected] >> >> To: [email protected] >> >> 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" >><[email protected]> >> >> 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: [email protected] >> >> >> To: [email protected] >> >> >> 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" >> >><[email protected]> >> >> >> 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! >> >> >> >> >> > >> >> >> > >> >
