Thu 31 Mar 2016 10:10:42 AM UTC, original submission:
I don't know whether this behavior is a FreeType bug or not but I'll report it.
The specified font size of scaled TrueType font (e.g. DejaVu Sans Mono: http://dejavu-fonts.org/ ) is rounded. For example, all of font sizes between 8.5 * 64 and 9.499... * 64 are the same.
Here is a C program that reproduces this behavior (Sorry. This uses cairo.):
<pre>
/* gcc -o truetype-size truetype-size.c $(pkg-config --cflags --libs cairo-pdf) */
#include <stdio.h>
#include <cairo.h>
#include <cairo-pdf.h>
int
main(void)
{
cairo_surface_t *surface;
surface = cairo_pdf_surface_create("truetype-size.pdf", 250, 250);
{
cairo_t *cr;
double font_size;
double y = 0.0;
cr = cairo_create(surface);
/* Select scalable TrueType font */
/* DejaVu fonts: http://dejavu-fonts.org/ */
cairo_select_font_face(cr,
"DejaVu Sans Mono",
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
for (font_size = 8.0; font_size <= 10; font_size += 0.125) {
char font_size_text[128];
y += 10.0;
/* Render font size */
cairo_set_font_size(cr, 8.0);
cairo_move_to(cr, 0.0, y);
snprintf(font_size_text, 128, "%.3f", font_size);
cairo_show_text(cr, font_size_text);
/* Render text */
cairo_set_font_size(cr, font_size);
cairo_move_to(cr, 35.0, y);
cairo_show_text(cr, "abcdefghijklm");
}
cairo_destroy(cr);
}
cairo_surface_finish(surface);
cairo_surface_destroy(surface);
return 0;
}
</pre>
See the first line how to build this program. This program outputs "truetype-size.pdf" to the current directory.
I'll attach two PDFs. One is generated by the current master ( http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=fb550bf4666586eedf840f7331c4796ad0739f1d ). Another is generated with the following change with the current master:
<pre>
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index bbebabd..39b0e78 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -311,7 +311,7 @@
if ( FT_IS_SCALABLE( size->face ) )
{
error = tt_size_reset( ttsize );
- ttsize->root.metrics = ttsize->metrics;
+ /* ttsize->root.metrics = ttsize->metrics; */
}
return error;
</pre>
Could you confirm whether the current behavior (8 * 64 to 9.49... * 64 are treated as the same size) is expected or not?
|