Skip to main content
Participating Frequently
August 24, 2009
Question

How to reset format to e.g. fontWeight==undefined?

  • August 24, 2009
  • 1 reply
  • 728 views

I want to reset formats to the default value "undefined" but only get "inherit". Aren't those values for intheritable format properties equal in the TextFlow model?

    public function test_reset_format():void 
    {
        var init:XML = <TextFlow xmlns="http://ns.adobe.com/textLayout/2008"><p><span>aaa</span></p></TextFlow>
        var textFlow:TextFlow = TextConverter.importToFlow(init, TextConverter.TEXT_LAYOUT_FORMAT)
        var editManager:IEditManager = new EditManager()
        textFlow.interactionManager = editManager
       
         var format:TextLayoutFormat = new TextLayoutFormat()
        format.fontWeight = FontWeight.BOLD
       
        editManager.selectRange(0,1)
        editManager.applyLeafFormat(format)
        assertEquals(FontWeight.BOLD, textFlow.getFirstLeaf().fontWeight)
   
         var resetFormat:TextLayoutFormat = new TextLayoutFormat()
        resetFormat.fontWeight = FormatValue.INHERIT
        editManager.applyLeafFormat(resetFormat)
       
        var resetFontWeight:* = textFlow.getFirstLeaf().fontWeight
        assertEquals(FormatValue.INHERIT, resetFontWeight)
        // How can I reset the format so that assertTrue(undefined == resetFontWeight) passes?
    }


Thanks for any hints,

Marc

This topic has been closed for replies.

1 reply

Adobe Employee
August 24, 2009

That operation doesn't exist at this time.  It's quite doable with the model level APIs - there's just no operation for it.

I wrote up a bug.

Thanks,

Richard

Participating Frequently
August 25, 2009

Thanks for filing the bug, Richard. Just to underline the severity of the bug, two examples:

- When working with TextFlow, you always need to check for undefined AND "inherit" if you want to know that the property is cascaded.

- Second examples is with exporting in the Layout_Format: properties set to "inherit" are written as attributes fontWeight="inherit" while undefined is ingored.

Just some motiviation to fix it

Marc