Adopted Span and MutableSpan for buffers across the library to adapt to Swift 6.4.
This commit is contained in:
@@ -23,9 +23,11 @@ extension Graphics {
|
||||
|
||||
/// Creates a font from the contents of a .pft file already in memory.
|
||||
/// The bytes are copied and retained for the font's lifetime.
|
||||
public convenience init?(data: UnsafeRawBufferPointer, wide: Bool = false) {
|
||||
public convenience init?(data: Span<UInt8>, wide: Bool = false) {
|
||||
let copy = UnsafeMutableRawPointer.allocate(byteCount: data.count, alignment: 4)
|
||||
copy.copyMemory(from: data.baseAddress.unsafelyUnwrapped, byteCount: data.count)
|
||||
data.withUnsafeBytes { bytes in
|
||||
copy.copyMemory(from: bytes.baseAddress.unsafelyUnwrapped, byteCount: bytes.count)
|
||||
}
|
||||
let fontData = OpaquePointer(copy)
|
||||
guard let pointer = gfx.pointee.makeFontFromData.unsafelyUnwrapped(
|
||||
fontData, wide ? 1 : 0, Int32(data.count)) else {
|
||||
|
||||
Reference in New Issue
Block a user