Fix small caps support

This commit is contained in:
Kovid Goyal 2007-08-04 21:57:13 +00:00
parent e6bcc95150
commit 1461146624
2 changed files with 14 additions and 10 deletions

View File

@ -229,15 +229,19 @@ class Span(_Span):
normal_font_size = attrs['fontsize'] normal_font_size = attrs['fontsize']
variant = attrs.pop('fontvariant', None) variant = attrs.pop('fontvariant', None)
if variant == 'small-caps': if variant == 'small-caps':
tokens = [ i.upper() for i in src.split()] dump = _Span(fontsize=normal_font_size-30)
spans = [] temp = []
for i in tokens: for c in src:
f, r = i[0], i[1:]+' ' if c.isupper():
spans.append(f) if temp:
spans.append(_Span(r, fontsize=normal_font_size-30)) dump.append(''.join(temp))
src = _Span(fontsize=normal_font_size) temp = []
for i in spans: dump.append(_Span(c, fontsize=normal_font_size))
src.append(i) else:
temp.append(c.upper())
src = dump
if temp:
src.append(''.join(temp))
family, key = attrs['fontfacename'] family, key = attrs['fontfacename']
if fonts[family].has_key(key): if fonts[family].has_key(key):

View File

@ -167,7 +167,7 @@
</p> </p>
<br/> <br/>
<br/> <br/>
<p><span style="font-variant: small-caps">This is an example</span> of small-caps. <p><span style="font-variant: small-caps">This is an Example</span> of small-caps.
It can also be used to highlight the start of a paragraph very effectively. It can also be used to highlight the start of a paragraph very effectively.
</p> </p>
<p class='toc'> <p class='toc'>