Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

See issue https://github.com/lvgl/lv_font_conv/issues/120 #122

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions lib/writers/lvgl/lv_table_glyf.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ class LvGlyf extends Glyf {
f.src.glyphs.forEach(g => {
const id = f.glyph_id[g.code];
const bin = this.lv_bitmap(g);
const dup = this.lv_data.find(d => d && d.bin.equals(bin));
this.lv_data[id] = {
bin,
offset,
bin: dup ? Buffer.from([]) : bin,
offset: dup ? dup.offset : offset,
glyph: g
};
offset += bin.length;
offset += dup ? 0 : bin.length;
});
}

Expand All @@ -55,17 +56,14 @@ class LvGlyf extends Glyf {

let result = [];
this.lv_data.forEach((d, idx) => {
if (idx === 0) return;
if (idx === 0 || d.bin.length === 0) return;
const code_hex = d.glyph.code.toString(16).toUpperCase();
const code_str = JSON.stringify(String.fromCodePoint(d.glyph.code));

let txt = ` /* U+${code_hex.padStart(4, '0')} ${code_str} */
${u.long_dump(d.bin, { hex: true })}`;
${u.long_dump(d.bin, { hex: true })},`;

if (idx < this.lv_data.length - 1) {
// skip comma for zero data
txt += d.bin.length ? ',\n\n' : '\n';
}
if (result.length > 0) result.push('\n\n');

result.push(txt);
});
Expand Down
Loading