Ok, I don't speak python and I'd like someone more fluent
to take the idea and program it more properly.
but after all this is only a workaround to avoid the situation
where there is no fallback font and the program won't work
even with path based svg files that happen to mention font info.
It works for me (with hola-path.svg and hola+empty.svg from my previous post).
This is an alternative to making a ~/.uniconvertor directory and
building a std.sfd file.
It implies changes to only one file in python-uniconvertor, and
does not require tools or font files from other packages.
The function could be called more than once without any bad effects.
But it is onlt a workaround, I still don't know why it doesn't
seem to load the fonts with read_font_dirs()
--
xdru...@tinet.cat
Signa per fer Collserola parc natural com cal
http://www.collserola.org/salvemelparcnatural/
--- /usr/lib/python2.5/site-packages/uniconvertor/app/Graphics/font.py.orig 2009-05-05 22:37:15.000000000 +0200
+++ /usr/lib/python2.5/site-packages/uniconvertor/app/Graphics/font.py 2009-05-05 22:15:25.000000000 +0200
@@ -433,4 +433,38 @@
# Initialisation on import
#
+## workaround for a bug that stops uniconvertor from working with svg
+## files winth font properties in style attributes, even if they apply
+## to no text because all text is empty or transformed to paths
+## see http://svn.berlios.de/viewcvs/bulmages/branches/docsMonolitic/bulmages/installbulmages/openreports/ca/
+
+class FakeFont(Font):
+ def __init__(self, name):
+ self.name = name
+ self.family = name
+ self.font_attrs = 'Regular Italic'
+ self.xlfd_start = '-adobe-Nimbus Roman No9 L-regular-i-normal'
+ self.encoding_name = 'iso8859-1'
+ self.outlines = None
+ self.ref_count = 0
+ font_cache[self.name] = self
+
+def ensure_there_is_at_least_a_fake_fallback_font():
+ fallback = 'Slim';
+ if (not (config is None)) and (hasattr(config,'preferences')) and (hasattr(config.preferences,'fallback_font')):
+ fallback = config.preferences.fallback_font
+ if not font_cache.has_key(fallback):
+ return FakeFont(fallback)
+ return font_cache[fallback]
+
+
+fallbackFont = ensure_there_is_at_least_a_fake_fallback_font()
+
+## end of font workaround
+
+
Subscribe(const.INITIALIZE, read_font_dirs)
+
+
+
+