Class DefaultFontRegistry
java.lang.Object
dev.jcputney.mjml.render.DefaultFontRegistry
Registry of well-known web fonts that MJML auto-imports when used in font-family. When a
component uses one of these fonts, it is automatically registered in the GlobalContext even
without an explicit
<mj-font> tag.-
Method Summary
Modifier and TypeMethodDescriptionBuilds a mutable set of currently registered font names from the given context.static voidregisterUsedFonts(String fontFamily, GlobalContext ctx) Checks the given font-family string against known default fonts and registers any matches in the GlobalContext (unless already registered by an explicit mj-font).static voidregisterUsedFonts(String fontFamily, GlobalContext ctx, Set<String> registeredNames) Checks the given font-family string against known default fonts and registers any matches in the GlobalContext (unless already registered by an explicit mj-font).
-
Method Details
-
registerUsedFonts
Checks the given font-family string against known default fonts and registers any matches in the GlobalContext (unless already registered by an explicit mj-font).- Parameters:
fontFamily- the CSS font-family string to check for known fontsctx- the global context to register discovered fonts in
-
registerUsedFonts
public static void registerUsedFonts(String fontFamily, GlobalContext ctx, Set<String> registeredNames) Checks the given font-family string against known default fonts and registers any matches in the GlobalContext (unless already registered by an explicit mj-font). This overload accepts a pre-built set of registered font names, avoiding the overhead of rebuilding it on every call. The caller is responsible for keeping the set in sync (the set is mutated in place when fonts are added).- Parameters:
fontFamily- the CSS font-family string to check for known fontsctx- the global context to register discovered fonts inregisteredNames- mutable set of already-registered font names for O(1) lookup
-
buildRegisteredNameSet
Builds a mutable set of currently registered font names from the given context.- Parameters:
ctx- the global context to read font registrations from- Returns:
- a mutable set of registered font names
-