stash
This commit is contained in:
parent
368268d288
commit
1356aa7749
2 changed files with 211 additions and 12 deletions
|
|
@ -322,26 +322,39 @@ const RULER_TIERS = [
|
|||
|
||||
//after manually comparing all fonts at all sizes, it was decides that in some cases it's more readable to round down the font size to a more readable
|
||||
// this is a lookup table for these optimal settings
|
||||
// An entry may also set `lineHeight` (px) and/or `tracking` (px, may be negative) to retune a
|
||||
// tier's spacing without touching its rendered glyphs at all - see drawMonoText's own doc comment
|
||||
// in freetype-preview.js for why (scaling a pixel font's bitmap to fit blurs it, so a tighter
|
||||
// lineHeight crops ascenders/descenders at the row edge instead, and tracking just overlaps
|
||||
// neighboring glyphs). Omit either field to fall back to the face's natural metrics.
|
||||
const optimal_fonts = (size) => {
|
||||
if (size > 32)
|
||||
return {family: "Inter", url: interCandidateFontUrl, size: size};
|
||||
return {family: "Inter", url: interCandidateFontUrl, size: size, lineHeight: size};
|
||||
if (size === 32)
|
||||
return {family: "Terminus", url: terminusFontUrl, size: 32, lineHeight: size}; // would even support bold mode
|
||||
if (size >= 28)
|
||||
return {family: "Terminus", url: terminusFontUrl, size: 28}; // would even support bold mode >=14px
|
||||
return {family: "Terminus", url: terminusFontUrl, size: 28, lineHeight: size}; // would even support bold mode
|
||||
if (size >= 24)
|
||||
return {family: "Terminus", url: terminusFontUrl, size: 24}; // would even support bold mode >=14px
|
||||
return {family: "Terminus", url: terminusFontUrl, size: 24, lineHeight: size}; // would even support bold mode
|
||||
if (size >= 12)
|
||||
return {family: "Terminus", url: terminusFontUrl, size: (size - (size % 2))}; // would even support bold mode >=14px
|
||||
return {family: "Terminus", url: terminusFontUrl, size: (size - (size % 2)), lineHeight: size}; // would even support bold mode >=14px
|
||||
if (size >= 10)
|
||||
return {family: "Pixelon", url: pixelonFontUrl, size: 10};
|
||||
return {family: "Pixelon", url: pixelonFontUrl, size: 10, lineHeight: size, tracking: -1};
|
||||
if (size >= 8)
|
||||
return {family: "Chava", url: chavaFontUrl, size: 8};
|
||||
if (size === 7)
|
||||
return {family: "Chava", url: chavaFontUrl, size: 7};
|
||||
if (size >= 5)
|
||||
return {family: "Silkscreen", url: silkscreenCandidateFontUrl, size: 8}; //Silkscreen comes out to an effective height of 5px at size 8
|
||||
return {family: "Chava", url: chavaFontUrl, size: 8, lineHeight: size};
|
||||
// TODO find or build better fonts for 6px, 7px and 9px
|
||||
// The criteria would be to make better use of the height available to be more readable
|
||||
if (size >= 6)
|
||||
return {family: "Silkscreen", url: silkscreenCandidateFontUrl, size: 8, lineHeight: size, tracking: -1}; //Silkscreen comes out to an effective height of 5px at size 8
|
||||
return null;
|
||||
};
|
||||
|
||||
// ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||
// abcdefghijklmnopqrstuvwxyz
|
||||
// 0123456789-_@~ /:
|
||||
// iiiiiiiiiiiiiiiiiiiiiiiiii
|
||||
// mmmmmmmmmmmmmmmmmmmmmmmmmm
|
||||
|
||||
export default {
|
||||
name: "Print",
|
||||
components: {
|
||||
|
|
@ -403,7 +416,7 @@ export default {
|
|||
niimbotCliExample: "niimprint --model b00 --conn usb print --density 3 --image label.png",
|
||||
|
||||
// Nominal sizes previewed by the "optimal font by size" card - 5px to 30px inclusive.
|
||||
previewSizes: Array.from({length: 36}, (_, i) => i + 5),
|
||||
previewSizes: Array.from({length: 36}, (_, i) => i + 6),
|
||||
previewZoom: 4,
|
||||
// Keyed by family, populated lazily the first time drawOptimalFontPreviews loads a font -
|
||||
// avoids refetching the same bytes on every varValues-triggered redraw.
|
||||
|
|
@ -823,7 +836,8 @@ export default {
|
|||
continue; // fails to parse for FreeType too - leave that cell blank.
|
||||
}
|
||||
this.freetypeLineHeights[size] =
|
||||
drawMonoText(ft, canvas, cfg.size, this.varValues.text, this.previewZoom);
|
||||
drawMonoText(ft, canvas, cfg.size, this.varValues.text, this.previewZoom,
|
||||
{lineHeight: cfg.lineHeight, tracking: cfg.tracking});
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue