Exemple #1
0
def create_table_from_map(script_to_cmap):
    """Create a table from a map from script to cmaps.  Outputs
  the script code, script name, count of code points, the
  codepoint ranges in hex separated by space, the count of
  excluded/fallback code points, and their ranges separated by
  space.  script_to_cmap can have values either of cmap or of
  a tuple of cmap, xcmap; in the first case xcmap is assumed
  None.  xcmaps that are None are marked as having an xcount of -1.
  This makes it possible to distinguish an empty xcmap from one
  that doesn't exist."""

    table_header = 'script,name,count,ranges,xcount,xranges'.split(',')
    RowData = collections.namedtuple('RowData', table_header)

    table_rows = []
    for script in sorted(script_to_cmap):
        cmap = script_to_cmap.get(script)
        xcmap = None
        if type(cmap) == tuple:
            xcmap = cmap[1]
            cmap = cmap[0]
        name = noto_fonts.script_name_for_report(script)
        count = len(cmap)
        cp_ranges = tool_utils.write_int_ranges(cmap)
        if xcmap == None:
            xcount = -1
            xcp_ranges = ''
        else:
            xcount = len(xcmap)
            xcp_ranges = tool_utils.write_int_ranges(xcmap)
        table_rows.append(
            RowData(script, name, str(count), cp_ranges, str(xcount),
                    xcp_ranges))
    return TableData(table_header, table_rows)
Exemple #2
0
def create_table_from_map(script_to_cmap):
  """Create a table from a map from script to cmaps.  Outputs
  the script code, script name, count of code points, the
  codepoint ranges in hex separated by space, the count of
  excluded/fallback code points, and their ranges separated by
  space.  script_to_cmap can have values either of cmap or of
  a tuple of cmap, xcmap; in the first case xcmap is assumed
  None.  xcmaps that are None are marked as having an xcount of -1.
  This makes it possible to distinguish an empty xcmap from one
  that doesn't exist."""

  table_header = 'script,name,count,ranges,xcount,xranges'.split(',')
  RowData = collections.namedtuple('RowData', table_header)

  table_rows = []
  for script in sorted(script_to_cmap):
    cmap = script_to_cmap.get(script)
    xcmap = None
    if type(cmap) == tuple:
      xcmap = cmap[1]
      cmap = cmap[0]
    name = noto_fonts.script_name_for_report(script)
    count = len(cmap)
    cp_ranges = tool_utils.write_int_ranges(cmap)
    if xcmap == None:
      xcount = -1
      xcp_ranges = ''
    else:
      xcount = len(xcmap)
      xcp_ranges = tool_utils.write_int_ranges(xcmap)
    table_rows.append(
        RowData(script, name, str(count), cp_ranges, str(xcount),
                xcp_ranges))
  return TableData(table_header, table_rows)
Exemple #3
0
def _write_script_to_punct(script_to_punct):
  print 'SCRIPT_TO_PUNCT = {'
  for script in sorted(script_to_punct):
    chars = script_to_punct[script]
    int_chars = [ord(cp) for cp in chars]
    print '  # %s' % ('|'.join(sorted(chars)))
    print "  '%s': '%s'," % (script, tool_utils.write_int_ranges(int_chars))
  print '}'
Exemple #4
0
def _write_script_to_punct(script_to_punct):
    print("SCRIPT_TO_PUNCT = {")
    for script in sorted(script_to_punct):
        chars = script_to_punct[script]
        int_chars = [ord(cp) for cp in chars]
        print("  # %s" % ("|".join(sorted(chars))))
        print("  '%s': '%s'," %
              (script, tool_utils.write_int_ranges(int_chars)))
    print("}")
Exemple #5
0
def _create_cmapdata(name, cmap):
  """Create a CmapData object from the name and cmap."""
  return CmapData(name, tool_utils.write_int_ranges(cmap))
def _create_cmapdata(name, cmap):
  """Create a CmapData object from the name and cmap."""
  return CmapData(name, tool_utils.write_int_ranges(cmap))