@mlightcad/mtext-renderer 0.13.6 → 0.13.8

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.
@@ -319,6 +319,30 @@ export declare class FontManager {
319
319
  * Used after primary and optional bigFont lookups per AutoCAD text-style semantics.
320
320
  */
321
321
  getCharShapeFromDefaults(char: string, size: number): BaseTextShape | undefined;
322
+ /**
323
+ * Looks up `char` in every loaded SHX BIGFONT face (and BIGFONT names listed
324
+ * in {@link defaultFonts}), using each face's own scale factor.
325
+ *
326
+ * AutoCAD text styles bind one Big Font file, but when that face's code page
327
+ * cannot represent a glyph (e.g. simplified Chinese on Japanese `bigfont.shx`)
328
+ * viewers still find the character in another available Big Font such as
329
+ * `gbcbig.shx`. A hand-maintained simplified→Japanese character map cannot
330
+ * cover the repertoire; searching loaded BIGFONT faces does.
331
+ *
332
+ * @param char - Character to resolve.
333
+ * @param layoutSize - MTEXT layout height (cap-height), before per-font scale.
334
+ * @param excludeFontName - Optional style Big Font already tried.
335
+ * @returns Shape plus the font that supplied it, or `undefined`.
336
+ */
337
+ getCharShapeFromLoadedBigfonts(char: string, layoutSize: number, excludeFontName?: string): {
338
+ shape: BaseTextShape;
339
+ fontName: string;
340
+ } | undefined;
341
+ /**
342
+ * Horizontal BIGFONT cell width at `layoutSize` for the named face, or
343
+ * `undefined` when the face is missing / not a BIGFONT.
344
+ */
345
+ getBigfontCellWidth(fontName: string, layoutSize: number): number | undefined;
322
346
  /**
323
347
  * Gets the text shape from configured GDT / symbol fonts (e.g. `amgdt.shx`)
324
348
  * by font-internal character code.
@@ -485,7 +485,8 @@ export declare class MTextProcessor {
485
485
  * Lays out and renders one parser word token, breaking to a new visual line when needed.
486
486
  *
487
487
  * - CJK / non-Latin: no whole-word wrap — {@link processChar} breaks between
488
- * characters when the next glyph would not fit in the defined width.
488
+ * characters when the pen has already reached the defined width (a glyph
489
+ * that starts inside may slightly overshoot).
489
490
  * - Latin/ASCII: wrap only at word boundaries (spaces). AutoCAD/GstarCAD do
490
491
  * not hyphenate: a token wider than the column stays on one visual line and
491
492
  * overflows the box (e.g. part numbers like `1157*25*1.5`). A short run that
@@ -560,10 +561,14 @@ export declare class MTextProcessor {
560
561
  * Renders one character glyph, including decorations and line-break handling.
561
562
  *
562
563
  * Missing glyphs are treated as spaces. Soft wrap is decided before placement:
563
- * if the glyph's advance would not fit in the remaining defined width, break
564
- * first (CJK may break between any two characters). Latin/ASCII word tokens
565
- * suppress this so they overflow instead of hyphenating. The first glyph on an
566
- * empty line is always placed even when wider than the box.
564
+ * break when the pen has already reached the defined width so the next glyph
565
+ * cannot *start* inside the column (CJK may break between any two characters).
566
+ * A glyph that starts inside the column is kept even if its advance slightly
567
+ * overshoots — AutoCAD title-block cells are often sized to N capital-A CJK
568
+ * advances within a fraction of a percent, and wrapping on end-past-width
569
+ * falsely pushes the last ideograph onto the next line. Latin/ASCII word
570
+ * tokens suppress this so they overflow instead of hyphenating. The first
571
+ * glyph on an empty line is always placed even when wider than the box.
567
572
  *
568
573
  * @param char Character to render.
569
574
  * @param geometries Mesh geometry accumulator.
@@ -618,15 +623,17 @@ export declare class MTextProcessor {
618
623
  */
619
624
  private resolvePercentSymbolShape;
620
625
  /**
621
- * Resolves the text shape for one character using primary font, big font, defaults, and symbol fonts.
626
+ * Drawing-space glyph size for a specific face.
622
627
  *
623
- * Updates {@link _maxFontSize} when the active font size exceeds the current line maximum.
624
- * Falls back to the not-found glyph when no renderable geometry is available.
625
- *
626
- * @param char Character to resolve.
627
- * @returns Renderable text shape and the font that supplied it.
628
+ * {@link currentFontSize} is inflated by the *primary* style font's scale
629
+ * factor (SHX cap-height or TrueType capital-A). BIGFONT / fallback faces
630
+ * have their own scale — fetching them at the primary size stretches CJK
631
+ * cells and shifts mixed runs.
628
632
  */
633
+ private shapeSizeForFont;
629
634
  private resolveCharShape;
635
+ /** CJK Unified Ideographs and common compatibility blocks used in CAD text. */
636
+ private isCjkIdeograph;
630
637
  private canProbeFontOwnership;
631
638
  private fontHasChar;
632
639
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlightcad/mtext-renderer",
3
- "version": "0.13.6",
3
+ "version": "0.13.8",
4
4
  "description": "AutoCAD MText renderer based on Three.js",
5
5
  "license": "MIT",
6
6
  "author": "MLight Lee <mlight.lee@outlook.com>",
@@ -49,14 +49,14 @@
49
49
  "opentype.js": "^2.0.0"
50
50
  },
51
51
  "devDependencies": {
52
- "@mlightcad/mtext-parser": "^1.5.5",
52
+ "@mlightcad/mtext-parser": "^1.5.7",
53
53
  "@types/opentype.js": "^1.3.10",
54
54
  "@types/three": "^0.186.0",
55
55
  "three": "^0.186.1",
56
56
  "vitest": "^3.2.4"
57
57
  },
58
58
  "peerDependencies": {
59
- "@mlightcad/mtext-parser": "^1.5.5",
59
+ "@mlightcad/mtext-parser": "^1.5.7",
60
60
  "three": ">=0.185.1"
61
61
  },
62
62
  "scripts": {