From 163d34261a161bb7204e0bddf277f4caa7171e78 Mon Sep 17 00:00:00 2001 From: Johannes Zillmann Date: Sun, 28 Feb 2021 12:56:23 +0100 Subject: [PATCH] Display Font Tooltip --- core/src/Debugger.ts | 2 ++ ui/src/components/Hoverable.svelte | 15 +++++++++ ui/src/debug/DebugView.svelte | 1 + ui/src/debug/FontTooltip.svelte | 35 +++++++++++++++++++++ ui/src/debug/FontsTooltip.svelte | 19 ++++++++++++ ui/src/debug/ItemTable.svelte | 50 ++++++++++++++++++++++++++++-- 6 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 ui/src/components/Hoverable.svelte create mode 100644 ui/src/debug/FontTooltip.svelte create mode 100644 ui/src/debug/FontsTooltip.svelte diff --git a/core/src/Debugger.ts b/core/src/Debugger.ts index d774477..7cb35fa 100644 --- a/core/src/Debugger.ts +++ b/core/src/Debugger.ts @@ -12,12 +12,14 @@ export default class Debugger { private context: TransformContext; private transformers: ItemTransformer[]; private stageResultCache: StageResult[]; + fontMap: Map; stageNames: string[]; stageDescriptions: string[]; constructor(inputSchema: string[], inputItems: Item[], context: TransformContext, transformers: ItemTransformer[]) { this.transformers = transformers; this.context = context; + this.fontMap = context.fontMap; this.stageNames = ['Parse Result', ...transformers.map((t) => t.name)]; this.stageDescriptions = ['Initial items as parsed by PDFjs', ...transformers.map((t) => t.description)]; this.stageResultCache = [initialStage(inputSchema, inputItems)]; diff --git a/ui/src/components/Hoverable.svelte b/ui/src/components/Hoverable.svelte new file mode 100644 index 0000000..d3dcad9 --- /dev/null +++ b/ui/src/components/Hoverable.svelte @@ -0,0 +1,15 @@ + + +
+ +
diff --git a/ui/src/debug/DebugView.svelte b/ui/src/debug/DebugView.svelte index 0a13420..10ba916 100644 --- a/ui/src/debug/DebugView.svelte +++ b/ui/src/debug/DebugView.svelte @@ -98,6 +98,7 @@ + import type Item from '@core/Item'; + + export let fontName: string; + export let fontMap: Map; + $: font = fontMap.get(fontName); + + +
+
{fontName}
+
+
Name:
+
{font['name']}
+
Type:
+
{font['type']}
+
MimeType:
+
{font['mimetype']}
+
Ascent:
+
{font['ascent'].toFixed(2)}
+
Descent:
+
{font['descent'].toFixed(2)}
+
BBox:
+
{font['bbox'].join(', ')}
+
Matrix:
+
{font['fontMatrix'].join(', ')}
+
Vertical:
+
{font['vertical']}
+
Monospace:
+
{font['isMonospace']}
+
Setif:
+
{font['isSerifFont']}
+
Type3:
+
{font['isType3Font']}
+
+
diff --git a/ui/src/debug/FontsTooltip.svelte b/ui/src/debug/FontsTooltip.svelte new file mode 100644 index 0000000..4cb0163 --- /dev/null +++ b/ui/src/debug/FontsTooltip.svelte @@ -0,0 +1,19 @@ + + +{#each distinctFontName as fontName} + +{/each} diff --git a/ui/src/debug/ItemTable.svelte b/ui/src/debug/ItemTable.svelte index 5980c3c..e5cd08d 100644 --- a/ui/src/debug/ItemTable.svelte +++ b/ui/src/debug/ItemTable.svelte @@ -7,7 +7,11 @@ import { formatValue } from './formatValues'; import type Page from '@core/debug/Page'; import ChangeSymbol from './ChangeSymbol.svelte'; + import Hoverable from '../components/Hoverable.svelte'; + import FontTooltip from './FontTooltip.svelte'; + import FontsTooltip from './FontsTooltip.svelte'; + export let fontMap: Map; export let schema: AnnotatedColumn[]; export let pages: Page[]; export let maxPage: number; @@ -102,7 +106,24 @@ {#each schema as column} - {formatValue(itemGroup.top.data[column.name])} + + {#if column.name === 'fontName'} + + + {#if hovering} + + + + {/if} +
{formatValue(itemGroup.top.data[column.name])}
+
+
+ {:else} +
{formatValue(itemGroup.top.data[column.name])}
+ {/if} + {/each} @@ -123,7 +144,24 @@ {#each schema as column} - {formatValue(child.data[column.name])} + + {#if column.name === 'fontName'} + + + {#if hovering} + + + + {/if} +
{formatValue(child.data[column.name])}
+
+
+ {:else} +
{formatValue(child.data[column.name])}
+ {/if} + {/each} {/each} @@ -205,4 +243,12 @@ tr.changeNeutral td:not(#page) { @apply text-yellow-600; } + + .fontTooltip { + position: absolute; + margin-right: 15px; + right: 100%; + with: 200px; + z-index: 4; + }