summaryrefslogtreecommitdiff
path: root/src/cairo-user-font.c
Commit message (Collapse)AuthorAgeFilesLines
* PDF Type 3 color fontsAdrian Johnson2023-01-291-1/+3
| | | | | | | | | 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.
* Foreground color fixes for ft, svg, colrv1Adrian Johnson2023-01-271-15/+2
|
* Add new cairo_user_scaled_font_get_foreground_source() functionAdrian Johnson2023-01-261-21/+185
| | | | | | | | | | | | 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.
* Fix user-font with foreground in group failures on image, PDF, and PSAdrian Johnson2023-01-031-2/+4
|
* user fonts: ensure snap_x/y_scale are initializedAdrian Johnson2022-12-281-0/+2
|
* Fix the scaled_glyph_init color glyph logicAdrian Johnson2022-04-251-160/+205
| | | | | | and split _cairo_user_scaled_glyph_init() into multiple functions. Update user-font test to test changing foreground text color.
* [user-font] Implement subpixel-positioningBehdad Esfahbod2022-02-131-0/+3
| | | | | | | | | | | | | 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.
* Apply 1 suggestion(s) to 1 file(s)Emmanuele Bassi2022-02-111-1/+1
|
* Plug another memory leakMatthias Clasen2022-02-101-0/+5
|
* user-font: Plug some memory leaksMatthias Clasen2022-02-101-0/+3
| | | | | We were leaking a cairo_t and a surface here, in some code paths.
* Allow user fonts to use the foreground colorAdrian Johnson2021-09-181-5/+18
|
* Support color fonts that use the foreground colorAdrian Johnson2021-08-281-2/+4
| | | | | | | | | | | | | 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.
* Fix some warningsAdrian Johnson2021-08-221-3/+3
|
* Add cairo_user_font_face_get_render_color_glyph_funcAdrian Johnson2021-08-141-0/+28
|
* Add color user-font supportAdrian Johnson2021-08-141-45/+169
| | | | | Adds new API cairo_user_font_face_set_render_color_glyph_func() to set a color glyph renderer.
* Use _cairo_malloc instead of mallocAdrian Johnson2018-05-071-2/+2
| | | | | | | | | | _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>
* font: Push the last reference dec into the backend->destroy() callbackChris Wilson2013-09-171-1/+1
| | | | | | | | | | | | | | 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>
* doc: Do not use the '@' prefix on some tagsAndrea Canciani2012-03-291-1/+1
| | | | | | | Make the 'Since' and 'Returns' tags consistent by removing the '@' prefix. Fixes some "missing 'Since' field" warnings.
* doc: Make documentation comments symmetricAndrea Canciani2012-03-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* api: Extend cairo_antialias_t to include performace/quality hintsChris Wilson2011-08-301-0/+3
| | | | | | | | | | | 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>
* clip: Rudimentary support for clip-polygon extractionChris Wilson2011-07-191-4/+5
| | | | | | | 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>
* doc: Move tmpl/ docs to inline docsBenjamin Otte2010-07-081-0/+22
| | | | | | 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).
* user-font: Check the status before destroying the contextChris Wilson2010-07-021-2/+2
|
* user-font: correct handling of size 0 textAndrea Canciani2010-06-301-24/+36
| | | | | | | | 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).
* user-font: ignore translation in scale matrixAndrea Canciani2010-06-291-1/+5
| | | | | | | | 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).
* Update FSF addressAndrea Canciani2010-04-271-1/+1
| | | | | | | | | | | 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
* Move _cairo_error() to a standalone headerChris Wilson2010-01-221-0/+1
| | | | | 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.
* [meta] Rename cairo_meta_surface_t to cairo_recording_surface_t.M Joonas Pihlaja2009-10-221-21/+21
| | | | | | | 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
* [API] Make _cairo_meta_surface_replay() private againBenjamin Otte2009-09-301-1/+1
| | | | | | | 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.
* Remove clip handling from generic surface layer.Chris Wilson2009-07-231-21/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 ▏
* Export meta-surfaceChris Wilson2009-07-031-4/+3
| | | | | | | | | | 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.
* [user-font] Set the initial colour to whiteChris Wilson2009-06-021-0/+1
| | | | | | | | | | | | | | | | 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.
* [user-font] Add CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTEDBehdad Esfahbod2009-05-061-3/+11
| | | | | This is useful for language bindings to signal that a method is not implemented.
* [twin] Add face propertiesBehdad Esfahbod2008-12-231-3/+1
| | | | Just parse them now. We don't use them yet.
* Clean up toy font face handlingBehdad Esfahbod2008-12-171-55/+7
| | | | | | | | | | | | | | | | | 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.
* Mark allocation failures as unlikely.Chris Wilson2008-11-291-1/+1
| | | | | Use the gcc likelihood annotation to indicate that allocation failures are extremely unlikely.
* Mark if(status) as being unlikely.Chris Wilson2008-11-291-9/+9
| | | | | The error paths should be hit very rarely during normal operation, so mark them as being unlikely so gcc may emit better code.
* [user-font] Eliminate shadowed variableChris Wilson2008-10-301-1/+0
| | | | Cleanup a minor -Wshadow warning.
* Map toy font face to implementation.Chris Wilson2008-10-221-9/+28
| | | | | | | | | | | | | | | | 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.
* Ensure that the scaled font is frozen for the lifetime of the scaled glyph.Chris Wilson2008-10-221-1/+0
| | | | | | | | | | | | | | | | 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.
* [user-font] Review locks under error conditions.Chris Wilson2008-10-191-16/+23
| | | | | | | | 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.
* [user-font] Check for error objects.Chris Wilson2008-10-191-12/+59
| | | | | Check that the user has not passed in an inert error object before any attempts to write to it and return the default values.
* [user-font] Fix comment re backend interfaceBehdad Esfahbod2008-10-061-1/+1
|
* [text_to_glyphs] Further enhance the docsBehdad Esfahbod2008-09-291-0/+5
| | | | The most complex public cairo API deserves more doc love...
* Add slim markers to make check-plt.sh happyBehdad Esfahbod2008-09-261-0/+4
|
* Add an internal font faceBehdad Esfahbod2008-09-251-5/+48
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* [show_text_glyphs] Replace the bool backward with cairo_text_cluster_flagsBehdad Esfahbod2008-09-181-12/+11
| | | | | | | | | | 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
* [user-font] Propagate status return.Chris Wilson2008-09-021-2/+8
| | | | | | 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.
* Rename _cairo_matrix_compute_scale_factors to ↵Behdad Esfahbod2008-08-271-1/+1
| | | | _cairo_matrix_compute_basis_scale_factors
* Add cairo_scaled_font_text_to_glyphs()Behdad Esfahbod2008-08-081-19/+19
| | | | | | | | 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.