| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
| |
This implements Type 3 color fonts for PDF for any font with a
CAIRO_SCALED_GLYPH_INFO_RECORDING_SURFACE. This includes user-fonts,
SVG fonts, and COLR fonts.
Glyphs with foreground colors are not yet implemented as Type 3 glyphs
and will be rendered as images by cairo-surface.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
The previous approach using foreground colors in user fonts does not
work for gradients since the foreground color is not available at the
time of recording.
Add a new function cairo_user_scaled_font_get_foreground_source() that
can be called by the color render function to retrieve the foreground
pattern. Calling this function signals to cairo that the foreground
color is used. In this case cairo will call the render function
whenever the foreground color has changed.
|
| |
|
| |
|
|
|
|
|
|
| |
and split _cairo_user_scaled_glyph_init() into multiple functions.
Update user-font test to test changing foreground text color.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
See:
https://github.com/harfbuzz/harfbuzz/pull/3411#issuecomment-1033118545
https://github.com/harfbuzz/harfbuzz/pull/3411#issuecomment-1033125311
https://github.com/harfbuzz/harfbuzz/pull/3411#issuecomment-1037765840
Basically the code in cairo-image-compositor.c:composite_glyphs()
is flooring glyph positions and putting some phase in the glyph-id.
This was being lost in the user-font backend. Fetch that and put it
in the recording-surface's device-transform translation, to be applied.
|
| |
|
| |
|
|
|
|
|
| |
We were leaking a cairo_t and a surface here, in
some code paths.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
COLR fonts can have a layer with the same color as the current text
color. This change passes the current color (if solid) through to
the font backend where it can be used to render color fonts.
scaled_glyph_lookup checks if the foreground color has changed (for
glyph that require it) and requests a new color surface if required.
This also fixes a bug where scaled_glyph_lookup would always request a
color surface for glyphs for glyphs in color fonts that do not have
color.
|
| |
|
| |
|
|
|
|
|
| |
Adds new API cairo_user_font_face_set_render_color_glyph_func()
to set a color glyph renderer.
|
|
|
|
|
|
|
|
|
|
| |
_cairo_malloc(0) always returns NULL, but has not been used
consistently. This patch replaces many calls to malloc() with
_cairo_malloc().
Fixes: fdo# 101547
CVE: CVE-2017-9814 Heap buffer overflow at cairo-truetype-subset.c:1299
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In order to close a race between locking the backend and resurrecting a
font via the cache, we need to keep the font face alive until after we
take the backend lock. Once we have that lock, we can drop our reference
and test if that was the last. Otherwise we must abort the destroy().
This fixes the double-free exposed by multithreaded applications trying
to create and destroy the same font concurrently.
Reported-by: Weeble <clockworksaint@gmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=69470
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
|
|
|
|
|
| |
Make the 'Since' and 'Returns' tags consistent by removing the '@'
prefix.
Fixes some "missing 'Since' field" warnings.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Documentation comments should always start with "/**" and end with
"**/". This is not required by gtk-doc, but it makes the
documentations formatting more consistent and simplifies the checking
of documentation comments.
The following Python script tries to enforce this.
from sys import argv
from sre import search
for filename in argv[1:]:
in_doc = False
lines = open(filename, "r").read().split("\n")
for i in range(len(lines)):
ls = lines[i].strip()
if ls == "/**":
in_doc = True
elif in_doc and ls == "*/":
lines[i] = " **/"
if ls.endswith("*/"):
in_doc = False
out = open(filename, "w")
out.write("\n".join(lines))
out.close()
This fixes most 'documentation comment not closed with **/' warnings
by check-doc-syntax.awk.
|
|
|
|
|
|
|
|
|
|
|
| |
The existing API only described the method to be used for performing
rasterisation and unlike other API provided no opportunity for the user
to give a hint as to how to trade off performance against speed. So in
order to no be overly prescriptive, we extend the NONE/GRAY/SUBPIXEL
methods with FAST/GOOD/BEST hints and leave the backend to decide how
best to achieve those goals.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
|
|
|
|
|
| |
Step 1, fix the failings sighted recently by tracking clip-boxes as an
explicit property of the clipping and of composition.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
|
|
|
|
| |
I did this manually so I could review the docs at the same time.
If anyone finds typos or other mistakes I did, please complain to me (or
better: fix them).
|
| |
|
|
|
|
|
|
|
|
| |
Text with size 0 has a singular scale matrix, thus requires special
handling to avoid invalidating the context where it is used.
Fixes pthread-show-text and text-zero-len (they failed with assertion
when ran using the user font backend).
|
|
|
|
|
|
|
|
| |
Currently the translation component of the scaled_font scale matrix
is applied by gstate and only linear components should be applied in
font backends.
Fixes font-matrix-translation (when using user-font as font backend).
|
|
|
|
|
|
|
|
|
|
|
| |
I updated the Free Software Foundation address using the following script.
for i in $(git grep Temple | cut -d: -f1 )
do
sed -e 's/59 Temple Place[, -]* Suite 330, Boston, MA *02111-1307[, ]* USA/51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA/' -i "$i"
done
Fixes http://bugs.freedesktop.org/show_bug.cgi?id=21356
|
|
|
|
|
| |
A pending commit will want to include some utility code from cairo and
so we need to extricate the error handling from the PLT symbol hiding.
|
|
|
|
|
|
|
| |
The new name is more descriptive than the rather opaque meta surface.
Discussed with vigour on the mailing list and #cairo:
http://lists.cairographics.org/archives/cairo/2009-July/017571.html
|
|
|
|
|
|
|
| |
Replaying a meta surface can be achieved by using it as a source for a
cairo_paint() so exporting a separate API is unnecesary and confusing.
So after consulting Chris and Carl, we decided to remove the function
again.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Handling clip as part of the surface state, as opposed to being part of
the operation state, is cumbersome and a hindrance to providing true proxy
surface support. For example, the clip must be copied from the surface
onto the fallback image, but this was forgotten causing undue hassle in
each backend. Another example is the contortion the meta surface
endures to ensure the clip is correctly recorded. By contrast passing the
clip along with the operation is quite simple and enables us to write
generic handlers for providing surface wrappers. (And in the future, we
should be able to write more esoteric wrappers, e.g. automatic 2x FSAA,
trivially.)
In brief, instead of the surface automatically applying the clip before
calling the backend, the backend can call into a generic helper to apply
clipping. For raster surfaces, clip regions are handled automatically as
part of the composite interface. For vector surfaces, a clip helper is
introduced to replay and callback into an intersect_clip_path() function
as necessary.
Whilst this is not primarily a performance related change (the change
should just move the computation of the clip from the moment it is applied
by the user to the moment it is required by the backend), it is important
to track any potential regression:
ppc:
Speedups
========
image-rgba evolution-20090607-0 1026085.22 0.18% -> 672972.07 0.77%: 1.52x speedup
▌
image-rgba evolution-20090618-0 680579.98 0.12% -> 573237.66 0.16%: 1.19x speedup
▎
image-rgba swfdec-fill-rate-4xaa-0 460296.92 0.36% -> 407464.63 0.42%: 1.13x speedup
▏
image-rgba swfdec-fill-rate-2xaa-0 128431.95 0.47% -> 115051.86 0.42%: 1.12x speedup
▏
Slowdowns
=========
image-rgba firefox-periodic-table-0 56837.61 0.78% -> 66055.17 3.20%: 1.09x slowdown
▏
|
|
|
|
|
|
|
|
|
|
| |
The meta-surface is a vital tool to record a trace of drawing commands
in-memory. As such it is used throughout cairo.
The value of such a surface is immediately obvious and should be
applicable for many applications. The first such case is by
cairo-test-trace which wants to record the entire graph of drawing commands
that affect a surface in the event of a failure.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
An issue occured when using subpixel antialiasing with user-fonts and
XRender - the glyphs were transparent, as demonstrated by the font-view
example.
The problem lies in that enabling subpixel antialiasing triggers use of an
ARGB32 image surface for rendering the glyph, but the default colour is
black (so the only information is in the alpha-channel). Given an ARGB32
glyph XRender treats it as a per-channel mask, but since the R,G,B
channels were uniformly zero, the glyph is rendered as transparent.
Fix this by setting the initial colour to white before rendering the image
surface for a user-font glyph, which generates the appropiate gray-level
mask by default.
|
|
|
|
|
| |
This is useful for language bindings to signal that a method is not
implemented.
|
|
|
|
| |
Just parse them now. We don't use them yet.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit moves the toy-to-real mapping from the scaled font creation
time to font face creation. A toy font face will keep an internal ref
to an implementation face. Then cairo_scaled_font_create() will simply
substitute the implementation face before creating anything.
This also modifies the cairo-ft toy creation in that we now create a
non-resolved pattern and store it in a cairo-ft font-face. We then
do the resolving and unscaled font creation at scaled-font creation
time. This also means that cairo_ft_font_face_create_for_pattern()
now accepts non-resolved patterns too, and does the right thing about
them. As much as that can be called right.
Some testing of toy font creation performance is in order, as is testing
win32 and quartz font backends.
|
|
|
|
|
| |
Use the gcc likelihood annotation to indicate that allocation failures are
extremely unlikely.
|
|
|
|
|
| |
The error paths should be hit very rarely during normal operation, so mark
them as being unlikely so gcc may emit better code.
|
|
|
|
| |
Cleanup a minor -Wshadow warning.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Quartz fonts and user fonts use an indirect font face when creating a
scaled font for the toy font face. This means that they insert a scaled
font into the font map that has a different font face to the one that is
initially searched upon. The result is that when we try to create an
identical scaled font, we fail to find the existing scaled font and
attempt to insert a duplicate into the hash table - which triggers an
assert.
In order to avoid creating duplicate fonts, we add a new method to the
font backends that allows cairo_scaled_font_create() to peek at the
font_face that will be used to actually implement the scaled font
constructor - thus we are able to use the correct font_face as part of the
hash key.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
After discussing the scaled font locking with Behdad, it transpired that it
is not sufficient for a font to be locked for the lifetime of a scaled glyph,
but that the scaled font's glyph cache must be frozen for the glyph'
lifetime. If the cache is not frozen, then there is a possibility that the
glyph may be evicted before the reference goes out of scope i.e. the glyph
becomes invalid whilst we are trying to use it.
Since the freezing of the cache is the stronger barrier, we remove the
locking/unlocking of the mutex from the backends and instead move the
mutex acquisition into the freeze/thaw routines. Then update the rule on
acquiring glyphs to enforce that the cache is frozen and review the usage
of freeze/thaw by all the backends to ensure that the cache is frozen for
the lifetime of the glyph.
|
|
|
|
|
|
|
|
| |
Simplify the error handling by only relinquishing the global
scaled_font_map mutex if we successfully insert the placeholder font. The
result is that on the error path, there are no changes to global state and
thus we can entirely skip the user-font initialisation and
re-registration.
|
|
|
|
|
| |
Check that the user has not passed in an inert error object before any
attempts to write to it and return the default values.
|
| |
|
|
|
|
| |
The most complex public cairo API deserves more doc love...
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The font data and rendering is adapted from Keith Packard's Twin
window system. The hinting stuff is not ported yet, but hey, it renders!
The implementation uses user fonts, and the user font backend is modified
to use this font face (which we call "twin" font face internally) when
a toy font is needed.
The font face layer is then modified to use this font if:
- The toy font face "cairo" is asked for, or
- No native font backend is available, or
- The preferred native font backend fails to return a font with
STATUS_UNSUPPORTED. No font backend does this right now but
the idea is to change FreeType to return it if no fonts found
on the system.
We also allow building with no font backends now!
The new doc/tutorial/src/twin.c file tests the twin face at various
sizes.
|
|
|
|
|
|
|
|
|
|
| |
Chris rightfully complained that having a boolean function argument is
new in cairo_show_text_glyphs, and indeed avoiding them has been one
of the API design criteria for cairo. Trying to come up with alternatives,
Owen suggested using a flag type which nicely solves the problem AND
future-proofs such a complex API.
Please welcome _flags_t APIs to cairo.h
|
|
|
|
|
|
| |
An error return possible went unpropagated - fix that. Also whilst in the
vicinity avoid the non-constant initialisation of the local variable
before the antiquated compilers moan.
|
|
|
|
| |
_cairo_matrix_compute_basis_scale_factors
|
|
|
|
|
|
|
|
| |
And update user-font text_to_glyphs() method to match.
Currently disable the win32-font text_to_glyphs(), until that one
is updated. Or better yet, remove it and implement ucs4_to_index().
It's the toy font API afterall.
|