tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

font-data.js (1486B)


      1 'use strict';
      2 
      3 // The OpenType spec mentions that the follow tables are required for a font to
      4 // function correctly. We'll have all the tables listed except for OS/2, which
      5 // is not present in all fonts on Mac OS.
      6 // https://docs.microsoft.com/en-us/typography/opentype/spec/otff#font-tables
      7 const BASE_TABLES = [
      8  'cmap',
      9  'head',
     10  'hhea',
     11  'hmtx',
     12  'maxp',
     13  'name',
     14  'post',
     15 ];
     16 
     17 const MAC_FONTS = new Map([
     18  ['Monaco', {
     19    postscriptName: 'Monaco',
     20    fullName: 'Monaco',
     21    family: 'Monaco',
     22    style: 'Regular',
     23  }],
     24  ['Menlo-Regular', {
     25    postscriptName: 'Menlo-Regular',
     26    fullName: 'Menlo Regular',
     27    family: 'Menlo',
     28    style: 'Regular',
     29  }],
     30 ]);
     31 
     32 const WIN_FONTS = new Map([
     33  ['Verdana', {
     34    postscriptName: 'Verdana',
     35    fullName: 'Verdana',
     36    family: 'Verdana',
     37    style: 'Regular',
     38  }],
     39 ]);
     40 
     41 const LINUX_FONTS = new Map([
     42  ['Ahem', {
     43    postscriptName: 'Ahem',
     44    fullName: 'Ahem',
     45    family: 'Ahem',
     46    style: 'Regular',
     47  }],
     48 ]);
     49 
     50 // Returns a map of known system fonts, mapping a font's postscript name to
     51 // FontData.
     52 function getTestData() {
     53  let output = undefined;
     54  if (navigator.platform.indexOf("Win") !== -1) {
     55    output = WIN_FONTS;
     56  } else if (navigator.platform.indexOf("Mac") !== -1) {
     57    output = MAC_FONTS;
     58  } else if (navigator.platform.indexOf("Linux") !== -1) {
     59    output = LINUX_FONTS;
     60  }
     61 
     62  assert_not_equals(
     63      output, undefined, 'Cannot get test set due to unsupported platform.');
     64 
     65  return output;
     66 }