mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2025-12-30 21:20:13 +01:00
Restore the ability to choose the internal font.
Behdad wants to include the feature with 1.10, so we enable it as early as possible in 1.9 dev cycle to generate as much feedback as possible. The first change is to use "<cairo>" as being a name unlikely to clash with any real font names. This reverts commits:a824d284be,2922336855,e0046aaf41,f534bd549e.
This commit is contained in:
parent
52c3fc58b5
commit
4f2f46ef1b
14 changed files with 125 additions and 2 deletions
|
|
@ -35,6 +35,7 @@ cairo_perf_SOURCES = \
|
|||
subimage_copy.c \
|
||||
tessellate.c \
|
||||
text.c \
|
||||
twin.c \
|
||||
unaligned-clip.c \
|
||||
world-map.c \
|
||||
world-map.h \
|
||||
|
|
|
|||
|
|
@ -458,5 +458,6 @@ const cairo_perf_case_t perf_cases[] = {
|
|||
{ rounded_rectangles, 512, 512},
|
||||
{ long_dashed_lines, 512, 512},
|
||||
{ composite_checker, 16, 512},
|
||||
{ twin, 800, 800},
|
||||
{ NULL }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -172,5 +172,6 @@ CAIRO_PERF_DECL (rectangles);
|
|||
CAIRO_PERF_DECL (rounded_rectangles);
|
||||
CAIRO_PERF_DECL (long_dashed_lines);
|
||||
CAIRO_PERF_DECL (composite_checker);
|
||||
CAIRO_PERF_DECL (twin);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
50
perf/twin.c
Normal file
50
perf/twin.c
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#define WIDTH 1350
|
||||
#define HEIGHT 900
|
||||
|
||||
#include "cairo-perf.h"
|
||||
|
||||
static cairo_perf_ticks_t
|
||||
do_twin (cairo_t *cr,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
int i, j, h;
|
||||
unsigned char s[2] = {0, 0};
|
||||
|
||||
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
|
||||
cairo_paint (cr);
|
||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||
|
||||
cairo_perf_timer_start ();
|
||||
|
||||
cairo_select_font_face (cr,
|
||||
"<cairo>",
|
||||
CAIRO_FONT_SLANT_NORMAL,
|
||||
CAIRO_FONT_WEIGHT_NORMAL);
|
||||
|
||||
h = 2;
|
||||
for (i = 8; i < 48; i >= 24 ? i+=3 : i++) {
|
||||
cairo_set_font_size (cr, i);
|
||||
for (j = 33; j < 128; j++) {
|
||||
if (j == 33 || (j == 80 && i > 24)) {
|
||||
h += i + 2;
|
||||
cairo_move_to (cr, 10, h);
|
||||
}
|
||||
s[0] = j;
|
||||
cairo_text_path (cr, (const char *) s);
|
||||
}
|
||||
}
|
||||
cairo_fill (cr);
|
||||
|
||||
cairo_perf_timer_stop ();
|
||||
return cairo_perf_timer_elapsed ();
|
||||
}
|
||||
|
||||
void
|
||||
twin (cairo_perf_t *perf,
|
||||
cairo_t *cr,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
cairo_perf_run (perf, "twin", do_twin);
|
||||
}
|
||||
|
|
@ -578,7 +578,8 @@ _cairo_toy_font_face_scaled_font_get_implementation (void *abstra
|
|||
if (font_face->base.status)
|
||||
return font_face->base.status;
|
||||
|
||||
if (CAIRO_SCALED_FONT_BACKEND_DEFAULT != &_cairo_user_scaled_font_backend)
|
||||
if (CAIRO_SCALED_FONT_BACKEND_DEFAULT != &_cairo_user_scaled_font_backend &&
|
||||
0 != strcmp (font_face->family, CAIRO_USER_FONT_FAMILY_DEFAULT))
|
||||
{
|
||||
const cairo_scaled_font_backend_t * backend = CAIRO_SCALED_FONT_BACKEND_DEFAULT;
|
||||
|
||||
|
|
@ -617,7 +618,8 @@ _cairo_toy_font_face_scaled_font_create (void *abstract_font_face
|
|||
if (status)
|
||||
return status;
|
||||
|
||||
if (CAIRO_SCALED_FONT_BACKEND_DEFAULT != &_cairo_user_scaled_font_backend)
|
||||
if (CAIRO_SCALED_FONT_BACKEND_DEFAULT != &_cairo_user_scaled_font_backend &&
|
||||
0 != strcmp (font_face->family, CAIRO_USER_FONT_FAMILY_DEFAULT))
|
||||
{
|
||||
const cairo_scaled_font_backend_t * backend = CAIRO_SCALED_FONT_BACKEND_DEFAULT;
|
||||
|
||||
|
|
|
|||
|
|
@ -938,6 +938,7 @@ typedef struct _cairo_traps {
|
|||
#define CAIRO_WIN32_FONT_FAMILY_DEFAULT "Arial"
|
||||
#define CAIRO_QUARTZ_FONT_FAMILY_DEFAULT "Helvetica"
|
||||
#define CAIRO_FT_FONT_FAMILY_DEFAULT ""
|
||||
#define CAIRO_USER_FONT_FAMILY_DEFAULT "<cairo>"
|
||||
|
||||
#if CAIRO_HAS_WIN32_FONT
|
||||
|
||||
|
|
|
|||
1
test/.gitignore
vendored
1
test/.gitignore
vendored
|
|
@ -233,6 +233,7 @@ transforms
|
|||
translate-show-surface
|
||||
trap-clip
|
||||
truetype-tables
|
||||
twin
|
||||
unantialiased-shapes
|
||||
unbounded-operator
|
||||
user-data
|
||||
|
|
|
|||
|
|
@ -180,6 +180,7 @@ transforms$(EXEEXT) \
|
|||
translate-show-surface$(EXEEXT) \
|
||||
trap-clip$(EXEEXT) \
|
||||
truetype-tables$(EXEEXT) \
|
||||
twin$(EXEEXT) \
|
||||
unantialiased-shapes$(EXEEXT) \
|
||||
unbounded-operator$(EXEEXT) \
|
||||
user-data$(EXEEXT) \
|
||||
|
|
@ -929,6 +930,11 @@ REFERENCE_IMAGES = \
|
|||
trap-clip-pdf-rgb24-ref.png \
|
||||
trap-clip-ps2-argb32-ref.png \
|
||||
trap-clip-ps2-rgb24-ref.png \
|
||||
twin-ref.png \
|
||||
twin-ps2-ref.png \
|
||||
twin-ps3-ref.png \
|
||||
twin-svg11-ref.png \
|
||||
twin-svg12-ref.png \
|
||||
unantialiased-shapes-ref.png \
|
||||
unantialiased-shapes-quartz-ref.png \
|
||||
unbounded-operator-ref.png \
|
||||
|
|
|
|||
BIN
test/twin-ps2-ref.png
Normal file
BIN
test/twin-ps2-ref.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
test/twin-ps3-ref.png
Normal file
BIN
test/twin-ps3-ref.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
test/twin-ref.png
Normal file
BIN
test/twin-ref.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
BIN
test/twin-svg11-ref.png
Normal file
BIN
test/twin-svg11-ref.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
BIN
test/twin-svg12-ref.png
Normal file
BIN
test/twin-svg12-ref.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
60
test/twin.c
Normal file
60
test/twin.c
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright 2008 Chris Wilson
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the name of
|
||||
* Chris Wilson not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior
|
||||
* permission. Chris Wilson makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* CHRIS WILSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
||||
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS, IN NO EVENT SHALL CHRIS WILSON BE LIABLE FOR ANY SPECIAL,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#include "cairo-test.h"
|
||||
|
||||
static cairo_test_draw_function_t draw;
|
||||
|
||||
static const cairo_test_t test = {
|
||||
"twin",
|
||||
"Tests the internal font",
|
||||
128, 20,
|
||||
draw
|
||||
};
|
||||
|
||||
static cairo_test_status_t
|
||||
draw (cairo_t *cr, int width, int height)
|
||||
{
|
||||
cairo_set_source_rgb (cr, 1, 1, 1);
|
||||
cairo_paint (cr);
|
||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||
|
||||
cairo_select_font_face (cr,
|
||||
"<cairo>",
|
||||
CAIRO_FONT_SLANT_NORMAL,
|
||||
CAIRO_FONT_WEIGHT_NORMAL);
|
||||
cairo_set_font_size (cr, 16);
|
||||
|
||||
cairo_move_to (cr, 4, 14);
|
||||
cairo_show_text (cr, "Is cairo's twin giza?");
|
||||
|
||||
return CAIRO_TEST_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
return cairo_test (&test);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue