summaryrefslogtreecommitdiff
path: root/scripts/roboto_data.py
blob: ef2a77330670380b9a52dbe044f70305fe609653 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/python
"""Post-build changes for Roboto for Android."""

import re

WEIGHTS = {
    'Thin': 250,
    'Light': 300,
    'Regular': 400,
    'Medium': 500,
    'Bold': 700,
    'Black': 900,
}

_ALL_WEIGHTS_RE = re.compile(
    '(' + '|'.join(WEIGHTS.keys()) + ')'
)


def extract_weight_name(font_name):
    """Extracts the weight part of the name from a font name."""
    match = re.search(_ALL_WEIGHTS_RE, font_name)
    if match is None:
        assert font_name in ['Roboto Italic', 'Roboto Condensed Italic']
        return 'Regular'
    else:
        return match.group(1)