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

Add ability to include MJXZERO to font-family used for undefined characters #449

Merged
merged 2 commits into from
Apr 3, 2020
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
5 changes: 5 additions & 0 deletions ts/output/chtml/fonts/tex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ import {delimiters} from '../../common/fonts/tex/delimiters.js';
export class TeXFont extends
CommonTeXFontMixin<CHTMLCharOptions, CHTMLVariantData, CHTMLDelimiterData, CHTMLFontDataClass>(CHTMLFontData) {

/**
* Fonts to prefix any explicit ones
*/
protected static defaultCssFamilyPrefix = 'MJXZERO';

/**
* The classes to use for each variant
*/
Expand Down
11 changes: 11 additions & 0 deletions ts/output/common/FontData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ export class FontData<C extends CharOptions, V extends VariantData<C>, D extends
monospace: ['monospace', false, false]
};

/**
* The default prefix for explicit font-family settings
*/
protected static defaultCssFamilyPrefix = '';

/**
* The default remappings
*/
Expand Down Expand Up @@ -373,6 +378,11 @@ export class FontData<C extends CharOptions, V extends VariantData<C>, D extends
protected sizeVariants: string[];
protected cssFontMap: CssFontMap = {};

/**
* A prefix to use for explicit font-family CSS settings
*/
public cssFamilyPrefix: string;

/**
* The character maps
*/
Expand All @@ -398,6 +408,7 @@ export class FontData<C extends CharOptions, V extends VariantData<C>, D extends
this.params = {...CLASS.defaultParams};
this.sizeVariants = [...CLASS.defaultSizeVariants];
this.cssFontMap = {...CLASS.defaultCssFonts};
this.cssFamilyPrefix = CLASS.defaultCssFamilyPrefix;
this.createVariants(CLASS.defaultVariants);
this.defineDelimiters(CLASS.defaultDelimiters);
for (const name of Object.keys(CLASS.defaultChars)) {
Expand Down
5 changes: 4 additions & 1 deletion ts/output/common/OutputJax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ export abstract class CommonOutputJax<
*/
public font: FD;

/**
* The wrapper factory for the MathML nodes
*/
public factory: F;

/**
Expand Down Expand Up @@ -541,7 +544,7 @@ export abstract class CommonOutputJax<
*/
public cssFontStyles(font: CssFontData, styles: StyleList = {}) {
const [family, italic, bold] = font;
styles['font-family'] = family;
styles['font-family'] = this.font.cssFamilyPrefix + ', ' + family;
if (italic) styles['font-style'] = 'italic';
if (bold) styles['font-weight'] = 'bold';
return styles;
Expand Down
2 changes: 1 addition & 1 deletion ts/output/svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ CommonOutputJax<N, T, D, SVGWrapper<N, T, D>, SVGWrapperFactory<N, T, D>, SVGFon
const adaptor = this.adaptor;
if (variant !== '-explicitFont') {
const [family, italic, bold] = this.font.getCssFont(variant);
adaptor.setAttribute(svg, 'font-family', family);
adaptor.setAttribute(svg, 'font-family', this.font.cssFamilyPrefix + ', ' + family);
if (italic) {
adaptor.setAttribute(svg, 'font-style', 'italic');
}
Expand Down