17d3ca83ae2dafefadd1273e762242227b906148253e78ffa1b72cc6e1375df87c1ee2ddb1f604970b8c8fbb9a66a5f8e48a00ce3646ac14ba83a69d01ff45 1.0 KB

1234567891011121314151617181920212223
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. export const allCharCodes = (() => {
  6. const v = [];
  7. for (let i = 32 /* Constants.START_CH_CODE */; i <= 126 /* Constants.END_CH_CODE */; i++) {
  8. v.push(i);
  9. }
  10. v.push(65533 /* Constants.UNKNOWN_CODE */);
  11. return v;
  12. })();
  13. export const getCharIndex = (chCode, fontScale) => {
  14. chCode -= 32 /* Constants.START_CH_CODE */;
  15. if (chCode < 0 || chCode > 96 /* Constants.CHAR_COUNT */) {
  16. if (fontScale <= 2) {
  17. // for smaller scales, we can get away with using any ASCII character...
  18. return (chCode + 96 /* Constants.CHAR_COUNT */) % 96 /* Constants.CHAR_COUNT */;
  19. }
  20. return 96 /* Constants.CHAR_COUNT */ - 1; // unknown symbol
  21. }
  22. return chCode;
  23. };