1 Reply Latest reply on Jan 18, 2017 9:02 AM by A. Patterson

    Set Character Style

    hong kiemp34358061

      Hi everyone!

      i'm setting style to character, but it doesn't change.

      code:

      Char *CharacterStyleName="Character Style 1";

      const ASUnicode *charStyleName=ai::UnicodeString(CharacterStyleName,kAIPlatformCharacterEncoding).as_ASUnicode().c_str();

      oChar.SetNamedCharStyle(charStyleName);

      anyone help me. thanks so much!

        • 1. Re: Set Character Style
          A. Patterson Level 4

          I don't know if I've ever gone that method. We do something more like this:

           

          ATE::DocumentTextResourcesRef textResourcesRef = 0
          auto error = sDocument->GetDocumentTextResources(&textResourcesRef);
          // check error
          IDocumentTextResources textResources(textResourcesRef);
          
          
          const auto charStyle = textResources.GetCharStyle(localStyleName.au_str());
          assert(!charStyle.IsNull());
          
          
          const ICharFeatures charFeatures = charStyle.GetFeatures();
          const AIArtHandle handle = GetHandle();
          ATE::TextRangeRef textRangeRef = 0;
          error = sAITextFrame->GetATETextRange(handle, &textRangeRef);
          // check error
          
          
          ATE::ITextRange textRange(textRangeRef);
          textRange.ReplaceOrAddLocalCharFeatures(charFeatures);