summaryrefslogtreecommitdiff
path: root/librsvg
diff options
context:
space:
mode:
authorRamiro Estrugo <ramiro@src.gnome.org>2000-08-02 19:38:53 +0000
committerRamiro Estrugo <ramiro@src.gnome.org>2000-08-02 19:38:53 +0000
commitee6964ff9e996309dd76d754bfb5e593f87309b3 (patch)
tree083bbbe9d2ead37b55ce31ee50e078f2b6ba4663 /librsvg
parentb93aa290e7c38ff483eae7c6acfe4c24427ee0fc (diff)
downloadnautilus-ee6964ff9e996309dd76d754bfb5e593f87309b3.tar.gz
Fix a small bug where a font entry was found in the table, but it wasnt
* librsvg/rsvg-ft.c: (rsvg_ft_intern), (rsvg_ft_font_resolve), (rsvg_ft_render_string): Fix a small bug where a font entry was found in the table, but it wasnt returned. Quiet down debug noise. * librsvg/test-ft.c: (glyph_render_test), (main): Add some options and make affine transformation a simple identity to help debug the coordinates of the rendered text.
Diffstat (limited to 'librsvg')
-rw-r--r--librsvg/rsvg-ft.c11
-rw-r--r--librsvg/test-ft.c52
2 files changed, 47 insertions, 16 deletions
diff --git a/librsvg/rsvg-ft.c b/librsvg/rsvg-ft.c
index 50296bee1..193ba830a 100644
--- a/librsvg/rsvg-ft.c
+++ b/librsvg/rsvg-ft.c
@@ -292,6 +292,8 @@ rsvg_ft_intern (RsvgFTCtx *ctx, const char *font_file_name)
}
ctx->font_list[n_font_list] = entry;
}
+
+/* fprintf (stderr, "handle = %d\n", entry->handle); */
return entry->handle;
}
@@ -339,8 +341,8 @@ rsvg_ft_font_attach (RsvgFTCtx *ctx, RsvgFTFontHandle fh,
static RsvgFTFont *
rsvg_ft_font_resolve (RsvgFTCtx *ctx, RsvgFTFontHandle fh)
{
- RsvgFTFontCacheEntry *entry;
- RsvgFTFont *font;
+ RsvgFTFontCacheEntry *entry = NULL;
+ RsvgFTFont *font = NULL;
if (fh < 0 || fh >= ctx->n_font_list)
return NULL;
@@ -360,6 +362,9 @@ rsvg_ft_font_resolve (RsvgFTCtx *ctx, RsvgFTFontHandle fh)
}
entry->font = font;
}
+ else {
+ font = entry->font;
+ }
return font;
}
@@ -560,7 +565,7 @@ rsvg_ft_render_string (RsvgFTCtx *ctx, RsvgFTFontHandle fh,
FT_Get_Kerning (font->face, last_glyph, glyph_index,
ft_kerning_unscaled,
&kern);
- fprintf (stderr, "kern = (%ld, %ld)\n", kern.x, kern.y);
+/* fprintf (stderr, "kern = (%ld, %ld)\n", kern.x, kern.y); */
kx = FT_TOFLOAT (kern.x);
ky = FT_TOFLOAT (kern.y);
glyph_affine[4] += glyph_affine[0] * kx +
diff --git a/librsvg/test-ft.c b/librsvg/test-ft.c
index 0cc544ffe..754ad371e 100644
--- a/librsvg/test-ft.c
+++ b/librsvg/test-ft.c
@@ -35,6 +35,8 @@
#include <libart_lgpl/art_misc.h>
#include <libart_lgpl/art_rect.h>
#include <libart_lgpl/art_alphagamma.h>
+#include <libart_lgpl/art_affine.h>
+#include <libart_lgpl/art_affine.h>
#include "art_render.h"
#include "art_render_mask.h"
@@ -284,12 +286,18 @@ static GdkPixbuf *
glyph_render_test (RsvgFTGlyph *glyph, int glyph_xy[2]) {
GdkPixbuf *pixbuf;
art_u8 *pixels;
- int width = 200;
- int height = 200;
+ int width;
+ int height;
int rowstride;
ArtRender *render;
ArtPixMaxDepth color[3] = {ART_PIX_MAX_FROM_8(0x80), 0, 0 };
+ width = glyph->width;
+ height = glyph->height;
+
+ width = 200;
+ height = 200;
+
rowstride = width << 2;
pixels = g_new (art_u8, rowstride * height);
@@ -318,20 +326,30 @@ int main(int argc, char **argv)
GdkPixbuf *pixbuf;
char *zoom_str = "1.0";
int n_iter = 1;
- poptContext optCtx;
- struct poptOption optionsTable[] = {
-
- {"zoom", 'z', POPT_ARG_STRING, &zoom_str, 0, NULL,
- "zoom factor"},
+
+ gint font_width = 36;
+ gint font_height = 36;
+ char *font_file_name = "/usr/share/fonts/default/Type1/n021003l.pfb";
- {"num-iter", 'n', POPT_ARG_INT, &n_iter, 0, NULL,
- "number of iterations"},
+ poptContext optCtx;
+ struct poptOption optionsTable[] =
+ {
+ {"zoom", 'z', POPT_ARG_STRING, &zoom_str, 0, NULL, "zoom factor"},
+ {"num-iter", 'n', POPT_ARG_INT, &n_iter, 0, NULL, "number of iterations"},
+ {"font-width", 'w', POPT_ARG_INT, &font_width, 0, NULL, "Font Width"},
+ {"font-height", 'h', POPT_ARG_INT, &font_height, 0, NULL, "Font Height"},
+ {"font-file-name", 'f', POPT_ARG_STRING, &font_file_name, 0, NULL, "Font File Name"},
POPT_AUTOHELP {NULL, 0, 0, NULL, 0}
};
char c;
const char *const *args;
int i;
+
+#if 0
const double affine[6] = { .707, -.707, .707, .707, 10, 150 };
+#else
+ double affine[6];
+#endif
RsvgFTCtx *ctx;
RsvgFTFontHandle fh;
@@ -348,15 +366,23 @@ int main(int argc, char **argv)
out_fn = (char *) args[0];
ctx = rsvg_ft_ctx_new ();
- fh = rsvg_ft_intern (ctx,
- "/usr/share/fonts/default/Type1/n021003l.pfb");
+ fh = rsvg_ft_intern (ctx, font_file_name);
for (i = 0; i < n_iter; i++) {
RsvgFTGlyph *glyph;
int glyph_xy[2];
- glyph = rsvg_ft_render_string (ctx, fh, "graphic(s)", 36, 36,
- affine, glyph_xy);
+ art_affine_identity (affine);
+
+ glyph = rsvg_ft_render_string (ctx, fh,
+ "graphic(s)",
+ font_width,
+ font_height,
+ affine,
+ glyph_xy);
+
+
+ glyph_xy[1] += glyph->ypen;
pixbuf = glyph_render_test (glyph, glyph_xy);