Wiladams / svgandme

SVG Parser and rendering using blend2d for graphics
MIT License
6 stars 4 forks source link

OSX errors #17

Open stuta opened 2 days ago

stuta commented 2 days ago

File svg/svgattributes.h is missing #include <list>, fixes std::list. File svg/bithacks.h is missing #include <cctype>, fixes std::tolower. File svg/maths.h namespace waavs static INLINE needs to be converted to INLINE.

Some warnings:

svg/bspan.h:277:121: warning: non-void function does not return a value [-Wreturn-type]
  277 |  static __attribute__((always_inline)) inline ByteSpan& chunk_skip_to_end(ByteSpan& dc) noexcept { dc.fStart = dc.fEnd; }
      |                                                                                                                         ^
In file included from svg-and-me.cpp:10:
In file included from svg/svg.h:15:
svg/svgcss.h:411:21: warning: 6 enumeration values not handled in switch: 'CSS_SELECTOR_INVALID', 'CSS_SELECTOR_ATTRIBUTE', 'CSS_SELECTOR_PSEUDO_CLASS'... [-Wswitch]
  411 |             switch (sel->fKind)
      |                     ^~~~~~~~~~
svg/svgcss.h:411:21: note: add missing switch cases
  411 |             switch (sel->fKind)
      |                     ^
  412 |             {
  413 |             case CSSSelectorKind::CSS_SELECTOR_ID:
  414 |     addSelectorToMap(fIDSelectors, sel);
  415 |                 break;

When I run my program I get an error FontHandler::loadFont Error: c:\Windows\Fonts\arial.ttf (0x10017). Then I get lots of these errors:

== FontHandler::selectFontFamily, NOT FOUND: Arial
== FontHandler::selectFontFamily, NOT FOUND: Courier
Wiladams commented 1 day ago

I obviously need to run my compiler with a higher level of warnings, and compile on other platforms.

I have fixed the overzealous usage of 'static INLINE', and those other warnings.

I've removed 'loadDefaultFonts()' from FontHandler, as that is something that is totally platform specific, and should be done at the application level (see svgview sample).

stuta commented 1 day ago

Now other errors are gone, but in OSX there is Courier New font by default, and installing Courier.ttf does not help. Same problem with Arial, but I was able to install it. So can we give our default font names?

Wiladams commented 1 day ago

I'm not familiar with how fonts are associated in MacOS. I'm assuming you are putting .ttf files in some well known directory, and then loading them into svgandme/blend2d using loadFontDirectory(), or something equivalent.

It is within FontHandler that the font substitution occurs, and the default is selected if nothing else is found. I've almost managed to surface the API enough to change that default. It's just a string value, so I should be able to do it.

Even at that, you will need to ensure the font is loaded in, and then it can be selected.

It will likely be something: FontHandler::setDefaultSerif, setDefaultSans, setDefaultMono, setDefaultCursive

And you'll just pass in the name you want to be the default family.