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

Set "Opts" comment in the web version #106

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ List of characters to copy, belongs to previously declared "--font". Examples:
//

let args = parser.parse_args(argv.length ? argv : [ '-h' ]);
args.opts_string = process.argv.slice(2).join(' ');

for (let font of args.font) {
if (font.ranges.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion lib/writers/lvgl/lv_font.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class LvFont extends Font {
return `/*******************************************************************************
* Size: ${this.src.size} px
* Bpp: ${this.opts.bpp}
* Opts: ${process.argv.slice(2).join(' ')}
* Opts: ${this.opts.opts_string}
******************************************************************************/

#ifdef LV_LVGL_H_INCLUDE_SIMPLE
Expand Down
58 changes: 58 additions & 0 deletions web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,62 @@ $('#insert-button').click(addFont);

addFontFileChangeHandlers();

function generate_range(start, end, transpose) {
if (start !== transpose) {
return start + '-' + end + '=>' + transpose;
}
if (start !== end) {
return start + '-' + end;
}
return start;
}

function generate_opts_string(args) {
var opts = [];

opts.push('--bpp', args.bpp);
opts.push('--size', args.size);
if (args.no_compress) {
opts.push('--no-compress');
}
if (args.lcd) {
opts.push('--lcd');
}
if (args.lcd_v) {
opts.push('--lcd-v');
}
if (args.use_color_info) {
opts.push('--use-color-info');
}

for (var i = 0; i < args.font.length; i++) {
opts.push('--font', args.font[i].source_path);
const r = args.font[i].ranges;

var symbols = '';
var ranges = [];
for (var j = 0; j < r.length; j++) {
if (r[i].symbols) {
symbols += r[i].symbols;
}
for (var k = 0; k < r[i].range.length; k += 3) {
ranges.push(generate_range(r[i].range[k + 0], r[i].range[k + 1], r[i].range[k + 2]));
}
}
if (symbols) {
opts.push('--symbols', symbols);
}
if (ranges) {
opts.push('--range', ranges.join(','));
}
}

opts.push('--format', args.format);
opts.push('-o', args.output + '.c');

return opts.join(' ');
}

document.querySelector('#converterForm').addEventListener('submit', function handleSubmit(e) {
e.preventDefault();

Expand Down Expand Up @@ -115,6 +171,8 @@ document.querySelector('#converterForm').addEventListener('submit', function han
lv_fallback: _fallback
};

args.opts_string = generate_opts_string(args);

convert(args).then(result => {
const blob = new Blob([ result[_name] ], { type: 'text/plain;charset=utf-8' });

Expand Down
Loading