项目作者: cc-ru

项目描述 :
OC bitmap font format
高级语言: Lua
项目地址: git://github.com/cc-ru/ocbf.git
创建时间: 2017-11-27T15:10:02Z
项目社区:https://github.com/cc-ru/ocbf

开源协议:Apache License 2.0

下载


OC Bitmap Font format (.ocbf)

API

  • ocbf.load(path: string): table, string.
    Loads a font. Returns nil and the reason if an error occured.
  • `ocbf.drawchar(set: function(x: number, y: number, v: number),
    1. font: table, size: number, char: string, x: number, y: number)`.
    Draws a single character at (x; y) calling set function for every pixel,
    where v is either 1 or 0.
  • `ocbf.draw(set: function(x: number, y: number, v: number),
    1. font: table, size: number, str: string, x: number, y: number)`.
    Draws a string at (x; y) calling set function for every pixel,
    where v is either 1 or 0.
  • ocbf.width(font: table, size: number, str: string): number.
    Returns string width in pixels.
  • font.family. Font family (i.e. Ubuntu)
  • font.style. Font style (i.e. Regular)

Format Specification

  1. [ocbf]
  2. [[len: u8-be]
  3. [family: utf8 string of *len]]
  4. [[len: u8-be]
  5. [style: utf8 string of *len]]
  6. [[char: utf8 single char]
  7. [size: u8-be]
  8. [width: u8-be]
  9. [bitmap: ceil(size * width / 8)]]*