mirror of
https://github.com/HeyPuter/puter.git
synced 2026-11-03 12:33:07 +00:00
* fix(ui): honor the default font in showFontPicker on the desktop
String arguments are normalized to { defaultFont } in the IPC handler,
matching showColorPicker, instead of throwing on property assignment.
UIWindowFontPicker reads defaultValue/defaultFont/default case-
insensitively, and the SDK fallback and docs accept the same aliases.
* fix(ui): document the showFontPicker cancel result and alias order
The JSDoc gains overloads for the string and options call forms and
states that closing the picker resolves false in an app and null on a
website; the docs page and examples match. e2e coverage adds a
scroll-into-view check for the preselected font and a close-without-
selecting case.
1.4 KiB
Executable File
1.4 KiB
Executable File
title, description, platforms
| title | description | platforms | ||
|---|---|---|---|---|
| puter.ui.showFontPicker() | Presents a list of fonts for previewing and selecting. |
|
Presents the user with a list of fonts allowing them to preview and select a font.
Syntax
puter.ui.showFontPicker()
puter.ui.showFontPicker(defaultFont)
puter.ui.showFontPicker(options)
Parameters
defaultFont (String)
The default font to select when the font picker is opened.
options (Object)
An object with the following properties:
defaultFont(String): The font to select when the font picker is opened. The name is matched without regard to case.defaultValueanddefaultare accepted as aliases. If more than one is given,defaultValueis used, thendefaultFont, thendefault.
Return value
A Promise that resolves to an object with a fontFamily property holding the name of the selected font. If the user closes the picker without selecting a font, the promise resolves to false in a Puter app and to null on a website.
Examples
<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<h1>A cool Font Picker demo!</h1>
<script>
puter.ui.showFontPicker().then((font)=>{
if (font) {
document.body.style.fontFamily = font.fontFamily;
}
})
</script>
</body>
</html>