Switch to utf8 capable fonts. Enable monospace for formatted notes.

svn: r2971
This commit is contained in:
Alex Roitman 2004-03-05 05:11:07 +00:00
parent 43547bf06d
commit 1e8b2e3f40
2 changed files with 11 additions and 0 deletions

View File

@ -1,6 +1,7 @@
2004-03-04 Alex Roitman <shura@alex.neuro.umn.edu> 2004-03-04 Alex Roitman <shura@alex.neuro.umn.edu>
* src/docgen/LPRDoc.py: New paragraph formatting algorithm. * src/docgen/LPRDoc.py: New paragraph formatting algorithm.
Proper alignment support (no implementation for justify yet). Proper alignment support (no implementation for justify yet).
Switch to utf8 capable fonts. Enable monospace for formatted notes.
2004-03-03 Alex Roitman <shura@alex.neuro.umn.edu> 2004-03-03 Alex Roitman <shura@alex.neuro.umn.edu>
* src/docgen/LPRDoc.py: Superscript support, line breaks, * src/docgen/LPRDoc.py: Superscript support, line breaks,

View File

@ -70,6 +70,7 @@ _FONT_REGULAR = "Regular"
_LINE_BREAK = "Break" _LINE_BREAK = "Break"
_BOLD = "Bold" _BOLD = "Bold"
_SUPER = "Super" _SUPER = "Super"
_MONO = "Mono"
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -260,6 +261,8 @@ class GnomePrintParagraph:
elif directive == _SUPER: elif directive == _SUPER:
size = fontstyle.get_size() size = fontstyle.get_size()
fontstyle.set_size(size-2) fontstyle.set_size(size-2)
elif directive == _MONO:
fontstyle.set_type_face(BaseDoc.FONT_MONOSPACE)
font = find_font_from_fontstyle(fontstyle) font = find_font_from_fontstyle(fontstyle)
width += font.get_width_utf8(text) width += font.get_width_utf8(text)
@ -279,6 +282,8 @@ class GnomePrintParagraph:
elif directive == _SUPER: elif directive == _SUPER:
size = fontstyle.get_size() size = fontstyle.get_size()
fontstyle.set_size(size-2) fontstyle.set_size(size-2)
elif directive == _MONO:
fontstyle.set_type_face(BaseDoc.FONT_MONOSPACE)
for word in text.split(): for word in text.split():
length = get_text_width(word,fontstyle) length = get_text_width(word,fontstyle)
@ -327,6 +332,8 @@ class GnomePrintParagraph:
elif directive == _SUPER: elif directive == _SUPER:
size = fontstyle.get_size() size = fontstyle.get_size()
fontstyle.set_size(size-2) fontstyle.set_size(size-2)
elif directive == _MONO:
fontstyle.set_type_face(BaseDoc.FONT_MONOSPACE)
if text and avail_width > get_text_width(text,fontstyle): if text and avail_width > get_text_width(text,fontstyle):
avail_width -= get_text_width(text,fontstyle) avail_width -= get_text_width(text,fontstyle)
@ -672,6 +679,7 @@ class LPRDoc(BaseDoc.BaseDoc):
if format == 1: if format == 1:
for line in text.split('\n'): for line in text.split('\n'):
self.start_paragraph(style_name) self.start_paragraph(style_name)
self.__paragraph_directive = _MONO
self.write_text(line) self.write_text(line)
self.end_paragraph() self.end_paragraph()
elif format == 0: elif format == 0:
@ -739,6 +747,8 @@ class LPRDoc(BaseDoc.BaseDoc):
size = fontstyle.get_size() size = fontstyle.get_size()
fontstyle.set_size(size-2) fontstyle.set_size(size-2)
y = y + 0.25 * _LINE_SPACING y = y + 0.25 * _LINE_SPACING
elif directive == _MONO:
fontstyle.set_type_face(BaseDoc.FONT_MONOSPACE)
textlist = text.split() textlist = text.split()
if start_piece == end_piece: if start_piece == end_piece: