SCNText渲染没有曲线,不像字体

当我运行这个SceneKit代码时:

let txt = SCNText(string: "Hello", extrusionDepth: 0.2) let textNode = SCNNode(geometry: txt) scene.rootNode.addChildNode(textNode) 

我得到非常有angular度的文字:

呈现效果不佳的文字

它似乎这样做,不pipe字体,它在设备上的行为与在模拟器中的行为相同。

以下是上下文中的代码:

  // create a new scene let scene = SCNScene() // create and add a camera to the scene let cameraNode = SCNNode() cameraNode.camera = SCNCamera() scene.rootNode.addChildNode(cameraNode) // place the camera cameraNode.position = SCNVector3(x: 10, y: 0, z: 75) // create and add a light to the scene let lightNode = SCNNode() lightNode.light = SCNLight() lightNode.light!.type = SCNLightTypeOmni lightNode.position = SCNVector3(x: 0, y: 10, z: 10) scene.rootNode.addChildNode(lightNode) // create and add an ambient light to the scene let ambientLightNode = SCNNode() ambientLightNode.light = SCNLight() ambientLightNode.light!.type = SCNLightTypeAmbient ambientLightNode.light!.color = UIColor.darkGrayColor() scene.rootNode.addChildNode(ambientLightNode) let txt = SCNText(string: "Hello", extrusionDepth: 0.2) let textNode = SCNNode(geometry: txt) scene.rootNode.addChildNode(textNode) // retrieve the SCNView let scnView = self.view as! SCNView // set the scene to the view scnView.scene = scene 

SCNText为您的文本细分SCNTextpath,就像Core Graphics在绘制文件时所做的一样。 您始终可以使用flatness属性使其更平滑,但不会获得“亚像素平滑度”。

为了解决这个问题,你可以使用更大的字体大小,这样当发生离散化时,底层Bézierpath更大,生成更多的顶点。