HEX
Server: Apache
System: Linux opal14.opalstack.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
User: curbgloabal_opal (1234)
PHP: 8.1.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/share/inkscape/extensions/replace_font.pyo
�
��Yc@s�dZddlZddlZddlZddlZdddddgZdd	gZdd
�Zd�Z	d�Z
d
�Zd�Zd�Z
d�Zdd�Zd�Zd�Zdejfd��YZedkr�e�Zej�ndS(s�
replace_font.py

Copyright (C) 2010 Craig Marshall, craig9 [at] gmail.com

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA

-----------------------

This script finds all fonts in the current drawing that match the
specified find font, and replaces them with the specified replacement
font.

It can also replace all fonts indiscriminately, and list all fonts
currently being used.
i����Ns!{http://www.w3.org/2000/svg}tspans {http://www.w3.org/2000/svg}texts${http://www.w3.org/2000/svg}flowRoots${http://www.w3.org/2000/svg}flowParas${http://www.w3.org/2000/svg}flowSpansfont-familys-inkscape-font-specificationcCset}|st|�}n|rax=tD]2}||kr(|||<t||�t}q(q(Wn|S(s�
    Sets the font attribute in the style attribute of node, using the
    font name stored in new_font. If the style dict is open already,
    it can be passed in, otherwise it will be optned anyway.

    Returns a dirty boolean flag
    (tFalset	get_styletfont_attributest	set_styletTrue(tnodetnew_fonttstyletdirtytatt((s./usr/share/inkscape/extensions/replace_font.pytset_font,s


cCsqt}t|�}|rmxRtD]G}||kr||j�j�|krt|||�t}qqWn|S(s�
    Searches the relevant font attributes/styles of node for find, and
    replaces them with replace.

    Returns a dirty boolean flag
    (RRRtstriptlowerR
R(RtfindtreplaceRRR	((s./usr/share/inkscape/extensions/replace_font.pytfind_replace_font?s
(cCs|jtkod|jkS(s[
    Returns true if the tag in question is a "styled" element that
    can hold text.
    R(ttagt	text_tagstattrib(R((s./usr/share/inkscape/extensions/replace_font.pytis_styled_textOscCs
|jtkS(sS
    Returns true if the tag in question is an element that
    can hold text.
    (RR(R((s./usr/share/inkscape/extensions/replace_font.pytis_textVscCs'd|jkr#tj|jd�SdS(s8
    Sugar coated way to get style dict from a node
    RN(Rtsimplestylet
parseStyle(R((s./usr/share/inkscape/extensions/replace_font.pyR^scCstj|�|jd<dS(s:
    Sugar coated way to set the style dict, for node
    RN(RtformatStyleR(RR((s./usr/share/inkscape/extensions/replace_font.pyRescCsQg}t|�}|s|Sx.tD]&}||kr#|j||�q#q#W|S(s[
    Given a node, returns a list containing all the fonts that
    the node is using.
    (RRtappend(Rtfontststa((s./usr/share/inkscape/extensions/replace_font.pyt	get_fontsks
sDying!cCstj|�tjd�dS(Ni(tinkexterrormsgtsystexit(tmsg((s./usr/share/inkscape/extensions/replace_font.pytdieys
cCs#|dkrttd��ndS(s`
    Sends a message to the end user showing success of failure
    of the font replacement
    isZCouldn't find anything using that font, please ensure the spelling and spacing is correct.N(R"t_(tnum((s./usr/share/inkscape/extensions/replace_font.pytreport_replacements}scCs|t|�dkr(tjtd��nPt|�dkrXtjtd�|d�n tjtd�dj|��dS(s7
    Tells the user which fonts were found, if any
    is1Didn't find any fonts in this document/selection.is!Found the following font only: %ssFound the following fonts:
%ss
N(tlenRRR#tjoin(tfindings((s./usr/share/inkscape/extensions/replace_font.pytreport_findings�s
tReplaceFontcBsMeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(s9
    Replaces all instances of one font with another
    cCs�tjj|�|jjdddddddddd	d
�|jjdddddddddd	d
�|jjd
ddddddddd	d
�|jjdddddddddd	d
�|jjdddddddddd	d
�dS(Ns	--fr_findtactiontstorettypetstringtdesttfr_findtdefaultthelpts--fr_replacet
fr_replaces--r_replacet	r_replaces--actions--scopetscope(RtEffectt__init__tOptionParsert
add_optiontNone(tself((s./usr/share/inkscape/extensions/replace_font.pyR8�s 



cCsAt|�r=|jj|�x|D]}|j|�q#WndS(sf
        Recursive method for appending all text-type elements
        to self.selected_items
        N(Rtselected_itemsRtfind_child_text_items(R<Rtchild((s./usr/share/inkscape/extensions/replace_font.pyR>�s
cCs�g}g}|dkr}g|_x(|jj�D]}|j|d�q1W|j}t|�dkr�ttd��q�n|jj�j	�}|j
tt|��|S(s�
        Depending on the scope, returns all text elements, or all
        selected text elements including nested children
        tselection_onlyiisThere was nothing selected(
R=tselectedt	iteritemsR>R&R"R#tdocumenttgetroottgetiteratortextendtfilterR(R<R6titemst	to_returntitem((s./usr/share/inkscape/extensions/replace_font.pytrelevant_items�s		cCsDd}x-|D]%}t|||�r
|d7}q
q
Wt|�dS(sg
        Walks through nodes, replacing fonts as it goes according
        to find and replace
        iiN(RR%(R<tnodesR
RtreplacementsR((s./usr/share/inkscape/extensions/replace_font.pytfind_replace�s

cCsAd}x*|D]"}t||�r
|d7}q
q
Wt|�dS(sF
        Walks through nodes, setting fonts indiscriminately.
        iiN(R
R%(R<RLRRMR((s./usr/share/inkscape/extensions/replace_font.pytreplace_all�s

cCs^g}xA|D]9}x0t|�D]"}||kr |j|�q q Wq
Wtt|��dS(sz
        Walks through nodes, building a list of all fonts found, then
        reports to the user with that list
        N(RRR)tsorted(R<RLtfonts_foundRtf((s./usr/share/inkscape/extensions/replace_font.pytlist_all�s
cCsU|jjjd�}|jj}|j|�}|dkr�|jj}|dks`|dkrsttd��n|j�j	�}|jj
}|dks�|dkr�ttd��n|j|||�n|dkr(|jj}|dks|dkrttd��n|j
||�n)|dkrQ|j|�tjd	�ndS(
Ns"RNR3s-Please enter a search string in the find box.s8Please enter a replacement font in the replace with box.ROs7Please enter a replacement font in the replace all box.t	list_onlyi(toptionsR+RR6RKR0R;R"R#RR4RNR5RORSRR (R<R+R6RKR
R((s./usr/share/inkscape/extensions/replace_font.pyteffect�s(
(
t__name__t
__module__t__doc__R8R>RKRNRORSRV(((s./usr/share/inkscape/extensions/replace_font.pyR*�s		
			
	t__main__(RYtosRRRRRR;R
RRRRRRR"R%R)R7R*RWtetaffect(((s./usr/share/inkscape/extensions/replace_font.pyt<module>s0									p