Jurkins Posted January 5 Share Posted January 5 Reāla problēma... 😁 Process uzrakstīts virsrakstā. Svgwrite bibliotēka. Mēģinot barot šim iekšā formatētu stringu, šamais visas atstarpes uztaisa vienu vienību lielas. import svgwrite dwg = svgwrite.Drawing('test2.svg', size = ('210mm', '297mm'), profile = 'full') dwg.add(dwg.text(' A A A A A A', insert = (10, 100))) dwg.save() Rezultātu izdod šādu: Gūglējot, vienīgais, ko atradu, ka jānorāda profile = 'full'. Ja paskatās svg failu redaktorā, tad ... <text x="10" y="100"> A A A A A A</text Ja gūgle nepalīdz, tad jālūdz palīdzība zālei ( ne tai😁) Link to comment Share on other sites More sharing options...
marrtins Posted January 5 Share Posted January 5 Piemet dwg.defs.add(dwg.style('* {white-space: pre; }')) 1 Link to comment Share on other sites More sharing options...
Jurkins Posted January 6 Author Share Posted January 6 Super, @marrtins, paldies! Mēģināju kaut kādas līdzīgas lietas darīt, tipa "preserve", bet pareizo neatradu. Link to comment Share on other sites More sharing options...
AndrisBB Posted January 6 Share Posted January 6 Visdrīzāk atribūts, kuru tu meklē, ir 'xml:space' https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xml:space import svgwrite dwg = svgwrite.Drawing('test2.svg', size = ('210mm', '297mm'), profile = 'full') test = dwg.text(' A A A A A A', insert = (10, 100)) test['xml:space'] = "preserve" dwg.add(test) dwg.save() 1 Link to comment Share on other sites More sharing options...
Jurkins Posted January 6 Author Share Posted January 6 (edited) Pirms 2 minūtēm , AndrisBB teica: Visdrīzāk atribūts, kuru tu meklē, ir 'xml:space' Tieši tā! Bet es nemācēju šo pareizi ielikt. Atšķirība, ka @marrtinsvariantā tas attiecas uz visu dokumentu, bet Tavā tikai uz objektu test. Edited January 6 by Jurkins Link to comment Share on other sites More sharing options...
marrtins Posted January 6 Share Posted January 6 Stilus jau var pielikt arī konkrētam elementam - un jā - daudz prātīgāk ir stilot pašu elementu, ne visu dokumentu, bet tas ātrais piemērs idejai. Par @AndrisBB ieliktu xml atribūtu arī nezināju. Link to comment Share on other sites More sharing options...
AndrisBB Posted January 6 Share Posted January 6 Šeit jau viss atkarīgs no tā, kas to SVG renderēs. Var jau gadīties ka renderētāj bibliotēka vienkārši ignorē kautkādus stilus. Pietiekoši esu noņēmies uz MCU, kur GUI ir SVG un tiek renderēti ar minimālām SVG bibliotēkām. Tad jo vienkāršāk, jo labāk. Link to comment Share on other sites More sharing options...
Jurkins Posted January 6 Author Share Posted January 6 Es pirms tam par svg vispār zināju tikai to, ka ir tāds grafiskais formāts tam pašam inkscape. Un tad tupa sāku skatīties, kas lācim vēderā ar notepadu. Rinda xml:space=preserved atradās uzreiz, bet nekādi nesanāca iekš pytona šo ierakstīt tā, lai nelamātos. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now