Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Support custom fonts, custom CSS style overrides #30

Merged
merged 18 commits into from
Dec 15, 2022

Conversation

bigtimebuddy
Copy link
Contributor

@bigtimebuddy bigtimebuddy commented Dec 1, 2022

Closes #2
Closes #13

Fixes

  • Fixes cross-browser issues:
    • Safari flips the Y-axis when using text-shadow
    • More consistent to scale style values with resolution than use context.scale when drawing image

Adds

Loading Custom Fonts

Allows the use of non-web fonts by loading the fonts.

const text = new HTMLText("Hello <b>World</b>", { fontFamily: 'Custom' });

await Promise.all([
    text.style.loadFont('./path/to/custom-regular.ttf', { family: 'Custom' }),
    text.style.loadFont('./path/to/custom-bold.ttf', { family: 'Custom', weight: 'bold' });
]);

CSS Overrides

Allows settings CSS styles that are not built-in by default.

const text = new HTMLText('Hello World');

text.style.addOverride(
  'background-color: blue',
  'writing-mode: vertical-rl'
);

Global CSS Rules

Setting global rules is now easy using the stylesheet property.

const text = new HTMLText('Hello World');

text.style.stylesheet = `b { color: red }`;

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

writing-mode is not supported Custom fonts not working
1 participant