Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
</ItemGroup>

<ItemGroup>
<Watch Remove="*.scss" />
<ScssFiles Include="**\*.scss" />
</ItemGroup>

Expand Down
8 changes: 7 additions & 1 deletion src/BlazorUI/Bit.BlazorUI.Extras/Bit.BlazorUI.Extras.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@
<ItemGroup>
<Content Remove="compilerconfig.json" />
<None Include="compilerconfig.json" />
<Watch Remove="*.scss" />
<!-- dotnet watch: watch the ts sources so edits trigger the tsc target on rebuilds.
The generated wwwroot css/js stay watched (default Content behavior) so dotnet watch can
hot-apply them when the demo server's ScssCompilerService regenerates them. Scss sources are
intentionally not watched here: the in-app compiler recompiles them without a rebuild. Paths
are rooted with $(MSBuildProjectDirectory) because dotnet watch resolves relative Watch items
of referenced projects against the startup project's directory. -->
<Watch Include="$(MSBuildProjectDirectory)\**\*.ts" Exclude="$(MSBuildProjectDirectory)\node_modules\**;$(MSBuildProjectDirectory)\bin\**;$(MSBuildProjectDirectory)\obj\**;$(MSBuildProjectDirectory)\**\*.d.ts" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public enum BitPdfRenderMode
/// a display list produced by the C# engine (the pdf.js model). Far fewer DOM
/// nodes; selection, search and links still work through the DOM text layer,
/// and zoom changes re-rasterize the canvases so text stays crisp. Requires
/// JavaScript a prerendered page shows a blank canvas until the client
/// JavaScript - a prerendered page shows a blank canvas until the client
/// loads.
/// </summary>
Canvas,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public partial class BitPdfViewer : BitComponentBase

/// <summary>
/// How painted text is emitted. <see cref="BitPdfTextCoalescing.Compact"/> merges
/// same-line, same-style runs into one span per visual line far fewer DOM
/// same-line, same-style runs into one span per visual line - far fewer DOM
/// nodes on per-glyph PDFs, with small intra-line position drift (explicit
/// kerning between runs is approximated). Rotated text always stays exact.
/// Default is <see cref="BitPdfTextCoalescing.Exact"/>.
Expand Down Expand Up @@ -1555,7 +1555,7 @@ private async Task RunSearchAsync()

// Search a per-page extracted-text index (built lazily) rather than the
// rendered DOM, so we only render the pages that actually contain matches
// a 500-page document with matches on 3 pages renders 3, not 500.
// - a 500-page document with matches on 3 pages renders 3, not 500.
_pageText ??= new string?[_document.PageCount];
string needle = _searchQuery;
int pageCount = _document.PageCount; // captured so the loop condition never reads a nulled _document
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@
pointer-events: auto;
}

/* Selection spans (data-bit-pdv-sel) hold the real Unicode but paint nothing keep
/* Selection spans (data-bit-pdv-sel) hold the real Unicode but paint nothing - keep
them transparent even while selected so only the highlight box shows and the
painted glyphs beneath stay visible through it. Without this the browser paints
the selected substitute glyphs opaque, stacking a wrong-font copy over the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
}

// Scrolls `target` into view by scrolling ONLY `container` unlike
// Scrolls `target` into view by scrolling ONLY `container` - unlike
// scrollIntoView, which also scrolls every scrollable ancestor (including
// the hosting page, yanking the whole document around when the viewer is
// embedded mid-page).
Expand Down Expand Up @@ -468,7 +468,7 @@
clone.style.transformOrigin = "top left";
// A cloned <canvas> loses its pixels: substitute a snapshot image so
// canvas-mode pages print their painted content. Pages with a cached
// display list re-rasterize at print resolution the screen-resolution
// display list re-rasterize at print resolution - the screen-resolution
// bitmap is sized for on-screen zoom and prints blurry.
const srcCanvases = el.querySelectorAll("canvas[data-bit-pdv-canvas]");
const dstCanvases = clone.querySelectorAll("canvas[data-bit-pdv-canvas]");
Expand Down Expand Up @@ -615,7 +615,7 @@
return;
}

// @font-face faces load lazily only when DOM text uses them and canvas
// @font-face faces load lazily - only when DOM text uses them - and canvas
// fillText never waits for (or reliably triggers) a load: it draws with the
// fallback immediately. In canvas mode no DOM references the embedded
// families, so without an explicit load the FIRST paint renders tofu until
Expand Down Expand Up @@ -827,7 +827,7 @@
const ranges: Range[] = [];

container.querySelectorAll("[data-page]").forEach((page) => {
// Search only the coalesced selection layer ([data-bit-pdv-sel]) it
// Search only the coalesced selection layer ([data-bit-pdv-sel]) - it
// holds the real Unicode in reading order. The painted layer beneath is
// presentational (real glyphs or Private-Use codepoints) and would
// otherwise double-count.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private void Traverse(BitPdfDict node, in InheritedAttributes inherited,
}

// A node explicitly typed /Pages but with no usable /Kids is a damaged
// interior node skip it rather than materializing a phantom page.
// interior node - skip it rather than materializing a phantom page.
if (BitPdfPrimitives.IsName(typeObj, "Pages"))
{
_xref.Warnings.Add("Interior /Pages node has no valid /Kids; skipping.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private static List<BitPdfStructElement> ReadKids(IBitPdfXRef xref, object? kids

private static void AddNode(IBitPdfXRef xref, object? item, List<BitPdfStructElement> result, HashSet<int> visited, int depth)
{
// Marked-content leaves are plain integers or MCR/OBJR dicts; skip them
// Marked-content leaves are plain integers or MCR/OBJR dicts; skip them -
// the structure tree API exposes the element hierarchy, not content refs.
if (item is double)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/// <summary>
/// Thrown when a document declares an <c>/Encrypt</c> dictionary that this
/// library cannot handle an unsupported security handler or revision, or a
/// library cannot handle - an unsupported security handler or revision, or a
/// cryptographic primitive that is unavailable on the current platform (for
/// example MD5/AES in the browser WebAssembly sandbox). Distinct from
/// <see cref="BitPdfFormatException"/> so callers can surface a clear "this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void Parse()
}

// If the classic/stream path did not yield a usable catalog, brute-force
// scan the file for objects and rebuild matching pdf.js recovery.
// scan the file for objects and rebuild - matching pdf.js recovery.
if (Trailer is null || Root is null)
{
RebuildByScanning();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Bit.BlazorUI;
/// <summary>
/// Extracts the visible text of a page by replaying its content stream and
/// decoding show-text operators through each selected font. Positioning is
/// approximated with simple space/newline heuristics enough for search and
/// approximated with simple space/newline heuristics - enough for search and
/// copy, not a layout-faithful reconstruction.
/// </summary>
public static class BitPdfTextExtractor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private sealed class HuffTable
switch (marker)
{
case 0xC0: // SOF0 baseline
case 0xC1: // SOF1 extended sequential (Huffman) same layout
case 0xC1: // SOF1 extended sequential (Huffman) - same layout
{
precision = data[segStart];
frameHeight = (data[segStart + 1] << 8) | data[segStart + 2];
Expand All @@ -122,7 +122,7 @@ private sealed class HuffTable
}
break;
}
case 0xC2: // SOF2 progressive not supported here
case 0xC2: // SOF2 progressive - not supported here
return null;
case 0xC4: // DHT
ReadHuffmanTables(data, segStart, segEnd, huffDc, huffAc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal sealed class BitPdfCffFontParser
/// <summary>The raw CFF Encoding offset from the Top DICT (0/1 = predefined).</summary>
public int EncodingOffset { get; private set; }

/// <summary><c>true</c> for a CID-keyed CFF (ROS present) unsupported here.</summary>
/// <summary><c>true</c> for a CID-keyed CFF (ROS present) - unsupported here.</summary>
public bool IsCid { get; private set; }

public static BitPdfCffFontParser? Parse(byte[] cff)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ private static (byte[]?, string?) ExtractEmbedded(BitPdfDict? descriptor)
: (data, "cff");
}
// Type1 program (/FontFile): parse it and build an OpenType/CFF font the
// browser can load. On any failure fall through to a substitute font
// browser can load. On any failure fall through to a substitute font -
// a rejected @font-face simply falls back to the generic family.
if (descriptor.Get("FontFile") is BitPdfStream t1Stream)
{
Expand Down Expand Up @@ -761,7 +761,7 @@ private double WidthFor(int code)
int index = code - _firstChar;
if (index >= 0 && index < _widths.Length)
{
// An explicit width of 0 is valid (e.g. combining marks) use it
// An explicit width of 0 is valid (e.g. combining marks) - use it
// rather than falling through to a substitute metric.
return _widths[index] * _glyphWidthScale;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internal static class BitPdfSfntGlyphMapper
var names = ReadPost(font, dir); // glyph name → gid

// Map each byte code to a unique Private-Use-Area codepoint (glyph
// painting is by exact glyph id no shaping, no Unicode collisions).
// painting is by exact glyph id - no shaping, no Unicode collisions).
var result = new Dictionary<int, int>();
for (int code = 0; code < 256; code++)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// A conservative TrueType/OpenType (sfnt) sanitizer. Embedded PDF subset fonts
// frequently ship with an unsorted table directory, wrong table checksums, a
// wrong head.checkSumAdjustment, or unpadded tables all of which strict font
// wrong head.checkSumAdjustment, or unpadded tables - all of which strict font
// parsers (including the browser's OTS) reject, so the @font-face silently fails
// to load. This rebuilds a structurally valid sfnt: recognized tables are kept
// verbatim, the directory is re-sorted, tables are 4-byte aligned, and all
Expand All @@ -21,7 +21,7 @@ internal static class BitPdfTrueTypeSanitizer

/// <summary>
/// As <see cref="Sanitize(byte[])"/>, but replaces the font's <c>cmap</c> with
/// <paramref name="replacementCmap"/> when supplied used to inject a clean
/// <paramref name="replacementCmap"/> when supplied - used to inject a clean
/// synthetic Unicode cmap for subset fonts whose own cmap OTS rejects.
/// </summary>
public static byte[]? Sanitize(byte[] input, byte[]? replacementCmap)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ private bool Escape(int op, InterpContext ctx)
? Pop(ctx.PostScriptStack)
: 0);
break;
case 6: // seac (accented char) not composed; ignore base for now
case 6: // seac (accented char) - not composed; ignore base for now
case 7: // sbw
case 0: // dotsection
case 1: // vstem3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Bit.BlazorUI;
/// <param name="TextLayerHtml">
/// The page's DOM part: the positioned page <c>div</c> containing the
/// <c>&lt;canvas&gt;</c> placeholder, the selectable text layer, and link/
/// annotation overlays everything except the painted content.
/// annotation overlays - everything except the painted content.
/// </param>
/// <param name="OpsJson">
/// The display list to replay onto the canvas (JSON array of drawing ops),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public sealed class BitPdfHtmlRenderer

// Coalesced selection/text layer (the pdf.js model): text is accumulated here
// separately from the painted glyph spans and emitted once, on top, at page end
// decoupled from paint order. Adjacent runs on a baseline merge into a single
// - decoupled from paint order. Adjacent runs on a baseline merge into a single
// transparent, selectable span per visual line (with spaces inserted for gaps),
// so double-click words, triple-click lines, click-drag and copy behave like
// normal text instead of fragmenting per glyph.
Expand All @@ -65,8 +65,9 @@ public sealed class BitPdfHtmlRenderer

/// <summary>
/// How painted text runs are emitted. <see cref="BitPdfTextCoalescing.Compact"/>
/// merges same-line, same-style substitute-font runs into one span per visual
/// line (embedded-font runs always stay per-run exact). Default is
/// merges same-line, same-style runs - including embedded-font (PUA
/// glyph-mapped) ones - into one span per visual line; only non-upright
/// (rotated, mirrored, or skewed) text stays per-run exact. Default is
/// <see cref="BitPdfTextCoalescing.Exact"/>.
/// </summary>
public BitPdfTextCoalescing TextCoalescing { get; set; } = BitPdfTextCoalescing.Exact;
Expand Down Expand Up @@ -270,7 +271,7 @@ public string Render()
// in, so dragging over text selects while empty areas stay clickable.
// font-size:0 collapses the flow-level <br> separators (the spans set their
// own size): the brs still put line breaks in copied text, but their empty
// line boxes which stack at the container's top-left become zero-sized,
// line boxes - which stack at the container's top-left - become zero-sized,
// so a multi-line selection no longer paints stray highlight blocks along
// the page's left edge.
if (_selLayer.Length > 0)
Expand Down Expand Up @@ -1336,7 +1337,7 @@ private static bool IsAllowedUri(string uri)
int colon = uri.IndexOf(':');
if (colon <= 0)
{
return false; // no scheme, or leading ':' treat as unsafe
return false; // no scheme, or leading ':' - treat as unsafe
}
// A URI scheme is letters/digits/+/-/. and must precede any '/', '?' or '#'.
for (int i = 0; i < colon; i++)
Expand Down Expand Up @@ -1370,8 +1371,8 @@ private void SetFont(BitPdfOperation op)
{
return null;
}
// Key the cache by the font's object identity the indirect reference if
// present (value-equal), otherwise the dictionary instance rather than
// Key the cache by the font's object identity - the indirect reference if
// present (value-equal), otherwise the dictionary instance - rather than
// "depth:name". Different resource dictionaries can reuse a resource name
// for different fonts, so a name-based key returned the wrong font.
object? raw = fonts.GetRaw(name);
Expand Down Expand Up @@ -1477,7 +1478,7 @@ private void ShowText(object? operand)
private void ShowType3Text(List<BitPdfGlyph> glyphs)
{
// Type3 glyphs paint graphics directly (below), reached via a whitelisted
// show-text operator flush any pending coalesced line to keep paint order.
// show-text operator - flush any pending coalesced line to keep paint order.
FlushPaintedLine();

BitPdfFont font = _state.Font!;
Expand Down Expand Up @@ -1592,18 +1593,18 @@ private void EmitText(string renderText, string realText, double runAdvance)
AccumulateSelectionText(realText, trm, left, top, fontHeight, targetWidth, linear);
}

// Emit only the PAINTED layer. It is never selectable or searchable all
// Emit only the PAINTED layer. It is never selectable or searchable - all
// selection and find-in-page run against the coalesced layer above.
if (invisible)
{
// Render modes 3/7 (e.g. an OCR text layer over a scanned image) paint
// nothing, so there is no glyph layer and no embedded @font-face to
// inline the coalesced selection span alone carries the text.
// inline - the coalesced selection span alone carries the text.
return;
}

// Canvas mode: one fillText/strokeText op per run at its exact device
// matrix (no DOM cost, so no coalescing) the selection layer above
// matrix (no DOM cost, so no coalescing) - the selection layer above
// already carries the real Unicode.
if (_ops is not null)
{
Expand All @@ -1612,13 +1613,14 @@ private void EmitText(string renderText, string realText, double runAdvance)
}

// Compact mode: coalesce painted runs into one span per visual line.
// Embedded fonts including PUA glyph-mapped ones, which is how every
// embedded font in this engine paints coalesce too: the browser lays the
// Embedded fonts - including PUA glyph-mapped ones, which is how every
// embedded font in this engine paints - coalesce too: the browser lays the
// merged run out with the font's own advance widths, so only explicit TJ
// kerning between runs is approximated while data-w pins the line's total
// advance. (A gap-bridging space missing from a subset font falls through
// to the generic fallback in the font stack.) Only rotated/mirrored text
// is excluded — its geometry can't be reduced to a horizontal line.
// to the generic fallback in the font stack.) Only non-upright text
// (rotated/mirrored/skewed) is excluded - its geometry can't be reduced
// to a horizontal line.
if (TextCoalescing == BitPdfTextCoalescing.Compact
&& a > 1e-3 && d > 1e-3
&& Math.Abs(b) < 1e-3 && Math.Abs(c) < 1e-3)
Expand All @@ -1639,8 +1641,8 @@ private void EmitText(string renderText, string realText, double runAdvance)

/// <summary>
/// Emits one canvas text op. The matrix's linear part maps the run's local em
/// space (x right, y down, baseline at the origin) to device space identical
/// to the HTML span's transform and (e, f) is the baseline origin, matching
/// space (x right, y down, baseline at the origin) to device space - identical
/// to the HTML span's transform - and (e, f) is the baseline origin, matching
/// canvas's alphabetic textBaseline. The interpreter measures the drawn text
/// and applies scaleX width-correction to <paramref name="targetWidth"/>, the
/// run's PDF-computed advance (the data-w mechanism, done inline).
Expand Down Expand Up @@ -1933,7 +1935,7 @@ private void AppendFontStyle(StringBuilder sb, BitPdfFont font)
/// <summary>
/// The CSS font-family list for <paramref name="font"/>, registering the
/// embedded face's <c>@font-face</c> rule on first use. Canvas text uses the
/// same registered faces <c>document.fonts</c> serves them to
/// same registered faces - <c>document.fonts</c> serves them to
/// <c>ctx.fillText</c> once loaded.
/// </summary>
private string FontFamilyList(BitPdfFont font)
Expand Down
Loading
Loading