@ggraphic/editor 0.1.0-alpha.5 → 0.1.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CanvasEditorProvider.d.ts +6 -1
- package/dist/components/CanvasEditor/CanvasEditorShell.js +139 -36
- package/dist/components/CanvasEditor/editorShell.d.ts +6 -0
- package/dist/components/CanvasEditor/types.d.ts +28 -0
- package/dist/components/GenericCanvas.d.ts +19 -2
- package/dist/components/GenericCanvas.js +28 -3
- package/dist/components/GenericCanvasElement.js +15 -1
- package/dist/components/PagePreview.d.ts +8 -1
- package/dist/components/PagePreview.js +4 -1
- package/dist/components/TopBar/ContextControls.js +1 -1
- package/dist/components/TopBar/DownloadSection.d.ts +24 -3
- package/dist/components/TopBar/DownloadSection.js +45 -7
- package/dist/components/TopBar/ShareDropdown.d.ts +4 -2
- package/dist/components/TopBar/ShareDropdown.js +2 -2
- package/dist/components/TopBar/modules/FloatingFontSizeControl.d.ts +3 -1
- package/dist/components/TopBar/modules/FloatingFontSizeControl.js +46 -4
- package/dist/components/kindRenderers.js +10 -1
- package/dist/entries/export.d.ts +14 -1
- package/dist/entries/export.js +14 -1
- package/dist/entries/services.d.ts +1 -1
- package/dist/export/fonts/fontFiles.d.ts +100 -0
- package/dist/export/fonts/fontFiles.js +333 -0
- package/dist/export/fonts/glyphs.d.ts +113 -0
- package/dist/export/fonts/glyphs.js +120 -0
- package/dist/export/fonts/variation.d.ts +23 -0
- package/dist/export/fonts/variation.js +43 -0
- package/dist/export/pdf/pdfContent.d.ts +108 -0
- package/dist/export/pdf/pdfContent.js +566 -0
- package/dist/export/pdf/pdfFontkit.d.ts +54 -0
- package/dist/export/pdf/pdfFontkit.js +159 -0
- package/dist/export/pdf/pdfGeometry.d.ts +54 -0
- package/dist/export/pdf/pdfGeometry.js +228 -0
- package/dist/export/pdf/pdfResources.d.ts +109 -0
- package/dist/export/pdf/pdfResources.js +314 -0
- package/dist/export/pdf/writePdf.d.ts +34 -0
- package/dist/export/pdf/writePdf.js +165 -0
- package/dist/export/pptx/exportPptxDeck.d.ts +10 -2
- package/dist/export/pptx/exportPptxDeck.js +5 -2
- package/dist/export/pptx/svgPicture.d.ts +19 -0
- package/dist/export/pptx/svgPicture.js +64 -0
- package/dist/export/pptx/vectorizeElement.d.ts +9 -0
- package/dist/export/pptx/vectorizeElement.js +118 -0
- package/dist/export/pptx/writePptx.d.ts +13 -0
- package/dist/export/pptx/writePptx.js +17 -0
- package/dist/export/printPdf.d.ts +1 -0
- package/dist/export/printPdf.js +1 -1
- package/dist/export/scene/browserDeps.d.ts +32 -0
- package/dist/export/scene/browserDeps.js +174 -0
- package/dist/export/scene/imageBytes.d.ts +79 -0
- package/dist/export/scene/imageBytes.js +330 -0
- package/dist/export/scene/itemBounds.d.ts +9 -0
- package/dist/export/scene/itemBounds.js +40 -0
- package/dist/export/scene/matrix.d.ts +13 -0
- package/dist/export/scene/matrix.js +32 -0
- package/dist/export/scene/rasterLimit.d.ts +13 -0
- package/dist/export/scene/rasterLimit.js +24 -0
- package/dist/export/scene/rebaseOps.d.ts +8 -0
- package/dist/export/scene/rebaseOps.js +51 -0
- package/dist/export/scene/recordPageScene.d.ts +28 -0
- package/dist/export/scene/recordPageScene.js +224 -0
- package/dist/export/scene/recordingCanvas.d.ts +55 -0
- package/dist/export/scene/recordingCanvas.js +71 -0
- package/dist/export/scene/recordingContext.d.ts +162 -0
- package/dist/export/scene/recordingContext.js +1031 -0
- package/dist/export/scene/replayScene.d.ts +31 -0
- package/dist/export/scene/replayScene.js +213 -0
- package/dist/export/scene/resolveScene.d.ts +48 -0
- package/dist/export/scene/resolveScene.js +236 -0
- package/dist/export/scene/trustedSvgImages.d.ts +3 -0
- package/dist/export/scene/trustedSvgImages.js +21 -0
- package/dist/export/scene/types.d.ts +241 -0
- package/dist/export/scene/types.js +38 -0
- package/dist/export/slidesPdf.d.ts +10 -2
- package/dist/export/slidesPdf.js +8 -4
- package/dist/export/svg/__fixtures__/barChart.svg +1 -0
- package/dist/export/svg/__golden__/fixture-editable.svg +87 -0
- package/dist/export/svg/__golden__/fixture-outlines.svg +88 -0
- package/dist/export/svg/inlineSvg.d.ts +10 -0
- package/dist/export/svg/inlineSvg.js +119 -0
- package/dist/export/svg/scopeCss.d.ts +45 -0
- package/dist/export/svg/scopeCss.js +214 -0
- package/dist/export/svg/svgColor.d.ts +8 -0
- package/dist/export/svg/svgColor.js +46 -0
- package/dist/export/svg/svgImageScene.d.ts +41 -0
- package/dist/export/svg/svgImageScene.js +128 -0
- package/dist/export/svg/svgPathData.d.ts +31 -0
- package/dist/export/svg/svgPathData.js +466 -0
- package/dist/export/svg/svgToScene.d.ts +19 -0
- package/dist/export/svg/svgToScene.js +1183 -0
- package/dist/export/svg/writeSvg.d.ts +33 -0
- package/dist/export/svg/writeSvg.js +594 -0
- package/dist/export/svg/xml.d.ts +23 -0
- package/dist/export/svg/xml.js +49 -0
- package/dist/export/vectorDeps.d.ts +27 -0
- package/dist/export/vectorDeps.js +37 -0
- package/dist/export/vectorExport.d.ts +85 -0
- package/dist/export/vectorExport.js +287 -0
- package/dist/hooks/useLiveFontSize.d.ts +6 -0
- package/dist/hooks/useLiveFontSize.js +26 -0
- package/dist/hostServices.d.ts +15 -0
- package/dist/i18n/de.d.ts +27 -9
- package/dist/i18n/de.js +27 -10
- package/dist/i18n/en.js +25 -0
- package/dist/page/actions.js +8 -2
- package/dist/primitives/AssetPrimitive.js +7 -2
- package/dist/primitives/CanvasIcons.js +6 -0
- package/dist/primitives/CanvasImage.js +86 -12
- package/dist/primitives/CanvasRichText.js +10 -5
- package/dist/primitives/CanvasStage.js +2 -2
- package/dist/primitives/CanvasText.d.ts +8 -1
- package/dist/primitives/CanvasText.js +25 -5
- package/dist/primitives/ChartPrimitive.d.ts +11 -1
- package/dist/primitives/ChartPrimitive.js +73 -19
- package/dist/primitives/IconPrimitive.js +3 -0
- package/dist/primitives/IllustrationPrimitive.js +14 -1
- package/dist/primitives/chartFont.d.ts +30 -0
- package/dist/primitives/chartFont.js +127 -0
- package/dist/sidebar/sections/ImageAdjustSection.js +5 -4
- package/dist/sidebar/sections/assets/ElementsPanel.js +4 -2
- package/dist/sidebar/sections/assets/assetAudience.d.ts +12 -0
- package/dist/sidebar/sections/assets/assetAudience.js +18 -0
- package/dist/sidebar/sections/assets/useElementCatalog.js +3 -2
- package/dist/styles/compiled.css +1 -1
- package/dist/utils/canvasAssets.d.ts +11 -1
- package/dist/utils/canvasAssets.js +8 -0
- package/dist/utils/canvasIcons.js +5 -3
- package/dist/utils/captureStage.d.ts +19 -0
- package/dist/utils/captureStage.js +14 -1
- package/dist/utils/cropGhost.d.ts +3 -2
- package/dist/utils/cropGhost.js +4 -3
- package/dist/utils/externalIcons.d.ts +7 -0
- package/dist/utils/externalIcons.js +70 -3
- package/dist/utils/filteredPan.d.ts +22 -0
- package/dist/utils/filteredPan.js +36 -0
- package/dist/utils/illustrations/svgCache.js +6 -1
- package/dist/utils/imageFilters.d.ts +13 -0
- package/dist/utils/imageFilters.js +11 -0
- package/dist/utils/zipPageImages.d.ts +8 -0
- package/dist/utils/zipPageImages.js +16 -4
- package/package.json +6 -2
- package/skills/ggraphic-embed/SKILL.md +33 -1
|
@@ -39,13 +39,15 @@ function ProgressBar({ progress }) {
|
|
|
39
39
|
}
|
|
40
40
|
const DEFAULT_RASTER_PIXEL_RATIO = 1;
|
|
41
41
|
const SCALE_OPTIONS = [1, 2];
|
|
42
|
-
export function DownloadSection({ onDownload, onDownloadAllZip, pageCount, isMultiExporting = false, exportProgress, exportError, exportNotice, printExport = null, slideDeck = null, }) {
|
|
42
|
+
export function DownloadSection({ onDownload, onDownloadAllZip, pageCount, isMultiExporting = false, exportProgress, exportError, exportNotice, printExport = null, slideDeck = null, vectorExport = null, }) {
|
|
43
43
|
const t = useMessages();
|
|
44
44
|
const [choice, setChoice] = useState(printExport ? 'pdf' : slideDeck ? 'pptx' : 'png');
|
|
45
45
|
const [pptxProgress, setPptxProgress] = useState(null);
|
|
46
46
|
const [printWarnings] = useState(() => printExport?.getWarnings() ?? []);
|
|
47
47
|
const [scale, setScale] = useState(DEFAULT_RASTER_PIXEL_RATIO);
|
|
48
48
|
const [transparent, setTransparent] = useState(false);
|
|
49
|
+
const [keepTextEditable, setKeepTextEditable] = useState(false);
|
|
50
|
+
const [report, setReport] = useState(null);
|
|
49
51
|
const [pageSelection, setPageSelection] = useState('current');
|
|
50
52
|
const [isDownloading, setIsDownloading] = useState(false);
|
|
51
53
|
const [downloadError, setDownloadError] = useState(null);
|
|
@@ -59,22 +61,49 @@ export function DownloadSection({ onDownload, onDownloadAllZip, pageCount, isMul
|
|
|
59
61
|
impressumGate?.ready === true &&
|
|
60
62
|
!impressum.isComplete(impressum.parse(impressumGate.locale, impressumGate.text ?? ''));
|
|
61
63
|
const isSlidesPdf = choice === 'pdf' && slideDeck !== null;
|
|
64
|
+
// A digital format has no print or slide service: its PDF comes with the vector export.
|
|
65
|
+
const isDigitalPdf = choice === 'pdf' && !printExport && !slideDeck && vectorExport !== null;
|
|
62
66
|
const isPptx = choice === 'pptx' && slideDeck !== null;
|
|
63
|
-
const
|
|
67
|
+
const isSvg = choice === 'svg' && vectorExport !== null;
|
|
68
|
+
// A PDF always holds every page, so it asks nothing.
|
|
69
|
+
const isMultiPage = pageCount > 1 &&
|
|
70
|
+
(isSvg || (onDownloadAllZip && !isPdf && !isSlidesPdf && !isDigitalPdf && !isPptx));
|
|
71
|
+
// What the person is told after a vector download: SVG, and every PDF but the old raster one.
|
|
72
|
+
const reportsExport = isSvg || choice === 'pdf';
|
|
64
73
|
// JPEG has no alpha channel — the transparency toggle is only meaningful for
|
|
65
74
|
// PNG/WebP.
|
|
66
75
|
const supportsTransparency = choice !== 'jpeg';
|
|
67
|
-
|
|
76
|
+
// A print page or a slide always has its background; only a digital format can leave it out.
|
|
77
|
+
const svgTransparency = vectorExport?.category === 'digital';
|
|
78
|
+
const rasterFormat = choice === 'pdf' || choice === 'pptx' || choice === 'svg' ? 'png' : choice;
|
|
79
|
+
const downloadPanel = t.shell.downloadPanel;
|
|
80
|
+
// Once each, in the order they happened: the same reason on three photos is one phrase.
|
|
81
|
+
const rasterReasons = [
|
|
82
|
+
...new Set(report?.rasterIslands.map((island) => downloadPanel.rasterReason[island.reason])),
|
|
83
|
+
];
|
|
68
84
|
const handleDownload = async () => {
|
|
69
85
|
setIsDownloading(true);
|
|
70
86
|
setDownloadError(null);
|
|
87
|
+
setReport(null);
|
|
71
88
|
try {
|
|
89
|
+
if (isSvg && vectorExport) {
|
|
90
|
+
setReport(await vectorExport.onDownloadSvg({
|
|
91
|
+
pages: pageCount > 1 ? pageSelection : 'current',
|
|
92
|
+
text: keepTextEditable ? 'editable' : 'outlines',
|
|
93
|
+
transparent: svgTransparency && transparent,
|
|
94
|
+
}));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
72
97
|
if (choice === 'pdf' && printExport) {
|
|
73
|
-
await printExport.onDownloadPdf();
|
|
98
|
+
setReport((await printExport.onDownloadPdf()) ?? null);
|
|
74
99
|
return;
|
|
75
100
|
}
|
|
76
101
|
if (isSlidesPdf && slideDeck) {
|
|
77
|
-
await slideDeck.onDownloadPdf();
|
|
102
|
+
setReport((await slideDeck.onDownloadPdf()) ?? null);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (isDigitalPdf && vectorExport) {
|
|
106
|
+
setReport(await vectorExport.onDownloadPdf());
|
|
78
107
|
return;
|
|
79
108
|
}
|
|
80
109
|
if (isPptx && slideDeck) {
|
|
@@ -97,6 +126,15 @@ export function DownloadSection({ onDownload, onDownloadAllZip, pageCount, isMul
|
|
|
97
126
|
setPptxProgress(null);
|
|
98
127
|
}
|
|
99
128
|
};
|
|
100
|
-
return (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: `${fieldId}-format`, className: "text-xs font-medium text-foreground-muted", children: t.shell.downloadPanel.format }), _jsxs(Select, { value: choice, onValueChange: (v) =>
|
|
101
|
-
|
|
129
|
+
return (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: `${fieldId}-format`, className: "text-xs font-medium text-foreground-muted", children: t.shell.downloadPanel.format }), _jsxs(Select, { value: choice, onValueChange: (v) => {
|
|
130
|
+
setChoice(v);
|
|
131
|
+
// What the last download reported is about that format only.
|
|
132
|
+
setReport(null);
|
|
133
|
+
}, children: [_jsx(SelectTrigger, { id: `${fieldId}-format`, size: "sm", className: "w-full", children: _jsx(SelectValue, {}) }), _jsxs(SelectContent, { position: "popper", className: "z-[10001]", children: [printExport && _jsx(SelectItem, { value: "pdf", children: t.shell.downloadPanel.pdfPrint }), slideDeck && _jsx(SelectItem, { value: "pptx", children: "PowerPoint (.pptx)" }), slideDeck && _jsx(SelectItem, { value: "pdf", children: "PDF" }), vectorExport && (printExport || slideDeck) && (_jsx(SelectItem, { value: "svg", children: downloadPanel.svg })), _jsx(SelectItem, { value: "png", children: "PNG" }), !printExport && _jsx(SelectItem, { value: "jpeg", children: "JPG" }), !printExport && _jsx(SelectItem, { value: "webp", children: "WebP" }), vectorExport && !printExport && !slideDeck && (_jsxs(_Fragment, { children: [_jsx(SelectItem, { value: "pdf", children: "PDF" }), _jsx(SelectItem, { value: "svg", children: downloadPanel.svg })] }))] })] })] }), !isPdf &&
|
|
134
|
+
!isSlidesPdf &&
|
|
135
|
+
!isDigitalPdf &&
|
|
136
|
+
!isPptx &&
|
|
137
|
+
!isSvg &&
|
|
138
|
+
pageSelection === 'current' && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: `${fieldId}-scale`, className: "text-xs font-medium text-foreground-muted", children: t.shell.downloadPanel.resolution }), _jsxs(Select, { value: String(scale), onValueChange: (v) => setScale(Number(v)), children: [_jsx(SelectTrigger, { id: `${fieldId}-scale`, size: "sm", className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { position: "popper", className: "z-[10001]", children: SCALE_OPTIONS.map((s) => (_jsxs(SelectItem, { value: String(s), children: [s, "\u00D7", ' ', s === DEFAULT_RASTER_PIXEL_RATIO ? t.shell.downloadPanel.defaultMark : ''] }, s))) })] })] }), supportsTransparency && (_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx(Label, { htmlFor: `${fieldId}-transparent`, className: "text-xs font-medium text-foreground-muted", children: t.shell.downloadPanel.transparentBackground }), _jsx(Switch, { id: `${fieldId}-transparent`, checked: transparent, onCheckedChange: setTransparent })] }))] })), isSvg && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex flex-col gap-1", children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx(Label, { htmlFor: `${fieldId}-editable-text`, className: "text-xs font-medium text-foreground-muted", children: downloadPanel.keepTextEditable }), _jsx(Switch, { id: `${fieldId}-editable-text`, "aria-describedby": `${fieldId}-editable-text-hint`, checked: keepTextEditable, onCheckedChange: setKeepTextEditable })] }), _jsx("p", { id: `${fieldId}-editable-text-hint`, className: "m-0 text-xs text-foreground-muted", children: downloadPanel.keepTextEditableHint })] }), svgTransparency && (_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx(Label, { htmlFor: `${fieldId}-transparent`, className: "text-xs font-medium text-foreground-muted", children: downloadPanel.transparentBackground }), _jsx(Switch, { id: `${fieldId}-transparent`, checked: transparent, onCheckedChange: setTransparent })] }))] })), isMultiPage && (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: `${fieldId}-pages`, className: "text-xs font-medium text-foreground-muted", children: t.shell.downloadPanel.selectPages }), _jsxs(Select, { value: pageSelection, onValueChange: (v) => setPageSelection(v), children: [_jsx(SelectTrigger, { id: `${fieldId}-pages`, size: "sm", className: "w-full", children: _jsx(SelectValue, {}) }), _jsxs(SelectContent, { position: "popper", className: "z-[10001]", children: [_jsx(SelectItem, { value: "current", children: t.shell.downloadPanel.currentPage }), _jsx(SelectItem, { value: "all", children: t.shell.allPagesZip(pageCount) })] })] })] })), isMultiExporting && exportProgress && exportProgress.total > 0 && (_jsx(ProgressBar, { progress: exportProgress })), pptxProgress && pptxProgress.total > 0 && _jsx(ProgressBar, { progress: pptxProgress }), impressumMissing && impressumGate && impressum && (_jsxs(_Fragment, { children: [_jsx(DownloadNotice, { tone: "info", children: t.shell.downloadPanel.imprintMissingNotice }), _jsx(ImpressumForm, { gate: impressumGate, impressum: impressum })] })), isPdf && print?.untestedNotice && (_jsx(DownloadNotice, { tone: "info", children: print.untestedNotice })), isPptx && slideDeck && carousel?.pptxFontHint && (_jsx(DownloadNotice, { tone: "info", children: carousel.pptxFontHint[slideDeck.locale] })), isPdf &&
|
|
139
|
+
printWarnings.map((warning) => (_jsx(DownloadNotice, { tone: "info", children: warning }, warning))), downloadError && _jsx(DownloadNotice, { children: downloadError }), exportError && !isMultiExporting && _jsx(DownloadNotice, { children: exportError }), exportNotice && _jsx(DownloadNotice, { tone: "info", children: exportNotice }), _jsxs(Button, { variant: "brand", className: "w-full rounded-lg", onClick: handleDownload, disabled: isDownloading || isMultiExporting, children: [isDownloading || isMultiExporting ? (_jsx(Skeleton, { className: "size-3.5 rounded-full" })) : (_jsx(PiDownloadSimple, { className: "size-3.5" })), isDownloading ? t.shell.downloading : t.shell.download] }), reportsExport && report?.fallback && (_jsx(DownloadNotice, { tone: "info", children: downloadPanel.pdfFallbackNotice[report.fallback.kind] })), reportsExport && report && report.missingElements.length > 0 && (_jsx(DownloadNotice, { children: downloadPanel.missingNotice(report.missingElements.length) })), reportsExport && report && report.reducedRasters.length > 0 && (_jsx(DownloadNotice, { tone: "info", children: downloadPanel.reducedRasterNotice })), reportsExport && report && report.defaultInstanceFonts.length > 0 && (_jsx(DownloadNotice, { tone: "info", children: downloadPanel.variableFontNotice(report.defaultInstanceFonts.join(', ')) })), reportsExport && rasterReasons.length > 0 && (_jsx(DownloadNotice, { tone: "info", children: downloadPanel.rasterNotice(rasterReasons.join(', ')) }))] }));
|
|
102
140
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CanvasDownloadChoice, type PrintExportProps, type SlideDeckExportProps } from './DownloadSection.js';
|
|
1
|
+
import { type CanvasDownloadChoice, type PrintExportProps, type SlideDeckExportProps, type VectorExportProps } from './DownloadSection.js';
|
|
2
2
|
export interface ShareDropdownProps {
|
|
3
3
|
onCaptureCanvas: () => Promise<string | null>;
|
|
4
4
|
onDownload: (format: CanvasDownloadChoice, pixelRatio: number, transparent: boolean) => void | Promise<void>;
|
|
@@ -22,6 +22,8 @@ export interface ShareDropdownProps {
|
|
|
22
22
|
printExport?: PrintExportProps | null;
|
|
23
23
|
/** Set for slide formats: the download section offers PowerPoint and a PDF of all pages. */
|
|
24
24
|
slideDeck?: SlideDeckExportProps | null;
|
|
25
|
+
/** SVG download; without it the download section offers no SVG. */
|
|
26
|
+
vectorExport?: VectorExportProps | null;
|
|
25
27
|
/**
|
|
26
28
|
* Optional host-supplied "invite people" action. When provided, the share
|
|
27
29
|
* popover shows a "Personen" icon button that opens the host's collaborator
|
|
@@ -51,4 +53,4 @@ export interface ShareDropdownProps {
|
|
|
51
53
|
*/
|
|
52
54
|
getPhotoCredit?: () => string;
|
|
53
55
|
}
|
|
54
|
-
export declare function ShareDropdown({ onCaptureCanvas, onDownload, onNavigateToGallery, canvasText, canvasWidth, canvasHeight, shareToken, pageCount, onDownloadAllZip, onShareAllPages, isMultiExporting, exportProgress, exportError, exportNotice, printExport, slideDeck, onInvitePeople, onSaveAsTemplate, hostControl, getPhotoCredit, }: ShareDropdownProps): import("react").JSX.Element;
|
|
56
|
+
export declare function ShareDropdown({ onCaptureCanvas, onDownload, onNavigateToGallery, canvasText, canvasWidth, canvasHeight, shareToken, pageCount, onDownloadAllZip, onShareAllPages, isMultiExporting, exportProgress, exportError, exportNotice, printExport, slideDeck, vectorExport, onInvitePeople, onSaveAsTemplate, hostControl, getPhotoCredit, }: ShareDropdownProps): import("react").JSX.Element;
|
|
@@ -16,7 +16,7 @@ import { useIsCanvasMobile } from '../../hooks/useIsCanvasMobile.js';
|
|
|
16
16
|
import { AltTextField, useCaptionAltText, useShareAltText, withAltText, } from '../../sidebar/components/AltTextField.js';
|
|
17
17
|
import { withPhotoCredit } from '../../utils/photoCredit.js';
|
|
18
18
|
import { DownloadSection, } from './DownloadSection.js';
|
|
19
|
-
export function ShareDropdown({ onCaptureCanvas, onDownload, onNavigateToGallery, canvasText, canvasWidth, canvasHeight, shareToken, pageCount = 1, onDownloadAllZip, onShareAllPages, isMultiExporting = false, exportProgress, exportError, exportNotice, printExport, slideDeck, onInvitePeople, onSaveAsTemplate, hostControl, getPhotoCredit, }) {
|
|
19
|
+
export function ShareDropdown({ onCaptureCanvas, onDownload, onNavigateToGallery, canvasText, canvasWidth, canvasHeight, shareToken, pageCount = 1, onDownloadAllZip, onShareAllPages, isMultiExporting = false, exportProgress, exportError, exportNotice, printExport, slideDeck, vectorExport, onInvitePeople, onSaveAsTemplate, hostControl, getPhotoCredit, }) {
|
|
20
20
|
const t = useMessages();
|
|
21
21
|
const isMobile = useIsCanvasMobile();
|
|
22
22
|
const [ownOpen, setOwnOpen] = useState(false);
|
|
@@ -92,7 +92,7 @@ export function ShareDropdown({ onCaptureCanvas, onDownload, onNavigateToGallery
|
|
|
92
92
|
setOpen(v);
|
|
93
93
|
if (!v)
|
|
94
94
|
setView('main');
|
|
95
|
-
}, children: [hostControl ? (_jsx(PopoverAnchor, { className: "absolute right-3 top-0 size-0" })) : (_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { size: "sm", className: "ml-auto h-9 rounded-full bg-white px-4 font-extrabold text-[var(--editor-green-deep)] hover:bg-white/90 max-canvas-mobile:h-8 max-canvas-mobile:px-3", children: [_jsx(IoShareOutline, { className: "size-4" }), _jsx("span", { children: t.shell.share })] }) })), _jsxs(PopoverContent, { align: "end", sideOffset: 8, className: "w-80 p-0 overflow-hidden", children: [view === 'download' ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "px-4 pt-3 pb-1", children: _jsxs("button", { type: "button", onClick: () => setView('main'), className: "flex items-center gap-2 bg-transparent border-none cursor-pointer p-0 text-sm font-semibold text-foreground transition-colors duration-150 hover:text-primary-600", children: [_jsx(PiArrowLeft, { size: 16 }), "Download"] }) }), _jsx("div", { className: "px-4 pt-2 pb-4", children: _jsx(DownloadSection, { onDownload: onDownload, onDownloadAllZip: onDownloadAllZip, pageCount: pageCount, isMultiExporting: isMultiExporting, exportProgress: exportProgress, exportError: exportError, exportNotice: exportNotice, printExport: printExport, slideDeck: slideDeck }) })] })) : (_jsxs(_Fragment, { children: [_jsx("div", { className: "px-4 pt-4 pb-2", children: _jsx("h3", { className: "text-base font-semibold text-foreground m-0", children: t.shell.share }) }), _jsxs(IconButtonRow, { gap: "lg", padding: "md", className: "justify-center py-3", children: [_jsx(IconButton, { size: "sm", icon: _jsx(PiDownloadSimple, {}), label: t.shell.downloadTab, onClick: () => setView('download') }), shareRoute !== null && (_jsx(IconButton, { size: "sm", icon: isSharing ? (_jsx(Skeleton, { className: "size-4 rounded-full" })) : shareSuccess ? (_jsx(PiCheck, {})) : (_jsx(IoShareOutline, {})), label: shareSuccess ? t.shell.shared : t.shell.share, onClick: handleNativeShare, disabled: isSharing })), onSaveAsTemplate && (_jsx(IconButton, { size: "sm", icon: _jsx(PiFloppyDisk, {}), label: t.shell.template, onClick: () => {
|
|
95
|
+
}, children: [hostControl ? (_jsx(PopoverAnchor, { className: "absolute right-3 top-0 size-0" })) : (_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { size: "sm", className: "ml-auto h-9 rounded-full bg-white px-4 font-extrabold text-[var(--editor-green-deep)] hover:bg-white/90 max-canvas-mobile:h-8 max-canvas-mobile:px-3", children: [_jsx(IoShareOutline, { className: "size-4" }), _jsx("span", { children: t.shell.share })] }) })), _jsxs(PopoverContent, { align: "end", sideOffset: 8, className: "w-80 p-0 overflow-hidden", children: [view === 'download' ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "px-4 pt-3 pb-1", children: _jsxs("button", { type: "button", onClick: () => setView('main'), className: "flex items-center gap-2 bg-transparent border-none cursor-pointer p-0 text-sm font-semibold text-foreground transition-colors duration-150 hover:text-primary-600", children: [_jsx(PiArrowLeft, { size: 16 }), "Download"] }) }), _jsx("div", { className: "px-4 pt-2 pb-4", children: _jsx(DownloadSection, { onDownload: onDownload, onDownloadAllZip: onDownloadAllZip, pageCount: pageCount, isMultiExporting: isMultiExporting, exportProgress: exportProgress, exportError: exportError, exportNotice: exportNotice, printExport: printExport, slideDeck: slideDeck, vectorExport: vectorExport }) })] })) : (_jsxs(_Fragment, { children: [_jsx("div", { className: "px-4 pt-4 pb-2", children: _jsx("h3", { className: "text-base font-semibold text-foreground m-0", children: t.shell.share }) }), _jsxs(IconButtonRow, { gap: "lg", padding: "md", className: "justify-center py-3", children: [_jsx(IconButton, { size: "sm", icon: _jsx(PiDownloadSimple, {}), label: t.shell.downloadTab, onClick: () => setView('download') }), shareRoute !== null && (_jsx(IconButton, { size: "sm", icon: isSharing ? (_jsx(Skeleton, { className: "size-4 rounded-full" })) : shareSuccess ? (_jsx(PiCheck, {})) : (_jsx(IoShareOutline, {})), label: shareSuccess ? t.shell.shared : t.shell.share, onClick: handleNativeShare, disabled: isSharing })), onSaveAsTemplate && (_jsx(IconButton, { size: "sm", icon: _jsx(PiFloppyDisk, {}), label: t.shell.template, onClick: () => {
|
|
96
96
|
setOpen(false);
|
|
97
97
|
onSaveAsTemplate();
|
|
98
98
|
} })), onInvitePeople && (_jsx(IconButton, { size: "sm", icon: _jsx(PiUserPlus, {}), label: t.shell.people, onClick: () => {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface FloatingFontSizeControlProps {
|
|
3
|
+
/** The text the field belongs to: while a corner drag scales it, the field shows the live size. */
|
|
4
|
+
elementId: string;
|
|
3
5
|
fontSize: number;
|
|
4
6
|
onFontSizeChange: (size: number) => void;
|
|
5
7
|
}
|
|
6
|
-
export declare function FloatingFontSizeControl({ fontSize, onFontSizeChange, }: FloatingFontSizeControlProps): React.JSX.Element;
|
|
8
|
+
export declare function FloatingFontSizeControl({ elementId, fontSize: committedFontSize, onFontSizeChange, }: FloatingFontSizeControlProps): React.JSX.Element;
|
|
7
9
|
export {};
|
|
@@ -2,20 +2,62 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
3
3
|
import { TileCaption, useBarTiles } from '../barTiles.js';
|
|
4
4
|
import { useMessages } from '../../../i18n/messages.js';
|
|
5
|
+
import { useLiveFontSize } from '../../../hooks/useLiveFontSize.js';
|
|
6
|
+
import { useState } from 'react';
|
|
5
7
|
import { PiPlus, PiMinus } from 'react-icons/pi';
|
|
6
8
|
const fontBtn = 'touch-target size-7 rounded-md border-none bg-transparent cursor-pointer flex items-center justify-center text-[var(--editor-text-secondary)] transition-colors duration-150 hover:enabled:bg-[var(--editor-surface-hover)] hover:enabled:text-[var(--editor-active-fg)] disabled:opacity-30 disabled:cursor-not-allowed';
|
|
7
|
-
|
|
9
|
+
const MIN_FONT_SIZE = 2;
|
|
10
|
+
const MAX_FONT_SIZE = 800;
|
|
11
|
+
const clampFontSize = (size) => Math.min(MAX_FONT_SIZE, Math.max(MIN_FONT_SIZE, Math.round(size)));
|
|
12
|
+
export function FloatingFontSizeControl({ elementId, fontSize: committedFontSize, onFontSizeChange, }) {
|
|
13
|
+
// Subscribed here, not in the bar: a drag re-renders this field only, once per whole size step.
|
|
14
|
+
const liveFontSize = useLiveFontSize(elementId);
|
|
15
|
+
const fontSize = liveFontSize ?? committedFontSize;
|
|
8
16
|
const t = useMessages();
|
|
9
17
|
const tiles = useBarTiles();
|
|
18
|
+
// What is typed, while the field has focus; null shows the text's size (live during a corner drag).
|
|
19
|
+
const [draft, setDraft] = useState(null);
|
|
20
|
+
const apply = (size) => {
|
|
21
|
+
const next = clampFontSize(size);
|
|
22
|
+
if (next !== Math.round(fontSize))
|
|
23
|
+
onFontSizeChange(next);
|
|
24
|
+
};
|
|
25
|
+
const commitDraft = () => {
|
|
26
|
+
if (draft === null)
|
|
27
|
+
return;
|
|
28
|
+
const parsed = Number(draft.replace(',', '.'));
|
|
29
|
+
setDraft(null);
|
|
30
|
+
if (draft.trim() !== '' && Number.isFinite(parsed))
|
|
31
|
+
apply(parsed);
|
|
32
|
+
};
|
|
33
|
+
const handleKeyDown = (e) => {
|
|
34
|
+
if (e.key === 'Enter') {
|
|
35
|
+
commitDraft();
|
|
36
|
+
e.currentTarget.blur();
|
|
37
|
+
}
|
|
38
|
+
else if (e.key === 'Escape') {
|
|
39
|
+
setDraft(null);
|
|
40
|
+
e.currentTarget.blur();
|
|
41
|
+
}
|
|
42
|
+
else if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
const step = (e.shiftKey ? 10 : 1) * (e.key === 'ArrowUp' ? 1 : -1);
|
|
45
|
+
setDraft(null);
|
|
46
|
+
apply(fontSize + step);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
10
49
|
const handleIncrease = (e) => {
|
|
11
50
|
e.stopPropagation();
|
|
12
|
-
|
|
51
|
+
apply(fontSize + 2);
|
|
13
52
|
};
|
|
14
53
|
const handleDecrease = (e) => {
|
|
15
54
|
e.stopPropagation();
|
|
16
|
-
|
|
55
|
+
apply(fontSize - 2);
|
|
17
56
|
};
|
|
18
|
-
const stepper = (_jsxs("div", { className: "flex items-center h-[34px] shrink-0 rounded-lg border border-[var(--editor-border-strong)] px-0.5", children: [_jsx("button", { className: fontBtn, onClick: handleDecrease, title: t.topBar.fontSmaller, "aria-label": t.topBar.fontSmaller, type: "button", children: _jsx(PiMinus, { size: 10 }) }), _jsx("
|
|
57
|
+
const stepper = (_jsxs("div", { className: "flex items-center h-[34px] shrink-0 rounded-lg border border-[var(--editor-border-strong)] px-0.5", children: [_jsx("button", { className: fontBtn, onClick: handleDecrease, title: t.topBar.fontSmaller, "aria-label": t.topBar.fontSmaller, type: "button", children: _jsx(PiMinus, { size: 10 }) }), _jsx("input", { type: "text", inputMode: "numeric", "aria-label": t.topBar.fontSizeInput, title: t.topBar.fontSizeInput, value: draft ?? String(Math.round(fontSize)), onFocus: (e) => {
|
|
58
|
+
setDraft(String(Math.round(fontSize)));
|
|
59
|
+
e.currentTarget.select();
|
|
60
|
+
}, onChange: (e) => setDraft(e.target.value), onBlur: commitDraft, onKeyDown: handleKeyDown, onClick: (e) => e.stopPropagation(), className: "w-10 h-7 rounded-md border-none bg-transparent text-[13px] font-semibold text-[var(--editor-text)] text-center tabular-nums outline-none hover:bg-[var(--editor-surface-hover)] focus-visible:bg-[var(--editor-surface-hover)] focus-visible:ring-2 focus-visible:ring-[var(--editor-active-fg)]" }), _jsx("button", { className: fontBtn, onClick: handleIncrease, title: t.topBar.fontLarger, "aria-label": t.topBar.fontLarger, type: "button", children: _jsx(PiPlus, { size: 10 }) })] }));
|
|
19
61
|
if (!tiles)
|
|
20
62
|
return stepper;
|
|
21
63
|
return (_jsxs("div", { className: "flex flex-col items-center justify-end gap-1 h-14 pb-2 shrink-0", children: [stepper, _jsx(TileCaption, { decorative: true, children: t.topBar.tiles.fontSize })] }));
|
|
@@ -125,17 +125,26 @@ export const KIND_RENDERERS = {
|
|
|
125
125
|
const textItem = item.data;
|
|
126
126
|
if (!textItem)
|
|
127
127
|
return null;
|
|
128
|
+
let scaledSize = null;
|
|
128
129
|
return (_jsx(SelectableCanvasText, { elementId: textItem.id, id: textItem.id, text: shownText(textItem, ctx.pageNumber), x: textItem.x, y: textItem.y, width: textItem.width, fontSize: textItem.fontSize, fontFamily: textItem.fontFamily, fontStyle: textItem.fontStyle || 'normal', fontWeight: textItem.fontWeight, letterSpacing: textItem.letterSpacing, strikethrough: textItem.strikethrough, fill: textItem.fill, stroke: textItem.stroke, strokeWidth: textItem.strokeWidth, shadowColor: textItem.shadowColor, shadowBlur: textItem.shadowBlur, shadowOffsetX: textItem.shadowOffsetX, shadowOffsetY: textItem.shadowOffsetY, shadowOpacity: textItem.shadowOpacity, fillGradient: textItem.fillGradient, align: textItem.align ?? 'left', lineHeight: textItem.lineHeight, accent: effectiveAccent(textItem), marker: effectiveMarker(textItem), opacity: textItem.opacity ?? 1, rotation: textItem.rotation || 0, scaleX: textItem.scale || 1, scaleY: textItem.scale || 1, draggable: true, onSelect: () => handlers.handleElementSelect(textItem.id), onTextChange: (val) => handlers.handleAdditionalTextChange(textItem.id, { text: val }), onTextPreview: handlers.handleAdditionalTextPreview
|
|
129
130
|
? (draft) => handlers.handleAdditionalTextPreview?.(textItem.id, draft) ?? null
|
|
130
131
|
: undefined, onDragEnd: (x, y) => {
|
|
131
132
|
handlers.handleAdditionalTextChange(textItem.id, { x, y });
|
|
132
|
-
}, transformConfig: { rotateEnabled: true },
|
|
133
|
+
}, transformConfig: { rotateEnabled: true },
|
|
134
|
+
// A corner drag reports its size right before its box, in the same release: both go
|
|
135
|
+
// into one change, so the drag is one undo step and the size is set by hand.
|
|
136
|
+
onFontSizeChange: (size) => {
|
|
137
|
+
scaledSize = size;
|
|
138
|
+
}, onTransformEnd: (x, y, width, scaleX, _scaleY, rotation) => {
|
|
139
|
+
const fontSize = scaledSize;
|
|
140
|
+
scaledSize = null;
|
|
133
141
|
handlers.handleAdditionalTextChange(textItem.id, {
|
|
134
142
|
x,
|
|
135
143
|
y,
|
|
136
144
|
width,
|
|
137
145
|
scale: scaleX,
|
|
138
146
|
rotation,
|
|
147
|
+
...(fontSize === null ? {} : { fontSize }),
|
|
139
148
|
});
|
|
140
149
|
}, editable: textItem.counter === undefined, onSnapChange: handleSnapChange, onSnapLinesChange: setSnapLines, getSnapTargets: getSnapTargets, onGeometryChange: registerGeometry, stageWidth: stageWidth, stageHeight: stageHeight }, textItem.id));
|
|
141
150
|
},
|
package/dist/entries/export.d.ts
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Export: PPTX (fonts, model, writer), print and slide PDFs, SVG (recorder, resolver, writer, font
|
|
3
|
+
* files), and zipped page images.
|
|
4
|
+
*/
|
|
2
5
|
export { pptxFamily, type PptxFontMapper, registerPptxFonts } from '../export/pptx/pptxFonts.js';
|
|
3
6
|
export { type PptxPageState } from '../export/pptx/buildPptxModel.js';
|
|
4
7
|
export { type PptxDeckModel, type PptxSlideModel, type PptxItem } from '../export/pptx/types.js';
|
|
5
8
|
export { writePptx, PPTX_MIME_TYPE } from '../export/pptx/writePptx.js';
|
|
6
9
|
export { exportPrintPdf, lowResolutionWarnings, type PrintExportPage, type PrintExportImage, } from '../export/printExport.js';
|
|
7
10
|
export { exportSlidesPdf } from '../export/slidesPdf.js';
|
|
11
|
+
export { resolveFontFiles, type FontFile, type FontFileSet, type FontSourceDeps, } from '../export/fonts/fontFiles.js';
|
|
12
|
+
export { fetchImageBytes, rasterizeOps, reencodeImage } from '../export/scene/browserDeps.js';
|
|
13
|
+
export { pngFromDataUrl } from '../export/scene/imageBytes.js';
|
|
14
|
+
export { recordPageScene, type RecordPageOptions } from '../export/scene/recordPageScene.js';
|
|
15
|
+
export { resolveScene, type ResolveDeps } from '../export/scene/resolveScene.js';
|
|
16
|
+
export { emptyReport, type ClipPath, type ColorStop, type ExportReport, type ExportScene, type FontSpec, type Matrix, type Paint, type PathCommand, type RasterReason, type RecordedScene, type SceneImageRef, type SceneImageSource, type SceneItem, type SceneOp, type Shadow, type StrokeStyle, } from '../export/scene/types.js';
|
|
17
|
+
export { writePdf, type WritePdfOptions } from '../export/pdf/writePdf.js';
|
|
18
|
+
export { writeSvg, type WriteSvgOptions } from '../export/svg/writeSvg.js';
|
|
19
|
+
export { createVectorDeps, type CreateVectorDepsOptions, type VectorExportCanvas, } from '../export/vectorDeps.js';
|
|
20
|
+
export { exportPagesPdf, exportPagesSvg, type PdfExportDeps, type PdfExportOptions, type VectorExportDeps, type VectorExportOptions, type VectorExportResult, } from '../export/vectorExport.js';
|
|
8
21
|
export { zipPageImages } from '../utils/zipPageImages.js';
|
package/dist/entries/export.js
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Export: PPTX (fonts, model, writer), print and slide PDFs, SVG (recorder, resolver, writer, font
|
|
4
|
+
* files), and zipped page images.
|
|
5
|
+
*/
|
|
3
6
|
export { pptxFamily, registerPptxFonts } from '../export/pptx/pptxFonts.js';
|
|
4
7
|
export { writePptx, PPTX_MIME_TYPE } from '../export/pptx/writePptx.js';
|
|
5
8
|
export { exportPrintPdf, lowResolutionWarnings, } from '../export/printExport.js';
|
|
6
9
|
export { exportSlidesPdf } from '../export/slidesPdf.js';
|
|
10
|
+
export { resolveFontFiles, } from '../export/fonts/fontFiles.js';
|
|
11
|
+
export { fetchImageBytes, rasterizeOps, reencodeImage } from '../export/scene/browserDeps.js';
|
|
12
|
+
export { pngFromDataUrl } from '../export/scene/imageBytes.js';
|
|
13
|
+
export { recordPageScene } from '../export/scene/recordPageScene.js';
|
|
14
|
+
export { resolveScene } from '../export/scene/resolveScene.js';
|
|
15
|
+
export { emptyReport, } from '../export/scene/types.js';
|
|
16
|
+
export { writePdf } from '../export/pdf/writePdf.js';
|
|
17
|
+
export { writeSvg } from '../export/svg/writeSvg.js';
|
|
18
|
+
export { createVectorDeps, } from '../export/vectorDeps.js';
|
|
19
|
+
export { exportPagesPdf, exportPagesSvg, } from '../export/vectorExport.js';
|
|
7
20
|
export { zipPageImages } from '../utils/zipPageImages.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Host services: the service types `CanvasEditorProvider` takes, their browser defaults, toasts, storage keys and screen-corner reservations. */
|
|
2
2
|
export { type CanvasEditorServices, type CanvasEditorHostServices, type CanvasSlotBudgetService, } from '../CanvasEditorProvider.js';
|
|
3
|
-
export { browserFileDelivery, type CanvasCarouselService, type CanvasFeedbackService, type CanvasImageUrlService, type CanvasImprintParts, type CanvasImprintService, type CanvasMediaItem, type CanvasMediaLibraryService, type CanvasMediaUploadResult, type CanvasMediaUploadState, type CanvasPrintService, plainImageUrls, } from '../hostServices.js';
|
|
3
|
+
export { browserFileDelivery, type CanvasCarouselService, type CanvasExportFontService, type CanvasFeedbackService, type CanvasImageUrlService, type CanvasImprintParts, type CanvasImprintService, type CanvasMediaItem, type CanvasMediaLibraryService, type CanvasMediaUploadResult, type CanvasMediaUploadState, type CanvasPrintService, plainImageUrls, } from '../hostServices.js';
|
|
4
4
|
export { type EditorToast, type EditorToastOptions, registerToast, type EditorToastAction, } from '../utils/editorToast.js';
|
|
5
5
|
export { registerHostStorageKeys, type HostStorageKeyName } from '../utils/hostStorageKeys.js';
|
|
6
6
|
export { type MeasuredCornerReservation, type MeasuredCornerReservationHook, registerMeasuredCornerReservation, type ScreenCorner, } from '../utils/cornerReservation.js';
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds the font files behind a recorded text op's `FontSpec`, for the writers that draw glyph
|
|
3
|
+
* outlines (SVG) or embed fonts (PDF).
|
|
4
|
+
*
|
|
5
|
+
* Sources, first one with a file wins: the host's `exportFonts` service, the brand pack's font
|
|
6
|
+
* faces, then the page's own `@font-face` rules. A CSS family can come as several files, one per
|
|
7
|
+
* `unicode-range`; `fileFor` picks the one that covers a code point. Nothing here is cached
|
|
8
|
+
* between exports: the caller passes the `Map` it wants to share.
|
|
9
|
+
*/
|
|
10
|
+
import { type BrandFontFace } from '@ggraphic/core';
|
|
11
|
+
import { type FontkitFont, type FontkitFsType } from './glyphs.js';
|
|
12
|
+
import { type Variation } from './variation.js';
|
|
13
|
+
import type { CanvasExportFontService } from '../../hostServices.js';
|
|
14
|
+
import type { FontSpec } from '../scene/types.js';
|
|
15
|
+
/**
|
|
16
|
+
* How far a browser shears the upright cut it draws for an italic nobody ships: Skia's fake italic
|
|
17
|
+
* is `skewX(-1/4)`, a quarter of the height above the baseline to the right.
|
|
18
|
+
*/
|
|
19
|
+
export declare const SYNTHETIC_ITALIC_SLANT = 0.25;
|
|
20
|
+
export interface FontFile {
|
|
21
|
+
bytes: Uint8Array;
|
|
22
|
+
font: FontkitFont;
|
|
23
|
+
/** What the font's licence flags allow; see `embeddingOf`. */
|
|
24
|
+
embeddable: 'yes' | 'outlines-only' | 'bitmap-only';
|
|
25
|
+
/** The `unicode-range` the stylesheet declared for the file; null = the whole font. */
|
|
26
|
+
ranges: readonly [number, number][] | null;
|
|
27
|
+
/**
|
|
28
|
+
* How far a writer shears the glyphs, per unit of height above the baseline: 0 for a real cut,
|
|
29
|
+
* `SYNTHETIC_ITALIC_SLANT` for the upright cut that stands in for an italic the family lacks.
|
|
30
|
+
*/
|
|
31
|
+
slant: number;
|
|
32
|
+
/**
|
|
33
|
+
* True for a cut lighter than 600 that stands in for a weight of 600 or more the family does not
|
|
34
|
+
* ship: a writer draws it emboldened like a browser does (`fakeBoldWidth`).
|
|
35
|
+
*/
|
|
36
|
+
fakeBold: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* How `font` stands to the weight asked for when the file is a variable font (`none` for any
|
|
39
|
+
* other): `instance` = `font` is the instance for that weight, `default-only` = it could not be
|
|
40
|
+
* made and `font` draws the file's default instance, which a writer reports.
|
|
41
|
+
*/
|
|
42
|
+
variation: Variation;
|
|
43
|
+
}
|
|
44
|
+
export interface FontFileSet {
|
|
45
|
+
face: FontSpec;
|
|
46
|
+
/** In declaration order; empty when no source has the face. */
|
|
47
|
+
files: readonly FontFile[];
|
|
48
|
+
/**
|
|
49
|
+
* The file that draws `codePoint`, or null. A file covers a code point only if its declared
|
|
50
|
+
* range includes it AND the font has a glyph for it: the glyph check alone is not enough for a
|
|
51
|
+
* file that claims a range it does not fully cover, and the range alone is not enough because
|
|
52
|
+
* fontkit silently answers `.notdef`. Where ranges overlap the later file wins, as in a browser.
|
|
53
|
+
*/
|
|
54
|
+
fileFor(codePoint: number): FontFile | null;
|
|
55
|
+
}
|
|
56
|
+
/** The members of `CSSFontFaceRule` the resolver reads, so a test needs no DOM. */
|
|
57
|
+
export interface FontFaceRuleLike {
|
|
58
|
+
style: {
|
|
59
|
+
getPropertyValue(name: string): string;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export interface FontSourceDeps {
|
|
63
|
+
host?: CanvasExportFontService;
|
|
64
|
+
brandFaces?: readonly BrandFontFace[];
|
|
65
|
+
/** `BrandFonts.boldFamilies`: regular family → the family whose regular cut is its bold. */
|
|
66
|
+
boldFamilies?: Readonly<Record<string, string>>;
|
|
67
|
+
/** Default: the `@font-face` rules of `document.styleSheets` (none without a document). Injected in tests. */
|
|
68
|
+
cssRules?: () => Iterable<FontFaceRuleLike>;
|
|
69
|
+
/** Default: `fetch`. A download that fails or answers an error status is a missing font. */
|
|
70
|
+
fetchBytes?: (url: string) => Promise<Uint8Array | null>;
|
|
71
|
+
/**
|
|
72
|
+
* The files by `family|weight|style`, shared by the faces of one export. The caller creates it
|
|
73
|
+
* and drops it with the export; there is no module-level cache.
|
|
74
|
+
*/
|
|
75
|
+
cache?: Map<string, Promise<readonly FontFile[]>>;
|
|
76
|
+
}
|
|
77
|
+
export declare function resolveFontFiles(face: FontSpec, deps: FontSourceDeps): Promise<FontFileSet>;
|
|
78
|
+
/**
|
|
79
|
+
* What the licence flags of a font (`OS/2.fsType`) allow: 0x0002 (restricted licence) = its
|
|
80
|
+
* outlines may be drawn but the font must not travel in the file; 0x0200 = only bitmaps may be
|
|
81
|
+
* embedded. Preview/print, editable and no-subsetting (0x0004, 0x0008, 0x0100) allow embedding.
|
|
82
|
+
* Takes the flag object fontkit decodes the field into as well as the raw number.
|
|
83
|
+
*/
|
|
84
|
+
export declare function embeddingOf(fsType: FontkitFsType): FontFile['embeddable'];
|
|
85
|
+
/**
|
|
86
|
+
* The code point ranges of a CSS `unicode-range` value: `U+26`, `U+0-7F` and `U+4??`. Tokens
|
|
87
|
+
* that are not a valid range are dropped.
|
|
88
|
+
*/
|
|
89
|
+
export declare function parseUnicodeRange(value: string): [number, number][];
|
|
90
|
+
/**
|
|
91
|
+
* The six capital letters a PDF font name carries before the `+` for a subset (`ABCDEF+Name`),
|
|
92
|
+
* derived from the face and the index of the file in its set, so the same export names its
|
|
93
|
+
* subsets the same way every time. pdf-lib's own default name has no such prefix.
|
|
94
|
+
*/
|
|
95
|
+
export declare function subsetTag(face: FontSpec, fileIndex: number): string;
|
|
96
|
+
/**
|
|
97
|
+
* The `@font-face` rules of every style sheet of the document, imports and grouping rules
|
|
98
|
+
* included. The default of `FontSourceDeps.cssRules`; exported for its own test.
|
|
99
|
+
*/
|
|
100
|
+
export declare function documentFontFaces(): Iterable<CSSFontFaceRule>;
|