GenerallyHelpfulSoftware / SVGgh

A framework for using SVG artwork in iOS Apps. Includes a UIView and a button class, printing and PDF export.
MIT License
141 stars 38 forks source link

SVGRenderer is not rendering "HelveticaNeue-Bold" Font correctly in iOS 10 , though same code is working iOS 9, Please help. #34

Closed maheshm255 closed 7 years ago

maheshm255 commented 7 years ago

This is text I am sending to SVG Renderer class

<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewport-fill=\"white\" width=\"612.0\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" height=\"212.0\" viewBox=\"0.0 0.0 612.0 212.0\">\n\n<text font-family=\"HelveticaNeue-Bold\" x=\"3.0\" font-size=\"18.0\" y=\"24.456\" text-anchor=\"start\" font-weight=\"600\">\nTitle for Graph\n<path d=\"M306.0 74.031L306.0 38.688A78.54 78.54 0 0 1 309.679916473083 38.7742568467818 L308.023954060196 74.07844126573 A 43.197 43.197 0 0 0 306.0 74.031 Z\" fill=\"#1ec388\"/>\n<path d=\"M308.023954060196 74.07844126573L309.679916473083 38.7742568467818A78.54 78.54 0 0 1 314.767039047215 39.1788448069769 L310.821871475968 74.3009646438373 A 43.197 43.197 0 0 0 308.023954060196 74.07844126573 Z\" fill=\"#e7411a\"/>\n<path d=\"M310.821871475968 74.3009646438373L314.767039047215 39.1788448069769A78.54 78.54 0 0 1 337.061727267813 45.0913193226915 L323.083949997297 77.5528256274803 A 43.197 43.197 0 0 0 310.821871475968 74.3009646438373 Z\" fill=\"#ffc633\"/>\n<path d=\"M323.083949997297 77.5528256274803L337.061727267813 45.0913193226915A78.54 78.54 0 1 1 306.0 38.688 L306.0 74.031 A 43.197 43.197 0 1 0 323.083949997297 77.5528256274803 Z\" fill=\"#8b3198\"/>\n<path fill=\"none\" d=\"M 307.426359313201 56.3762145589824 L 308.208556355924 23.0058806074566 h 76.2086961834488\" stroke=\"#CCC\"/>\n<text font-family=\"HelveticaNeue\" x=\"384.417252539373\" font-size=\"24.0\" y=\"23.0058806074566\" text-anchor=\"start\" font-weight=\"400\">\n0.7%\n<text font-family=\"HelveticaNeue\" x=\"384.417252539373\" font-size=\"12.0\" y=\"36.9858806074566\" text-anchor=\"start\" font-weight=\"normal\">\nNEW PRODUCT \n<text font-family=\"HelveticaNeue\" x=\"384.417252539373\" font-size=\"12.0\" y=\"50.9658806074566\" text-anchor=\"start\" font-weight=\"normal\">\COSMETIC\n<path fill=\"none\" d=\"M 310.82574262111 56.5510974718979 L 313.472117606881 96.6618806074566 h 71.1249990648109\" stroke=\"#CCC\"/>\n<text font-family=\"HelveticaNeue\" x=\"400.247134621987\" font-size=\"24.0\" y=\"96.6618806074566\" text-anchor=\"start\" font-weight=\"400\">\n1.0%\n<text font-family=\"HelveticaNeue\" x=\"400.247134621987\" font-size=\"12.0\" y=\"110.641880607457\" text-anchor=\"start\" font-weight=\"normal\">\nNEW PRODUCT \n<text font-family=\"HelveticaNeue\" x=\"400.247134621987\" font-size=\"12.0\" y=\"124.621880607457\" text-anchor=\"start\" font-weight=\"normal\">\nRE-TREATMENT\n<path fill=\"none\" d=\"M 321.60277293972 58.3932503290654 L 330.15913229376 164.06 h -115.304363918898\" stroke=\"#CCC\"/>\n<text font-family=\"HelveticaNeue\" x=\"214.854768374862\" font-size=\"24.0\" y=\"164.06\" text-anchor=\"end\" font-weight=\"400\">\n4.7%\n<text font-family=\"HelveticaNeue\" x=\"214.854768374862\" font-size=\"12.0\" y=\"178.04\" text-anchor=\"end\" font-weight=\"normal\">\nOther\n<path fill=\"none\" d=\"M 293.71048530861 176.842948803971 L 286.971074026235 99.272 h -72.1163056513731\" stroke=\"#CCC\"/>\n<text font-family=\"HelveticaNeue\" x=\"214.854768374862\" font-size=\"24.0\" y=\"99.272\" text-anchor=\"end\" font-weight=\"400\">\n93.5%\n<text font-family=\"HelveticaNeue\" x=\"214.854768374862\" font-size=\"12.0\" y=\"113.252\" text-anchor=\"end\" font-weight=\"normal\">\nCOSMETIC ONLY\n\n

grhowes commented 7 years ago

I recently changed the code that makes font descriptors. Are you sure the exact same build renders differently?

maheshm255 commented 7 years ago

Yes , Please see below screenshot for reference.

ra-screenshot-ios9 ra-screenshot-ios10
grhowes commented 7 years ago

Have you updated to the current version? The one in the master branch? It seems like it works better than previous versions.

maheshm255 commented 7 years ago

Yes I have updated to current version still issue persist, I have attached the sample code , You can run this in iOS 9 and iOS 10 and can see the difference as I mentioned in above screen shot. Also I debugged the code and below are my observation which leads to this kind of behaviour.

In "SVGTextUtilities" class's below function returns "font description" which is different for iOS 10 and iOS 9 , below is screen shot for reference.

"+(CTFontDescriptorRef) newFontDescriptorFromAttributes:(NSDictionary*) SVGattributes baseDescriptor:(CTFontDescriptorRef)baseDescriptor"

SVGghGraphs.zip

ios9 ios10
grhowes commented 7 years ago

Well, this is odd. your screen shots indicate that for you the fonts resolved to the wrong fonts on both OS versions although obviously HelveticaLTMN (whatever that is) is better than emoji.

But on the project you sent me, after updating to SVGgh 1.9.1 cocoa pod, both OS versions pulled in the various flavors of Helvetica Neue. This was against the iOS 9.0 and 10.3 simulators and appear to render correctly (or close enough).

So, I don't know what could be different between your environment than mine. I'm running Xcode 8.3.2.

You could try simplifying the font descriptions by removing the font-weight properties from the SVG, but that would be shooting in the dark.

screen shot 2017-05-05 at 12 38 46 am

screen shot 2017-05-05 at 12 44 41 am

maheshm255 commented 7 years ago

Thanks! , updating the version to 1.9.1 resolved the issue.