@deephaven/grid 0.85.33-dh-19864.0 → 0.85.35-alpha-pivots.1
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/dist/CellRenderer.d.ts +1 -1
- package/dist/CellRenderer.d.ts.map +1 -1
- package/dist/CellRenderer.js +1 -1
- package/dist/CellRenderer.js.map +1 -1
- package/dist/DataBarCellRenderer.d.ts +2 -2
- package/dist/DataBarCellRenderer.d.ts.map +1 -1
- package/dist/DataBarCellRenderer.js +5 -5
- package/dist/DataBarCellRenderer.js.map +1 -1
- package/dist/ExpandableColumnGridModel.d.ts +45 -0
- package/dist/ExpandableColumnGridModel.d.ts.map +1 -0
- package/dist/ExpandableColumnGridModel.js +8 -0
- package/dist/ExpandableColumnGridModel.js.map +1 -0
- package/dist/Grid.d.ts.map +1 -1
- package/dist/Grid.js +1 -0
- package/dist/Grid.js.map +1 -1
- package/dist/GridMetricCalculator.d.ts +29 -11
- package/dist/GridMetricCalculator.d.ts.map +1 -1
- package/dist/GridMetricCalculator.js +111 -34
- package/dist/GridMetricCalculator.js.map +1 -1
- package/dist/GridMetrics.d.ts +2 -1
- package/dist/GridMetrics.d.ts.map +1 -1
- package/dist/GridMetrics.js.map +1 -1
- package/dist/GridRenderer.d.ts +2 -1
- package/dist/GridRenderer.d.ts.map +1 -1
- package/dist/GridRenderer.js +16 -17
- package/dist/GridRenderer.js.map +1 -1
- package/dist/TextCellRenderer.d.ts +3 -3
- package/dist/TextCellRenderer.d.ts.map +1 -1
- package/dist/TextCellRenderer.js +11 -10
- package/dist/TextCellRenderer.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -59,8 +59,12 @@ export declare class GridMetricCalculator {
|
|
|
59
59
|
protected calculatedColumnWidths: ModelSizeMap;
|
|
60
60
|
/** Calculated row heights based on cell contents */
|
|
61
61
|
protected calculatedRowHeights: ModelSizeMap;
|
|
62
|
-
/** Cache of fonts to estimated width of
|
|
63
|
-
protected
|
|
62
|
+
/** Cache of fonts to estimated width of the smallest char */
|
|
63
|
+
protected fontWidthsLower: Map<string, number>;
|
|
64
|
+
/** Cache of fonts to estimated width of the largest char */
|
|
65
|
+
protected fontWidthsUpper: Map<string, number>;
|
|
66
|
+
/** Cache of fonts to width of all chars */
|
|
67
|
+
protected allCharWidths: Map<string, Map<string, number>>;
|
|
64
68
|
/** Map from visible index to model index for rows (e.g. reversing movedRows operations) */
|
|
65
69
|
protected modelRows: VisibleToModelMap;
|
|
66
70
|
/** Map from visible index to model index for columns (e.g. reversing movedColumns operations) */
|
|
@@ -69,12 +73,14 @@ export declare class GridMetricCalculator {
|
|
|
69
73
|
protected movedRows: readonly MoveOperation[];
|
|
70
74
|
/** List of moved column operations. Need to track the previous value so we know if modelColumns needs to be cleared. */
|
|
71
75
|
protected movedColumns: readonly MoveOperation[];
|
|
72
|
-
constructor({ userColumnWidths, userRowHeights, calculatedColumnWidths, calculatedRowHeights,
|
|
76
|
+
constructor({ userColumnWidths, userRowHeights, calculatedColumnWidths, calculatedRowHeights, fontWidthsLower, fontWidthsUpper, allCharWidths, modelRows, modelColumns, movedRows, movedColumns, initialRowHeights, initialColumnWidths, }?: {
|
|
73
77
|
userColumnWidths?: Map<any, any> | undefined;
|
|
74
78
|
userRowHeights?: Map<any, any> | undefined;
|
|
75
79
|
calculatedColumnWidths?: Map<any, any> | undefined;
|
|
76
80
|
calculatedRowHeights?: Map<any, any> | undefined;
|
|
77
|
-
|
|
81
|
+
fontWidthsLower?: Map<any, any> | undefined;
|
|
82
|
+
fontWidthsUpper?: Map<any, any> | undefined;
|
|
83
|
+
allCharWidths?: Map<any, any> | undefined;
|
|
78
84
|
modelRows?: Map<any, any> | undefined;
|
|
79
85
|
modelColumns?: Map<any, any> | undefined;
|
|
80
86
|
movedRows?: readonly MoveOperation[] | undefined;
|
|
@@ -428,14 +434,22 @@ export declare class GridMetricCalculator {
|
|
|
428
434
|
* @param state The grid metric state
|
|
429
435
|
* @returns The calculated width of the column header
|
|
430
436
|
*/
|
|
431
|
-
calculateColumnHeaderWidth(modelColumn: ModelIndex, state: GridMetricState): number;
|
|
437
|
+
calculateColumnHeaderWidth(modelColumn: ModelIndex, state: GridMetricState, maxColumnWidth: number): number;
|
|
432
438
|
/**
|
|
433
439
|
* Calculate the width of the specified column's data
|
|
434
440
|
* @param modelColumn ModelIndex of the column to get the data width for
|
|
435
441
|
* @param state The grid metric state
|
|
436
442
|
* @returns The calculated width of the column data
|
|
437
443
|
*/
|
|
438
|
-
calculateColumnDataWidth(modelColumn: ModelIndex, state: GridMetricState): number;
|
|
444
|
+
calculateColumnDataWidth(modelColumn: ModelIndex, state: GridMetricState, maxColumnWidth: number): number;
|
|
445
|
+
/**
|
|
446
|
+
* Calculates the width of a string using widths of individual and pairs of characters to take into account font kerning
|
|
447
|
+
* @param context The canvas rendering context
|
|
448
|
+
* @param font The font to get the width for
|
|
449
|
+
* @param text The text to calculate the width for
|
|
450
|
+
* @param maxWidth The maximum width to calculate to
|
|
451
|
+
*/
|
|
452
|
+
calculateTextWidth(context: CanvasRenderingContext2D, font: string, text: string, maxWidth?: number): number;
|
|
439
453
|
/**
|
|
440
454
|
* The coordinate for where the tree padding should be drawn
|
|
441
455
|
* @param state The grid metric state
|
|
@@ -443,13 +457,17 @@ export declare class GridMetricCalculator {
|
|
|
443
457
|
*/
|
|
444
458
|
calculateTreePaddingX(state: GridMetricState): Coordinate;
|
|
445
459
|
/**
|
|
446
|
-
*
|
|
447
|
-
* using tabular figures so every character is same width
|
|
460
|
+
* Calculates the lower bound width of a character of the provided font.
|
|
448
461
|
* @param font The font to get the width for
|
|
449
|
-
* @param
|
|
450
|
-
|
|
462
|
+
* @param context The canvas rendering context
|
|
463
|
+
*/
|
|
464
|
+
calculateLowerFontWidth(font: GridFont, context: CanvasRenderingContext2D): void;
|
|
465
|
+
/**
|
|
466
|
+
* Calculates the upper bound width of a character of the provided font.
|
|
467
|
+
* @param font The font to get the width for
|
|
468
|
+
* @param context The canvas rendering context
|
|
451
469
|
*/
|
|
452
|
-
|
|
470
|
+
calculateUpperFontWidth(font: GridFont, context: CanvasRenderingContext2D): void;
|
|
453
471
|
/**
|
|
454
472
|
* Sets the width for the specified column
|
|
455
473
|
* @param column The column model index to set
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridMetricCalculator.d.ts","sourceRoot":"","sources":["../src/GridMetricCalculator.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,UAAU,EACV,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,aAAa,EACb,OAAO,EACR,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAE7E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAI9C,MAAM,WAAW,eAAe;IAE9B,IAAI,EAAE,YAAY,CAAC;IACnB,GAAG,EAAE,YAAY,CAAC;IAGlB,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE,UAAU,CAAC;IAGtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IAGf,OAAO,EAAE,wBAAwB,CAAC;IAGlC,KAAK,EAAE,SAAS,CAAC;IAGjB,KAAK,EAAE,SAAS,CAAC;IAGjB,YAAY,EAAE,SAAS,aAAa,EAAE,CAAC;IACvC,SAAS,EAAE,SAAS,aAAa,EAAE,CAAC;IAGpC,6BAA6B,EAAE,OAAO,CAAC;IACvC,2BAA2B,EAAE,OAAO,CAAC;IAErC,cAAc,EAAE,cAAc,GAAG,IAAI,CAAC;CACvC;AAED;;;;;;GAMG;AACH,wBAAgB,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T;;;;OAIG;IACH,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,UAAU;IAmBzD;;;;OAIG;IACH,uBAAuB,CACrB,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,wBAAwB,GAChC,IAAI;IAgBP;;;;OAIG;IACH,uBAAuB,CACrB,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,wBAAwB,GAChC,IAAI;IAgBP;;;;OAIG;IACH,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAQtD;;;OAGG;IACH,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAO1C;;;OAGG;IACH,2BAA2B,IAAI,IAAI;IAInC;;;;OAIG;IACH,YAAY,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAQjD;;;OAGG;IACH,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI;IAQrC;;;OAGG;IACH,yBAAyB,IAAI,IAAI;CAGlC;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -68,7 +68,9 @@ export class GridMetricCalculator {
|
|
|
68
68
|
/** User set row heights */
|
|
69
69
|
/** Calculated column widths based on cell contents */
|
|
70
70
|
/** Calculated row heights based on cell contents */
|
|
71
|
-
/** Cache of fonts to estimated width of
|
|
71
|
+
/** Cache of fonts to estimated width of the smallest char */
|
|
72
|
+
/** Cache of fonts to estimated width of the largest char */
|
|
73
|
+
/** Cache of fonts to width of all chars */
|
|
72
74
|
/** Map from visible index to model index for rows (e.g. reversing movedRows operations) */
|
|
73
75
|
/** Map from visible index to model index for columns (e.g. reversing movedColumns operations) */
|
|
74
76
|
/** List of moved row operations. Need to track the previous value so we know if modelRows needs to be cleared. */
|
|
@@ -79,7 +81,9 @@ export class GridMetricCalculator {
|
|
|
79
81
|
userRowHeights = new Map(),
|
|
80
82
|
calculatedColumnWidths = new Map(),
|
|
81
83
|
calculatedRowHeights = new Map(),
|
|
82
|
-
|
|
84
|
+
fontWidthsLower = new Map(),
|
|
85
|
+
fontWidthsUpper = new Map(),
|
|
86
|
+
allCharWidths = new Map(),
|
|
83
87
|
modelRows = new Map(),
|
|
84
88
|
modelColumns = new Map(),
|
|
85
89
|
movedRows = [],
|
|
@@ -93,7 +97,9 @@ export class GridMetricCalculator {
|
|
|
93
97
|
_defineProperty(this, "userRowHeights", void 0);
|
|
94
98
|
_defineProperty(this, "calculatedColumnWidths", void 0);
|
|
95
99
|
_defineProperty(this, "calculatedRowHeights", void 0);
|
|
96
|
-
_defineProperty(this, "
|
|
100
|
+
_defineProperty(this, "fontWidthsLower", void 0);
|
|
101
|
+
_defineProperty(this, "fontWidthsUpper", void 0);
|
|
102
|
+
_defineProperty(this, "allCharWidths", void 0);
|
|
97
103
|
_defineProperty(this, "modelRows", void 0);
|
|
98
104
|
_defineProperty(this, "modelColumns", void 0);
|
|
99
105
|
_defineProperty(this, "movedRows", void 0);
|
|
@@ -102,7 +108,9 @@ export class GridMetricCalculator {
|
|
|
102
108
|
this.userRowHeights = userRowHeights;
|
|
103
109
|
this.calculatedRowHeights = calculatedRowHeights;
|
|
104
110
|
this.calculatedColumnWidths = calculatedColumnWidths;
|
|
105
|
-
this.
|
|
111
|
+
this.allCharWidths = allCharWidths;
|
|
112
|
+
this.fontWidthsLower = fontWidthsLower;
|
|
113
|
+
this.fontWidthsUpper = fontWidthsUpper;
|
|
106
114
|
|
|
107
115
|
// Need to track the last moved rows/columns array so we know if we need to reset our models cache
|
|
108
116
|
this.modelRows = modelRows;
|
|
@@ -266,7 +274,8 @@ export class GridMetricCalculator {
|
|
|
266
274
|
var bottomVisible = lastTop > 0 ? this.getBottomVisible(state, allRowYs, allRowHeights, visibleRows, gridY) : bottom;
|
|
267
275
|
var rightVisible = lastLeft > 0 ? this.getRightVisible(state, allColumnXs, allColumnWidths, visibleColumns, gridX) : right;
|
|
268
276
|
var {
|
|
269
|
-
|
|
277
|
+
fontWidthsLower,
|
|
278
|
+
fontWidthsUpper,
|
|
270
279
|
userColumnWidths,
|
|
271
280
|
userRowHeights,
|
|
272
281
|
calculatedRowHeights,
|
|
@@ -371,7 +380,8 @@ export class GridMetricCalculator {
|
|
|
371
380
|
movedRows,
|
|
372
381
|
movedColumns,
|
|
373
382
|
// Map of the width of the fonts
|
|
374
|
-
|
|
383
|
+
fontWidthsLower,
|
|
384
|
+
fontWidthsUpper,
|
|
375
385
|
// Map of user set column/row width/height
|
|
376
386
|
userColumnWidths,
|
|
377
387
|
userRowHeights,
|
|
@@ -1290,8 +1300,8 @@ export class GridMetricCalculator {
|
|
|
1290
1300
|
} = theme;
|
|
1291
1301
|
return _columnWidth;
|
|
1292
1302
|
}
|
|
1293
|
-
var headerWidth = this.calculateColumnHeaderWidth(modelColumn, state);
|
|
1294
|
-
var dataWidth = this.calculateColumnDataWidth(modelColumn, state);
|
|
1303
|
+
var headerWidth = this.calculateColumnHeaderWidth(modelColumn, state, maxColumnWidth);
|
|
1304
|
+
var dataWidth = this.calculateColumnDataWidth(modelColumn, state, maxColumnWidth);
|
|
1295
1305
|
var cachedValue = this.calculatedColumnWidths.get(modelColumn);
|
|
1296
1306
|
var columnWidth = Math.ceil(Math.max(headerWidth, dataWidth));
|
|
1297
1307
|
columnWidth = Math.max(minColumnWidth, columnWidth);
|
|
@@ -1314,21 +1324,24 @@ export class GridMetricCalculator {
|
|
|
1314
1324
|
* @param state The grid metric state
|
|
1315
1325
|
* @returns The calculated width of the column header
|
|
1316
1326
|
*/
|
|
1317
|
-
calculateColumnHeaderWidth(modelColumn, state) {
|
|
1327
|
+
calculateColumnHeaderWidth(modelColumn, state, maxColumnWidth) {
|
|
1318
1328
|
var {
|
|
1319
1329
|
model,
|
|
1320
|
-
theme
|
|
1330
|
+
theme,
|
|
1331
|
+
context
|
|
1321
1332
|
} = state;
|
|
1322
1333
|
var {
|
|
1323
|
-
|
|
1324
|
-
|
|
1334
|
+
headerHorizontalPadding,
|
|
1335
|
+
headerFont
|
|
1325
1336
|
} = theme;
|
|
1337
|
+
this.calculateLowerFontWidth(headerFont, context);
|
|
1338
|
+
this.calculateUpperFontWidth(headerFont, context);
|
|
1339
|
+
var totalPadding = headerHorizontalPadding * 2;
|
|
1326
1340
|
var headerText = model.textForColumnHeader(modelColumn, 0);
|
|
1327
1341
|
if (headerText !== undefined && headerText !== '') {
|
|
1328
|
-
|
|
1329
|
-
return headerText.length * headerFontWidth + headerHorizontalPadding * 2;
|
|
1342
|
+
return this.calculateTextWidth(context, headerFont, headerText, maxColumnWidth - totalPadding) + totalPadding;
|
|
1330
1343
|
}
|
|
1331
|
-
return
|
|
1344
|
+
return totalPadding;
|
|
1332
1345
|
}
|
|
1333
1346
|
|
|
1334
1347
|
/**
|
|
@@ -1337,13 +1350,14 @@ export class GridMetricCalculator {
|
|
|
1337
1350
|
* @param state The grid metric state
|
|
1338
1351
|
* @returns The calculated width of the column data
|
|
1339
1352
|
*/
|
|
1340
|
-
calculateColumnDataWidth(modelColumn, state) {
|
|
1353
|
+
calculateColumnDataWidth(modelColumn, state, maxColumnWidth) {
|
|
1341
1354
|
var {
|
|
1342
1355
|
top,
|
|
1343
1356
|
height,
|
|
1344
1357
|
width,
|
|
1345
1358
|
model,
|
|
1346
|
-
theme
|
|
1359
|
+
theme,
|
|
1360
|
+
context
|
|
1347
1361
|
} = state;
|
|
1348
1362
|
var {
|
|
1349
1363
|
floatingTopRowCount,
|
|
@@ -1359,28 +1373,74 @@ export class GridMetricCalculator {
|
|
|
1359
1373
|
scrollBarSize,
|
|
1360
1374
|
dataBarHorizontalPadding
|
|
1361
1375
|
} = theme;
|
|
1376
|
+
this.calculateLowerFontWidth(font, context);
|
|
1377
|
+
this.calculateUpperFontWidth(font, context);
|
|
1362
1378
|
var columnWidth = 0;
|
|
1363
|
-
var fontWidth = this.getWidthForFont(font, state);
|
|
1364
1379
|
var rowsPerPage = height / rowHeight;
|
|
1365
1380
|
var bottom = Math.ceil(top + rowsPerPage);
|
|
1381
|
+
var cellPadding = cellHorizontalPadding * 2;
|
|
1366
1382
|
GridUtils.iterateAllItems(top, bottom, floatingTopRowCount, floatingBottomRowCount, rowCount, row => {
|
|
1367
1383
|
var modelRow = this.getModelRow(row, state);
|
|
1368
1384
|
var text = model.textForCell(modelColumn, modelRow);
|
|
1369
1385
|
var cellRenderType = model.renderTypeForCell(modelColumn, modelRow);
|
|
1370
1386
|
var cellWidth = 0;
|
|
1371
1387
|
if (text) {
|
|
1372
|
-
|
|
1373
|
-
cellWidth = text.length * fontWidth + cellPadding;
|
|
1388
|
+
cellWidth = this.calculateTextWidth(context, font, text, maxColumnWidth - cellPadding) + cellPadding;
|
|
1374
1389
|
}
|
|
1375
1390
|
if (cellRenderType === 'dataBar') {
|
|
1376
1391
|
cellWidth += dataBarHorizontalPadding;
|
|
1377
1392
|
}
|
|
1378
1393
|
columnWidth = Math.max(columnWidth, cellWidth);
|
|
1379
1394
|
});
|
|
1380
|
-
columnWidth = Math.max(Math.min(columnWidth, (width - rowHeaderWidth - scrollBarSize - rowFooterWidth) * GridMetricCalculator.MAX_COLUMN_WIDTH),
|
|
1395
|
+
columnWidth = Math.max(Math.min(columnWidth, (width - rowHeaderWidth - scrollBarSize - rowFooterWidth) * GridMetricCalculator.MAX_COLUMN_WIDTH), cellPadding);
|
|
1381
1396
|
return columnWidth;
|
|
1382
1397
|
}
|
|
1383
1398
|
|
|
1399
|
+
/**
|
|
1400
|
+
* Calculates the width of a string using widths of individual and pairs of characters to take into account font kerning
|
|
1401
|
+
* @param context The canvas rendering context
|
|
1402
|
+
* @param font The font to get the width for
|
|
1403
|
+
* @param text The text to calculate the width for
|
|
1404
|
+
* @param maxWidth The maximum width to calculate to
|
|
1405
|
+
*/
|
|
1406
|
+
calculateTextWidth(context, font, text, maxWidth) {
|
|
1407
|
+
if (text.length === 0) return 0;
|
|
1408
|
+
context.font = font;
|
|
1409
|
+
if (!this.allCharWidths.has(font)) {
|
|
1410
|
+
this.allCharWidths.set(font, new Map());
|
|
1411
|
+
}
|
|
1412
|
+
var charWidths = getOrThrow(this.allCharWidths, font);
|
|
1413
|
+
var result = 0;
|
|
1414
|
+
for (var i = 0; i < text.length; i += 1) {
|
|
1415
|
+
var char = text[i];
|
|
1416
|
+
var nextChar = text[i + 1];
|
|
1417
|
+
if (!charWidths.has(char)) {
|
|
1418
|
+
charWidths.set(char, context.measureText(char).width);
|
|
1419
|
+
}
|
|
1420
|
+
if (nextChar !== undefined) {
|
|
1421
|
+
if (!charWidths.has(nextChar)) {
|
|
1422
|
+
charWidths.set(nextChar, context.measureText(nextChar).width);
|
|
1423
|
+
}
|
|
1424
|
+
var pair = char + nextChar;
|
|
1425
|
+
if (!charWidths.has(pair)) {
|
|
1426
|
+
charWidths.set(pair, context.measureText(pair).width);
|
|
1427
|
+
}
|
|
1428
|
+
result += getOrThrow(charWidths, pair);
|
|
1429
|
+
if (i > 0) {
|
|
1430
|
+
// Need to remove the current character that was already counted in the previous pair
|
|
1431
|
+
result -= getOrThrow(charWidths, char);
|
|
1432
|
+
}
|
|
1433
|
+
if (maxWidth !== undefined && result > maxWidth) {
|
|
1434
|
+
return maxWidth;
|
|
1435
|
+
}
|
|
1436
|
+
} else if (result === 0) {
|
|
1437
|
+
// On last char and no pair found before that => Only one char in string
|
|
1438
|
+
result = getOrThrow(charWidths, char);
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
return result;
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1384
1444
|
/**
|
|
1385
1445
|
* The coordinate for where the tree padding should be drawn
|
|
1386
1446
|
* @param state The grid metric state
|
|
@@ -1412,30 +1472,47 @@ export class GridMetricCalculator {
|
|
|
1412
1472
|
}
|
|
1413
1473
|
|
|
1414
1474
|
/**
|
|
1415
|
-
*
|
|
1416
|
-
* using tabular figures so every character is same width
|
|
1475
|
+
* Calculates the lower bound width of a character of the provided font.
|
|
1417
1476
|
* @param font The font to get the width for
|
|
1418
|
-
* @param
|
|
1419
|
-
* @returns Width of the char `8` for the specified font
|
|
1477
|
+
* @param context The canvas rendering context
|
|
1420
1478
|
*/
|
|
1421
|
-
|
|
1422
|
-
if (this.
|
|
1423
|
-
return
|
|
1479
|
+
calculateLowerFontWidth(font, context) {
|
|
1480
|
+
if (this.fontWidthsLower.has(font)) {
|
|
1481
|
+
return;
|
|
1424
1482
|
}
|
|
1483
|
+
context.font = font;
|
|
1484
|
+
// Assume char `.` is the smallest character
|
|
1485
|
+
var textMetrics = context.measureText('.');
|
|
1425
1486
|
var {
|
|
1426
|
-
|
|
1427
|
-
} =
|
|
1487
|
+
width
|
|
1488
|
+
} = textMetrics;
|
|
1489
|
+
|
|
1490
|
+
// context.font changes the string a little bit, e.g. '10px Arial, sans serif' => '10px Arial, "sans serif"'
|
|
1491
|
+
// Rather than require checking with the correct font def (theme, or context font), just key it to both
|
|
1492
|
+
this.fontWidthsLower.set(font, width);
|
|
1493
|
+
this.fontWidthsLower.set(context.font, width);
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
/**
|
|
1497
|
+
* Calculates the upper bound width of a character of the provided font.
|
|
1498
|
+
* @param font The font to get the width for
|
|
1499
|
+
* @param context The canvas rendering context
|
|
1500
|
+
*/
|
|
1501
|
+
calculateUpperFontWidth(font, context) {
|
|
1502
|
+
if (this.fontWidthsUpper.has(font)) {
|
|
1503
|
+
return;
|
|
1504
|
+
}
|
|
1428
1505
|
context.font = font;
|
|
1429
|
-
|
|
1506
|
+
// Assume char `m` is the largest character
|
|
1507
|
+
var textMetrics = context.measureText('m');
|
|
1430
1508
|
var {
|
|
1431
1509
|
width
|
|
1432
1510
|
} = textMetrics;
|
|
1433
1511
|
|
|
1434
1512
|
// context.font changes the string a little bit, e.g. '10px Arial, sans serif' => '10px Arial, "sans serif"'
|
|
1435
1513
|
// Rather than require checking with the correct font def (theme, or context font), just key it to both
|
|
1436
|
-
this.
|
|
1437
|
-
this.
|
|
1438
|
-
return width;
|
|
1514
|
+
this.fontWidthsUpper.set(font, width);
|
|
1515
|
+
this.fontWidthsUpper.set(context.font, width);
|
|
1439
1516
|
}
|
|
1440
1517
|
|
|
1441
1518
|
/**
|