Commit graph

3604 commits

Author SHA1 Message Date
Behdad Esfahbod
86e57671dd [check-*.sh] Redirect error reports to stderr 2008-09-26 11:08:22 -04:00
Behdad Esfahbod
096f9def0f Add slim markers to make check-plt.sh happy 2008-09-26 11:07:10 -04:00
Behdad Esfahbod
9662be8ee7 [twin-font] Adjust ascent/descent
The font data uses a 64 int high font space with baseline at 50.
2008-09-26 10:04:36 -04:00
Behdad Esfahbod
3883a371f2 [scaled-font] Use full ctm matrix when comparing scaled-font keys
We use the full matrix in hash computation, but only compare the
non-translation items in equality check.  This is no bug though,
as we set the ctm translation components of a scaled font to zero
explicitly.  But the change makes the hash and equal functions
consistent, which is good.
2008-09-26 10:04:36 -04:00
Chris Wilson
681424cbaf [analysis] Merge two analysis status codes.
Since there is an implicit precedence in the ranking of the analysis
return codes, provide a function to centralize the logic within the
analysis surface and isolate the backends from the complexity.
2008-09-26 13:42:28 +01:00
Chris Wilson
06f0cc81d2 Add a macro to determine whether a status is a fatal error.
In a few places we need to check whether we have a fatal error or an
internal return code, so provide a utility macro to centralise the check.
2008-09-26 13:42:28 +01:00
Chris Wilson
ba18d57339 [pdf] Propagate status
Check and return a few forgotten error codes from static functions.
2008-09-26 13:42:28 +01:00
Adrian Johnson
907f550a1b Fix bitmap-font XFAIL
Images in PDF are scaled to a unit square. In PS we set the
ImageMatrix to do the same. When the image is painted we scale the
graphics state to paint the image at the right size. In the case of
Type 3 fonts consisting of bitmap images we want to paint the images
at their original size so we scale the graphics state by the image
width and height.

The bug was that we were scaling by the width/height in the glyph
metrics. For non rotated fonts this worked. However for rotated fonts
the width/height of the glyph images may be larger than the
width/height in the glyph metrics. This resulted in a Type 3 font
where the glyph images were scaled slightly smaller than they should
have been.
2008-09-26 20:26:55 +09:30
Behdad Esfahbod
f8542dc9dd [twin-font] Clean up font data by joining lines and closing paths
Two changes here:

  * Replace move_to;line_to;move_to;line_to sequences with
    move_to;line_to;line_to when feasible.

  * Close paths for round glyphs.

Both improve the stroke rendering of the joint.

The first change also saves 3 bytes per joint (33 such joints).
Which we have just left unused for now.  To reclaim them one need
to update the charset table.  Something for a lazy Sunday afternoon
scripting task.

In the saving department, we can save further by:

  - Getting rid of the left/ascent/descent values as we compute
    glyph bounding box automatically.  Then we can liberally use
    the right value to adjust glyph advance width.  Saves three
    bytes per glyph (there's 96 glyphs in the font).

  - First operation is always a move_to.  So we can remove the 'm'
    for that.  Ugly though.

And the charset has zeros for the first 32 entries.  Can get rid of
that too at the expense of handling it in the code...

In total, combining the above we can save some 500 bytes.  The font
currently takes about 3.7kb.
2008-09-25 19:25:11 -04:00
Behdad Esfahbod
d5a998387b Add an internal font face
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.
2008-09-25 19:25:11 -04:00
Carl Worth
1d896aa9d8 Actually remove cairo_has_show_text_glyphs
The release notes for 1.7.6 say that we had dropped this
function, but apparently we had only planned to do that
and didn't actually get around to it until now.

Thanks to the RELEASING insctructions which gave a diff
command that pointed out this problem.
2008-09-25 15:56:57 -07:00
Carl Worth
5d887ad5dc Remove all lcd_filter code.
We reverted the public API for setting lcd_filter font options
back in 1b42bc8033 , but we had left the implementation which
would examine fontconfig and Xft properties for the option, and
which would call into freetype for subpixel glyph rasterization.

However, I recently realized, (and the test suite had been trying
to tell me for a while), that this approach would cause a
regression for users who were previously using sub-pixel text,
but without sub-pixel rendering built directly into freetype.
That's not acceptable, so all the code is coming out for now.
2008-09-25 13:31:20 -07:00
Chris Wilson
31ff6c863f [pdf] Explicitly order the sequence of checks when analyzing masks
There is an implicit precedence when analyzing patterns for
compatibilty, in order of descending precedence:
  fatal error
  unsupported
  needs image fallback
  needs meta-surface analysis
  success.

So wehen we have two patterns, we need to check both analysis statuses
simulataneously, in order to correctly report the combined status.
2008-09-25 02:09:44 -07:00
Carl Worth
69635bc054 Fix the analysis of mask operations (fixing mask-transformed-similar test case)
The primary bug here was some missing braces. The code was conditionally
assigning to backend_status, but then unconditionally checking for the
value assigned. The result was the leaking of an internal status value
(CAIRO_INT_STATUS_ANALYZE_META_SURFACE) which finally resulted in
an incomplete PDF file in the mask-transformed-similar test case.

While fixing this, also avoid re-using the backend_status variable so
much so that the code is more readable.
2008-09-25 02:09:40 -07:00
Carl Worth
5599b08dfa Drop _cairo_analysis_surface prefix from some static functions
Since these functions are static we don't really need the full
name. And these two functions were both so long that they were
causing some serious line-wrap issues.
2008-09-25 01:42:03 -07:00
Carl Worth
261dd83b31 Eliminate paranoid check for PNG_INTERLACE_NONE.
Commit 20b1b33c0f added some "paranoid checks" to our png
loading code. One of these was checking that if png_get_IHDR
first reports an interlace value other than PNG_INTERLACE_NONE
that after we call png_set_interlace_handling then we do
get PNG_INTERLACE_NONE from the next call to png_get_IHDR.

However, libpng doesn't seem to actually have that behavior.
When testing cairo_image_surface_create_from_png with an
interlanced PNG file, (which the test suite happens not to
do---even now), the call to png_set_interlace_handling is
doing the trick, but the check for PNG_INTERLACE_NONE is
failing.

So, with the check in place, loading an interlaced PNG image
fails with CAIRO_STATUS_READ_ERROR. By simply removing
that check, an interlaced image loads just fine.
2008-09-24 21:55:53 -07:00
Behdad Esfahbod
e84ef3c54e [.gitignore] Remove Makefile.*.config
I renamed those generated files to Makefile.*.features but forgot to
update ignore lists.  Carl already added the new ones, but didn't
remove the old ones.
2008-09-24 20:00:30 -04:00
Carl Worth
9335ad313f Ignore generated files.
I know that I didn't create these Makefile.win32.features files,
so I assume that they are the result of Behdad's build magic and
that he just forgot to add them to .gitignore.
2008-09-24 16:20:35 -07:00
Chris Wilson
dfe9f7093f Revert "[pdf] Tweak the mask analysis to avoid an assertion failure."
This reverts commit c9ec82f3a8, which
notably caused regresions in the mask and clip-operator tests.

Obviously I'm not smart enough to fix bugs. Since the computer found the
assertion failure, I need to train the computer to fix the bugs as well.
2008-09-24 22:37:08 +01:00
Behdad Esfahbod
5a06ca852c [Makefile.win32] Also report installing cairo-version.h and cairo-features.h
Those two files needs special care and hence are not listed in
enabled_cairo_sources.
2008-09-24 17:23:28 -04:00
Behdad Esfahbod
a91101df31 [Makefile.sources] Remove mention of cairo-features-win32.h
That file is not generated anymore.  Instead, cairo-features.h is
generated from Makefile.win32 on the fly.
2008-09-24 17:23:28 -04:00
Behdad Esfahbod
2fb59b3ebd [Makefile.win32] Report which files to install
The win32 build system has no way to install anything, but it has
full knowledge of what needs to be installed (which headers).  So
we now report files to be installed at the end of the build.
2008-09-24 17:09:54 -04:00
Behdad Esfahbod
6eee90784e Enable CAIRO_HAS_UTF8_TO_UTF16 if PDF_OPERATORS is enabled
We are being cheap and don't define the cairo_utf8_to_utf16 function
if no one is using it.  Previously PS surface was not using it, but
after the pdf-operators merge, it was.

Before this commit, building with PS but without PDF failed.  Fixing.
2008-09-24 15:04:11 -04:00
Behdad Esfahbod
bb125689d3 Simplify preprocessor conditional syntax
We never do #ifdef-type conditions on CAIRO_HAS_* macros, because we
want to allow setting them to zero.  Then if we need to enable a feature
if either of PS or PDF is enabled, the proper syntax is:

	#if CAIRO_HAS_PS_SURFACE || CAIRO_HAS_PDF_SURFACE

This works because the preprocessor replaces any unknown identifiers with
zero.  Some versions of gcc had a bug that got them very confused with
complex versions of the above.  As a workaround for that I have been using
the uglier version:

	#if CAIRO_HAS_PS_SURFACE+0 || CAIRO_HAS_PDF_SURFACE+0

which magically worked around that bug.  Or more recently replacing that
with the duplicated version:

	#if CAIRO_HAS_PS_SURFACE
	...
	#endif
	#if CAIRO_HAS_PDF_SURFACE
	...
	#endif

Both are uglier than the original.  Since the gcc bug was very short lived
and there's lots of software out there relying on the original form to work,
moving back to the simple version seems harmless.
2008-09-24 15:04:11 -04:00
Chris Wilson
444d44acde [stroke] Cap trailing segment when skipping invisible segments.
If we do not maintain the current_face even for invisible dashed segments,
then we will generate spurious line segments when attempting to close the
path (ala leaky-dashed-rectangle).

This fixes the long standing regression introduced just prior to 1.6 and
captured in these bug reports:
http://lists.cairographics.org/archives/cairo/2008-April/013912.html
http://bugs.freedesktop.org/show_bug.cgi?id=17177
2008-09-24 18:41:24 +01:00
M Joonas Pihlaja
b5b1134c2c [tessellator] Skip edges that lie outside the region of interest.
We don't need to tessellate edges strictly above or below the
the limits of the traps.
2008-09-24 17:54:53 +01:00
M Joonas Pihlaja
018a64bf7f [traps] Impose limits on traps for cairo_in_(fill|stroke)
We don't need to tessellate edges strictly above or below the
hit-test point.

(Patch split and modified by Chris Wilson to apply to cairo_in_stroke()
as well - all bugs are his alone.)
2008-09-24 17:54:50 +01:00
Chris Wilson
8c0ff8b585 [cairo] Define min-tolerance in terms of cairo_fixed_t
By using the cairo_fixed_t macros we can compute the correct minimum
tolerance for any configuration.
2008-09-24 17:05:08 +01:00
Chris Wilson
c9ec82f3a8 [pdf] Tweak the mask analysis to avoid an assertion failure.
Both the source and mask need to be analyzed and checked for an
UNSUPPORTED operation before determining the best course of action.
As before this is simply decided based on the requirements of the
source.
2008-09-24 15:05:23 +01:00
Chris Wilson
b9c92842d9 [trap] Trivial reject if trapezoid is entirely above or below
Also check whether is vertically within limits.
2008-09-24 11:45:51 +01:00
Chris Wilson
911d5f1a25 [traps] Adjust lines if either point is on the boundary.
If either point lies on the limit and the other outside, adjust the line
to be parallel to the boundary. This adjusts the previous test where both
points needed to be entirely outside.
2008-09-24 11:45:40 +01:00
Chris Wilson
7357e80054 [clip] Limit traps.
Apply prior knowledge to limit the traps during clipping to avoid
generating extra work.
2008-09-24 11:45:26 +01:00
Chris Wilson
c36a242303 [traps] Replace open-coding of box->rectangle->box
Use the utility functions _cairo_box_from_rectangle and
_cairo_box_round_to_rectangle() instead of open-coding. Simultaneously
tweak the whitespace so that all users of traps look similar.
2008-09-24 11:45:13 +01:00
Chris Wilson
651c6598c9 [traps] Limit extents to imposed constraints.
When reporting the extents of the traps, constrain them to the imposed
limits. This is relied upon in the analysis-surface which sets the
limits on the traps (based on clip/surface extents) and then reports the
extents of the traps as the region of the operation.
2008-09-24 01:02:48 +01:00
Behdad Esfahbod
0baf12f450 [scaled-font] Another typo fix in the comments
Both this and previous one kindly pointed out by Carl.
2008-09-23 19:18:00 -04:00
Behdad Esfahbod
70207aadfd [mutex] Fix typo in comments 2008-09-23 19:11:31 -04:00
Chris Wilson
0a4a6213e2 [fill] Check for the most common rectilinear case first.
Avoid the iterative search for the extreme points by first checking the
most likely arrangement (as produced by cairo_rectangle() under no
transformation).
2008-09-23 23:55:38 +01:00
Chris Wilson
8f51ea4657 [pattern] Beware unsigned wrap-around with pathological surface patterns.
A surface pattern under an extreme transformation could lie entirely in
the negative quadrant. This would trigger the fixup such that it's lower
left corner was clamped to the origin, but the upper right corner was left
unchecked. This could result in the width,height being negative and
wrapping around to large values instead of being clamped to 0.
2008-09-23 23:35:53 +01:00
Chris Wilson
5e54084126 [test-meta] Use real meta-surface snapshot.
The meta-surface workaround an old bug, which is no longer present in the
tree and open-coded the surface snapshot. However, the workaround itself
was buggy (not respecting the surface content). The lesson to take away
from this is not to add workarounds in test code for bugs in the library!
2008-09-23 23:35:53 +01:00
Chris Wilson
ae0511fbbe [pdf] Do not modify the dashes in-place.
As PS has different semantics regarding a zero-length dash, we need to
adjust the dash array before emitting. However, we need to modify a copy
of the dash array since the same array may be used by the meta-surface
when replaying to an image fallback.
2008-09-23 20:08:38 +01:00
Chris Wilson
b7ab1fc791 Return the real error status for set_user_data()
Instead of returning a new NO_MEMORY error, return the status from the
error object.
2008-09-23 20:08:30 +01:00
Adrian Johnson
0204d2f4e2 Replace two boolean args with one enum arg
The use of multiple booleans in a function call can make it easy to
mix up the parameters.
2008-09-23 22:38:55 +09:30
Behdad Esfahbod
afb32c7f07 [src/Makefile.am.analysis] Fix out-of-tree build 2008-09-23 03:58:17 -04:00
Behdad Esfahbod
fba0211ed6 [Makefile.win32] Add makefile rules to generate cairo-features.h 2008-09-22 23:41:07 -04:00
Behdad Esfahbod
0bedbe78fe [Makefile.win32] Misc cleanup 2008-09-22 22:46:05 -04:00
Behdad Esfahbod
ebb5eb57b7 Generate build/Makefile.win32.features 2008-09-22 22:24:38 -04:00
Behdad Esfahbod
0ac7a242f8 [build] Add Makefile.win32.common 2008-09-22 20:11:38 -04:00
Behdad Esfahbod
23b9767bb3 Rename Makefile.*.config to Makefile.*.features as they should not be modified
The .config naming was giving people the impression that they can modify it.
That's not the case.
2008-09-22 17:34:36 -04:00
Kai-Uwe Behrmann
20be3182ef [svg] Counteract application of object matrix to mask.
The expected behaviour for masking in Cairo is to set the mask according
to the current active matrix and apply unchanged to the masked surface.

In SVG, the mask element is bound to the masked object and thus the local
matrix from that image object applies to the nested mask as well.

Attached is a small patch for substracting the matrix of a image
surface from the matrix of the mask to comply to Cairo's behaviour.
I did not test for other stuff like vectors or text and would expect this
part is incomplete.
2008-09-22 12:01:11 +01:00
Behdad Esfahbod
3a45ff0e2f Make checks happy again
Minor syntax changes and improved check regexps.
2008-09-20 18:35:10 -04:00