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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
'''

import inkex, os, sys
from xml.dom.minidom import parse

sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from stroke_font_common import syncFontList, runEffect


class SyncFontListEffect(inkex.Effect):
    def __init__(self):
        inkex.Effect.__init__(self)

    def effect(self):
        extPath = os.path.dirname(os.path.abspath(__file__))
        syncFontList(extPath)


runEffect(SyncFontListEffect())
        elif (action == "renderFile"):
            try:
                readmode = 'rU' if CommonDefs.pyVer == 2 else 'r'
                with open(filePath, readmode) as f:
                    text = f.read()
                    if (CommonDefs.pyVer == 2): text = unicode(text, 'utf-8')
            except Exception as e:
                errormsg(
                    "Error reading the file specified in Text File input box."
                    + str(e))
                return

        if (text[0] == u'\ufeff'):
            text = text[1:]

        if (flowInBox == True):
            selElems = getSelectedElements(self)
            selIds = [selElems[key].get('id') for key in selElems.keys()]
            rectNodes = [r for r in self.document.xpath('//svg:rect', \
                namespaces=NSS) if r.get('id') in selIds]
            if (len(rectNodes) == 0):
                errormsg(_("No rectangle objects selected."))
                return
            context.renderCharsInSelBoxes(text, rectNodes, margin, hAlignment, vAlignment, \
                False, expandDir, expandDist)
        else:
            context.renderCharsWithoutBox(text)


runEffect(RenderStrokeFontText())
        lineT = CommonDefs.lineT * fontSize

        if ('bold' in fontType):
            fontWeight = 'bold'
        else:
            fontWeight = 'normal'

        if ('italic' in fontType):
            fontStyle = 'italic'
        else:
            fontStyle = 'normal'

        self.textStyle = {'font-family':srcFontFamily, 'font-size':str(fontSize),\
        'fill':'#000000', 'fill-opacity':str(fillOpacity), 'stroke':'#000000', 'stroke-width':str(lineT),\
        'stroke-opacity':str(strokeOpacity), 'font-style':fontStyle,'font-weight':fontWeight,\
        'text-align':'start'}

        vgScaleFact = CommonDefs.vgScaleFact

        fontName = 'NA'

        extraInfo = getDefaultExtraInfo(fontName, fontSize)
        extraInfo[xSpaceROff] = spaceWidth

        createTempl(self.addElem, self, extraInfo, rowCnt, glyphCnt, vgScaleFact, \
            rvGuides, lineT, newCallBackLayerName = 'Source Glyphs')


runEffect(CustStrokeFontTempl())
Beispiel #4
0
        getEtree().SubElement(editLayer, addNS('path', 'svg'), attribs)

        return charData.rOffset

    def effect(self):
        rowCnt = self.options.rowCnt
        fontName = self.options.fontName
        fontSize = self.options.fontSize

        lineT = CommonDefs.lineT * fontSize
        strokeWidth = 0.02 * fontSize
        self.charStyle = { 'stroke': '#000000', 'fill': 'none', \
            'stroke-width':strokeWidth, 'stroke-linecap':'round', \
                'stroke-linejoin':'round'}

        vgScaleFact = CommonDefs.vgScaleFact

        extPath = os.path.dirname(os.path.abspath(__file__))
        self.strokeFontData = FontData(extPath, fontName, fontSize, \
            InkscapeCharDataFactory())

        self.fontChars = sorted(self.strokeFontData.glyphMap.keys())

        glyphCnt = len(self.fontChars)

        createTempl(self.addElem, self, self.strokeFontData.extraInfo, rowCnt, \
            glyphCnt, vgScaleFact, True, lineT)


runEffect(EditStrokeFont())
Beispiel #5
0
        if (round(spaceWidth, 1) == 0):
            spaceWidth = extraInfo[xSpaceROff]
            if (round(spaceWidth, 1) == 0): spaceWidth = fontSize / 2

        extraInfo[xSpaceROff] = spaceWidth

        extPath = os.path.dirname(os.path.abspath(__file__))
        strokeFontData = FontData(extPath, fontName, fontSize,
                                  InkscapeCharDataFactory())

        strokeFontData.setCRInfo(crInfo)
        strokeFontData.setExtraInfo(extraInfo)

        glyphPaths = [p for p in self.document.xpath('//svg:path', namespaces=inkex.NSS) \
                if (len(p.get(CommonDefs.idAttribName)) == 1)]

        updateFontData(strokeFontData, glyphPaths, hGuides, lvGuides, rvGuides,
                       rightOffsetType)

        strokeFontData.updateFontXML()

        syncFontList(extPath)


try:
    runEffect(GenStrokeFontData())
except:
    inkex.errormsg('The data was not generated due to an error. ' + \
 'If you are creating non-english glyphs then save the document, re-open and' + \
 'try generating the font data once again.')