* src/plugins/FilterEditor.py: handle unicode characters

* src/PeopleStore.py: handle corrupt iter
* src/GenericFilter.py: handle unicode
* src/docgen/PSDrawDoc.py: handle iso-8859-1 characters


svn: r2664
This commit is contained in:
Don Allingham 2004-01-20 03:57:19 +00:00
parent 7b471d126d
commit 384a6c0fae
2 changed files with 70 additions and 35 deletions

View File

@ -1418,40 +1418,48 @@ class GenericFilter:
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
tasks = { tasks = {
_("Everyone") : Everyone, unicode(_("Everyone")) : Everyone,
_("Has the Id") : HasIdOf, unicode(_("Has the Id")) : HasIdOf,
_("Has a name") : HasNameOf, unicode(_("Has a name")) : HasNameOf,
_("Has the relationships") : HasRelationship, unicode(_("Has the relationships")) : HasRelationship,
_("Has the death") : HasDeath, unicode(_("Has the death")) : HasDeath,
_("Has the birth") : HasBirth, unicode(_("Has the birth")) : HasBirth,
_("Is a descendant of") : IsDescendantOf, unicode(_("Is a descendant of")) : IsDescendantOf,
_("Is a descendant family member of") : IsDescendantFamilyOf, unicode(_("Is a descendant family member of"))
_("Is a descendant of filter match") : IsDescendantOfFilterMatch, : IsDescendantFamilyOf,
_("Is a descendant of person not more than N generations away") unicode(_("Is a descendant of filter match"))
: IsDescendantOfFilterMatch,
unicode(_("Is a descendant of person not more than N generations away"))
: IsLessThanNthGenerationDescendantOf, : IsLessThanNthGenerationDescendantOf,
_("Is a descendant of person at least N generations away") unicode(_("Is a descendant of person at least N generations away"))
: IsMoreThanNthGenerationDescendantOf, : IsMoreThanNthGenerationDescendantOf,
_("Is a child of filter match") : IsChildOfFilterMatch, unicode(_("Is a child of filter match"))
_("Is an ancestor of") : IsAncestorOf, : IsChildOfFilterMatch,
_("Is an ancestor of filter match") : IsAncestorOfFilterMatch, unicode(_("Is an ancestor of"))
_("Is an ancestor of person not more than N generations away") : IsAncestorOf,
unicode(_("Is an ancestor of filter match"))
: IsAncestorOfFilterMatch,
unicode(_("Is an ancestor of person not more than N generations away"))
: IsLessThanNthGenerationAncestorOf, : IsLessThanNthGenerationAncestorOf,
_("Is an ancestor of person at least N generations away") unicode(_("Is an ancestor of person at least N generations away"))
: IsMoreThanNthGenerationAncestorOf, : IsMoreThanNthGenerationAncestorOf,
_("Is a parent of filter match") : IsParentOfFilterMatch, unicode(_("Is a parent of filter match"))
_("Has a common ancestor with") : HasCommonAncestorWith, : IsParentOfFilterMatch,
_("Has a common ancestor with filter match") unicode(_("Has a common ancestor with"))
: HasCommonAncestorWith,
unicode(_("Has a common ancestor with filter match"))
: HasCommonAncestorWithFilterMatch, : HasCommonAncestorWithFilterMatch,
_("Is a female") : IsFemale, unicode(_("Is a female")) : IsFemale,
_("Is a male") : IsMale, unicode(_("Is a male")) : IsMale,
_("Has complete record") : HasCompleteRecord, unicode(_("Has complete record")) : HasCompleteRecord,
_("Has the personal event") : HasEvent, unicode(_("Has the personal event")) : HasEvent,
_("Has the family event") : HasFamilyEvent, unicode(_("Has the family event")) : HasFamilyEvent,
_("Has the personal attribute") : HasAttribute, unicode(_("Has the personal attribute")) : HasAttribute,
_("Has the family attribute") : HasFamilyAttribute, unicode(_("Has the family attribute")) : HasFamilyAttribute,
_("Matches the filter named") : MatchesFilter, unicode(_("Matches the filter named")) : MatchesFilter,
_("Is spouse of filter match") : IsSpouseOfFilterMatch, unicode(_("Is spouse of filter match")) : IsSpouseOfFilterMatch,
_("Relationship path between two people") : RelationshipPathBetween, unicode(_("Relationship path between two people"))
: RelationshipPathBetween,
} }
#------------------------------------------------------------------------- #-------------------------------------------------------------------------

View File

@ -86,7 +86,7 @@ class PSDrawDoc(BaseDoc.BaseDoc):
else: else:
font_name = "/Helvetica" font_name = "/Helvetica"
return "%s findfont %d scalefont setfont\n" % (font_name,font.get_size()) return "%s find-latin-font %d scalefont setfont\n" % (font_name,font.get_size())
def translate(self,x,y): def translate(self,x,y):
return (x,self.height-y) return (x,self.height-y)
@ -115,6 +115,19 @@ class PSDrawDoc(BaseDoc.BaseDoc):
self.f.write('%%Orientation: Portrait\n') self.f.write('%%Orientation: Portrait\n')
self.f.write('%%EndComments\n') self.f.write('%%EndComments\n')
self.f.write('/cm { 28.34 mul } def\n') self.f.write('/cm { 28.34 mul } def\n')
self.f.write('% build iso-latin-1 version of a font\n')
self.f.write('/font-to-iso-latin-1 { % <font> font-to-iso-latin-1 <font>\n')
self.f.write('%% reencode for iso latin1; from the 2nd edition red book, sec 5.6.1\n')
self.f.write('dup length dict begin {1 index /FID ne {def} {pop pop} ifelse} forall\n')
self.f.write('/Encoding ISOLatin1Encoding def currentdict end\n')
self.f.write('dup /FontName get 80 string cvs (-ISOLatin1) concatstrings cvn \n')
self.f.write('exch definefont\n')
self.f.write('} def\n')
self.f.write('\n')
self.f.write('/find-latin-font { % <name> find-latin-font <font>\n')
self.f.write('findfont font-to-iso-latin-1\n')
self.f.write('} def\n')
self.filename = filename self.filename = filename
def close(self): def close(self):
@ -140,6 +153,15 @@ class PSDrawDoc(BaseDoc.BaseDoc):
self.f.write('showpage\n') self.f.write('showpage\n')
self.f.write('%%PageTrailer\n') self.f.write('%%PageTrailer\n')
def encode_text(self,p,text):
fdef = self.fontdef(p)
try:
orig = unicode(text)
new_text = orig.encode('iso-8859-1')
except:
new_text = "?"
return (new_text,fdef)
def center_text(self,style,text,x,y): def center_text(self,style,text,x,y):
x += self.lmargin x += self.lmargin
y += self.tmargin y += self.tmargin
@ -148,10 +170,12 @@ class PSDrawDoc(BaseDoc.BaseDoc):
pname = stype.get_paragraph_style() pname = stype.get_paragraph_style()
p = self.style_list[pname] p = self.style_list[pname]
(text,fdef) = self.encode_text(p,text)
self.f.write('gsave\n') self.f.write('gsave\n')
self.f.write('%.4f %.4f %.4f setrgbcolor\n' % rgb_color(stype.get_color())) self.f.write('%.4f %.4f %.4f setrgbcolor\n' % rgb_color(stype.get_color()))
self.f.write(self.fontdef(p)) self.f.write(fdef)
self.f.write('(%s) dup stringwidth pop -2 div ' % text.encode('iso-8859-1')) self.f.write('(%s) dup stringwidth pop -2 div ' % text)
self.f.write('%.4f cm add %.4f cm moveto ' % self.translate(x,y)) self.f.write('%.4f cm add %.4f cm moveto ' % self.translate(x,y))
self.f.write('show\n') self.f.write('show\n')
self.f.write('grestore\n') self.f.write('grestore\n')
@ -232,8 +256,10 @@ class PSDrawDoc(BaseDoc.BaseDoc):
size = font.get_size() size = font.get_size()
(new_text,fdef) = self.encode_text(p,text[0])
self.f.write('gsave\n') self.f.write('gsave\n')
self.f.write(self.fontdef(p)) self.f.write(fdef)
self.f.write('%4.2f cm %4.2f cm translate\n' % self.translate(x,y)) self.f.write('%4.2f cm %4.2f cm translate\n' % self.translate(x,y))
self.f.write('%4.2f rotate\n' % -angle) self.f.write('%4.2f rotate\n' % -angle)
@ -321,7 +347,7 @@ class PSDrawDoc(BaseDoc.BaseDoc):
box_style = self.draw_styles[style] box_style = self.draw_styles[style]
para_name = box_style.get_paragraph_style() para_name = box_style.get_paragraph_style()
p = self.style_list[para_name] p = self.style_list[para_name]
text = self.patch_text(text) (junk,fdef) = self.encode_text(p,text)
bh = box_style.get_height() bh = box_style.get_height()
bw = box_style.get_width() bw = box_style.get_width()
@ -354,7 +380,8 @@ class PSDrawDoc(BaseDoc.BaseDoc):
self.f.write('%.4f setlinewidth\n' % box_style.get_line_width()) self.f.write('%.4f setlinewidth\n' % box_style.get_line_width())
self.f.write('%.4f %.4f %.4f setrgbcolor stroke\n' % rgb_color(box_style.get_color())) self.f.write('%.4f %.4f %.4f setrgbcolor stroke\n' % rgb_color(box_style.get_color()))
if text != "": if text != "":
self.f.write(self.fontdef(p)) (text,fdef) = self.encode_text(p,text)
self.f.write(fdef)
lines = string.split(text,'\n') lines = string.split(text,'\n')
nlines = len(lines) nlines = len(lines)
mar = 10/28.35 mar = 10/28.35