@itwin/core-backend 5.3.0-dev.2 → 5.3.0-dev.4

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.
Files changed (45) hide show
  1. package/lib/cjs/IModelDb.js +1 -1
  2. package/lib/cjs/IModelDb.js.map +1 -1
  3. package/lib/cjs/annotations/FrameGeometry.js +6 -6
  4. package/lib/cjs/annotations/FrameGeometry.js.map +1 -1
  5. package/lib/cjs/annotations/LeaderGeometry.js +4 -4
  6. package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
  7. package/lib/cjs/annotations/TextAnnotationElement.d.ts +101 -20
  8. package/lib/cjs/annotations/TextAnnotationElement.d.ts.map +1 -1
  9. package/lib/cjs/annotations/TextAnnotationElement.js +202 -64
  10. package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -1
  11. package/lib/cjs/annotations/TextBlockGeometry.js +3 -3
  12. package/lib/cjs/annotations/TextBlockGeometry.js.map +1 -1
  13. package/lib/cjs/annotations/TextBlockLayout.d.ts +2 -2
  14. package/lib/cjs/annotations/TextBlockLayout.d.ts.map +1 -1
  15. package/lib/cjs/annotations/TextBlockLayout.js +52 -25
  16. package/lib/cjs/annotations/TextBlockLayout.js.map +1 -1
  17. package/lib/esm/IModelDb.js +1 -1
  18. package/lib/esm/IModelDb.js.map +1 -1
  19. package/lib/esm/annotations/FrameGeometry.js +6 -6
  20. package/lib/esm/annotations/FrameGeometry.js.map +1 -1
  21. package/lib/esm/annotations/LeaderGeometry.js +4 -4
  22. package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
  23. package/lib/esm/annotations/TextAnnotationElement.d.ts +101 -20
  24. package/lib/esm/annotations/TextAnnotationElement.d.ts.map +1 -1
  25. package/lib/esm/annotations/TextAnnotationElement.js +201 -63
  26. package/lib/esm/annotations/TextAnnotationElement.js.map +1 -1
  27. package/lib/esm/annotations/TextBlockGeometry.js +3 -3
  28. package/lib/esm/annotations/TextBlockGeometry.js.map +1 -1
  29. package/lib/esm/annotations/TextBlockLayout.d.ts +2 -2
  30. package/lib/esm/annotations/TextBlockLayout.d.ts.map +1 -1
  31. package/lib/esm/annotations/TextBlockLayout.js +52 -25
  32. package/lib/esm/annotations/TextBlockLayout.js.map +1 -1
  33. package/lib/esm/test/AnnotationTestUtils.js +1 -1
  34. package/lib/esm/test/AnnotationTestUtils.js.map +1 -1
  35. package/lib/esm/test/annotations/Fields.test.js +2 -2
  36. package/lib/esm/test/annotations/Fields.test.js.map +1 -1
  37. package/lib/esm/test/annotations/FrameGeometry.test.js +4 -4
  38. package/lib/esm/test/annotations/FrameGeometry.test.js.map +1 -1
  39. package/lib/esm/test/annotations/LeaderGeometry.test.js +8 -8
  40. package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
  41. package/lib/esm/test/annotations/TextAnnotation.test.js +130 -35
  42. package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
  43. package/lib/esm/test/annotations/TextBlock.test.js +218 -151
  44. package/lib/esm/test/annotations/TextBlock.test.js.map +1 -1
  45. package/package.json +14 -14
@@ -19,11 +19,11 @@ function setColor(color, context) {
19
19
  }
20
20
  function createTextString(text, run, origin) {
21
21
  (0, core_bentley_1.assert)(text.length > 0);
22
- const { lineHeight, widthFactor, isBold, isItalic, isUnderlined } = run.style;
22
+ const { textHeight, widthFactor, isBold, isItalic, isUnderlined } = run.style;
23
23
  return new core_common_1.TextString({
24
24
  text,
25
25
  font: run.fontId,
26
- height: lineHeight,
26
+ height: textHeight,
27
27
  widthFactor,
28
28
  bold: isBold,
29
29
  italic: isItalic,
@@ -74,7 +74,7 @@ function processFractionRun(run, transform, context) {
74
74
  return;
75
75
  }
76
76
  (0, core_bentley_1.assert)(undefined !== run.numeratorRange && undefined !== run.denominatorRange);
77
- const fontSize = new core_geometry_1.Vector2d(run.style.lineHeight * run.style.widthFactor, run.style.lineHeight);
77
+ const fontSize = new core_geometry_1.Vector2d(run.style.textHeight * run.style.widthFactor, run.style.textHeight);
78
78
  fontSize.scale(run.style.stackedFractionScale, fontSize);
79
79
  const numeratorOffset = new core_geometry_1.Point3d(run.numeratorRange.low.x, run.numeratorRange.low.y, 0);
80
80
  const denominatorOffset = new core_geometry_1.Point3d(run.denominatorRange.low.x, run.denominatorRange.low.y, 0);
@@ -1 +1 @@
1
- {"version":3,"file":"TextBlockGeometry.js","sourceRoot":"","sources":["../../../src/annotations/TextBlockGeometry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AA8IH,4DAmCC;AA/KD,oDAAqH;AAErH,wDAA4F;AAC5F,sDAA6C;AAO7C,SAAS,QAAQ,CAAC,KAAqB,EAAE,OAAwB;IAC/D,IAAI,KAAK,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC/B,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC;QACzB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAClC,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY,EAAE,GAAc,EAAE,MAAgB;IACtE,IAAA,qBAAM,EAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAExB,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC;IAE9E,OAAO,IAAI,wBAAU,CAAC;QACpB,IAAI;QACJ,IAAI,EAAE,GAAG,CAAC,MAAM;QAChB,MAAM,EAAE,UAAU;QAClB,WAAW;QACX,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,YAAY;QACvB,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CAAC,GAAc,EAAE,SAAoB,EAAE,OAAwB;IACpF,IAAA,qBAAM,EAAC,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG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AAE,CAAC;gBAC/B,cAAc,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YACzC,CAAC;iBAAM,IAAI,UAAU,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC1C,kBAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC7C,CAAC;iBAAM,CAAC;gBACN,eAAe,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;AACtC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ElementGeometry\n */\n\nimport { TextBlockGeometryProps, TextBlockGeometryPropsEntry, TextString, TextStyleColor } from \"@itwin/core-common\";\nimport { RunLayout, TextBlockLayout } from \"./TextBlockLayout\";\nimport { LineSegment3d, Point3d, Range2d, Transform, Vector2d } from \"@itwin/core-geometry\";\nimport { assert } from \"@itwin/core-bentley\";\n\ninterface GeometryContext {\n curColor?: TextStyleColor;\n entries: TextBlockGeometryPropsEntry[];\n}\n\nfunction setColor(color: TextStyleColor, context: GeometryContext): void {\n if (color !== context.curColor) {\n context.curColor = color;\n context.entries.push({ color });\n }\n}\n\nfunction createTextString(text: string, run: RunLayout, origin?: Point3d): TextString {\n assert(text.length > 0);\n\n const { lineHeight, widthFactor, isBold, isItalic, isUnderlined } = run.style;\n\n return new TextString({\n text,\n font: run.fontId,\n height: lineHeight,\n widthFactor,\n bold: isBold,\n italic: isItalic,\n underline: isUnderlined,\n origin,\n });\n}\n\nfunction processTextRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\n assert(run.source.type === \"text\");\n const text = run.source.content.substring(run.charOffset, run.charOffset + run.numChars);\n if (text.length === 0) {\n return;\n }\n\n const ts = createTextString(text, run);\n if (\"none\" !== run.source.baselineShift) {\n const isSub = \"subscript\" === run.source.baselineShift;\n const offsetFactor = run.style[isSub ? \"subScriptOffsetFactor\" : \"superScriptOffsetFactor\"];\n const scale = run.style[isSub ? \"subScriptScale\" : \"superScriptScale\"];\n\n ts.origin.y += offsetFactor * ts.height;\n ts.height *= scale;\n }\n\n ts.transformInPlace(transform);\n\n setColor(run.style.color, context);\n context.entries.push({ text: ts });\n}\n\nfunction processFieldRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\n assert(run.source.type === \"field\");\n const text = run.source.cachedContent.substring(run.charOffset, run.charOffset + run.numChars);\n if (text.length === 0) {\n return;\n }\n\n const ts = createTextString(text, run);\n ts.transformInPlace(transform);\n\n setColor(run.style.color, context);\n context.entries.push({ text: ts });\n}\n\nfunction createFractionTextString(text: string, run: RunLayout, origin: Point3d, transform: Transform): TextString {\n const ts = createTextString(text, run, origin);\n assert(undefined !== ts.widthFactor);\n\n ts.height *= run.style.stackedFractionScale;\n\n ts.transformInPlace(transform);\n\n return ts;\n}\n\nfunction processFractionRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\n const source = run.source;\n assert(source.type === \"fraction\");\n\n if (source.numerator.length === 0 && source.denominator.length === 0) {\n return;\n }\n\n assert(undefined !== run.numeratorRange && undefined !== run.denominatorRange);\n\n const fontSize = new Vector2d(run.style.lineHeight * run.style.widthFactor, run.style.lineHeight);\n fontSize.scale(run.style.stackedFractionScale, fontSize);\n\n const numeratorOffset = new Point3d(run.numeratorRange.low.x, run.numeratorRange.low.y, 0);\n const denominatorOffset = new Point3d(run.denominatorRange.low.x, run.denominatorRange.low.y, 0);\n\n setColor(run.style.color, context);\n\n if (source.numerator.length > 0) {\n context.entries.push({ text: createFractionTextString(source.numerator, run, numeratorOffset, transform) });\n }\n\n const numeratorRange = Range2d.fromJSON(run.numeratorRange);\n const denominatorRange = Range2d.fromJSON(run.denominatorRange);\n\n let separator: LineSegment3d;\n if (run.style.stackedFractionType === \"horizontal\") {\n const fractionWidth = Math.max(numeratorRange.xLength(), denominatorRange.xLength());\n const y = 1.25 * denominatorRange.yLength();\n separator = LineSegment3d.createXYXY(0, y, fractionWidth, y);\n } else {\n const p0 = new Point3d(denominatorRange.low.x - fontSize.x / 2, denominatorRange.low.y + fontSize.y * (1 / 3), 0);\n const p1 = new Point3d(p0.x + fontSize.x, p0.y + fontSize.y * 1.5, 0);\n separator = LineSegment3d.createCapture(p0, p1);\n }\n\n separator.tryTransformInPlace(transform);\n\n context.entries.push({\n separator: {\n startPoint: separator.point0Ref.toJSON(),\n endPoint: separator.point1Ref.toJSON(),\n },\n });\n\n if (source.denominator.length > 0) {\n context.entries.push({ text: createFractionTextString(source.denominator, run, denominatorOffset, transform) });\n }\n}\n\n/**\n * Produces the geometry for a text block in a way that can be interpreted by a [[GeometryStreamBuilder]] or [[ElementBuilder.Geometry]].\n * To build the geometry for a whole [[TextAnnotation]], use [[appendTextAnnotationGeometry]] instead.\n * @param layout of the text block as computed by [[layoutTextBlock]].\n * @param documentTransform that positions the text block in world coordinates.\n * @returns TextBlockGeometryProps.\n * @beta\n */\nexport function produceTextBlockGeometry(layout: TextBlockLayout, documentTransform: Transform): TextBlockGeometryProps {\n const context: GeometryContext = { entries: [] };\n for (const line of layout.lines) {\n const lineTrans = Transform.createTranslationXYZ(line.offsetFromDocument.x, line.offsetFromDocument.y, 0);\n\n // Create geometry for list markers if present\n if (line.marker) {\n const markerTrans = Transform.createTranslationXYZ(line.marker.offsetFromLine.x, line.marker.offsetFromLine.y, 0);\n lineTrans.multiplyTransformTransform(markerTrans, markerTrans);\n documentTransform.multiplyTransformTransform(markerTrans, markerTrans);\n\n processTextRun(line.marker, markerTrans, context);\n }\n\n // Create geometry for runs\n for (const run of line.runs) {\n // Skip runs that are solely whitespace\n if (run.source.isWhitespace) {\n continue;\n }\n\n const runTrans = Transform.createTranslationXYZ(run.offsetFromLine.x, run.offsetFromLine.y, 0);\n lineTrans.multiplyTransformTransform(runTrans, runTrans);\n documentTransform.multiplyTransformTransform(runTrans, runTrans);\n if (\"text\" === run.source.type) {\n processTextRun(run, runTrans, context);\n } else if (\"fraction\" === run.source.type) {\n processFractionRun(run, runTrans, context);\n } else {\n processFieldRun(run, runTrans, context);\n }\n }\n }\n\n return { entries: context.entries };\n}\n"]}
1
+ {"version":3,"file":"TextBlockGeometry.js","sourceRoot":"","sources":["../../../src/annotations/TextBlockGeometry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AA8IH,4DAmCC;AA/KD,oDAAqH;AAErH,wDAA4F;AAC5F,sDAA6C;AAO7C,SAAS,QAAQ,CAAC,KAAqB,EAAE,OAAwB;IAC/D,IAAI,KAAK,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC/B,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC;QACzB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAClC,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY,EAAE,GAAc,EAAE,MAAgB;IACtE,IAAA,qBAAM,EAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAExB,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC;IAE9E,OAAO,IAAI,wBAAU,CAAC;QACpB,IAAI;QACJ,IAAI,EAAE,GAAG,CAAC,MAAM;QAChB,MAAM,EAAE,UAAU;QAClB,WAAW;QACX,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,YAAY;QACvB,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CAAC,GAAc,EAAE,SAAoB,EAAE,OAAwB;IACpF,IAAA,qBAAM,EAAC,GAAG,CAAC,MAAM,CAAC,IAAI,K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I,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC/B,cAAc,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YACzC,CAAC;iBAAM,IAAI,UAAU,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC1C,kBAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC7C,CAAC;iBAAM,CAAC;gBACN,eAAe,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;AACtC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ElementGeometry\n */\n\nimport { TextBlockGeometryProps, TextBlockGeometryPropsEntry, TextString, TextStyleColor } from \"@itwin/core-common\";\nimport { RunLayout, TextBlockLayout } from \"./TextBlockLayout\";\nimport { LineSegment3d, Point3d, Range2d, Transform, Vector2d } from \"@itwin/core-geometry\";\nimport { assert } from \"@itwin/core-bentley\";\n\ninterface GeometryContext {\n curColor?: TextStyleColor;\n entries: TextBlockGeometryPropsEntry[];\n}\n\nfunction setColor(color: TextStyleColor, context: GeometryContext): void {\n if (color !== context.curColor) {\n context.curColor = color;\n context.entries.push({ color });\n }\n}\n\nfunction createTextString(text: string, run: RunLayout, origin?: Point3d): TextString {\n assert(text.length > 0);\n\n const { textHeight, widthFactor, isBold, isItalic, isUnderlined } = run.style;\n\n return new TextString({\n text,\n font: run.fontId,\n height: textHeight,\n widthFactor,\n bold: isBold,\n italic: isItalic,\n underline: isUnderlined,\n origin,\n });\n}\n\nfunction processTextRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\n assert(run.source.type === \"text\");\n const text = run.source.content.substring(run.charOffset, run.charOffset + run.numChars);\n if (text.length === 0) {\n return;\n }\n\n const ts = createTextString(text, run);\n if (\"none\" !== run.source.baselineShift) {\n const isSub = \"subscript\" === run.source.baselineShift;\n const offsetFactor = run.style[isSub ? \"subScriptOffsetFactor\" : \"superScriptOffsetFactor\"];\n const scale = run.style[isSub ? \"subScriptScale\" : \"superScriptScale\"];\n\n ts.origin.y += offsetFactor * ts.height;\n ts.height *= scale;\n }\n\n ts.transformInPlace(transform);\n\n setColor(run.style.color, context);\n context.entries.push({ text: ts });\n}\n\nfunction processFieldRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\n assert(run.source.type === \"field\");\n const text = run.source.cachedContent.substring(run.charOffset, run.charOffset + run.numChars);\n if (text.length === 0) {\n return;\n }\n\n const ts = createTextString(text, run);\n ts.transformInPlace(transform);\n\n setColor(run.style.color, context);\n context.entries.push({ text: ts });\n}\n\nfunction createFractionTextString(text: string, run: RunLayout, origin: Point3d, transform: Transform): TextString {\n const ts = createTextString(text, run, origin);\n assert(undefined !== ts.widthFactor);\n\n ts.height *= run.style.stackedFractionScale;\n\n ts.transformInPlace(transform);\n\n return ts;\n}\n\nfunction processFractionRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\n const source = run.source;\n assert(source.type === \"fraction\");\n\n if (source.numerator.length === 0 && source.denominator.length === 0) {\n return;\n }\n\n assert(undefined !== run.numeratorRange && undefined !== run.denominatorRange);\n\n const fontSize = new Vector2d(run.style.textHeight * run.style.widthFactor, run.style.textHeight);\n fontSize.scale(run.style.stackedFractionScale, fontSize);\n\n const numeratorOffset = new Point3d(run.numeratorRange.low.x, run.numeratorRange.low.y, 0);\n const denominatorOffset = new Point3d(run.denominatorRange.low.x, run.denominatorRange.low.y, 0);\n\n setColor(run.style.color, context);\n\n if (source.numerator.length > 0) {\n context.entries.push({ text: createFractionTextString(source.numerator, run, numeratorOffset, transform) });\n }\n\n const numeratorRange = Range2d.fromJSON(run.numeratorRange);\n const denominatorRange = Range2d.fromJSON(run.denominatorRange);\n\n let separator: LineSegment3d;\n if (run.style.stackedFractionType === \"horizontal\") {\n const fractionWidth = Math.max(numeratorRange.xLength(), denominatorRange.xLength());\n const y = 1.25 * denominatorRange.yLength();\n separator = LineSegment3d.createXYXY(0, y, fractionWidth, y);\n } else {\n const p0 = new Point3d(denominatorRange.low.x - fontSize.x / 2, denominatorRange.low.y + fontSize.y * (1 / 3), 0);\n const p1 = new Point3d(p0.x + fontSize.x, p0.y + fontSize.y * 1.5, 0);\n separator = LineSegment3d.createCapture(p0, p1);\n }\n\n separator.tryTransformInPlace(transform);\n\n context.entries.push({\n separator: {\n startPoint: separator.point0Ref.toJSON(),\n endPoint: separator.point1Ref.toJSON(),\n },\n });\n\n if (source.denominator.length > 0) {\n context.entries.push({ text: createFractionTextString(source.denominator, run, denominatorOffset, transform) });\n }\n}\n\n/**\n * Produces the geometry for a text block in a way that can be interpreted by a [[GeometryStreamBuilder]] or [[ElementBuilder.Geometry]].\n * To build the geometry for a whole [[TextAnnotation]], use [[appendTextAnnotationGeometry]] instead.\n * @param layout of the text block as computed by [[layoutTextBlock]].\n * @param documentTransform that positions the text block in world coordinates.\n * @returns TextBlockGeometryProps.\n * @beta\n */\nexport function produceTextBlockGeometry(layout: TextBlockLayout, documentTransform: Transform): TextBlockGeometryProps {\n const context: GeometryContext = { entries: [] };\n for (const line of layout.lines) {\n const lineTrans = Transform.createTranslationXYZ(line.offsetFromDocument.x, line.offsetFromDocument.y, 0);\n\n // Create geometry for list markers if present\n if (line.marker) {\n const markerTrans = Transform.createTranslationXYZ(line.marker.offsetFromLine.x, line.marker.offsetFromLine.y, 0);\n lineTrans.multiplyTransformTransform(markerTrans, markerTrans);\n documentTransform.multiplyTransformTransform(markerTrans, markerTrans);\n\n processTextRun(line.marker, markerTrans, context);\n }\n\n // Create geometry for runs\n for (const run of line.runs) {\n // Skip runs that are solely whitespace\n if (run.source.isWhitespace) {\n continue;\n }\n\n const runTrans = Transform.createTranslationXYZ(run.offsetFromLine.x, run.offsetFromLine.y, 0);\n lineTrans.multiplyTransformTransform(runTrans, runTrans);\n documentTransform.multiplyTransformTransform(runTrans, runTrans);\n if (\"text\" === run.source.type) {\n processTextRun(run, runTrans, context);\n } else if (\"fraction\" === run.source.type) {\n processFractionRun(run, runTrans, context);\n } else {\n processFieldRun(run, runTrans, context);\n }\n }\n }\n\n return { entries: context.entries };\n}\n"]}
@@ -20,7 +20,7 @@ export interface ComputeRangesForTextLayoutArgs {
20
20
  baselineShift: BaselineShift;
21
21
  fontId: FontId;
22
22
  widthFactor: number;
23
- lineHeight: number;
23
+ textHeight: number;
24
24
  }
25
25
  /** A function that uses a font to compute the layout and justification ranges of a string of text.
26
26
  * @internal
@@ -130,7 +130,7 @@ declare class LayoutContext {
130
130
  private readonly _findFontId;
131
131
  private readonly _fontIds;
132
132
  constructor(textStyleResolver: TextStyleResolver, _computeTextRange: ComputeRangesForTextLayout, _findFontId: FindFontId);
133
- findFontId(name: string): FontId;
133
+ findFontId(name: string, type?: FontType): FontId;
134
134
  computeRangeForText(chars: string, style: TextStyleSettings, baselineShift: BaselineShift): TextLayoutRanges;
135
135
  computeRangeForTextRun(style: TextStyleSettings, run: TextRun | FieldRun, charOffset: number, numChars: number): TextLayoutRanges;
136
136
  computeRangeForFractionRun(style: TextStyleSettings, source: FractionRun): {
@@ -1 +1 @@
1
- {"version":3,"file":"TextBlockLayout.d.ts","sourceRoot":"","sources":["../../../src/annotations/TextBlockLayout.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAiB,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,eAAe,EAAgC,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,qBAAqB,EAAoB,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACtU,OA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,EAAE,sBAAsB,EAAE,OAAO,CAAC,EAAE,aAAa,EAAE,KAAK,GAAE,MAAU;IAM5H,yEAAyE;IAClE,SAAS,IAAI,MAAM;IAK1B,kEAAkE;IAClE,IAAW,IAAI,IAAI,aAAa,CAAC,SAAS,CAAC,CAAuB;IAClE,qDAAqD;IACrD,IAAW,OAAO,YAAsC;IACxD,4CAA4C;IAC5C,IAAW,IAAI,IAAI,SAAS,CAG3B;IAED;;;SAGK;IACL,IAAW,MAAM,IAAI,SAAS,GAAG,SAAS,CAAyB;IACnE,IAAW,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,EAA2B;IAElE,MAAM,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI;IAKnC,6CAA6C;IAC7C,OAAO,CAAC,aAAa;IAyEd,QAAQ,IAAI,gBAAgB;CASpC;AAED;;;;;GAKG;AACH,qBAAa,eAAe;IACnB,MAAM,EAAE,SAAS,CAAC;IAEzB,8FAA8F;IACvF,SAAS,UAAiB;IAEjC,wDAAwD;IACjD,KAAK,UAAiB;IACtB,KAAK,EAAE,UAAU,EAAE,CAAM;IAChC,OAAO,CAAC,QAAQ,CAAgB;gBAEb,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa;IAcrD,QAAQ,IAAI,qBAAqB;IAOxC,yEAAyE;IAClE,SAAS,IAAI,MAAM;IAI1B,OAAO,KAAK,KAAK,GAGhB;IAED,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,iBAAiB;IAkFzB,OAAO,CAAC,WAAW;IAwCnB,OAAO,CAAC,SAAS;IA2CjB,OAAO,CAAC,YAAY;IA6BpB,OAAO,CAAC,YAAY;CAoBrB"}
@@ -79,7 +79,7 @@ function scaleRange(range, scale) {
79
79
  range.high.scaleInPlace(scale);
80
80
  }
81
81
  /**
82
- * Applies block level settings (lineSpacingFactor, lineHeight, widthFactor, frame, and leader) to a [TextStyleSettings]($common).
82
+ * Applies block level settings (lineSpacingFactor, paragraphSpacingFactor, widthFactor, frame, margins, justification, and leader) to a [TextStyleSettings]($common).
83
83
  * These must be set on the block, as they are meaningless on individual paragraphs/runs.
84
84
  * However, leaders are a special case and can override the block's leader settings.
85
85
  * Setting `isLeader` to `true` makes the [TextBlock]($common) settings not override the leader's settings.
@@ -90,21 +90,27 @@ function applyBlockSettings(target, source, isLeader = false) {
90
90
  return target;
91
91
  }
92
92
  const lineSpacingFactor = source.lineSpacingFactor ?? target.lineSpacingFactor;
93
- const lineHeight = source.lineHeight ?? target.lineHeight;
93
+ const paragraphSpacingFactor = source.paragraphSpacingFactor ?? target.paragraphSpacingFactor;
94
94
  const widthFactor = source.widthFactor ?? target.widthFactor;
95
+ const justification = source.justification ?? target.justification;
95
96
  const frame = source.frame ?? target.frame;
97
+ const margins = source.margins ?? target.margins;
96
98
  const leader = source.leader ?? target.leader;
97
99
  const leaderShouldChange = !isLeader && !target.leaderEquals(leader);
98
100
  if (lineSpacingFactor !== target.lineSpacingFactor ||
99
- lineHeight !== target.lineHeight ||
101
+ paragraphSpacingFactor !== target.paragraphSpacingFactor ||
100
102
  widthFactor !== target.widthFactor ||
103
+ justification !== target.justification ||
101
104
  !target.frameEquals(frame) ||
105
+ !target.marginsEqual(margins) ||
102
106
  leaderShouldChange) {
103
107
  const cloneProps = {
104
108
  lineSpacingFactor,
105
- lineHeight,
109
+ paragraphSpacingFactor,
106
110
  widthFactor,
111
+ justification,
107
112
  frame,
113
+ margins,
108
114
  };
109
115
  if (leaderShouldChange) {
110
116
  cloneProps.leader = leader;
@@ -160,35 +166,35 @@ class LayoutContext {
160
166
  this._computeTextRange = _computeTextRange;
161
167
  this._findFontId = _findFontId;
162
168
  }
163
- findFontId(name) {
169
+ findFontId(name, type) {
164
170
  let fontId = this._fontIds.get(name);
165
171
  if (undefined === fontId) {
166
- this._fontIds.set(name, fontId = this._findFontId(name));
172
+ this._fontIds.set(name, fontId = this._findFontId(name, type));
167
173
  }
168
174
  return fontId;
169
175
  }
170
176
  computeRangeForText(chars, style, baselineShift) {
171
177
  if (chars.length === 0) {
172
178
  return {
173
- layout: new core_geometry_1.Range2d(0, 0, 0, style.lineHeight),
179
+ layout: new core_geometry_1.Range2d(0, 0, 0, style.textHeight),
174
180
  justification: new core_geometry_1.Range2d(),
175
181
  };
176
182
  }
177
- const fontId = this.findFontId(style.fontName);
183
+ const fontId = this.findFontId(style.font.name, style.font.type);
178
184
  const { layout, justification } = this._computeTextRange({
179
185
  chars,
180
186
  fontId,
181
187
  baselineShift,
182
188
  bold: style.isBold,
183
189
  italic: style.isItalic,
184
- lineHeight: this.textStyleResolver.blockSettings.lineHeight,
190
+ textHeight: style.textHeight,
185
191
  widthFactor: this.textStyleResolver.blockSettings.widthFactor,
186
192
  });
187
193
  if ("none" !== baselineShift) {
188
194
  const isSub = "subscript" === baselineShift;
189
195
  const scale = isSub ? style.subScriptScale : style.superScriptScale;
190
196
  const offsetFactor = isSub ? style.subScriptOffsetFactor : style.superScriptOffsetFactor;
191
- const offset = { x: 0, y: style.lineHeight * offsetFactor };
197
+ const offset = { x: 0, y: style.textHeight * offsetFactor };
192
198
  scaleRange(layout, scale);
193
199
  layout.cloneTranslated(offset, layout);
194
200
  scaleRange(justification, scale);
@@ -240,7 +246,7 @@ class LayoutContext {
240
246
  computeRangeForTabRun(style, source, lengthFromLastTab) {
241
247
  const interval = source.styleOverrides.tabInterval ?? style.tabInterval;
242
248
  const tabEndX = interval - lengthFromLastTab % interval;
243
- const range = new core_geometry_1.Range2d(0, 0, 0, style.lineHeight);
249
+ const range = new core_geometry_1.Range2d(0, 0, 0, style.textHeight);
244
250
  range.extendXY(tabEndX, range.low.y);
245
251
  return range;
246
252
  }
@@ -297,7 +303,7 @@ class RunLayout {
297
303
  }
298
304
  static create(source, context, cumulativeOverrides) {
299
305
  const style = context.textStyleResolver.resolveSettings(cumulativeOverrides);
300
- const fontId = context.findFontId(style.fontName);
306
+ const fontId = context.findFontId(style.font.name, style.font.type);
301
307
  const charOffset = 0;
302
308
  const offsetFromLine = { x: 0, y: 0 };
303
309
  let numChars = 0;
@@ -323,7 +329,7 @@ class RunLayout {
323
329
  default: { // "linebreak" or "tab"
324
330
  // "tab": Tabs rely on the context they are in, so we compute its range later.
325
331
  // lineBreak: We do this so that blank lines space correctly without special casing later.
326
- range = new core_geometry_1.Range2d(0, 0, 0, style.lineHeight);
332
+ range = new core_geometry_1.Range2d(0, 0, 0, style.textHeight);
327
333
  break;
328
334
  }
329
335
  }
@@ -437,15 +443,36 @@ class LineLayout {
437
443
  this.runRange.low.setZero();
438
444
  this.runRange.high.setZero();
439
445
  this.lengthFromLastTab = 0;
440
- // Some runs (fractions) are taller than others.
441
- // We want to center each run vertically inside the line.
442
446
  let lineHeight = 0;
447
+ let tallestNonFractionRun;
443
448
  for (const run of this._runs) {
444
- lineHeight = Math.max(lineHeight, run.range.yLength());
449
+ const runHeight = run.range.yLength();
450
+ lineHeight = Math.max(lineHeight, runHeight);
451
+ if (run.source.type !== "fraction" && (!tallestNonFractionRun || runHeight > tallestNonFractionRun.range.yLength())) {
452
+ tallestNonFractionRun = run;
453
+ }
454
+ }
455
+ // // The baseline for the line is the bottom of the tallest non-fraction run, centered in the line.
456
+ let baseline = 0;
457
+ if (tallestNonFractionRun) {
458
+ baseline = (lineHeight + tallestNonFractionRun.range.yLength()) / 2;
445
459
  }
446
460
  for (const run of this._runs) {
447
461
  const runHeight = run.range.yLength();
448
- const runOffset = { x: this.runRange.high.x, y: (lineHeight - runHeight) / 2 };
462
+ // Vertically align runs: normal text at baseline, fractions visually centered on text or line as appropriate.
463
+ let yOffset = lineHeight - baseline;
464
+ if (run.source.type === "fraction") {
465
+ const denominatorHeight = run.denominatorRange?.yLength() ?? 0;
466
+ if (tallestNonFractionRun && run.style.textHeight <= tallestNonFractionRun.style.textHeight) {
467
+ // Shift fraction to baseline, then down by half the denominator height so it appears centered relative to any non-fraction text of the same height.
468
+ yOffset = (lineHeight - baseline) - denominatorHeight / 2;
469
+ }
470
+ else {
471
+ // If the fraction text height is greater than the largest non-fraction text, just center it in the line.
472
+ yOffset = (lineHeight - runHeight) / 2;
473
+ }
474
+ }
475
+ const runOffset = { x: this.runRange.high.x, y: yOffset };
449
476
  run.offsetFromLine = runOffset;
450
477
  const runLayoutRange = run.range.cloneTranslated(runOffset);
451
478
  this.runRange.extendRange(runLayoutRange);
@@ -507,8 +534,8 @@ class TextBlockLayout {
507
534
  this.textRange.high.x = source.width;
508
535
  }
509
536
  this.populateLines(context);
510
- this.justifyLines();
511
- this.applyMargins(source.margins);
537
+ this.justifyLines(context);
538
+ this.applyMargins(context.textStyleResolver.blockSettings.margins);
512
539
  }
513
540
  toResult() {
514
541
  return {
@@ -647,7 +674,7 @@ class TextBlockLayout {
647
674
  }
648
675
  if (curLine.source.type !== "linebreak") {
649
676
  const newLine = new LineLayout(next, cumulativeOverrides, context, depth);
650
- newLine.offsetFromDocument.y -= context.textStyleResolver.blockSettings.paragraphSpacingFactor * context.textStyleResolver.blockSettings.lineHeight;
677
+ newLine.offsetFromDocument.y -= context.textStyleResolver.blockSettings.paragraphSpacingFactor * context.textStyleResolver.blockSettings.textHeight;
651
678
  return newLine;
652
679
  }
653
680
  const run = curLine.source.clone();
@@ -659,7 +686,7 @@ class TextBlockLayout {
659
686
  // Place it below any existing lines
660
687
  if (this.lines.length > 0) {
661
688
  lineOffset.y += this._back.offsetFromDocument.y;
662
- lineOffset.y -= context.textStyleResolver.blockSettings.lineSpacingFactor * context.textStyleResolver.blockSettings.lineHeight;
689
+ lineOffset.y -= context.textStyleResolver.blockSettings.lineSpacingFactor * context.textStyleResolver.blockSettings.textHeight;
663
690
  }
664
691
  curLine.offsetFromDocument = lineOffset;
665
692
  // Update document range from computed line range and position
@@ -667,14 +694,14 @@ class TextBlockLayout {
667
694
  this.lines.push(curLine);
668
695
  if (newParagraph) {
669
696
  const newLine = new LineLayout(next, cumulativeOverrides, context, depth);
670
- newLine.offsetFromDocument.y -= context.textStyleResolver.blockSettings.paragraphSpacingFactor * context.textStyleResolver.blockSettings.lineHeight;
697
+ newLine.offsetFromDocument.y -= context.textStyleResolver.blockSettings.paragraphSpacingFactor * context.textStyleResolver.blockSettings.textHeight;
671
698
  return newLine;
672
699
  }
673
700
  return new LineLayout(next, cumulativeOverrides, context, depth);
674
701
  }
675
- justifyLines() {
702
+ justifyLines(context) {
676
703
  // We don't want to justify empty text, or a single line of text whose width is 0. By default text is already left justified.
677
- if (this.lines.length < 1 || (this.lines.length === 1 && this.source.width === 0) || "left" === this.source.justification) {
704
+ if (this.lines.length < 1 || (this.lines.length === 1 && this.source.width === 0) || "left" === context.textStyleResolver.blockSettings.justification) {
678
705
  return;
679
706
  }
680
707
  // This is the minimum width of the document's bounding box.
@@ -683,7 +710,7 @@ class TextBlockLayout {
683
710
  for (const line of this.lines) {
684
711
  const lineWidth = line.justificationRange.xLength() + line.offsetFromDocument.x;
685
712
  let offset = docWidth - lineWidth;
686
- if ("center" === this.source.justification) {
713
+ if ("center" === context.textStyleResolver.blockSettings.justification) {
687
714
  offset = offset / 2;
688
715
  }
689
716
  line.offsetFromDocument.x += offset;