Returns an array of {unicode, glyph} sets for all valid code points up to bounds
518102
function getCodePoints(codePoints, bounds) {
  bounds = bounds || Number.MAX_VALUE;

  var result = [];

  _.forEach(codePoints, function (glyph, unicode) {
    unicode = parseInt(unicode, 10);
    // Since this is a sparse array, iterating will only yield the valid code points
    if (unicode > bounds) {
      return false;
    }
    result.push({
      unicode: unicode,
      glyph: glyph
    });
  });
  return result;
}
513428
function (keyCode) {
        return list.contains([
          keyMap.LEFT,
          keyMap.UP,
          keyMap.RIGHT,
          keyMap.DOWN
        ], keyCode);
      }
47099
function getLastCharIndex(glyphs) {
    var maxGlyph = _.max(glyphs, 'unicode');
    if (maxGlyph) {
        return maxGlyph.unicode > 0xFFFF ? 0xFFFF : (maxGlyph.unicode || 0);
    } else {
        return 0xFFFF;
    }
}
210469
def SpacesInsideBrackets( logical_line, tokens ):
  """"""
  for index in range( len( tokens ) ):
    _, prev_text, _, prev_end, _ = ( tokens[ index - 1 ] if index - 1 >= 0 else
                                     ( None, None, None, None, None ) )
    token_type, text, start, end, _ = tokens[ index ]
    next_token_type, next_text, next_start, _, _ = (
      tokens[ index + 1 ] if index + 1 < len( tokens ) else
      ( None, None, None, None, None ) )
    if text in LEFT_BRACKETS:
      if ( next_text == CORRESPONDING_BRACKET[ text ] and
           next_start != end ):
        code = 'YCM204'
        message = ( ' no spaces between {} and {}'
                    ' for empty content'.format( text, next_text ) )
        yield end, code + message
      if ( next_token_type not in [ tokenize.NL, tokenize.NEWLINE ] and
           next_text != CORRESPONDING_BRACKET[ text ] and
           next_start and
           next_start[ 0 ] == start[ 0 ] and
           next_start[ 1 ] - start[ 1 ] != 2 ):
        code = 'YCM201'
        message = ' exactly one space required after {}'.format( text )
        yield end, code + message
    if text in RIGHT_BRACKETS:
      if ( prev_text != CORRESPONDING_BRACKET[ text ] and
           prev_end and
           prev_end[ 0 ] == end[ 0 ] and
           end[ 1 ] - prev_end[ 1 ] != 2 ):
        code = 'YCM202'
        message = ' exactly one space required before {}'.format( text )
        yield start, code + message
432136
def solidity_names(code):  # pylint: disable=too-many-branches
    
    names = []
    in_string = None
    backslash = False
    comment = None

    # "parse" the code by hand to handle the corner cases:
    #  - the contract or library can be inside a comment or string
    #  - multiline comments
    #  - the contract and library keywords could not be at the start of the line
    for pos, char in enumerate(code):
        if in_string:
            if not backslash and in_string == char:
                in_string = None
                backslash = False

            if char == '\\':  # pylint: disable=simplifiable-if-statement
                backslash = True
            else:
                backslash = False

        elif comment == '//':
            if char in ('\n', '\r'):
                comment = None

        elif comment == '/*':
            if char == '*' and code[pos + 1] == '/':
                comment = None

        else:
            if char == '"' or char == "'":
                in_string = char

            if char == '/':
                if code[pos + 1] == '/':
                    comment = '//'
                if code[pos + 1] == '*':
                    comment = '/*'

            if char == 'c' and code[pos: pos + 8] == 'contract':
                result = re.match(
                    '^contract[^_$a-zA-Z]+([_$a-zA-Z][_$a-zA-Z0-9]*)', code[pos:])

                if result:
                    names.append(('contract', result.groups()[0]))

            if char == 'i' and code[pos: pos + 9] == 'interface':
                result = re.match(
                    '^interface[^_$a-zA-Z]+([_$a-zA-Z][_$a-zA-Z0-9]*)', code[pos:])

                if result:
                    names.append(('contract', result.groups()[0]))

            if char == 'l' and code[pos: pos + 7] == 'library':
                result = re.match(
                    '^library[^_$a-zA-Z]+([_$a-zA-Z][_$a-zA-Z0-9]*)', code[pos:])

                if result:
                    names.append(('library', result.groups()[0]))

    return names
572918
function glyphDataSize(glyph) {
  // Ignore glyphs without outlines. These will get a length of zero in the “loca” table
  if (!glyph.contours.length) {
    return 0;
  }

  var result = 12; //glyph fixed properties

  result += glyph.contours.length * 2; //add contours

  _.forEach(glyph.ttf_x, function (x) {
    //add 1 or 2 bytes for each coordinate depending of its size
    result += ((-0xFF <= x && x <= 0xFF)) ? 1 : 2;
  });

  _.forEach(glyph.ttf_y, function (y) {
    //add 1 or 2 bytes for each coordinate depending of its size
    result += ((-0xFF <= y && y <= 0xFF)) ? 1 : 2;
  });

  // Add flags length to glyph size.
  result += glyph.ttf_flags.length;

  if (result % 4 !== 0) { // glyph size must be divisible by 4.
    result += 4 - result % 4;
  }
  return result;
}
107080
def com_google_fonts_check_whitespace_glyphnames(ttFont):
  """"""
  from fontbakery.utils import get_glyph_name

  def getGlyphEncodings(font, names):
    result = set()
    for subtable in font['cmap'].tables:
      if subtable.isUnicode():
        for codepoint, name in subtable.cmap.items():
          if name in names:
            result.add(codepoint)
    return result

  if ttFont['post'].formatType == 3.0:
    yield SKIP, "Font has version 3 post table."
  else:
    failed = False
    space_enc = getGlyphEncodings(ttFont, ["uni0020", "space"])
    nbsp_enc = getGlyphEncodings(
        ttFont, ["uni00A0", "nonbreakingspace", "nbspace", "nbsp"])
    space = get_glyph_name(ttFont, 0x0020)
    if 0x0020 not in space_enc:
      failed = True
      yield FAIL, Message("bad20", ("Glyph 0x0020 is called \"{}\":"
                                    " Change to \"space\""
                                    " or \"uni0020\"").format(space))

    nbsp = get_glyph_name(ttFont, 0x00A0)
    if 0x00A0 not in nbsp_enc:
      if 0x00A0 in space_enc:
        # This is OK.
        # Some fonts use the same glyph for both space and nbsp.
        pass
      else:
        failed = True
        yield FAIL, Message("badA0", ("Glyph 0x00A0 is called \"{}\":"
                                      " Change to \"nbsp\""
                                      " or \"uni00A0\"").format(nbsp))

    if failed is False:
      yield PASS, "Font has **proper** whitespace glyph names."
51880
def characters(self, numberOfCharacters):
        """"""
        return self.code[self.index:self.index + numberOfCharacters]
1175323
def makeFontBoundingBox(self):
        
        if not hasattr(self, "glyphBoundingBoxes"):
            self.glyphBoundingBoxes = self.makeGlyphsBoundingBoxes()
        fontBox = None
        for glyphName, glyphBox in self.glyphBoundingBoxes.items():
            if glyphBox is None:
                continue
            if fontBox is None:
                fontBox = glyphBox
            else:
                fontBox = unionRect(fontBox, glyphBox)
        if fontBox is None:  # unlikely
            fontBox = BoundingBox(0, 0, 0, 0)
        return fontBox
590647
def getGDEFGlyphClasses(feaLib):
    
    for st in feaLib.statements:
        if isinstance(st, ast.TableBlock) and st.name == "GDEF":
            for st in st.statements:
                if isinstance(st, ast.GlyphClassDefStatement):
                    return _GDEFGlyphClasses(
                        frozenset(st.baseGlyphs.glyphSet())
                        if st.baseGlyphs is not None
                        else frozenset(),
                        frozenset(st.ligatureGlyphs.glyphSet())
                        if st.ligatureGlyphs is not None
                        else frozenset(),
                        frozenset(st.markGlyphs.glyphSet())
                        if st.markGlyphs is not None
                        else frozenset(),
                        frozenset(st.componentGlyphs.glyphSet())
                        if st.componentGlyphs is not None
                        else frozenset(),
                    )
    return _GDEFGlyphClasses(None, None, None, None)
229083
function isUnicodeLetter(code) {
  for (var i = 0; i < unicodeLetterTable.length;) {
    if (code < unicodeLetterTable[i++])
      return false;
    if (code <= unicodeLetterTable[i++])
      return true;
  }
  return false;
}
523625
def _getCharFont(self, font_files, code_point):
        
        return_font_files = []
        for font_file in font_files:
            face = ft.Face(font_file)
            if face.get_char_index(code_point):
                return_font_files.append(font_file)
        return return_font_files
1018930
def getAllRegexp():
    '''
        
    '''

    listAll = []

    ############################################################################
    ############################################################################

    # --------------------------------------------------------------------------
    # Dinamically collecting all the "official" modules
    # --------------------------------------------------------------------------

    # A list that will contain all of the module names
    all_modules = []

    # Grabbing all the module names
    for _, name, _ in pkgutil.iter_modules(osrframework.patterns.__path__):
        all_modules.append("osrframework.patterns." + name)

    # Iterating through all the module names to grab them
    for moduleName in all_modules:
        # Importing the module
        my_module = importlib.import_module(moduleName)

        # Getting all the classNames.
        classNames = [m[0] for m in inspect.getmembers(my_module, inspect.isclass) if m[1].__module__ == moduleName]

        # Dinamically grabbing the first class of the module. IT SHOULD BE ALONE!
        MyClass = getattr(my_module, classNames[0])

        # Instantiating the object
        newInstance = MyClass()

        # Adding to the list!
        listAll.append(newInstance)

    # --------------------------------------------------------------------------
    # Loading user-defined wrappers under [OSRFrameworkHOME]/plugins/patterns/
    # --------------------------------------------------------------------------

    # Creating the application paths
    paths = configuration.getConfigPath()

    newPath = os.path.abspath(paths["appPathPatterns"])

    # Inserting in the System Path
    if not newPath in sys.path:
        sys.path.append(newPath)

    userImportedModules = {}

    for module in os.listdir(newPath):
        if module[-3:] == '.py':
            current = module.replace('.py', '')
            userImportedModules[current] = __import__(current)

    del newPath

    userClasses = []

    # Iterating through all the files
    for userModule in userImportedModules.keys():

        my_module = userImportedModules[userModule]
        # Getting all the classNames.
        classNames = [m[0] for m in inspect.getmembers(my_module, inspect.isclass) if m[1].__module__ == userModule]

        # Dinamically grabbing the first class of the module. IT SHOULD BE ALONE!
        MyClass = getattr(my_module, classNames[0])

        # Instantiating the object
        newInstance = MyClass()

        # Adding to the list!
        userClasses.append(newInstance)

    # --------------------------------------------------------------------------
    # Overwriting original modules with the user plugins
    # --------------------------------------------------------------------------
    listToAdd = []
    for userClass in userClasses:
        for i, officialClass in enumerate(listAll):
            # Checking if the name is the same
            if str(userClass) == str(officialClass):
                # Replacing the official module if a user module exists for it
                listAll[i] = userClass
            else:
                if userClass not in listToAdd:
                    # Appending the new class
                    listToAdd.append(userClass)

    # Merging listAll and listToAdd
    listAll = listAll + listToAdd
    ############################################################################
    ############################################################################

    return listAll
104456
def com_google_fonts_check_points_out_of_bounds(ttFont):
  """"""
  failed = False
  out_of_bounds = []
  for glyphName in ttFont['glyf'].keys():
    glyph = ttFont['glyf'][glyphName]
    coords = glyph.getCoordinates(ttFont['glyf'])[0]
    for x, y in coords:
      if x < glyph.xMin or x > glyph.xMax or \
         y < glyph.yMin or y > glyph.yMax or \
         abs(x) > 32766 or abs(y) > 32766:
        failed = True
        out_of_bounds.append((glyphName, x, y))

  if failed:
    yield WARN, ("The following glyphs have coordinates which are"
                 " out of bounds:\n{}\nThis happens a lot when points"
                 " are not extremes, which is usually bad. However,"
                 " fixing this alert by adding points on extremes may"
                 " do more harm than good, especially with italics,"
                 " calligraphic-script, handwriting, rounded and"
                 " other fonts. So it is common to"
                 " ignore this message".format(out_of_bounds))
  else:
    yield PASS, "All glyph paths have coordinates within bounds!"
1126579
def _get_valid_indices(shape, ix0, ix1, iy0, iy1):
    """"""
    ymax, xmax = shape

    if ix0 < 0:
        ix0 = 0
    if ix1 > xmax:
        ix1 = xmax
    if iy0 < 0:
        iy0 = 0
    if iy1 > ymax:
        iy1 = ymax

    if iy1 <= iy0 or ix1 <= ix0:
        raise IndexError(
            'array[{0}:{1},{2}:{3}] is invalid'.format(iy0, iy1, ix0, ix1))

    return list(map(int, [ix0, ix1, iy0, iy1]))
169809
def get(cls, uni_char):
        """"""
        uni_char = unicod(uni_char)  # Force to Unicode
        code_point = ord(uni_char)
        if Block._RANGE_KEYS is None:
            Block._RANGE_KEYS = sorted(Block._RANGES.keys())
        idx = bisect.bisect_left(Block._RANGE_KEYS, code_point)
        if (idx > 0 and
            code_point >= Block._RANGES[Block._RANGE_KEYS[idx - 1]].start and
            code_point <= Block._RANGES[Block._RANGE_KEYS[idx - 1]].end):
            return Block._RANGES[Block._RANGE_KEYS[idx - 1]]
        elif (idx < len(Block._RANGES) and
              code_point >= Block._RANGES[Block._RANGE_KEYS[idx]].start and
              code_point <= Block._RANGES[Block._RANGE_KEYS[idx]].end):
            return Block._RANGES[Block._RANGE_KEYS[idx]]
        else:
            return Block.UNKNOWN
553894
private List<Glyph> getGlyphsOfPEs(Set<PhysicalEntity> pes, String context) {
		List<Glyph> gs = new ArrayList<Glyph>();

		for (PhysicalEntity pe : pes)
			if (glyphMap.containsKey(convertID(pe.getUri())))
				gs.add(getGlyphToLink(pe, context));

		return gs;
	}