Mercurial > MadButterfly
comparison tools/svg2code.py @ 333:bdf36a26e420
Make generated code clean.
- Before changes, generated code include a lot of redundant empty lines.
- Add dnl after each command when svg2code.py generates code lines.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sat, 07 Mar 2009 10:55:42 +0800 |
parents | 5737548e922f |
children | 2212f515584c |
comparison
equal
deleted
inserted
replaced
332:f90c60967a9c | 333:bdf36a26e420 |
---|---|
475 #print [style_map] | 475 #print [style_map] |
476 if style_map.has_key('font-size'): | 476 if style_map.has_key('font-size'): |
477 # FIXME: Implement all units here | 477 # FIXME: Implement all units here |
478 if style_map['font-size'].endswith('px'): | 478 if style_map['font-size'].endswith('px'): |
479 font_sz = float(style_map['font-size'][:-2]) | 479 font_sz = float(style_map['font-size'][:-2]) |
480 print >> codefo, 'PANGO_SIZE(%d,%d,%d)' % (font_sz*1024,start,end) | 480 print >> codefo, 'PANGO_SIZE(%d,%d,%d)dnl' % (font_sz*1024,start,end) |
481 else: | 481 else: |
482 font_sz = float(style_map['font-size']) | 482 font_sz = float(style_map['font-size']) |
483 print >> codefo, 'PANGO_SIZE(%d,%d,%d)' % (font_sz*1024,start,end) | 483 print >> codefo, 'PANGO_SIZE(%d,%d,%d)dnl' % (font_sz*1024,start,end) |
484 pass | 484 pass |
485 | 485 |
486 if style_map.has_key('font-style'): | 486 if style_map.has_key('font-style'): |
487 font_style = style_map['font-style'].lower() | 487 font_style = style_map['font-style'].lower() |
488 if font_style == 'normal': | 488 if font_style == 'normal': |
489 print >> codefo, 'PANGO_STYLE(PANGO_STYLE_NORMAL,%d,%d)' % (start,end) | 489 print >> codefo, 'PANGO_STYLE(PANGO_STYLE_NORMAL,%d,%d)dnl' % (start,end) |
490 elif font_style == 'italic': | 490 elif font_style == 'italic': |
491 print >> codefo, 'PANGO_STYLE(PANGO_STYLE_ITALIC,%d,%d)' % (start,end) | 491 print >> codefo, 'PANGO_STYLE(PANGO_STYLE_ITALIC,%d,%d)dnl' % (start,end) |
492 elif font_style == 'oblique': | 492 elif font_style == 'oblique': |
493 print >> codefo, 'PANGO_STYLE(PANGO_STYLE_OBLIQUE,%d,%d)' % (start,end) | 493 print >> codefo, 'PANGO_STYLE(PANGO_STYLE_OBLIQUE,%d,%d)dnl' % (start,end) |
494 pass | 494 pass |
495 | 495 |
496 if style_map.has_key('font-family'): | 496 if style_map.has_key('font-family'): |
497 font_family = style_map['font-family'] | 497 font_family = style_map['font-family'] |
498 print >> codefo, 'PANGO_FAMILY(%s,%d,%d)' % (font_family,start,end) | 498 print >> codefo, 'PANGO_FAMILY(%s,%d,%d)dnl' % (font_family,start,end) |
499 pass | 499 pass |
500 if style_map.has_key('text-anchor'): | 500 if style_map.has_key('text-anchor'): |
501 text_anchor = style_map['text-anchor'].lower() | 501 text_anchor = style_map['text-anchor'].lower() |
502 # FIXME: We need to implement a mb_text_set_aligment to implement SVG-styled alignment. | 502 # FIXME: We need to implement a mb_text_set_aligment to implement SVG-styled alignment. |
503 print "The text-anchor is not implemented yet" | 503 print "The text-anchor is not implemented yet" |
507 print "The font-variant is not implemented yet" | 507 print "The font-variant is not implemented yet" |
508 pass | 508 pass |
509 if style_map.has_key('font-weight'): | 509 if style_map.has_key('font-weight'): |
510 font_weight = style_map['font-weight'].lower() | 510 font_weight = style_map['font-weight'].lower() |
511 if font_weight == 'normal': | 511 if font_weight == 'normal': |
512 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_NORMAL,%d,%d)' % (start,end) | 512 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_NORMAL,%d,%d)dnl' % (start,end) |
513 elif font_weight == 'bold': | 513 elif font_weight == 'bold': |
514 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_BOLD,%d,%d)' % (start,end) | 514 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_BOLD,%d,%d)dnl' % (start,end) |
515 elif font_weight == 'bolder': | 515 elif font_weight == 'bolder': |
516 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_HEAVY,%d,%d)' % (start,end) | 516 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_HEAVY,%d,%d)dnl' % (start,end) |
517 elif font_weight == 'lighter': | 517 elif font_weight == 'lighter': |
518 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_ULTRALIGHT,%d,%d)' % (start,end) | 518 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_ULTRALIGHT,%d,%d)dnl' % (start,end) |
519 elif font_weight == '100': | 519 elif font_weight == '100': |
520 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_ULTRALIGHT,%d,%d)' % (start,end) | 520 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_ULTRALIGHT,%d,%d)dnl' % (start,end) |
521 elif font_weight == '200': | 521 elif font_weight == '200': |
522 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_ULTRALIGHT,%d,%d)' % (start,end) | 522 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_ULTRALIGHT,%d,%d)dnl' % (start,end) |
523 elif font_weight == '300': | 523 elif font_weight == '300': |
524 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_LIGHT,%d,%d)' % (start,end) | 524 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_LIGHT,%d,%d)dnl' % (start,end) |
525 elif font_weight == '400': | 525 elif font_weight == '400': |
526 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_NORMAL,%d,%d)' % (start,end) | 526 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_NORMAL,%d,%d)dnl' % (start,end) |
527 elif font_weight == '500': | 527 elif font_weight == '500': |
528 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_NORMAL,%d,%d)' % (start,end) | 528 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_NORMAL,%d,%d)dnl' % (start,end) |
529 elif font_weight == '600': | 529 elif font_weight == '600': |
530 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_SEMIBOLD,%d,%d)' % (start,end) | 530 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_SEMIBOLD,%d,%d)dnl' % (start,end) |
531 elif font_weight == '700': | 531 elif font_weight == '700': |
532 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_BOLD,%d,%d)' % (start,end) | 532 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_BOLD,%d,%d)dnl' % (start,end) |
533 elif font_weight == '800': | 533 elif font_weight == '800': |
534 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_ULTRABOLD,%d,%d)' % (start,end) | 534 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_ULTRABOLD,%d,%d)dnl' % (start,end) |
535 elif font_weight == '900': | 535 elif font_weight == '900': |
536 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_HEAVY,%d,%d)' % (start,end) | 536 print >> codefo, 'PANGO_STYLE(PANGO_WEIGHT_HEAVY,%d,%d)dnl' % (start,end) |
537 else: | 537 else: |
538 print "The font-weight %s is not supported" % font_weight | 538 print "The font-weight %s is not supported" % font_weight |
539 pass | 539 pass |
540 if style_map.has_key('direction'): | 540 if style_map.has_key('direction'): |
541 direction = style_map['direction'].lower() | 541 direction = style_map['direction'].lower() |