title: How to draw text in iOS swift using Metal Framework
body: <p>I am working on a Real-Time Data Monitoring app. I have successfully drawn waves using the Metal framework but I am facing problems while drawing simple text/strings. Like how to print "Hello" in MTKView. Here I am updating the vertices using a timer and then calling draw() to perform drawing. Only GPU rendering is required.</p>
  
  <p>func draw(in view: MTKView) {</p>
  
  <pre><code>    // print("calling")
  
  
  
      //  guard let drawablelayer = metalLayer!.nextDrawable(),
      guard //let mainDrawable = view.currentDrawable,
         // let _pipeLineState = self.pipelineState,
          let discriptor = view.currentRenderPassDescriptor else  {
              return
      }
  
      let commandBuffer = commandQue.makeCommandBuffer()
      let commandEncoder = commandBuffer?.makeRenderCommandEncoder(descriptor: discriptor)
  
      //commandEncoder?.setRenderPipelineState(_pipeLineState)
  
  
  
  
  
      viewPort = MTLViewport.init(originX: 0.0, originY: 0.0, width: 750, height: 1334, znear: 0.0, zfar: 0.0)
      commandEncoder?.setViewport(viewPort!)
  
  
  
  
      commandEncoder?.setVertexBuffer(layoutBuffer, offset: 0, index: 0)
      commandEncoder?.setRenderPipelineState(noninterleavedRenderPipeline)
      commandEncoder?.drawPrimitives(type: .triangle, vertexStart:0, vertexCount: verticesLayout.count)
  
  
      commandEncoder?.setVertexBuffer(vertexBuffer, offset: 0, index: 0)
      commandEncoder?.setRenderPipelineState(interleavedRenderPipeline)
      commandEncoder?.drawPrimitives(type: .line, vertexStart:0, vertexCount: vertices.count)
  
  
      commandEncoder?.setVertexBuffer(topBuffer, offset: 0, index: 0)
      commandEncoder?.setRenderPipelineState(topInterleavedRenderPipeline)
      commandEncoder?.drawPrimitives(type: .triangle, vertexStart:0, vertexCount: verticesRect.count)
  
  
  
      commandEncoder?.endEncoding()
     // commandBuffer?.present(mainDrawable)
  
      if let drawable = view.currentDrawable {
          commandBuffer?.present(drawable)
      }
  
      commandBuffer?.commit()
  
  
  }
  </code></pre>