[PATCH 2/2] scaled font: Fix the docs for cairo_scaled_font_get_font_face

Uli Schlachter psychon at znc.in
Tue Jan 25 07:29:58 PST 2011


With the toy font API, it is possible that cairo_scaled_font_get_font_face()
doesn't return the font face which was passed to cairo_scaled_font_create()
despite the docs saying otherwise.

Signed-off-by: Uli Schlachter <psychon at znc.in>
---
 src/cairo-scaled-font.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 2702877..196af4d 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -2870,8 +2870,9 @@ _cairo_scaled_font_get_max_scale (cairo_scaled_font_t *scaled_font)
  * cairo_scaled_font_get_font_face:
  * @scaled_font: a #cairo_scaled_font_t
  *
- * Gets the font face that this scaled font uses.  This is the
- * font face passed to cairo_scaled_font_create().
+ * Gets the font face that this scaled font uses.  This might be the
+ * font face passed to cairo_scaled_font_create(), but this does not
+ * hold true for all possible cases.
  *
  * Return value: The #cairo_font_face_t with which @scaled_font was
  * created.
-- 
1.7.2.3


--------------050807090703090200070404
Content-Type: text/x-csrc;
 name="footest.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="footest.c"

#include <src/cairo.h>
#include <stdlib.h>

static void fatal(const char *msg)
{
    puts (msg);
    exit (125);
}

int main()
{
    cairo_surface_t *surf;
    cairo_t *cr;
    cairo_font_face_t *ff;
    cairo_matrix_t font_mat, ctm;
    cairo_scaled_font_t *sf;
    cairo_font_options_t *options;
    const int width = 10;
    const int height = 10;

    cairo_matrix_init_identity (&ctm);
    cairo_matrix_init_scale (&font_mat, 23, 23);
    options = cairo_font_options_create ();

    surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
    cr = cairo_create (surf);
    if (cairo_surface_status (surf) != CAIRO_STATUS_SUCCESS)
	fatal ("surface 1 in error!");
    cairo_surface_destroy(surf);

    ff = cairo_get_font_face (cr);
    sf = cairo_scaled_font_create (ff, &font_mat, &ctm, options);
    if (cairo_scaled_font_status (sf) != CAIRO_STATUS_SUCCESS)
	fatal ("scaled font 1 in error!");
    if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
	fatal ("cr 1 in error!");
    cairo_destroy (cr);
    cairo_scaled_font_destroy (sf);

    surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
    cr = cairo_create (surf);
    if (cairo_surface_status (surf) != CAIRO_STATUS_SUCCESS)
	fatal ("surface 2 in error!");
    cairo_surface_destroy(surf);
    cairo_select_font_face (cr, "default", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);

    ff = cairo_get_font_face (cr);
    sf = cairo_scaled_font_create (ff, &font_mat, &ctm, options);
    if (cairo_scaled_font_status (sf) != CAIRO_STATUS_SUCCESS)
	fatal ("scaled font 2 in error!");
    if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
	fatal ("cr 2 in error!");
    cairo_font_options_destroy (options);
    if (cairo_scaled_font_get_font_face (sf) != ff) {
	puts("error");
	return 1;
    }
    puts("success!");
    return 0;
}

--------------050807090703090200070404
Content-Type: application/octet-stream;
 name="0001-User-fonts-Make-it-clear-what-should-NOT-be-freed.patch.sig"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename*0="0001-User-fonts-Make-it-clear-what-should-NOT-be-freed.patch";
 filename*1=".sig"

iQEcBAABCAAGBQJNPu7AAAoJECLkKOvLj8sGcOgIAKGP/8ssIrVb3t+QeXVtgYIA6KoBfaj7
FaCi1n09313n2ZGeHSNFnuJ91RST5HiIS0Q5taxMgJSS0JtOh7/ws3ZltxWbCJw4EGVDuXLK
svRBiByUxrBzvRmNgsb2P3gbZimhnotcnJH7MPON3A7gI82Bblyt0a5eF1TKntgXEXyomptG
h6nevlqpxuXrpoimTM+/DqqCpCDcEExBrCn1141QxKuhO7RiafDdZ7pVLPzgNgdoUuRemsgE
GuzHp8ARtLYmY+7u1wKQQMzu3Eo0WUbgNcetZxqgaLe7y5JSZpPhuwaQWva3xGG3NUe+QIDo
MrfQdOdqGRR8k4Vs/yb1E0c=
--------------050807090703090200070404
Content-Type: application/octet-stream;
 name="0002-scaled-font-Fix-the-docs-for-cairo_scaled_font_get_f.patch.sig"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename*0="0002-scaled-font-Fix-the-docs-for-cairo_scaled_font_get_f.pa";
 filename*1="tch.sig"

iQEcBAABCAAGBQJNPu7AAAoJECLkKOvLj8sGNXAIANV6S8zVeCShhQptMBiItfZCTwCARNQn
RVfgffnDfhDn6O1WsHIoK8YV7YXN8ZT8rCKOJkD1ytV1X7mmSQhGp51SGQHKA0cQL30EefWk
OjrpVPBioSs0vkNKMyjxvk2e3so0gdiRCi9O7cyxAQ/EWROCrq2m/ozbq7fsfUHHQeEG6DhX
0kN5m/t7BRdUQzT+haEDyk2g5OeshN96TrHKeoiGmKvc3ki+HLNrgUAE6rPahoeL1o1Y6jBK
fLkMPVABpw9us79njeKthMrOsMJ+HNod6S34WEqg5gUmrziNXbsMu/oRg7rB6ZrcQ8i80pAM
G2dxCH9kpOigaEI+sb1zjjU=
--------------050807090703090200070404
Content-Type: application/octet-stream;
 name="footest.c.sig"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="footest.c.sig"

iQEcBAABCAAGBQJNPu7AAAoJECLkKOvLj8sGlrgH/1kiSfatPTqYDGzgNE479ejU43yz+rn/
LPfTbH9bOVVT3zbegeiA6RCKSaWi23GyHxsUKc9Dds4Yqo0dPz6f/0bKqDq++kOCKy+hx93w
hTxWiIxBK/NN7edrJbfLKEcTf95LM4Oy4NJYMbfOrNxHdLrxuCT20cfiIkbCea07XlYoq6yU
cdzwwKl52x7q59LHZm82DfJX7wQUQbtR2GZuSyxRmZYcBU3hgQM440ZeKEdM5QtZuOYMwwIW
Zsi/sz+RPUwo3LgIuLa1X76qXEZjyPKs/6iZ9oGLuD+sKyheyB9eZ3yYupKKnDDItc7Cw8jt
mkttwpkcahjhuwtmApMw5Nc=
--------------050807090703090200070404--


More information about the cairo mailing list