web: glyphinfo format compatibility
This commit is contained in:
parent
be9e8a0bfa
commit
cc6505cae9
2 changed files with 26 additions and 7 deletions
|
|
@ -326,6 +326,9 @@ function render() {
|
||||||
|
|
||||||
// glyphInfo: {
|
// glyphInfo: {
|
||||||
// "glyphs": [
|
// "glyphs": [
|
||||||
|
// // <=v2.5:
|
||||||
|
// [name :string, unicode? :int|null, unicodeName? :string, color? :string|null],
|
||||||
|
// // >=v2.6: (has mtime)
|
||||||
// [name :string, unicode? :int|null, unicodeName? :string, mtime? :string, color? :string|null],
|
// [name :string, unicode? :int|null, unicodeName? :string, mtime? :string, color? :string|null],
|
||||||
// ["A", 65, "LATIN CAPITAL LETTER A", "#dbeaf7"],
|
// ["A", 65, "LATIN CAPITAL LETTER A", "#dbeaf7"],
|
||||||
// ...
|
// ...
|
||||||
|
|
@ -387,10 +390,18 @@ function renderGlyphGraphic(glyphName) {
|
||||||
|
|
||||||
|
|
||||||
function renderGlyphGraphicG(g, lastGlyphName, lastGlyphEl, singleGlyph) {
|
function renderGlyphGraphicG(g, lastGlyphName, lastGlyphEl, singleGlyph) {
|
||||||
var name = g[0]
|
let name = g[0], uc = g[1], ucName = g[2], mtime = g[3], color = g[4]
|
||||||
var names, glyph
|
var names, glyph
|
||||||
var svg = svgRepository[name]
|
var svg = svgRepository[name]
|
||||||
|
|
||||||
|
// XXX compatibility with v2.5 (remove when moving to v2.6)
|
||||||
|
// glyphinfo for 2.5 doesn't contain mtime.
|
||||||
|
if (mtime && typeof mtime == 'string' &&
|
||||||
|
(mtime.indexOf('rgba') != -1 || mtime.indexOf('#') != -1)) {
|
||||||
|
color = mtime
|
||||||
|
mtime = null
|
||||||
|
}
|
||||||
|
|
||||||
if (!svg) {
|
if (!svg) {
|
||||||
// ignore
|
// ignore
|
||||||
return null
|
return null
|
||||||
|
|
@ -403,10 +414,10 @@ function renderGlyphGraphicG(g, lastGlyphName, lastGlyphEl, singleGlyph) {
|
||||||
|
|
||||||
var info = {
|
var info = {
|
||||||
name: name,
|
name: name,
|
||||||
unicode: g[1],
|
unicode: uc,
|
||||||
unicodeName: g[2],
|
unicodeName: ucName,
|
||||||
// mtime: g[3],
|
// mtime: mtime,
|
||||||
color: g[4],
|
color: color,
|
||||||
|
|
||||||
// These are all in 1:1 UPM (not scaled)
|
// These are all in 1:1 UPM (not scaled)
|
||||||
advance: metrics.advance,
|
advance: metrics.advance,
|
||||||
|
|
|
||||||
|
|
@ -478,9 +478,17 @@ samples.set('Repertoire', {
|
||||||
|
|
||||||
for (const g of glyphs) {
|
for (const g of glyphs) {
|
||||||
// let [name, uc, ucName, mtime, color] = g
|
// let [name, uc, ucName, mtime, color] = g
|
||||||
let name = g[0], uc = g[1], ucName = g[2], mtime = g[3] color = g[4]
|
let name = g[0], uc = g[1], ucName = g[2], mtime = g[3], color = g[4]
|
||||||
const ucHex = hexstr(uc, 4)
|
const ucHex = hexstr(uc, 4)
|
||||||
|
|
||||||
|
// XXX compatibility with v2.5 (remove when moving to v2.6)
|
||||||
|
// glyphinfo for 2.5 doesn't contain mtime.
|
||||||
|
if (mtime && typeof mtime == 'string' &&
|
||||||
|
(mtime.indexOf('rgba') != -1 || mtime.indexOf('#') != -1)) {
|
||||||
|
color = mtime
|
||||||
|
mtime = null
|
||||||
|
}
|
||||||
|
|
||||||
const style = color && color != '<derived>' ?
|
const style = color && color != '<derived>' ?
|
||||||
'style="background-color:' + color + '"' : ''
|
'style="background-color:' + color + '"' : ''
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue