Em size is based on the current setting of the fontSize. Used in CSS export. >>> units('10em') 10em >>> Em(10) 10em >>> u = units('10em') >>> u.isEm and u.isRelative True >>> u 10em >>> u/2 5em >>> u-8 2em >>> # Caller can set the base ref
| 1913 | return u |
| 1914 | |
| 1915 | class Em(RelativeUnit): |
| 1916 | """Em size is based on the current setting of the fontSize. Used in CSS |
| 1917 | export. |
| 1918 | |
| 1919 | >>> units('10em') |
| 1920 | 10em |
| 1921 | >>> Em(10) |
| 1922 | 10em |
| 1923 | >>> u = units('10em') |
| 1924 | >>> u.isEm and u.isRelative |
| 1925 | True |
| 1926 | >>> u |
| 1927 | 10em |
| 1928 | >>> u/2 |
| 1929 | 5em |
| 1930 | >>> u-8 |
| 1931 | 2em |
| 1932 | >>> # Caller can set the base reference value. |
| 1933 | >>> u.base = 12 |
| 1934 | >>> pt(u) |
| 1935 | 120pt |
| 1936 | >>> u.base = 24 |
| 1937 | >>> pt(u) |
| 1938 | 240pt |
| 1939 | >>> em(1, 2, 3, 4) |
| 1940 | (1em, 2em, 3em, 4em) |
| 1941 | """ |
| 1942 | isEm = True |
| 1943 | UNIT = 'em' |
| 1944 | # Key in optional base of relative units. |
| 1945 | BASE_KEY = 'em' |
| 1946 | |
| 1947 | def _get_pt(self): |
| 1948 | """Answers the rendered value in pt. Base value for absolute unit |
| 1949 | values is ignored. self.base can be a unit or a number. |
| 1950 | |
| 1951 | >>> u = units('10em', base=12) |
| 1952 | >>> # Answer the rendered value |
| 1953 | >>> u, u.rv |
| 1954 | (10em, 120) |
| 1955 | >>> # Alter the base em. |
| 1956 | >>> u.base = 8 |
| 1957 | >>> # Full representation. |
| 1958 | >>> u |
| 1959 | 10em |
| 1960 | >>> # Defined base for the em (often set in pt units). |
| 1961 | >>> u.base |
| 1962 | 8pt |
| 1963 | >>> # Raw stored value. |
| 1964 | >>> u.v |
| 1965 | 10 |
| 1966 | >>> # Render to Pt value. |
| 1967 | >>> u.rv |
| 1968 | 80 |
| 1969 | >>> # Render to Pt instance |
| 1970 | >>> u.ru |
| 1971 | 80pt |
| 1972 | >>> # Render to points numbe value |