question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SVG Font-family does not apply after convert to png(Splash screen)

See original GitHub issue

Description

Font ‘Poppins’ after conversion does not apply to the result PNG files: obj\Debug\net7.0-android\resizetizer\r\drawable (any folders)

I’m using the following SVG file:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="413.852" height="808.197" viewBox="0 0 413.852 808.197">
  <defs>
	<style>
		@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@800');
		.st0{fill:#223F3B;}
		.st1{fill:#5AC87A;}
	</style>
	  <pattern id="pattern" x="0" y="0" width="30" height="31" viewBox="0 0 30 31" patternUnits="userSpaceOnUse" >
		  <rect x="0" y="0" width="30" height="31" fill="#ffffff"/>
		  <path d="M-12.627,0H-21.6a1.07,1.07,0,0,0-1.062,1.075A1.071,1.071,0,0,0-21.6,2.152h7.908v7.975A1.069,1.069,0,0,0-12.627,11.2a1.068,1.068,0,0,0,1.061-1.076V1.075A1.068,1.068,0,0,0-12.627,0" transform="translate(24.996 9.291)" fill="rgba(82,190,41,0.1)"/>
	  </pattern>
  </defs>
	<rect x="0" y="0" width="413.852" height="808.197" opacity="0.999" fill="url(#pattern)"/>
  <g transform="translate(87.526 250) scale(1.5)">
	<g id="Text" transform="translate(77.589 0)">
		<text y="70" font-family="Poppins" font-size="15" fill="#404D3A" text-anchor="middle">Test message with font</text>
		<text y="90" font-size="15" fill="#404D3A" text-anchor="middle">Test message without font</text>
	</g>
  </g>
</svg>

Steps to Reproduce

  1. Create a MAUI App solution
  2. Paste the following svg to existing splash.svg
  3. Change in proj file: <MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128"/> to <MauiSplashScreen Include="Resources\Splash\splash.svg"/>
  4. Clean bin and obj folders if build project previously
  5. Run on the Android 10 where full screen splash supported or see result png in folder: \obj\Debug\net7.0-android\resizetizer\r\drawable-xxxhdpi
  6. The result png and opened svg are not the same, font-family does not apply

Please note

  1. the same issue for iOS font do not apply after publish to test flight
  2. the same when I use @font-face { font-family: ‘PoppinsBoldBase64’; src: url('data:font/truetype;base64,AAEAA… and font-family=“PoppinsBoldBase64”

Link to public reproduction project repository

https://github.com/denhaandrei/BadSvgConverter.App

Version with bug

7.0.49

Last version that worked well

NOT work

Affected platforms

iOS, Android

Affected platform versions

I think all Android/IOS, because issue with convert svg

Did you find any workaround?

No response

Relevant log output

No response

Issue Analytics

  • State:open
  • Created 2 months ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
moljaccommented, Jul 28, 2023

This is not directly maui issue. namely managed libraries used by resizetizer have issues converting some (complex) SVG images to PNG.

Workaround would be to convert SVG to PNG using reliable converters.

  • original

    ! OK - github does not render font correctly splash.svg splash

  • resizetizer

    ! OK - font resizetizer-splash.png resizetizer-splash

  • Chrome browser - screenshot MacOSX

    OK chrome-browser-splash

  • inkscape

    ! OK - font inkscape-splash

Online Converters

I work on collecting reported issues in MAUI repo, so I can open issues on GitHub in relevant repositories.

0reactions
moljaccommented, Aug 14, 2023

I understand that the issue is not dotnet/maui, but MAUI uses some packages to convert .svg automatically.

I understand you completely. There are expectations which are not fulfilled.

My suggestion is: please open issue in Svg.Net repo too (with svg that has issue and expected png output).

Thanks for your help. Wait and check it after the update packages.

You re welcome. This is the reason we are here.

Unfortunately, we can`t use the converter on the splash screen, because the application can have different resolutions on different devices. So we continue to use .svg without font applying.

I understand. This must be fixed. Only the problem is where and how fast. Rewriting everything could cause more issues.

Please note, only “Chrome browser - screenshot MacOSX”(windows the same) is expected.

Thanks for the info. It was quite confusing when I saw several online converters having issues (similar incorrect output)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Font style of text in svg not propagating to png on download
I am generating an svg, with text, using D3.js for a user to download. Unfortunately, when an svg is downloaded, the font family...
Read more >
Using Custom Fonts With SVG in an Image Tag
When we produce a PNG image, we use an <img> tag or a CSS background, and that's about it. It is dead simple...
Read more >
png to .svg issue
Solved: When I try to convert a .png logo to a .svg with a transparent background, the logo looks black. It's in RGB...
Read more >
Preserving font type in illustrator SVG file
The reason why the font does not render correctly to the actual font type is because, when the SVG is saved using the...
Read more >
Why svg image font changes - General
Hi, I have created an svg images and imported into webflow. When viewing the published state ... It is an image not an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found