Commit graph

8269 commits

Author SHA1 Message Date
Jeff Muizelaar
78ae474d96 Rename has_sub_path to has_initial_sub_path
has_initial_sub_path more accurately describes the condition we want to
track. This flag is used to indicate when an initial sub_path needs capping
but has no associated slope and thus no associated faces.
2007-02-19 16:06:56 -05:00
Jeff Muizelaar
9f3fb4f753 Add a comment about the point choice when capping degenerate paths 2007-02-19 16:06:56 -05:00
Jeff Smith
a1a4d6966e Modify how _cairo_stroker_add_caps handles zero-length sub-paths
For zero-length sub-paths, _cairo_stroker_add_caps sets up a dummy face,
then lets later parts of the function add the caps.
2007-02-19 16:06:56 -05:00
Jeff Smith
849a9ef81b Change type of cairo_stroker_t's dash_on from int to cairo_bool_t 2007-02-19 16:06:56 -05:00
Adrian Johnson
9927dde533 TrueType: fix bug #9998 - build error with gcc 2.95 2007-02-17 10:55:14 +10:30
Brian Ewins
9bae496a0a [ATSUI] implement load_truetype_table
Implements load truetype table, allowing selection of
text and searching in pdfs generated using the atsui
font backend.
2007-02-15 23:08:40 +00:00
Adrian Johnson
16e20568a5 TrueType: Add post table and 3,0 cmap encoding
Commit 05ff2c77da contained
a fix for the acroread printing problem. However this
patch caused a problem for the Mac Preview PDF viewer.

  http://lists.freedesktop.org/archives/cairo/2007-February/009615.html

This patch fixes the Mac Preview problem. The patch

- Adds a platform 3, encoding 0 cmap table
- Adds a post table that maps the glyph names in the
  PDF truetype font dictionary (/g0 /g1 /g2 ...)
  to glyph indices in the font.
2007-02-16 08:38:26 +10:30
Jorn Baayen
2715f20981 [cairo-pattern] Cache surface for solid patterns
We use a small cache of size 16 for surfaces created for solid patterns.
This mainly helps with the X backends where we don't have to create a
pattern for every operation, so we save a lot on X traffic.  Xft uses a
similar cache, so cairo's text rendering traffic with the xlib backend
now completely matches that of Xft.

The cache uses an static index variable, which itself acts like a cache of
size 1, remembering the most recently used solid pattern.  So repeated
lookups for the same pattern hit immediately.  If that fails, the cache is
searched linearly, and if that fails too, a new surface is created and a
random member of the cache is evicted.

Only surfaces that are "compatible" are used.  The definition of compatible
is backend specific.  For the xlib backend, it means that the two surfaces
are allocated on the same display.  Implementations for compatibility are
provided for all backends that it makes sense.
2007-02-14 18:28:56 -08:00
Carl Worth
9966551dc7 Fix cairo_ft_unscaled_font_t to have a lock_count again not an is_locked Boolean
This was inadvertently changed as part of fdffde8b9e

With the Boolean, pango-using programs that locked the same
unscaled_font multiple times would crash with a message such as:

 cairo-ft-font.c:569: _cairo_ft_unscaled_font_unlock_face: Assertion `unscaled->is_locked' failed.
2007-02-13 23:49:26 -08:00
Carl Worth
7adab2866b Add missing call to set_scale of unscaled_font in scaled_glyph init
This fixes a regression introduced with commit:

	25a370d799

This was showing up as a failure of the bitmap-font test case
with the ps, pdf, and svg backends.
2007-02-13 22:05:57 -08:00
Jinghua Luo
17b4496ae9 type1-subset: fix error handling.
This fixes potenial memory leak and leaving font face locked on error.
2007-02-14 11:52:11 +08:00
Dan Amelang
01a133167c Update Win32 makefiles
Since the last time these makefiles were last updated some new source
files have been added and one renamed. In addition, a "clean" rule
needed to be added to the pixman makefile. And the "clean" rule in the
main cairo makefile wasn't working properly for me.
2007-02-13 16:53:12 -08:00
Dan Amelang
f0a16b5bdd Fix Win32 text spacing problem
Thanks to Jordan Miner for reporting the problem and a fix.
2007-02-13 16:32:05 -08:00
Carl Worth
aad1374caa Rename cairo_toy_font_face_hash_table_mutex to cairo_font_face_mutex
The new name more accurately reflects its recently expanded role.
2007-02-13 10:59:51 -08:00
Carl Worth
e107b70b4d Add locking to cairo_font_face_reference/destroy
The reference count of cairo_font_face_t is rather intimately tied,
(for toy font faces), with the cairo_font_face_hash_table, so we
expand the existing cairo_toy_font_face_hash_table_mutex to cover
the manipulation of font_face->ref_count as well.

This commit eliminates an assertion failure that is (occasionally)
exposed by the pthread-show-text test case:

lt-pthread-show-text: cairo-hash.c:196: _cairo_hash_table_destroy: Assertion `hash_table->live_entries == 0' failed.
2007-02-13 10:58:20 -08:00
Carl Worth
fdffde8b9e Add mutex to implement _cairo_ft_unscaled_font_lock_face and _cairo_ft_unscaled_font_unlock_face
Previously we just had an integer counter here, but that is not
sufficient as multiple cairo_scaled_font_t objects, (which are
implicitly shared through the font caches), can reference the
same cairo_ft_unscaled_font_t so real locking is needed here.

This commit eliminates an assertion failure exposed by the
pthread-show-text test case:

lt-pthread-show-text: cairo-ft-font.c:562: _cairo_ft_unscaled_font_unlock_face: Assertion `unscaled->lock > 0' failed.
2007-02-13 10:46:52 -08:00
Carl Worth
25a370d799 Avoid public cairo_ft_scaled_font_lock_face for internal use
We're planning to change the implementation of the public function,
(which will remove some locking safety), so use the safe, locked
_cairo_ft_unscaled_font_lock_face for internal use instead.
2007-02-13 10:40:53 -08:00
Carl Worth
7e1301ffb0 Add missing _cairo_ft_unscaled_font_unlock_face to _cairo_ft_scaled_font_create 2007-02-13 10:22:32 -08:00
Adrian Johnson
6f7cfdf5c7 PDF: Add missing character code to Differences array 2007-02-13 23:53:38 +10:30
Adrian Johnson
88cae7766d output-stream: coding style fix 2007-02-13 23:29:05 +10:30
Adrian Johnson
88f7ea4ad7 CFF: Fix Visual C++ compile problem
Don't use structure intitialization for assigning
structure values.

Add a new field to cff_charset_t to point to the sids
charset array instead of casting it into the data field.
2007-02-13 22:52:53 +10:30
Adrian Johnson
ac01dcb5ad PDF: Remove dead code
The function _cairo_pdf_surface_write_fonts is the
original PDF TrueType font embedding function that was
disabled in commit f500cef19f
shortly before Type3 font support was added.

TrueType font embedding was later reintroduced as new code
making this function obsolete.
2007-02-11 23:14:40 +10:30
Adrian Johnson
d6f15b2600 Output-stream: Omit the minus sign from negative zero 2007-02-11 22:20:58 +10:30
Adrian Johnson
a2fefcc9e9 PDF: Compress Type3 fonts 2007-02-11 21:57:43 +10:30
Adrian Johnson
9f47879ae3 PDF: Fix Type3 font metrics to make text selection work 2007-02-11 21:50:46 +10:30
Brian Ewins
9dce321a11 [ATSUI] scale fonts using font size not font matrix
Mozilla bug #327522 - fonts scaled up over 16pt on mac
had nonsensical extents. The scaling was being done using
the font matrix, it turns out this does not work for 16x
scaling and up. This patch switches back to using the
font size to scale fonts, with emboldening and condensing
effects applied separately using the font matrix.
2007-02-11 01:42:22 +00:00
Brian Ewins
eec62c2975 Unreleased lock typo in cairo-scaled-font.c
One path through _cairo_scaled_font_text_to_glyphs grabbed
the mutex but didn't release it, causing hangs in all
text rendering on the mac.
2007-02-10 00:20:40 +00:00
Eugeniy Meshcheryakov
a37f21cb17 [PS/PDF/SVG] Return a write_error nil surface on write errors 2007-02-08 15:29:58 -08:00
Eugeniy Meshcheryakov
bf3cbe7660 [cairo-surface] Use a macro definition for all nil surfaces 2007-02-08 15:28:14 -08:00
Kalle Vahlman
aea0831d24 [cairoint] Make it compile with libpng disabled 2007-02-08 15:07:45 -08:00
Peter Weilbacher
4773b8a6d2 Oops, correct typo in previous commit
FALSA -> FALSE
2007-02-08 20:34:26 +01:00
Peter Weilbacher
e711700d5d Correct scaled font mutex definitions for OS/2
Using a zero without brackets to quiet remaining GCC compilation warning.
Use FALSE so that the mutex does not block on creation.
2007-02-08 20:29:18 +01:00
Adrian Johnson
2d1db24d1e PDF: Another fix for TrueType metrics
Not all TrueType fonts have an em size of 2048.
2007-02-07 23:10:47 +10:30
Adrian Johnson
274dfa4598 PDF: Make text selection and extraction work
- Add a to_unicode array to the scaled_font_subsets
  for mapping glyphs to unicode characters

- Add a function to the TrueType subsetting for
  performing a reverse cmap for mapping glyph indices
  to unicode characters.

- Add a new scaled font backend function for mapping
  glyph indices to unicode characters. Provide FreeType
  and Win32 implementations of the font backend mapping
  function.

- Modify the PDF backend to embed ToUnicode streams
  into each font. The unicode mapping is obtained by
  first trying the reverse cmap. If this fails the font
  backend mapping function is called.
2007-02-07 22:35:59 +10:30
Carl Worth
97a2522e0b Add missing locking to _cairo_scaled_font_text_to_glyphs
We recently added locking to cairo_scaled_font_glyph_extents and
to _cairo_surface_show_glyphs, but we had neglected the third
separate entry point into scaled_font code that does cache-using
glyph lookups, namely: _cairo_scaled_font_text_to_glyphs.

These three separate functions are plainly visible in the
implementation of cairo_show_text.
2007-02-06 21:19:30 -08:00
Carl Worth
1503a41c7f Expand font_map locking to cover call to backend->scaled_font_create
It seemed like a good idea to avoid holding the lock over the call
into the backend. But the procedure in place was quite broken:

	LOCK
	Fail to find font in hash table
	UNLOCK
	Create font
	LOCK
	Insert font into hash table
	UNLOCK

since while we're busy creating the font and unlocked, another thread
can insert the font. Our paranoid hash table implementation noted
the problem quite readily.

This patch simply removes the internal UNLOCK/LOCK to hold the mutex
over the whole procedure.
2007-02-06 20:42:09 -08:00
Carl Worth
db3493bef7 Remove dead cff_dict_remove function
I assume this was just a leftover that was meant to be removed
earlier. If not, please feel free to bring it back again.
2007-02-06 18:28:44 -08:00
Carl Worth
89cf8dbf52 Remove half-leftover debugging code from previous commit
This was leading to link failures on CAIRO_LOCK_FILE, etc.
2007-02-06 18:27:33 -08:00
Carl Worth
5d58e7ee66 Add scaled_font->mutex to allow locking for all subordinate objects
A cairo_scaled_font_t can be implicitly shared among multiple threads
as the same cairo_scaled_font_t can be returned from different calls
to cairo_scaled_font_create. To retain the illusion that these
different calls produce distinct objects, cairo must internally lock
access when modifying them.

Each glyph in the scaled font is represented by a cairo_surface_t
which is used when rendering the glyph. Instead of attempting to push
fine-grained locking of these surfaces down to the backend rendering
functions, a simple per-cairo_scaled_font_t lock has been introduced
which protects the entire rendering path against re-entrancy.

Some care was required to ensure that existing re-entrancy was handled
appropriately; these cases are in the wrapping surfaces
(cairo-paginated, test-meta and test-paginated).

Thanks to Vladimir Vukicev and Peter Weilbacher for testing/providing
the mutex definitions for win32 and os2 (respectively).
2007-02-06 17:53:27 -08:00
Carl Worth
765715ad93 Move scaled font holdovers magic from reference to create to fix race condition
Previously, with the magic in _cairo_scaled_font_reference(),
cairo_scaled_font_create() was releasing its lock just before
calling into reference() which would re-acquire the lock.
That left a window open during which a font we just discovered
in the holdovers table could be destroyed before we had a chance
to give it its initial reference back.
2007-02-06 17:53:27 -08:00
Carl Worth
9c359d61fc Avoid holding lock when calling _cairo_scaled_font_fini
As in the previous commit with the backend->scaled_font_create
function, we also don't want to hold the lock when calling into
the backend's fini function.
2007-02-06 17:53:27 -08:00
Carl Worth
258175ffcd Don't hold mutex over backend->scaled_font_create
This also allows some cleanup of the error-handling in
cairo_scaled_font_create, (no more goto statements).
2007-02-06 17:53:26 -08:00
Adrian Johnson
fc660511ec PDF: Correct the y value of Td in show_glyphs
This bug would occur if the y coordinate of all the glyphs
in a single cairo_show_glyphs() call was not the same.
2007-02-07 11:05:33 +10:30
Adrian Johnson
a8f8efb750 PS: Correct the TrueType Encoding and Charstrings
The offsets and count was out by one as a result of the
change to include .notdef on the TrueType font.
2007-02-05 18:29:30 +10:30
Adrian Johnson
28e3a20d79 PDF: Fix TrueType font metrics 2007-02-04 23:47:28 +10:30
Adrian Johnson
05ff2c77da PDF: Add Encoding dictionary to TrueType fonts
This is a fix for the bugs reported here

  http://lists.freedesktop.org/archives/cairo/2006-December/008984.html

  http://lists.freedesktop.org/archives/cairo/2007-January/009387.html

Cairo PDFs will not print correctly from Adobe Reader. The symptoms are
that all the glyphs on the page are replaced with the same glyph.

According to the PDF Reference an Encoding dictionary is not required
for the symbolic fonts used by cairo. However including the Encoding
dictionary fixes the printing problem.
2007-02-04 19:00:16 +10:30
Adrian Johnson
3f8d5f505a TrueType: Include notdef glyph in the subset
Required by the TrueType specification.
2007-02-04 18:21:50 +10:30
Adrian Johnson
d22ba141e6 TrueType Subsetting: Whitespace change 2007-02-04 16:58:04 +10:30
Adrian Johnson
e4a5011a27 TrueType Subsetting: Add comment 2007-02-04 16:51:44 +10:30
Eugeniy Meshcheryakov
7d05b9bdd3 TrueType Subsetting: Sort table directory
The TrueType specification requires the table directory
to be sorted by tag.
2007-02-04 16:36:01 +10:30