Skip to content

Commit

Permalink
Let change fonts loading via context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
linev committed Sep 27, 2024
1 parent fecbc61 commit 290c294
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions modules/base/FontHandler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ async function loadFontFile(fname) {

entry = gFontFiles[fname] = { promises: [] };

console.log('loading', fname)

const locations = [];
if (fname.indexOf('/') >= 0)
locations.push(''); // just use file name as is
else {
locations.push(source_dir + 'fonts/');
if (isNodeJs())
locations.push('../../fonts/');
else if (source_dir.indexOf('jsrootsys/') >= 0)
else if (source_dir.indexOf('jsrootsys/') >= 0) {
locations.unshift(source_dir.replace(/jsrootsys/g, 'rootsys_fonts'));
locations.unshift(source_dir.replace(/jsrootsys/g, 'rootsys/fonts'));
}
}

function completeReading(base64) {
Expand All @@ -70,6 +70,7 @@ async function loadFontFile(fname) {
throw new Error(`Fail to load ${fname} font`);
}
let path = locations.shift() + fname;
console.log('loading font', path);
const pr = isNodeJs() ? import('fs').then(fs => {
const prefix = 'file://' + (process?.platform === 'win32' ? '/' : '');
if (path.indexOf(prefix) === 0)
Expand Down
2 changes: 1 addition & 1 deletion modules/core.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ settings = {
YValuesFormat: undefined,
/** @summary custom format for all Z values, when not specified {@link gStyle.fStatFormat} is used */
ZValuesFormat: undefined,
/** @summary Let detect and solve problem when browser returns wrong content-length parameter
/** @summary Let detect and solve problem when server returns wrong Content-Length header
* @desc See [jsroot#189]{@link https://github.com/root-project/jsroot/issues/189} for more info
* Can be enabled by adding 'wrong_http_response' parameter to URL when using JSROOT UI
* @default false */
Expand Down
4 changes: 3 additions & 1 deletion modules/gui/menu.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ class JSRootMenu {
this.addchk(settings.UseStamp, 'Use stamp arg', flag => { settings.UseStamp = flag; });
this.addSizeMenu('Max ranges', 1, 1000, [1, 10, 20, 50, 200, 1000], settings.MaxRanges, value => { settings.MaxRanges = value; }, 'Maximal number of ranges in single http request');

this.addchk(settings.HandleWrongHttpResponse, 'Handle wrong http response', flag => { settings.HandleWrongHttpResponse = flag; });
this.addchk(settings.HandleWrongHttpResponse, 'Handle wrong http response', flag => { settings.HandleWrongHttpResponse = flag; }, 'Let detect and solve problem when server returns wrong Content-Length header, see https://github.com/root-project/jsroot/issues/189');
this.addchk(settings.WithCredentials, 'With credentials', flag => { settings.WithCredentials = flag; }, 'Submit http request with user credentials');

this.endsub();
Expand Down Expand Up @@ -837,6 +837,8 @@ class JSRootMenu {
this.endsub();
this.addPaletteMenu(settings.Palette, pal => { settings.Palette = pal; });
this.addchk(settings.AutoStat, 'Auto stat box', flag => { settings.AutoStat = flag; });
this.addchk(settings.LoadSymbolTtf, 'Load symbol.ttf', flag => { settings.LoadSymbolTtf = flag; }, 'Use symbol.ttf font file to render greek symbols, also used in PDF');

this.sub('Axis');
this.addchk(settings.StripAxisLabels, 'Strip labels', flag => { settings.StripAxisLabels = flag; }, 'Provide shorter labels like 10^0 -> 1');
this.addchk(settings.CutAxisLabels, 'Cut labels', flag => { settings.CutAxisLabels = flag; }, 'Remove labels which may exceed graphical range');
Expand Down

0 comments on commit 290c294

Please sign in to comment.