Le 02/06/2020 à 11:33, JLuc a écrit : > Has somebody writtend a script to add thin typographic spaces where required > for french ? > > (Before and/or after » « : ; ! etc) > > I've been planning to write a rough version of such a script someday > (adapting the autoquote2 script) > but it'd be great when it exists allready. > > JLuc
Hi JLuc and all, running this in console, in Scribus 1.5.5, with text frame selected, seems to work for me. It is reworked from a larger function so it is not tested much as is. Utf8 and regex is a bit tricky, not sure it is optimal as is, but thin space is correctly replaced before "»", which is not the case if utf8/regex is messed up. It only replace existing spaces with thin spaces, does not add missing spaces. Also, formatting will probably be lost, maybe autoquote does things better to prevent this, didn't check yet. Hope it can help, will be interested in a solid function too ! Victor ---- 8< ---- #!/usr/bin/env python3 # -*- coding: utf-8 -*- import re thin_space = u"\u2009" thin_nbsp = u"\u202F" thin_before = "!?;:%»)" re_thin_before = re.compile(ur'\s([%s])'%thin_before) thin_after = "«(" re_thin_after = re.compile(ur'([%s])\s'%thin_after) def traitement_typo(text) : text = re_thin_before.sub(thin_nbsp+ur"\1", text) text = re_thin_after.sub(ur"\1"+thin_nbsp, text) return text def main() : frame = scribus.getSelectedObject(0) text = scribus.getAllText(frame).decode("utf-8") scribus.setText(traitement_typo(text), frame) main() ___ Scribus Mailing List: scribus@lists.scribus.net Edit your options or unsubscribe: http://lists.scribus.net/mailman/listinfo/scribus See also: http://wiki.scribus.net http://forums.scribus.net