Enable the no-var rule in the src/core/fonts_utils.js file

These changes were made *mostly* automatically, using `gulp lint --fix`, with the following manual changes:

```diff
diff --git a/src/core/fonts_utils.js b/src/core/fonts_utils.js
index f88ce4a8c..c4b3f3808 100644
--- a/src/core/fonts_utils.js
+++ b/src/core/fonts_utils.js
@@ -167,8 +167,8 @@ function type1FontGlyphMapping(properties, builtInEncoding,
glyphNames) {
   }

   // Lastly, merge in the differences.
-  let differences = properties.differences,
-    glyphsUnicodeMap;
+  const differences = properties.differences;
+  let glyphsUnicodeMap;
   if (differences) {
     for (charCode in differences) {
       const glyphName = differences[charCode];
```
This commit is contained in:
Jonas Jenwald 2021-05-02 16:19:13 +02:00
parent 77b258440b
commit d4606712f2

View File

@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable no-var */
import { FontType, info } from "../shared/util.js"; import { FontType, info } from "../shared/util.js";
import { getEncoding, StandardEncoding } from "./encodings.js"; import { getEncoding, StandardEncoding } from "./encodings.js";
@ -26,9 +25,9 @@ import { getUnicodeForGlyph } from "./unicode.js";
// Linux (freetype) requires that when a seac style endchar is used // Linux (freetype) requires that when a seac style endchar is used
// that the charset must be a predefined one, however we build a // that the charset must be a predefined one, however we build a
// custom one. Windows just refuses to draw glyphs with seac operators. // custom one. Windows just refuses to draw glyphs with seac operators.
var SEAC_ANALYSIS_ENABLED = true; const SEAC_ANALYSIS_ENABLED = true;
var FontFlags = { const FontFlags = {
FixedPitch: 1, FixedPitch: 1,
Serif: 2, Serif: 2,
Symbolic: 4, Symbolic: 4,
@ -41,7 +40,7 @@ var FontFlags = {
}; };
// prettier-ignore // prettier-ignore
var MacStandardGlyphOrdering = [ const MacStandardGlyphOrdering = [
".notdef", ".null", "nonmarkingreturn", "space", "exclam", "quotedbl", ".notdef", ".null", "nonmarkingreturn", "space", "exclam", "quotedbl",
"numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft",
"parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash",
@ -109,9 +108,9 @@ function recoverGlyphName(name, glyphsUnicodeMap) {
return name; return name;
} }
// The glyph name is non-standard, trying to recover. // The glyph name is non-standard, trying to recover.
var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap); const unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
if (unicode !== -1) { if (unicode !== -1) {
for (var key in glyphsUnicodeMap) { for (const key in glyphsUnicodeMap) {
if (glyphsUnicodeMap[key] === unicode) { if (glyphsUnicodeMap[key] === unicode) {
return key; return key;
} }
@ -132,9 +131,9 @@ function recoverGlyphName(name, glyphsUnicodeMap) {
* @returns {Object} A char code to glyph ID map. * @returns {Object} A char code to glyph ID map.
*/ */
function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) { function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
var charCodeToGlyphId = Object.create(null); const charCodeToGlyphId = Object.create(null);
var glyphId, charCode, baseEncoding; let glyphId, charCode, baseEncoding;
var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic); const isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
if (properties.baseEncodingName) { if (properties.baseEncodingName) {
// If a valid base encoding name was used, the mapping is initialized with // If a valid base encoding name was used, the mapping is initialized with
@ -168,18 +167,18 @@ function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
} }
// Lastly, merge in the differences. // Lastly, merge in the differences.
var differences = properties.differences, const differences = properties.differences;
glyphsUnicodeMap; let glyphsUnicodeMap;
if (differences) { if (differences) {
for (charCode in differences) { for (charCode in differences) {
var glyphName = differences[charCode]; const glyphName = differences[charCode];
glyphId = glyphNames.indexOf(glyphName); glyphId = glyphNames.indexOf(glyphName);
if (glyphId === -1) { if (glyphId === -1) {
if (!glyphsUnicodeMap) { if (!glyphsUnicodeMap) {
glyphsUnicodeMap = getGlyphsUnicode(); glyphsUnicodeMap = getGlyphsUnicode();
} }
var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap); const standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
if (standardGlyphName !== glyphName) { if (standardGlyphName !== glyphName) {
glyphId = glyphNames.indexOf(standardGlyphName); glyphId = glyphNames.indexOf(standardGlyphName);
} }