{"id":19152233,"url":"https://github.com/autokaka/ios17_core_text_repro","last_synced_at":"2025-04-19T16:32:30.326Z","repository":{"id":203286524,"uuid":"707375636","full_name":"Autokaka/ios17_core_text_repro","owner":"Autokaka","description":"Minimal reproduction code in https://developer.apple.com/forums/thread/734464","archived":false,"fork":false,"pushed_at":"2023-10-26T06:19:02.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-10-27T05:32:21.930Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Autokaka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-10-19T19:07:26.000Z","updated_at":"2023-10-27T05:32:21.931Z","dependencies_parsed_at":null,"dependency_job_id":"387e7016-d1fe-4da4-91c9-0aa1a0d19d0a","html_url":"https://github.com/Autokaka/ios17_core_text_repro","commit_stats":null,"previous_names":["autokaka/ios17_core_text_repro"],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Autokaka%2Fios17_core_text_repro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Autokaka%2Fios17_core_text_repro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Autokaka%2Fios17_core_text_repro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Autokaka%2Fios17_core_text_repro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Autokaka","download_url":"https://codeload.github.com/Autokaka/ios17_core_text_repro/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223800955,"owners_count":17205031,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T08:17:11.880Z","updated_at":"2024-11-09T08:17:12.484Z","avatar_url":"https://github.com/Autokaka.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"[TOC]\n\n# Feedback for Developer Technologies \u0026 SDKs\n\n## Please provide a descriptive title for your feedback:\n\n`CTFramesetterSuggestFrameSizeWithConstraints` result does not match with `CTFrameDraw` actual drawing result\n\n## Which platform is most relevant for your report?\n\niOS\n\n## Which technology does your report involve?\n\nCore Text\n\n## What type of feedback are you reporting?\n\nIncorrect/Unexpected Behavior\n\n## What build does the issue occur on?\n\niOS 17.1 Seed 3 (21B5066a)\n\n## Where does the issue occur?\n\nOn device\n\n## Please describe the issue and what steps we can take to reproduce it:\n\n1. Create NSAttributedString:\n\n   ```objective-c\n   int fontSize = 16 * [NSScreen.mainScreen backingScaleFactor];\n   NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:@\"《眼中星》\" attributes:@{\n       NSFontAttributeName: [NSFont boldSystemFontOfSize:fontSize],\n       NSForegroundColorAttributeName: [NSColor whiteColor],\n   }];\n   ```\n\n2. Create CTFramesetter:\n\n   ```objective-c\n   CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(attributedString);\n   ```\n\n3. Get suggested size using `CTFramesetterSuggestFrameSizeWithConstraints`:\n\n   ```objective-c\n   CGSize stringSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRangeMake(0, 0), NULL, CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX), NULL);\n   ```\n\n4. Create CTFrame:\n\n   ```objective-c\n   float width = ceil(stringSize.width);\n   float height = ceil(stringSize.height);\n   CGPathRef path = CGPathCreateWithRect(CGRectMake(0.0, 0.0, width, height), NULL);\n   CTFrameRef ctFrame = CTFramesetterCreateFrame(framesetter, CFRangeMake(0, 0), path, NULL);\n   ```\n\n5. Get, print and compare the VisibleStringRange and StringRange:\n\n   ```objective-c\n   CFRange stringRange =  CTFrameGetStringRange(ctFrame);\n   CFRange visibleStringRange =  CTFrameGetVisibleStringRange(ctFrame);\n   NSLog(@\"stringRange.location: %@ stringRange.length: %@\", @(stringRange.location), @(stringRange.length));\n   NSLog(@\"visibleStringRange.location: %@ visibleStringRange.length: %@\", @(visibleStringRange.location), @(visibleStringRange.length));\n   NS\n   NSAssert(stringRange.length == visibleStringRange.length, @\"StringRange mismatch!\");\n   ```\n\nOn iOS 16.* and below, macOS 13.* and below, the assertion won't be triggered, while devices running iOS 17.* and macOS 14.* does. \n\nThis issue could also be observed by drawing the CTFrame on screen. The expected output should be \"《眼中星》\", but the actual drawing result shows \"《眼中\".\n\n**The above code is disassembled from `SpriteKit.framework::SKCLabelNode::rebuildText` and simplified as a demo to explain the issue, which means a simple cross-platform game application using SpriteKit will also reproduce it. There is also a simple game application project to reproduce the issue in the appendix and [Github repo](https://github.com/Autokaka/ios17_core_text_repro).** \n\nIt seems that the UIKit does not rely on `CTFramesetterSuggestFrameSizeWithConstraints` but the `NSStringDrawingEngine` to get the suggest size and draw the final frame since the Symbolic Breakpoint won't be triggered when using `UILabel` in normal applications, so the issue can't be reproduced.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fautokaka%2Fios17_core_text_repro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fautokaka%2Fios17_core_text_repro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fautokaka%2Fios17_core_text_repro/lists"}