This commit is contained in:
Kovid Goyal 2007-09-23 06:37:54 +00:00
parent ffd3ac2b21
commit 887718b331
2 changed files with 7 additions and 5 deletions

View File

@ -22,7 +22,7 @@ from PyQt4.QtGui import QGraphicsRectItem, QGraphicsScene, QPen, \
QFont, QGraphicsItem, QGraphicsLineItem, QPixmap, \ QFont, QGraphicsItem, QGraphicsLineItem, QPixmap, \
QGraphicsPixmapItem, QTextCharFormat, QTextFrameFormat, \ QGraphicsPixmapItem, QTextCharFormat, QTextFrameFormat, \
QTextBlockFormat, QTextCursor, QTextImageFormat, \ QTextBlockFormat, QTextCursor, QTextImageFormat, \
QTextDocument QTextDocument, QTextOption
from libprs500.ebooks.lrf.fonts import FONT_MAP from libprs500.ebooks.lrf.fonts import FONT_MAP
from libprs500.gui2 import qstring_to_unicode from libprs500.gui2 import qstring_to_unicode
@ -126,7 +126,7 @@ class Line(QGraphicsRectItem):
'dashed' : QTextCharFormat.DashUnderline, 'dashed' : QTextCharFormat.DashUnderline,
'double' : QTextCharFormat.WaveUnderline, 'double' : QTextCharFormat.WaveUnderline,
} }
dto = QTextOption(Qt.AlignJustify)
def __init__(self, offset, linespace, linelength, align, hyphenate, ts, block_id): def __init__(self, offset, linespace, linelength, align, hyphenate, ts, block_id):
QGraphicsRectItem.__init__(self, 0, 0, 0, 0) QGraphicsRectItem.__init__(self, 0, 0, 0, 0)
@ -187,7 +187,9 @@ class Line(QGraphicsRectItem):
def create_text_item(self, ts): def create_text_item(self, ts):
self.item = QGraphicsTextItem(self) self.item = QGraphicsTextItem(self)
self.cursor = QTextCursor(self.item.document()) doc = self.item.document()
doc.setDefaultTextOption(self.__class__.dto)
self.cursor = QTextCursor(doc)
f = self.cursor.currentFrame() f = self.cursor.currentFrame()
ff = QTextFrameFormat() ff = QTextFrameFormat()
ff.setBorder(0) ff.setBorder(0)

View File

@ -169,8 +169,8 @@ def option_parser():
default=False, action='store_true', dest='visual_debug') default=False, action='store_true', dest='visual_debug')
parser.add_option('--disable-hyphenation', dest='hyphenate', default=True, action='store_false', parser.add_option('--disable-hyphenation', dest='hyphenate', default=True, action='store_false',
help='Disable hyphenation. Should significantly speed up rendering.') help='Disable hyphenation. Should significantly speed up rendering.')
parser.add_option('--profile', dest='profile', default='False', action='store_true', parser.add_option('--profile', dest='profile', default=False, action='store_true',
help='Profile the LRf renderer') help='Profile the LRF renderer')
return parser return parser
def main(args=sys.argv, logger=None): def main(args=sys.argv, logger=None):