summaryrefslogtreecommitdiff
path: root/src/cairo-ft-font.c
AgeCommit message (Collapse)AuthorFilesLines
2008-01-09[cairo-ft] Revert "Force non-AA text when using a bitmap strike with only ↵Behdad Esfahbod1-24/+0
scaling transform." (#13479) The reasoning for that commit was that fonts with bitmap strikes should be rendered with antialiasing off for those (hopefully) few glyphs that don't have a bitmap. However, it turns out, there are fonts that have some, but very few, bitmaps, and this changed forces non-AA rendering on them. We now support multiple glyph formats per font in the Xlib backend, so backing this out to let every glyph render as is. Fontconfig rules can be used to force AA off on a per-font basis. This reverts commit 06af5c2891b89da28581c30afcde06c5442884db. (cherry picked from commit 83963d2a9ec445e23cfbe692b877177a9d9d135e)
2007-11-26Force non-AA text when using a bitmap strike with only scaling transform.Keith Packard1-0/+24
When the current font size matches one of the available fixed sizes, and the overall transform has only scaling components, FreeType will use the fixed size bitmaps by default. For glyphs which do not have bitmaps, force them to be rendered in monochrome instead of anti-aliased so that they all match nicely. (cherry picked from commit 06af5c2891b89da28581c30afcde06c5442884db)
2007-11-26[malloc] Take advantage of calloc() argument checking.Chris Wilson1-2/+2
calloc() will check its arguments for integer overflows so it is safer not to pre-multiply them. (cherry picked from commit 66664596559c55913fb0b9c8784fe8ab862c217b)
2007-11-26[cairo-ft-font] Ignore FT_Load_Glyph errors other than out-of-memoryBehdad Esfahbod1-5/+9
Same for FT_Render_Glyph. When the user asks us to render a glyph that is not available in the font, it's mostly an unavoidable kind of error for them, as in, they can't avoid such a call. So it's not nice to put cairo_t in an error state and refuse any further drawying. Many PDF files are created using buggy software and cause such glpyh-not-found errors for CID 0 for example. Eventually we should propagate these kind of errors up and return it from the function call causing it, but that needs API change to add return value to all text functions, so for now we just ignore these errors. (cherry picked from commit 79d975f84bcc32e91db517d71a7312e2e1d653d4)
2007-11-26[cairo-ft-font] Early detection of a zero sized bitmap.Chris Wilson1-0/+6
Under rare circumstances we may need to extract a surface that represents a bitmap with width==0 and rows==0. Detect this case at the start and simply return a zero-sized surface. Fixes https://bugs.freedesktop.org/show_bug.cgi?id=12284. (cherry picked from commit d62f8861689d8b9a9a837043fb78813f0407abd4)
2007-11-26[cairo-ft-font] Decrement lock count on error.Chris Wilson1-0/+1
As noted in http://bugs.freedesktop.org/show_bug.cgi?id=12026 the error path of _cairo_ft_unscaled_font_lock_face() failed to reset the unscaled->lock_count before releasing the mutex and returning NULL. (cherry picked from commit bc635da45a32eb9b7aff6fa5f7f560ebf99092a8)
2007-11-20[fix] Avoid int overflow when allocating large buffersVladimir Vukicevic1-2/+2
This patch introduces three macros: _cairo_malloc_ab, _cairo_malloc_abc, _cairo_malloc_ab_plus_c and replaces various calls to malloc(a*b), malloc(a*b*c), and malloc(a*b+c) with them. The macros return NULL if int overflow would occur during the allocation. See CODING_STYLE for more information. (cherry picked from commit 5c7d2d14d78e4dfb1ef6d2c40f0910f177e07360)
2007-06-05[cairo-ft-font] Markup error paths with _cairo_error().Chris Wilson1-17/+41
Behdad Esfahbod noted that in ff5af0f540ec4 I had introduce new error paths without the appropriate _cairo_error(). So review cairo-ft-font to ensure that _cairo_error() is called at the start of every error path, as close to the originating error as possible.
2007-05-30[cairo-ft-font] Propagate error rather than asserting.Chris Wilson1-11/+30
FT_Set_Char_Size can fail due to an out-of-memory condition, so propagate the error status instead of asserting that it never fails.
2007-05-25[cairo-ft-font] Remove erroneous cached font faces.Chris Wilson1-4/+11
Only return a font face from the cache if it is not in an error condition. Otherwise unlink the bad font face from the cache and construct a new one.
2007-05-16[cairo-ft-font] Destroy the path on error.Chris Wilson1-10/+12
During _decompose_glyph_outline() destroy the fixed path if we encounter an error.
2007-05-16[cairo-ft-font] Destroy the unscaled reference on error.Chris Wilson1-0/+1
Release the reference to the unscaled font if we encounter an error whilst initialising the cairo_ft_scaled_font_t.
2007-05-16[cairo-ft-font] Race between unscaled removal from hash table and creationChris Wilson1-1/+1
Small window of opportunity for the unscaled font to be destroyed and removed from the hash table before _cairo_ft_unscaled_font_create_for_pattern() takes a reference on behalf of its cairo. Close the window by taking the reference with the font map lock held.
2007-05-16[cairo-ft-font] Destroy surface if glyph transformation fails.Chris Wilson1-1/+4
As we allocated the surface we need to destroy it if we encounter an error.
2007-05-01[cairo-mutex] Make CAIRO_MUTEX_INIT/FINI take mutex object, not pointer to itBehdad Esfahbod1-2/+2
This is more consistent with CAIRO_MUTEX_LOCK/UNLOCK.
2007-04-10Add missing error check of return value of _cairo_path_fixed_close_pathCarl Worth1-2/+4
2007-04-09Free the bitmap->buffer on failureChris Wilson1-1/+6
Currently if the ownership of the bitmap->buffer is passed to _get_bitmap_surface() then the status of the buffer is inconsistent should the function detect an error (i.e. CAIRO_STATUS_NO_MEMORY). Fix it up that should we encounter an error and we own the buffer then we always free it on behalf of the caller.
2007-04-09cairo-ft-font - handle trivial failuresChris Wilson1-28/+54
Catch the status return, cleanup and propagate the error.
2007-04-06_get_bitmap_surface - check for calloc failureChris Wilson1-0/+2
2007-04-03[src] Make sure all source files #include "cairoint.h" as their first includeBehdad Esfahbod1-1/+3
This is necessary to avoid many portability problems as cairoint.h includes config.h. Without a test, we will regress again, hence add it. The inclusion idiom for cairo now is: #include "cairoint.h" #include "cairo-something.h" #include "cairo-anotherthing-private.h" #include <some-library.h> #include <other-library/other-file.h> Moreover, some standard headers files are included from cairoint.h and need not be included again.
2007-03-20Move declaration of cairo_mutex_t to cairo-mutex-private.hMathias Hasselmann1-1/+0
2007-03-20Initialize mutexes at central location.Mathias Hasselmann1-2/+1
All mutex declarations have been moved to cairo-mutex-list.h. This should avoid breaking of less frequently tested backends, when mutexes are introduced or when existing mutexes are renamed. Instead of initializing mutexes on library startup, mutexes are lazily initialized within the few entry points of now by calling CAIRO_MUTEX_INITIALIZE(). Currently only the OS/2 backend takes care about releasing global mutexes. Therefore there is no counter part of that macro for finalizing all global mutexes yet - but as cairo-backend-os2.c shows such a function would be quite easy to implement.
2007-03-09Fix a LOCK vs. UNLOCK typo, (yes, I'm that stupid).Carl Worth1-1/+1
Thanks to M.Drochner@fz-juelich.de for noticing the bug. This fixes bug #10235: locking bug in cairo_ft_scaled_font_unlock_face() http://bugs.freedesktop.org/show_bug.cgi?id=10235
2007-03-05Rename all mutex variables to start with an underscoreBehdad Esfahbod1-6/+6
since they are not static in some of the implementations (win32, ...)
2007-02-22[FreeType] Truely return unhinted advance width if metrics hinting is offBehdad Esfahbod1-4/+11
David Turner said: The returned 26.6 advance is always rounded, even with FT_LOAD_NO_HINTING. You can however retrieve the linearly scaled value as a 16.16 fixed float number through face->glyph->linearHoriAdvance. This works even with hinted glyphs.
2007-02-13Fix cairo_ft_unscaled_font_t to have a lock_count again not an is_locked BooleanCarl Worth1-6/+6
This was inadvertently changed as part of fdffde8b9e7a2308b822ddef7b02a8e85cc8ba1e 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-13Add missing call to set_scale of unscaled_font in scaled_glyph initCarl Worth1-0/+3
This fixes a regression introduced with commit: 25a370d7992d7f70d8cf79f1b328e40437b40ac4 This was showing up as a failure of the bitmap-font test case with the ps, pdf, and svg backends.
2007-02-13Add mutex to implement _cairo_ft_unscaled_font_lock_face and ↵Carl Worth1-29/+53
_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-13Avoid public cairo_ft_scaled_font_lock_face for internal useCarl Worth1-3/+3
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-13Add missing _cairo_ft_unscaled_font_unlock_face to _cairo_ft_scaled_font_createCarl Worth1-0/+2
2007-02-07PDF: Make text selection and extraction workAdrian Johnson1-0/+33
- 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-01-07Spell check the docsBehdad Esfahbod1-3/+3
2006-12-10[FreeType] Remove "UNSUPPORTED" show_glyphs stub and NULL its entryBehdad Esfahbod1-18/+1
The fallback paths always assume UNSUPPORTED if a method is NULL, so, no need for a method to just return UNSUPPORTED.
2006-12-08[FreeType] Do not return large structs from functionsBehdad Esfahbod1-12/+13
Pass cairo_ft_options_t around by pointer, not by value. That's what we do with cairo_font_options_t anyway, and there is no reason to not do the same here. (makes -Waggregate-return warnings go away btw).
2006-11-22Replace existing rounding code with _cairo_lroundDaniel Amelang1-2/+2
2006-09-05Add many missing slim_hidden calls to bypass PLT entries for local use of ↵Carl Worth1-0/+3
public functions
2006-09-01bug 8104: Eliminate unused variables. Replicate assert statement to identify ↵Carl Worth1-7/+2
branch of interest.
2006-08-15[FreeType] Use _cairo_ft_scaled_font_is_vertical where appropriateBehdad Esfahbod1-2/+2
instead of poking at the loadflags.
2006-08-15[FreeType] Fix vertical metrics adjustment to work with non-identity shapesBehdad Esfahbod1-11/+18
2006-08-15[FreeType] Fix comment about font coordinateBehdad Esfahbod1-2/+1
2006-08-10Remove the ft_load_sfnt_table check from PS/PDF/SVG backendsBehdad Esfahbod1-0/+3
and make sure that _cairo_ft_load_truetype_table returns UNSUPPORTED if the version of FreeType used doesn't support FT_Load_Sfnt_Table.
2006-08-08[FreeType] Unset and set to FC_RGBA_NONE the FC_RGBA attribute on patternBehdad Esfahbod1-1/+3
if we don't want it. This stuff is tricky, but I hope to explain: In your fontconfig configuration, you may match on "font", or on "pattern". Turning subpixel on typically looks like: <match target="font"> <test qual="all" name="rgba"> <const>unknown</const> </test> <edit name="rgba" mode="assign"><const>rgb</const></edit> </match> This works good enough, and if you set to ANTIALIAS_GRAY, this will not override that. Now one may forget to match on "font" target, or intentionally match on the pattern. That happens before cairo font options are substituted in the pattern. So, to give a hint of subpixel in your config file, you can write: <match target="pattern"> <edit name="rgba" mode="assign"><const>rgb</const></edit> </match> You don't really need to check for current values, as FcConfigSubstitute is run before merging cairo_font_options_t in. What this patch does, is to reset pattern's rgba property if the font options explicitly ask for ANTIALIAS_GRAY. This is the only place in cairo-ft-font.c that we use FcPatternDel, so I thought some explanation is needed.
2006-08-08Restructure subpixel_order handling such that the code doesn't look suspicious!Behdad Esfahbod1-5/+10
Shouldn't make /any/ difference at all in any case.
2006-08-08[fontconfig] Set FC_RGBA_NONE on the pattern if we don't want subpixel.Behdad Esfahbod1-0/+2
otherwise, it looks like "I don't care" and fontconfig configuration is allowed to decide to turn subpixel on. This fixes the bug that subpixel colors where showing up in fallback images in PS/PDF/SVG backends, observed in the test fallback-resolution.
2006-08-07Merge branch 'warnings-cleanup' into cairoCarl Worth1-0/+5
Conflicts: src/cairo-font-subset.c
2006-08-07Add -Wswitch-enum compiler flag and fix all trivial warningsCarl Worth1-0/+5
2006-08-03Use base pointer to avoid compiler warning.Carl Worth1-1/+1
2006-08-03Fail FreeType load_truetype_table on vertical fonts as we don't do itBehdad Esfahbod1-0/+3
right now. Failing disables the subsetting for vertical fonts, like it was being done before the recent changes to the TrueType subsetter.
2006-08-02Remove freetype dependency for truetype subsetting code.Adrian Johnson1-0/+26
Add a load_truetype_table function to cairo_scaled_font_backend_t and use it to load the truetype sfnt tables. Implement this with freetype for the freetype font backend and use GetFontData for win32. Atsui remains unimplemented, and still falls back to type3 fonts.
2006-06-29Skip TrueType font output for PS/PDF until it handles vertical layout.Keith Packard1-1/+15
The TrueType font subsetting code fails to emit VHEA/VMTX headers for the font, so WMode 1 doesn't work to switch to vertical metrics. Added a bug about this, and changed the PS/PDF output code to just use Type3 in this case until the bug is fixed. Updated the reference images to match the output for PDF/PS backends for the vertical font check.