Skip to content

Swift package for creating SpriteKit labels using bitmap fonts generated by BMFont xml format compatible apps such as BMGlyph, BMFont and Glyph Designer 2

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE-BMGlyphLabel.TXT
Notifications You must be signed in to change notification settings

nyxhub/bitmapglyphlabel

Repository files navigation

BitmapGlyphLabel

This is a Swift package for creating SpriteKit labels using bitmap fonts generated by BMFont xml format compatible apps such as BMGlyph, BMFont and Glyph Designer 2

Usage

  1. add the package to your project through Xcode or by editing your Package.swift file and adding: .package(url: "https://github.com/gabrielnica/bmglyph-swift.git", from: "1.0.0")
  2. import the library import BitmapGlyphLabel
  3. create a font object
let font = BitmapGlyphFont(named: "myFont")

or

let cachedAtlas = ...
let font = BitmapGlyphFont(named: "myFont", usingAtlas: cachedAtlas)

if you already loaded the atlas in memory for caching purposes. It is recommended to also store the font for future use

  1. create a label node add it to your scene
let labelNode = BitmapGlyphLabel(text: "Some text", font: font)

self.addChild(labelNode)

By default the text is horizontally and vertically centered, with left justification. You can change this by modifying the .horizontalAlignment, .verticalAlignment and .justification properties respectively. The text can also be modified after the label has been created by changing the, surprise, .text property of the label

The node returned by BitmapGlyphLabel is of type SKNode. To get the total size of the node without computing it through SpriteKit you can access the .totalSize property of the label

About

Swift package for creating SpriteKit labels using bitmap fonts generated by BMFont xml format compatible apps such as BMGlyph, BMFont and Glyph Designer 2

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE-BMGlyphLabel.TXT

Stars

Watchers

Forks

Packages

No packages published

Languages