How to display SVG Templates in SwiftUI - swift

I am trying to display an SVG Template in my SwiftUI app.
So, I have a var svgTemplate: String variable in my SwiftUI App that contains an SVG Template string, an example is displayed below
"<svg width=\"1024\" height=\"440\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:
<!-- more data -->
xml:space=\"preserve\" text-anchor=\"start\" font-family=\"
Helvetica, Arial, sans-serif\" font-size=\"24\" id=\"svg_1\" y=\"151.52317\"
x=\"93.43789\" stroke-width=\"0\" fill=\"#000000\">This is sample svg template
</text>\n </g>\n</svg>"
Now, I want to render this SVG Template in my SwiftUI app, but I cannot figure out a way to do so.
I tried to convert my svgTemplate to a base64StringImage so that I can display a base64StringImage by extending the Image View, but I cannot find a way to convert my svgTemplate to a base64StringImage.
The other way I tried was just to display the svgTemplate but that was unsuccessful as well.
Any kind of solution would be helpful.
Thank you in advance! :)

Related

How to add an image to a pdf using Capacitor pdf-generator plugin

I’m using capacitor pdf-generator plugin to create a pdf. I managed to do so as long as the html code is limited to non image tag, code in which I inject some dynamic data by nesting variable using ${ }.
Now, my aim is to bind the src attribute of an ```img`` tag to a variable so that I can change the logo displayed in the created PDF.
Where I fail: what appears on the PDF is a white space with dashed borders (check picture attached). So I guess that the path must be correct because if not it would show the missing icon (issue I went through before I could format correctly the path).
Anyone who already had that trouble?
Finally bypassed this issue by storing the base64 data when selecting a logo and using it directly in the img tag.
<img src="data:image/png;base64,${base64data} " />
You can convert the images to base64 here https://www.base64-image.de/
then add the codes directly to your image tag

custom svg not displaying properly in fluttericon

I am trying to create custom icons (so svgs) in Adobe Illustrator for flutter so I am trying to load svg files into fluttericon. However, once I upload the svg file to fluttericon it only shows an outline and the actual symbol is not showing.
In Illustrator, I tried to Saves as SVG, Export as SVG and Exports for Screens -> SVG but none of them seem to work.
Am I missing something? If I upload another svg I got online it works perfectly fine.
I figured it out: In Illustrator, you need to turn the shapes into a compound path first and then export as svg (Object -> Compound path -> make). That way it shows up fine in fluttericon.
fluttericon has a good explanation for that as well: https://github.com/fontello/fontello/wiki/How-to-use-custom-images#importing-svg-images

Icons in Leaflet tooltips

Trying to add an icon to Leaflet tooltip, but unsuccessfully - does anyone have an example?
For example, adding
layer.bindTooltip(msg+"<i class=\"fas fa-headphones\"></i>")
doesn't work
Thanks
The string you add to a tooltip can be a html string:
layer.bindTooltip("<div><span style='display:block'><strong>Custom Html with an Icon<strong></span><img src='https://pbs.twimg.com/profile_images/780792637481689088/8y-GChEY.jpg' width='30' /></div>");
But I think your problem is that your Font-Awesome style is not working. Have you added the library to your project?

Ionic React: How to integrate custom fonts and icon set

I’m new with Ionic React and I’m looking for the correct way to integrate custom fonts and a custom icon set into my project, so that it’s working on all platforms as intended.
Custom Icon set
My goal is to make my custom icons work with IonIcon so that I can use the default styling options like “size” and the CSS variables (e…g --ioinc-stroke-weight).
What I did so far:
I added the icon set (all icons are svgs) into “public/assets/customicons/”
I imported IonIcon into my components where needed
Integrated the (e.g. )
So far the icons are displayed as intended and custom attributes “size” is working.
But, I’m not able to set the icon color or stroke-width programmatically. All the icons have set a default attributes (e.g. < g fill=“none” fill-rule=“evenodd” stroke="#092A5E" stroke-linecap=“round” stroke-linejoin=“round” stroke-width=“8” >). Even if I remove those default attributes, I’m not able to set them via CSS variables
Question 1: Is “public/assets/customicons/” the correct folder to store the icons?
Question 2: How can I make it work that I can change the color of the icon via CSS?
Custom Font
Goal: I want that the custom font is shown on all platforms
What I did so far:
Added the custom fonts in “src/assets/fonts/”
Created a “fonts.css” in “src/theme/” where I integrated the font via “#font-face”
#font-face {
font-family: ‘FONTNAME’;
src: url(’…/assets/fonts/FONTNAME.ttf’);
font-style: normal;
font-weight: 400;
font-display: swap;
}
assigned the font to differnet elements
Question 1: Is this the correct folder to store the custom fonts? (I wasn’t able to do the same when the custom font was saved under “public/assets/fonts/” like the icon set)
Unfortunately, I wasn’t able to find any docs, tutorials or posts on any of these topics.
Thanks for your help!

Is window copyable in Flutter

I need copy data of window and add to clipboard. I searched and I found nothing.
I reiceved data from rest api with html tags and I use html view for render the html tag. that's why I can't selectable text.
How to copy data of window or body of stateful widget? Any idea?
If you want to copy text from your app, you can use the SelectableText widget. There was recently a Widget of the Week video on it here:
https://www.youtube.com/watch?v=ZSU3ZXOs6hc&vl=en
There isn't a way to copy images or other data except for text, as far as I know.
You can use the following package to capture a screenshot.
Add the following to install
dependencies:
screenshot: ^0.1.1
Then import it
import 'package:screenshot/screenshot.dart';
Example can be found here Screenshot Example
References
screenshot package