-
Notifications
You must be signed in to change notification settings - Fork 2
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
Migrate to single layer text styling #3
base: main
Are you sure you want to change the base?
Conversation
Use After Effects 24.5.0x41 per-character styles
remove modified local copy
I only updated the deps really and moved stuff into the main files. @fartinmartin had a few questions, let me know what you think. Love the use of the reducer btw!
I feel like a simpler API of |
Woo! I can't remember exactly my reasoning for returning a render function, it may have been a hesitancy to auto run |
@fartinmartin updated a few things, let me know what you think. I rewrote the API to be simply
Quite a change, but think it all makes sense 😅 You might want to test it out, make sure I didn't break anything. Updated the README, but still need to do the tests. |
Oh nice! I like the idea of simplifying the API. However, maybe there's a way to keep some of the
So, my expression is now (unless I'm missing something!): const { parse } = footage("style-parser.jsx").sourceData.get();
const textLayer = thisComp.layer("Text:Input");
const inputText = textLayer.text.sourceText.value;
// can't set "regular" style via expressions—must set via UI
// thisLayer.text.sourceText.style.setFont("Menlo-Regular");
const defaultOverrides = [
{
name: "bold",
styles: { font: "Menlo-Bold" },
},
{
name: "italic",
styles: { font: "Menlo-Italic" },
},
{
name: "h1",
styles: { font: "Menlo-Bold" },
},
{
name: "h2",
styles: { font: "Menlo-Bold" },
},
{
name: "h3",
styles: { font: "Menlo-Bold" },
},
{
name: "h4",
styles: { font: "Menlo-Bold" },
},
{
name: "h5",
styles: { font: "Menlo-Bold" },
},
{
name: "h6",
styles: { font: "Menlo-Bold" },
},
];
const customParsers = [
...defaultOverrides,
{
style: "highlight",
matcher: /==(.+?)==/g,
styles: { fillColor: [1, 1, 0] },
},
];
parse(inputText, customParsers); Which feels a little heavy on boilerplate, maybe? What do you think? Also, I do like the ability to set base styles via expressions as it's more explicit than relying on the UI settings, but maybe more importantly—it'd be nice to have dynamic control of base styles. |
Yeah good point! Totally see what you mean. Adding in control over the default fonts makes sense, so you don't have to do each one manually. I'll add As for the base style agree setting the styles with expressions is often better then with the UI so we should have a way to allow that. I think my intuition would be to handle this outside of the How do you feel about optionally parsing in a const { parse } = footage("style-parser.jsx").sourceData.get();
const textStyle = thisLayer.text.sourceText.style.setFont("Arial");
parse(value, { textStyle }); |
So the API would be: parse(markdown: string,
parsers?: Parsers[],
fontMap?: FontMap,
textStyle?: TextStyle,
}): TextStyle; |
@fartinmartin okay updated the API, let me know what you think. Pretty sure it's all working well! |
@timhaywood hey, sorry for the delay! This looks great! Coming back to this code I felt like I needed to clarify some of the type names to help make sense of things—hope that's ok. I think the API you've landed on makes a lot of sense. Re: the const { parse, setStyles } = footage('style-parser.jsx').sourceData.get();
const inputText = thisComp.layer("Input").text.sourceText.value;
const textStyle = setStyles({
font: "ArialMT",
fontSize: 20,
});
parse(inputText, { textStyle }); Here's an example project with that idea: style-parser.zip |
Pretty much a full rewrite by @fartinmartin to make use of the new CC 2025 text style expressions, where you can set the style for a range of characters.
This enables markdown type rendering on a single text layer.