- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
// bitmap constants
const LOG2_PAGE_SIZE = 9;
const PAGE_SIZE = 1 << LOG2_PAGE_SIZE;
/**
* a glyph representing a single character in a font
* @ignore
*/
export default class Glyph {
/**
* @ignore
*/
constructor() {
this.id = 0;
this.x = 0;
this.y = 0;
this.width = 0;
this.height = 0;
this.u = 0;
this.v = 0;
this.u2 = 0;
this.v2 = 0;
this.xoffset = 0;
this.yoffset = 0;
this.xadvance = 0;
this.fixedWidth = false;
}
/**
* @ignore
*/
getKerning(ch) {
if (this.kerning) {
let page = this.kerning[ch >>> LOG2_PAGE_SIZE];
if (page) {
return page[ch & PAGE_SIZE - 1] || 0;
}
}
return 0;
}
/**
* @ignore
*/
setKerning(ch, value) {
if (!this.kerning) {
this.kerning = {};
}
let page = this.kerning[ch >>> LOG2_PAGE_SIZE];
if (typeof page === "undefined") {
this.kerning[ch >>> LOG2_PAGE_SIZE] = {};
page = this.kerning[ch >>> LOG2_PAGE_SIZE];
}
page[ch & PAGE_SIZE - 1] = value;
}
}