forked from Blendman974/faceclaw
iOS porting: EvenHub app compatibility first pass
This commit is contained in:
1 parent
79b6c276f8
commit
44bd1d8a2d
24 files changed
+843
-24
No files matched your search
@@ -0,0 +1,16 @@
|
||||
import { LvglFont } from '../graphics/lvgl-font'
|
||||
import { readBinaryFile } from './file-access'
|
||||
const cache = new Map<string, LvglFont>()
|
||||
function load(path: string): LvglFont {
|
||||
let font = cache.get(path)
|
||||
if (!font) {
|
||||
const bytes = readBinaryFile(path)
|
||||
if (!bytes) throw new Error('Cannot read LVGL font')
|
||||
font = new LvglFont(bytes)
|
||||
if (cache.size >= 2) cache.delete(cache.keys().next().value!)
|
||||
cache.set(path, font)
|
||||
}
|
||||
return font
|
||||
}
|
||||
export function lvglMetrics(path: string): Uint8Array { return load(path).metrics }
|
||||
export function lvglGlyph(path: string, codePoint: number): Uint8Array { return load(path).glyph(codePoint) }
|
||||
@@ -0,0 +1,4 @@
|
||||
import { toUint8Array } from '../util/array-util'
|
||||
declare const com: any
|
||||
export function lvglMetrics(path: string): Uint8Array { return toUint8Array(com.faceclaw.app.LvglFontFile.getMetrics(path)) }
|
||||
export function lvglGlyph(path: string, codePoint: number): Uint8Array { return toUint8Array(com.faceclaw.app.LvglFontFile.getGlyph(path, codePoint)) }
|
||||
Reference in new issue
Block a user