feedback-assistant / reports

Open collection of Apple Feedback Assistant reports

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FB13203965: `NSAttributedString.DocumentAttributeKey.defaultFontExcluded` does not work when converting NSAttributedString to RTF

sindresorhus opened this issue · comments

  • Date: 2023-09-25
  • Resolution: Open
  • Area: Foundation
  • OS: macOS 14
  • Type: Incorrect/Unexpected Behavior

Description

https://developer.apple.com/documentation/foundation/nsattributedstring/documentattributekey/4273964-defaultfontexcluded

It does not exclude the default font.

To reproduce, run the attached sample project.

The output will be:

Optional("{\\rtf1\\ansi\\ansicpg1252\\cocoartf2757\n\\cocoatextscaling0\\cocoaplatform0{\\fonttbl\\f0\\fswiss\\fcharset0 Helvetica;}\n{\\colortbl;\\red255\\green255\\blue255;}\n{\\*\\expandedcolortbl;;}\n\\pard\\tx560\\tx1120\\tx1680\\tx2240\\tx2800\\tx3360\\tx3920\\tx4480\\tx5040\\tx5600\\tx6160\\tx6720\\pardirnatural\\partightenfactor0\n\n\\f0\\fs24 \\cf0 Hello}")

Notice Helvetica; in there, which should not be there because we passed .defaultFontExcluded: true.

Files

Sample project.zip