drawnui-react 0.1.0-preview.30 → 0.1.0-preview.31

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/SKIPPED.md CHANGED
@@ -72,7 +72,7 @@ DrawnUi name and semantics; nothing here is a redesign, only an omission.
72
72
  | `SkiaLayout` Wrap (static children) + `SkiaWrap` alias | ported | Left-to-right flow, `Spacing` between items and rows, row height = tallest item. Not ported: `Split`, main-axis `Fill` children sharing a row (1.9.7.4 flex-fill), `UseDynamicColumns`, RTL. |
73
73
  | `SkiaLayout` Masonry + `SkiaMasonry` alias (Split 2, horizontal fill) | ported | C# `MeasureMasonry` / `BuildMasonryLayout`: `Split` columns of width round((width - (Split - 1) * Spacing) / Split), every visible item measured unbounded at that width and placed at the bottom of the shortest column (the first on a tie), `Spacing` between columns and items. Children or `ItemsSource` + `ItemTemplate` (recycled slots, taps, `ScrollToIndex` from the slot rect, `LoadMore`); a templated slot keeps its item's size, so an appended page or a changed item is the only one measured and every item is placed again. No items window. Content = used columns wide, tallest column high. `npm run check:masonry` (C# MasonryLayoutTests) |
74
74
  | `SkiaLayout` Grid (static children) + `SkiaGrid` alias | ported | Port of `SkiaGridStructure` (MAUI grid manager): `ColumnDefinitions`/`RowDefinitions` as `"*, 2*, Auto, 100"` or arrays, `DefaultColumnDefinition`/`DefaultRowDefinition` (Auto, like C#), `ColumnSpacing`/`RowSpacing`, child `Column`/`Row`/`ColumnSpan`/`RowSpan` (plain props instead of attached properties), implicit tracks, unknown/known measure passes, span resolution, star compression, Fill-child minimums, last-track stretch when the grid fills, remeasure at final cells. Not ported: `Split`/`Invert` (templated grids), `UseDynamicColumns`, `SkiaDecoratedGrid`, `GetOrderedSubviews` ZIndex ordering. |
75
- | `SkiaLabel` | partial | Word wrap (+ character break for long words), `MaxLines` with tail ellipsis, `LineBreakMode` (NoWrap / wraps / Tail; Head/Middle behave as Tail), `HorizontalTextAlignment` Start/Center/End (Fill* accepted, align Start), `VerticalTextAlignment`, `LineSpacing`, `LineHeight`, `FontWeight` + `FontAttributes` via faces registered per weight (`AddFont(src, alias, weight)`, nearest weight wins, synthetic bold (`setEmbolden`) when the nearest face is lighter than 600 — C# `Font.Embolden`; italic = synthetic skew when no italic face; empty `FontFamily` = the first registered family, weights included), `TextTransform`, `Padding`, `LinesCount`; text measured with unhinted (linear) advances, the same widths as DrawnUi.Rust on every platform; defaults as C# (`FontSize` 12, `TextColor` GreenYellow). `FontFamilyFallback` ported and extended: comma-separated chain (`"FontSymbols,FontSymbols2"`), per-codepoint run segmentation, spaces always stay on the main font; `fonts.AddSymbols()` (`FontSymbols` = Noto Sans Math subset, `FontSymbols2` = Noto Sans Symbols 2 subset) and `fonts.AddEmojis()` (`FontEmoji` = Noto Color Emoji subset: faces, hands, skin tones and the demo emoji) ship the same subsets as DrawnUi.Blazor. A joiner, variation selector, skin tone, keycap or tag keeps the font of the glyph before it (C# JoinsPreviousGlyph). Text shaping where the text needs it (C# `UnicodeNeedsShaping` ranges plus Hebrew, Arabic supplements and emoji sequence characters): Arabic joins, Indic conjuncts and marks, emoji sequences as one glyph, through the CanvasKit paragraph module already in the build (HarfBuzz + ICU, no extra wasm); other text keeps the plain glyph-by-glyph path. Right-to-left lines: runs cut where the bidirectional level changes (ICU levels; the paragraph direction from its first strong letter, explicit embeddings reported as their direction only) and placed in visual order (rule L2). A space keeps the style of the span it was written in; where two spans meet with a space each, both stay (C#). `Spans` ported as `<TextSpan>` children: `Text`, `TextColor`/`FontSize`/`FontFamily` (unset = inherit from the label, like C# HasSetColor/HasSetSize/HasSetFont), `FontWeight`, `IsBold`, `IsItalic`, `Underline`/`UnderlineWidth`, `Strikeout`/`StrikeoutWidth`/`StrikeoutColor` (Red default), `BackgroundColor`, `Tapped` + `ForceCaptureInput` (hit-tested through per-fragment `Rects`, ripple on the label, `OnSpanTapped` overridable), mixed sizes on one line share a baseline. TextSpan not ported: `ParagraphColor`, `CommandTapped`, per-span `LineSpacing`/`LineHeight`, `AutoFindFont`, `DrawingOffset`. `CharacterSpacing` (C#: (value - 1) points after every glyph, measured, wrapped and cut at the drawn width), Chinese / Japanese line breaks between characters with kinsoku (C# FitAtBreak, `CanBreakInsideWord`). Text `StrokeColor`/`StrokeWidth`/`StrokeGradient`, `DropShadow*` and `GradientByLines` ported (C# DrawText order). Not ported: `AutoFont`, `AutoSize`/`AutoSizeText`, `MonoForDigits`, `KeepSpacesOnLineBreaks` (accepted, no effect), `Format`, hyphenation, right-to-left alignment by paragraph direction (alignment stays Start / Center / End, as C#). |
75
+ | `SkiaLabel` | partial | Word wrap (+ character break for long words), `MaxLines` with tail ellipsis, `LineBreakMode` (NoWrap / wraps / Tail; Head/Middle behave as Tail), `HorizontalTextAlignment` Start/Center/End, Start and End following each paragraph's direction (a right-to-left paragraph starts at the right; Fill* accepted, not stretched, placed at the paragraph's start), `VerticalTextAlignment`, `LineSpacing`, `LineHeight`, `FontWeight` + `FontAttributes` via faces registered per weight (`AddFont(src, alias, weight)`, nearest weight wins, synthetic bold (`setEmbolden`) when the nearest face is lighter than 600 — C# `Font.Embolden`; italic = synthetic skew when no italic face; empty `FontFamily` = the first registered family, weights included), `TextTransform`, `Padding`, `LinesCount`; text measured with unhinted (linear) advances, the same widths as DrawnUi.Rust on every platform; synthetic italic keeps its slant in every cache type (drawing room only, widths unchanged); defaults as C# (`FontSize` 12, `TextColor` GreenYellow). `FontFamilyFallback` ported and extended: comma-separated chain (`"FontSymbols,FontSymbols2"`), per-codepoint run segmentation, spaces always stay on the main font; `fonts.AddSymbols()` (`FontSymbols` = Noto Sans Math subset, `FontSymbols2` = Noto Sans Symbols 2 subset) and `fonts.AddEmojis()` (`FontEmoji` = Noto Color Emoji subset: faces, hands, skin tones and the demo emoji) ship the same subsets as DrawnUi.Blazor. A joiner, variation selector, skin tone, keycap or tag keeps the font of the glyph before it (C# JoinsPreviousGlyph). Text shaping where the text needs it (C# `UnicodeNeedsShaping` ranges plus Hebrew, Arabic supplements and emoji sequence characters): Arabic joins, Indic conjuncts and marks, emoji sequences as one glyph, through the CanvasKit paragraph module already in the build (HarfBuzz + ICU, no extra wasm); other text keeps the plain glyph-by-glyph path. Right-to-left lines: runs cut where the bidirectional level changes (ICU levels; the paragraph direction from its first strong letter, explicit embeddings reported as their direction only) and placed in visual order (rule L2). A space keeps the style of the span it was written in; where two spans meet with a space each, both stay (C#). `Spans` ported as `<TextSpan>` children: `Text`, `TextColor`/`FontSize`/`FontFamily` (unset = inherit from the label, like C# HasSetColor/HasSetSize/HasSetFont), `FontWeight`, `IsBold`, `IsItalic`, `Underline`/`UnderlineWidth`, `Strikeout`/`StrikeoutWidth`/`StrikeoutColor` (Red default), `BackgroundColor`, `Tapped` + `ForceCaptureInput` (hit-tested through per-fragment `Rects`, ripple on the label, `OnSpanTapped` overridable), mixed sizes on one line share a baseline. TextSpan not ported: `ParagraphColor`, `CommandTapped`, per-span `LineSpacing`/`LineHeight`, `AutoFindFont`, `DrawingOffset`. `CharacterSpacing` (C#: (value - 1) points after every glyph, measured, wrapped and cut at the drawn width), Chinese / Japanese line breaks between characters with kinsoku (C# FitAtBreak, `CanBreakInsideWord`). Text `StrokeColor`/`StrokeWidth`/`StrokeGradient`, `DropShadow*` and `GradientByLines` ported (C# DrawText order). Not ported: `AutoFont`, `AutoSize`/`AutoSizeText`, `MonoForDigits`, `KeepSpacesOnLineBreaks` (accepted, no effect), `Format`, hyphenation, |
76
76
  | `SkiaHotspot` | ported | Fill/Fill, `Tapped`, `Down`, `Up`, `LockPanning`, `TouchDown`; consumes only Tapped like the C# one. No `AnimationTapped`/ripple/shimmer. |
77
77
  | `SkiaButton` | partial | Default look only: rounded frame radius 8 (hardcoded like the C# default content), centered label, `Text`/`TextColor`/`FontSize`/`FontFamily`/`BackgroundColor`/`IsPressed`/`RespondsToGestures` (`IsDisabled` = its obsolete opposite)/`LockPanning`, `Tapped`/`Down`/`Up`. `RespondsToGestures = false`: no press, no `Tapped`/`Down`/`Up`, a press or tap on it stops there, keyboard skips it, reported disabled (drawnui-cross 6w). `IsPressed` is tracked but has no visual; press feedback = `ApplyEffect="Ripple"`. No `ButtonStyle` platform looks, icons, `TextCase`, elevation, shimmer, `BtnText`/`BtnShape` templating. |
78
78
  | `SkiaImage` | partial | Effects ported: `AddEffect` (BlackAndWhite/Grayscale, Pastel, Sepia, InvertColors, Tint + `ColorTint`/`EffectBlendMode`, Darken, Lighten, Contrast, Saturation, Brightness, TSL, Gamma ≈ linear fit — CanvasKit has no table color filter), `Blur` (image filter, mirror tile), `ZoomX/ZoomY`, `HorizontalOffset/VerticalOffset`; C# color matrices use 0..255 translations, CanvasKit 0..1 — converted. `HSL` (hue from `Gamma`, `Saturation`, `Brightness`, tint blend), `Custom` = your own `PaintColorFilter` (C# public fields `PaintColorFilter` / `PaintImageFilter`, the latter replaces `Blur`), `ImageBitmap` (decoded image shared, not owned), `LoadPriority` of the queued `Source` load. Not ported: `UseGradient`/`StartColor`/`EndColor`, sprites, `InflateAmount`, `EraseChangedContent`, `RescaleSource`/`RescalingQuality`. `Source` (URL), `Aspect` (all `TransformAspect` values; `Tile` is a no-op like C#, tiling is `SkiaImageTiles`, same `RescaleAspect` math), `HorizontalAlignment`/`VerticalAlignment`, `Success`/`Error`, `IsLoading`, `LoadedSource`, `DisplayRect`, `AspectScale`; overflow clipped to the box. Not ported: `LoadSourceOnFirstDraw`, `PreviewBase64`, `ImageBitmap`/`LoadedImageSource`, `RescaleSource`/`CacheRescaledSource`/`RescalingQuality`, all adjustments (`Brightness`…`Blur`, `ColorTint`, gradient, `Zoom*`, offsets), sprites, `DrawWhenEmpty`, `EraseChangedContent`, `UseAssembly`. Measure: bounded box taken as is, unbounded axis from source aspect; no `NeedAutoWidth/Height` from Start alignment. |
@@ -191,6 +191,19 @@ export declare class SkiaLabel extends SkiaControl {
191
191
  /** ParagraphSpacing above a line that starts a paragraph (after the first): that many of its lines, with their spacing. */
192
192
  private ParagraphSpace;
193
193
  private BlockHeight;
194
+ /** Skew of synthetic italic (Super.GetFont setSkewX -0.25): x moves by 0.25 per pixel above the baseline. */
195
+ private static readonly ItalicSkew;
196
+ /** Pixels synthetic italic glyphs reach past the line box: right at the ascent, left at the descent. */
197
+ private slantRight;
198
+ private slantLeft;
199
+ /** The slant of synthetic italic is drawn outside the label's box: caches record that room too (C# / DrawnUi.Rust draw it whole). */
200
+ ComputeEffectsMargin(scale: number): Thickness;
201
+ /**
202
+ * Where a line starts inside [left, right] (drawnui-cross 6am): Start and End follow the paragraph's direction (in a
203
+ * right-to-left paragraph Start is the right edge); Center is centered; Fill* lines are not stretched here and sit
204
+ * at the paragraph's start.
205
+ */
206
+ private LineX;
194
207
  protected MeasureAbsolute(widthConstraint: number, heightConstraint: number, scale: number): ScaledSize;
195
208
  /** C# GradientByLines: FillGradient spans each line's bounds (default) instead of the whole text block. */
196
209
  GradientByLines: boolean;
@@ -138,7 +138,7 @@ export class SkiaLabel extends SkiaControl {
138
138
  const main = Super.GetFont(family, weight, italic, sizePx);
139
139
  const m = main.getMetrics();
140
140
  f = {
141
- Key: key, Main: main, SizePx: sizePx, Ascent: -m.ascent, Descent: m.descent,
141
+ Key: key, Main: main, SizePx: sizePx, Ascent: -m.ascent, Descent: m.descent, Italic: italic,
142
142
  Fallbacks: this.fontFamilyFallback
143
143
  ? this.fontFamilyFallback.split(",").map((a) => a.trim()).filter(Boolean).map((a) => Super.GetFont(a, weight, italic, sizePx))
144
144
  : [],
@@ -549,6 +549,7 @@ export class SkiaLabel extends SkiaControl {
549
549
  end++;
550
550
  rtlParagraph = SkiaLabel.FirstStrongIsRtl(lines.slice(li, end).map(lineText).join(""));
551
551
  }
552
+ line.Rtl = rtlParagraph;
552
553
  const map = BidiRuns(lineText(line), rtlParagraph);
553
554
  if (map) {
554
555
  line.Runs = this.SplitByRuns(line.Runs, map);
@@ -605,6 +606,30 @@ export class SkiaLabel extends SkiaControl {
605
606
  }
606
607
  return h;
607
608
  }
609
+ /** Skew of synthetic italic (Super.GetFont setSkewX -0.25): x moves by 0.25 per pixel above the baseline. */
610
+ static ItalicSkew = 0.25;
611
+ /** Pixels synthetic italic glyphs reach past the line box: right at the ascent, left at the descent. */
612
+ slantRight = 0;
613
+ slantLeft = 0;
614
+ /** The slant of synthetic italic is drawn outside the label's box: caches record that room too (C# / DrawnUi.Rust draw it whole). */
615
+ ComputeEffectsMargin(scale) {
616
+ const m = super.ComputeEffectsMargin(scale);
617
+ if (this.slantRight === 0 && this.slantLeft === 0)
618
+ return m;
619
+ return new Thickness(m.Left + this.slantLeft, m.Top, m.Right + this.slantRight, m.Bottom);
620
+ }
621
+ /**
622
+ * Where a line starts inside [left, right] (drawnui-cross 6am): Start and End follow the paragraph's direction (in a
623
+ * right-to-left paragraph Start is the right edge); Center is centered; Fill* lines are not stretched here and sit
624
+ * at the paragraph's start.
625
+ */
626
+ LineX(line, left, right, lineW) {
627
+ const a = this.horizontalTextAlignment;
628
+ if (a === "Center")
629
+ return left + (right - left - lineW) / 2;
630
+ const atEnd = a === "End" ? !line.Rtl : !!line.Rtl;
631
+ return atEnd ? right - lineW : left;
632
+ }
608
633
  MeasureAbsolute(widthConstraint, heightConstraint, scale) {
609
634
  this.mainFonts = this.ResolveMainFonts(scale);
610
635
  const glyphSpacing = scale * (this.characterSpacing - 1);
@@ -616,6 +641,19 @@ export class SkiaLabel extends SkiaControl {
616
641
  const extraH = this.EffectsExtra(scale).H;
617
642
  this.lines = this.text || this.Spans.length > 0 ? this.LayoutLines(widthConstraint - px, scale, heightConstraint - py - extraH) : [];
618
643
  this.ShapeLines(this.lines);
644
+ // synthetic italic leans its glyphs past their advances: drawing room for caches, widths unchanged (DrawnUi.Rust label.rs)
645
+ let slantRight = 0, slantLeft = 0;
646
+ for (const l of this.lines)
647
+ for (const r of l.Runs)
648
+ if (r.Fonts.Italic && r.Text.trim()) {
649
+ slantRight = Math.max(slantRight, SkiaLabel.ItalicSkew * r.Fonts.Ascent);
650
+ slantLeft = Math.max(slantLeft, SkiaLabel.ItalicSkew * r.Fonts.Descent);
651
+ }
652
+ if (slantRight !== this.slantRight || slantLeft !== this.slantLeft) {
653
+ this.slantRight = slantRight;
654
+ this.slantLeft = slantLeft;
655
+ this.InvalidateEffectsMargin();
656
+ }
619
657
  let width = 0;
620
658
  for (const l of this.lines)
621
659
  width = Math.max(width, l.Width);
@@ -649,11 +687,7 @@ export class SkiaLabel extends SkiaControl {
649
687
  y += this.ParagraphSpace(line);
650
688
  const lh = this.LineHeightPx(line);
651
689
  const lineW = line.Width + extra.W;
652
- let x = left;
653
- if (this.horizontalTextAlignment === "Center")
654
- x = left + (right - left - lineW) / 2;
655
- else if (this.horizontalTextAlignment === "End")
656
- x = right - lineW;
690
+ let x = this.LineX(line, left, right, lineW);
657
691
  x += extra.Stroke / 2;
658
692
  out.push({ x, y, w: line.Width, h: lh, text: line.Runs.map((r) => r.Text).join("") });
659
693
  y += lh * this.lineSpacing;
@@ -820,11 +854,7 @@ export class SkiaLabel extends SkiaControl {
820
854
  y += this.ParagraphSpace(line);
821
855
  const lh = this.LineHeightPx(line);
822
856
  const lineW = line.Width + extra.W;
823
- let x = left;
824
- if (this.horizontalTextAlignment === "Center")
825
- x = left + (right - left - lineW) / 2;
826
- else if (this.horizontalTextAlignment === "End")
827
- x = right - lineW;
857
+ let x = this.LineX(line, left, right, lineW);
828
858
  x += extra.Stroke / 2;
829
859
  const baseline = y + line.Ascent;
830
860
  // C# paintDefault gets the gradient over rectDraw, or over line.Bounds per line (GradientByLines)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drawnui-react",
3
- "version": "0.1.0-preview.30",
3
+ "version": "0.1.0-preview.31",
4
4
  "description": "DrawnUi for React: the DrawnUi (.NET) drawn-UI engine in TypeScript on CanvasKit (Skia WASM). Same controls, same PascalCase API as DrawnUi.Net.",
5
5
  "license": "MIT",
6
6
  "author": "Nick Kovalsky (AppoMobi)",
@@ -87,6 +87,7 @@
87
87
  "check:editor-focus": "node dev/check.mjs dev/check-editor-focus.ts",
88
88
  "check:shaping": "node dev/check.mjs dev/check-shaping.ts",
89
89
  "check:editor-rtl": "node dev/check.mjs dev/check-editor-rtl.ts",
90
+ "check:label-direction": "node dev/check.mjs dev/check-label-direction.ts",
90
91
  "site:extras": "node dev/site-extras.mjs dist/demo",
91
92
  "build:lib": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
92
93
  "prepublishOnly": "npm run build:lib",