calling cairo_restore on the initial state makes all drawing operations
afterwards do nothing, which does not match browser behavior
also merges save+saveState, restore+restoreState functions
- Remove pug in favour of simple html file
- Stop sending code over the wire to eval on the server
- Remove jpeg view since it doesn't make sense to have it here
this should make it much less likely registering a font will fail:
1. paths to fonts with .., sym links, etc are resolved before passed to
the OS and freetype
2. when you register a font with identical metadata to one you have
already registered, its description will be adjusted accordingly (if you
call registerFont with name = 'a' then name = 'b', you will then need
to set ctx.font = 'b' to select it)
this commit also fixes some minor memory leaks
* so you can now specify ctx.font = 'custom1, arial'; etc and the later
fonts will be used for glyphs that aren't in the first ones
* i'm now calling them sys_desc and user_desc to distinguish the
description that matches the font on the system vs the description the
user passes to Canvas.registerFont
* cleaned up some style
* Canvas.registerFont is now implemented entirely in C++
* second arg is required and must have at least `family`.
the others default to 'normal' per w3 fonts specification
* when there is a family match for registered fonts, it
should be chosen even if weight/style are wrong. this is
also in the spec
* update example and documentation
* registerFont is now implemented as a static member function of the
Canvas class itself. there is a static list of fonts registered
on the class, which are picked up by setting the font when necessary.
* register_font will fill in its second arg with a PangoFontDescription
that should resolve to the file specified
* to do that, freetype is now required again
this has the benefit of really simplifying the code, since we can use
pango_font_description_copy and remove the need for a couple helpers.
there is also no more need for setFontFromState since doing that becomes
a one-liner
the behavior of ctx.font should be unchanged, I tested the default font
as well as save and restore, of course
issue was limited to osx and windows
before this, if you create a canvas and get its context, the fonts would
freeze - you cannot add any fonts after getContext is called once, even
if you set up a new canvas. i fixed this by refreshing the Pango FontMap
(the component that does font lookups)
after you create a canvas+context, that canvas+context will not be able
to use new fonts, but that is less of a problem
this is implemented differently depending on the operating system. for
MacOS, CTFontManagerRegisterFontsForURL is the call to add a temporary
font. for Linux we use FontConfig, and for Windows use
AddFontResourceEx. all have been tested successfully
updated README and examples/font.js
* this commit gets rid of the HAVE_PANGO pragma and HAVE_FREETYPE,
preferring the Pango sections of HAVE_PANGO. using Cairo methods for
fonts is discouraged (http://cairographics.org/FAQ/#using_pango),
and freetype was only ever needed for cairo font rendering, so that
code was running in the Pango build for no reason at all.
* it also gets rid of context2d's `addFont`, which was never compatible
with the Pango build. `FontFace` is completely removed since it was
never used by the Pango build either, and instead of parsing the fonts
with FreeType we will instead prefer to let the OS do that in
succeeding commits
* the Windows build has been updated to work with Pango, which it did
not before
TL;DR - Pango is now required and and as of this commit custom fonts are
removed