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 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
* Use default arguments when undefined arguments are passed.
* Throw TypeError on first invalid argument
* Accept a number 'encoderOptions' as the quality
* Fall through to image/png if an unsupported encoding is requested
* Return "data:," if the canvas has no pixels
* Lower-case the format before testing for support
Remove the undocumented 3rd argument of the emitters (bytes left in buffer).
Add a column to the browser tests that displays JPEGs.
Revise how buffers are allocated.
Added some argument testing/manipulation to match WebKit/Moz behaviors.
Additionally benchmarked:
* branching on `if (a == 0 || a == 255)`, as it is
* not branching (always doing the alpha calculation)
* Mozilla's implementation found here: https://dxr.mozilla.org/mozilla-central/source/dom/canvas/CanvasRenderingContext2D.cpp#5083
Mozilla's is insignificantly faster (p=0.17) :) so left it as-is.
Progressive jpegs have several very useful advantages over baseline
jpegs:
* Slightly smaller for the same quality (3-7%)
* Load much faster in most browsers.
This adds the `options.progressive` option to the
canvas.jpegCreateStream() function.