Пример #1
0
def setup_fonts_conf():
    """We first look for fonts.conf under the root nototools, and if we don't
  find it we write it.  The fontconfig cache also goes there.  This of course
  requires nototools to be writable."""

    # We require notoconfig because we don't know where this code is located,
    # nor whether the font directories might be relative to it.

    TOOLS_DIR = notoconfig.noto_tools()
    fonts_conf = path.join(TOOLS_DIR, 'fonts.conf')
    if not path.isfile(fonts_conf):
        noto_font_dirs = []
        FONTS_DIR = notoconfig.noto_fonts()
        if FONTS_DIR:
            noto_font_dirs.extend([
                path.join(FONTS_DIR, 'hinted'),
                path.join(FONTS_DIR, 'unhinted')
            ])
        CJK_DIR = notoconfig.noto_cjk()
        if CJK_DIR:
            noto_font_dirs.append(CJK_DIR)
        EMOJI_DIR = notoconfig.noto_emoji()
        if EMOJI_DIR:
            noto_font_dirs.append(path.join(EMOJI_DIR, 'fonts'))
        font_dirs = '\n  '.join('<dir>%s</dir>' % d for d in noto_font_dirs)

        cache_dir = path.join(TOOLS_DIR, 'fontconfig')
        template = string.Template(_fonts_conf_template)
        conf_text = template.substitute(font_dirs=font_dirs,
                                        cache_dir=cache_dir)
        try:
            with open(fonts_conf, 'w') as f:
                f.write(conf_text)
        except IOError as e:
            raise Exception('unable to write %s: %s' % (fonts_conf, e))

    # Note: ensure /etc/fonts/conf.d/10-scale-bitmap-fonts.conf is
    # in sync with fontconfig to make sure color emoji font scales properly.
    os.putenv('FONTCONFIG_FILE', fonts_conf)
Пример #2
0
def setup_fonts_conf():
  """We first look for fonts.conf under the root nototools, and if we don't
  find it we write it.  The fontconfig cache also goes there.  This of course
  requires nototools to be writable."""

  # We require notoconfig because we don't know where this code is located,
  # nor whether the font directories might be relative to it.

  TOOLS_DIR = notoconfig.noto_tools()
  fonts_conf = path.join(TOOLS_DIR, 'fonts.conf')
  if not path.isfile(fonts_conf):
    noto_font_dirs = []
    FONTS_DIR = notoconfig.noto_fonts()
    if FONTS_DIR:
      noto_font_dirs.extend(
          [path.join(FONTS_DIR, 'hinted'), path.join(FONTS_DIR, 'unhinted')])
    CJK_DIR = notoconfig.noto_cjk()
    if CJK_DIR:
      noto_font_dirs.append(CJK_DIR)
    EMOJI_DIR = notoconfig.noto_emoji()
    if EMOJI_DIR:
      noto_font_dirs.append(path.join(EMOJI_DIR, 'fonts'))
    font_dirs = '\n  '.join('<dir>%s</dir>' % d for d in noto_font_dirs)

    cache_dir = path.join(TOOLS_DIR, 'fontconfig')
    template = string.Template(_fonts_conf_template)
    conf_text = template.substitute(font_dirs=font_dirs, cache_dir=cache_dir)
    try:
      with open(fonts_conf, 'w') as f:
        f.write(conf_text)
    except IOError as e:
      raise Exception('unable to write %s: %s' % (fonts_conf, e))

  # Note: ensure /etc/fonts/conf.d/10-scale-bitmap-fonts.conf is
  # in sync with fontconfig to make sure color emoji font scales properly.
  os.putenv('FONTCONFIG_FILE', fonts_conf)
Пример #3
0
import subprocess
import xml.etree.cElementTree as ElementTree

from fontTools import ttLib

from nototools import cldr_data
from nototools import coverage
from nototools import create_image
from nototools import extra_locale_data
from nototools import lang_data
from nototools import notoconfig
from nototools import noto_fonts
from nototools import tool_utils
from nototools import unicode_data

TOOLS_DIR = notoconfig.noto_tools()
FONTS_DIR = notoconfig.noto_fonts()
CJK_DIR = notoconfig.noto_cjk()
EMOJI_DIR = notoconfig.noto_emoji()

CLDR_DIR = path.join(TOOLS_DIR, 'third_party', 'cldr')

LAT_LONG_DIR = path.join(TOOLS_DIR, 'third_party', 'dspl')
SAMPLE_TEXT_DIR = path.join(TOOLS_DIR, 'sample_texts')

# The Apache license is currently not used for our fonts, but leave
# this just in case this changes in the future.  We have a copy of
# the Apache license in the noto-emoji repo, since it covers the
# code there, so just use that.
APACHE_LICENSE_LOC = path.join(EMOJI_DIR, 'LICENSE')
SIL_LICENSE_LOC = path.join(CJK_DIR, 'LICENSE')