Checkpoint current UI and ink integration state
This commit is contained in:
@@ -19,6 +19,7 @@ class ParagraphLayoutModule extends BaseModule {
|
||||
hyphenationEnabled: true,
|
||||
defaultFontSize: '1rem',
|
||||
defaultFontFamily: "'EB Garamond', serif",
|
||||
defaultFontFeatureSettings: "'kern' on, 'liga' on, 'onum' on, 'pnum' on, 'dlig' on, 'clig' on, 'calt' on",
|
||||
defaultLineHeight: 1.5,
|
||||
debugMode: false
|
||||
});
|
||||
@@ -104,10 +105,7 @@ class ParagraphLayoutModule extends BaseModule {
|
||||
if (event.detail) {
|
||||
const { fontSize, fontFamily } = event.detail;
|
||||
if (fontSize || fontFamily) {
|
||||
this.updateFont(
|
||||
fontSize || this.config.defaultFontSize,
|
||||
fontFamily || this.config.defaultFontFamily
|
||||
);
|
||||
this.updateFont(fontSize || this.config.defaultFontSize, fontFamily || this.config.defaultFontFamily);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -119,7 +117,7 @@ class ParagraphLayoutModule extends BaseModule {
|
||||
});
|
||||
}
|
||||
|
||||
updateFont(fontSize, fontFamily) {
|
||||
updateFont(fontSize, fontFamily, fontFeatureSettings = null, fontVariantCaps = null) {
|
||||
if (!this.ruler) {
|
||||
console.warn("Text measurement ruler not initialized");
|
||||
return;
|
||||
@@ -130,7 +128,8 @@ class ParagraphLayoutModule extends BaseModule {
|
||||
|
||||
this.ruler.style.fontSize = fontSize;
|
||||
this.ruler.style.fontFamily = fontFamily;
|
||||
this.ruler.style.fontFeatureSettings = "'kern' on, 'liga' on, 'onum' on, 'clig' on, 'hlig' on";
|
||||
this.ruler.style.fontFeatureSettings = fontFeatureSettings || this.config.defaultFontFeatureSettings;
|
||||
this.ruler.style.fontVariantCaps = fontVariantCaps || 'normal';
|
||||
|
||||
if (this.config.debugMode) {
|
||||
console.log(`Font updated: ${fontSize} ${fontFamily}`);
|
||||
@@ -214,6 +213,8 @@ class ParagraphLayoutModule extends BaseModule {
|
||||
fontFamily: options.fontFamily || this.config.defaultFontFamily,
|
||||
lineHeight: options.lineHeight || this.config.defaultLineHeight,
|
||||
lineHeightPx: options.lineHeightPx,
|
||||
fontFeatureSettings: options.fontFeatureSettings || this.config.defaultFontFeatureSettings,
|
||||
fontVariantCaps: options.fontVariantCaps || null,
|
||||
tolerance: options.tolerance || 3,
|
||||
demerits: options.demerits || {
|
||||
line: 10,
|
||||
@@ -222,7 +223,12 @@ class ParagraphLayoutModule extends BaseModule {
|
||||
}
|
||||
};
|
||||
|
||||
this.updateFont(layoutOptions.fontSize, layoutOptions.fontFamily);
|
||||
this.updateFont(
|
||||
layoutOptions.fontSize,
|
||||
layoutOptions.fontFamily,
|
||||
layoutOptions.fontFeatureSettings,
|
||||
layoutOptions.fontVariantCaps
|
||||
);
|
||||
const numericFontSize = parseFloat(layoutOptions.fontSize) || 16;
|
||||
const lineHeightPx = layoutOptions.lineHeightPx || (numericFontSize * layoutOptions.lineHeight);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user