Alexei Podtelezhnikov | 23 Nov 03:20 2014
Picon

[ft] Rendering differences between 2.3.12 and 2.5.3

> If the text rendered by freetype is only a little bit wider than it
> used to be, whole words might suddenly end up on a new line
> which can mess up the whole layout.

You've got to admit that 2.5.3 looks better. :)
Yes advances for emboldened text changed,
but ultimately Freetype is not a text layout engine,
so *you* can use old advances if you wish.

This is the change that you want to undo for yourself
http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=cea9d7a6820bf7cca8d79d813908ce085a3d3d5d
Andreas Falkenhahn | 22 Nov 20:48 2014

[ft] Rendering differences between 2.3.12 and 2.5.3

I've been using freetype 2.3.12 for several years now in my application
and I am planning to update to the latest version soon. Unfortunately,
freetype 2.5.3 renders text that uses algorithmic emboldening or shearing
using FT_GlyphSlot_Embolden() and/or FT_GlyphSlot_Oblique() quite differently
than 2.3.12 did (cf. screenshots). 

As I've customers who maintain projects that contain hundreds of pages
of freetype rendered text it's very important that the way text is
rendered is consistent with previous versions or it might break the
layout, especially in case automatic line wrapping is used. If the
text rendered by freetype is only a little bit wider than it used to
be, whole words might suddenly end up on a new line which can mess up
the whole layout.

That's why I'd like to ask whether there is any option to force freetype
2.5.3 to give me the old look of version 2.3.12 or am I forced to
stay with 2.3.12 forever now?

--

-- 
Best regards,
 Andreas Falkenhahn                          mailto:andreas <at> falkenhahn.com
_______________________________________________
Freetype mailing list
Freetype <at> nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype
Marco Wertz | 18 Nov 18:35 2014
Picon
Picon

[ft] Drawing monochrome pixels into byte buffer

Hi,

what's the most efficient way to draw non-antialiased pixels into a byte buffer? I've had a 
look at FT_PIXEL_MODE_MONOCHROME but this uses only 1 bit per pixel whereas I want FreeType
to always plot 1 byte per pixel (255 for visible and 0 for invisible pixels). Setting "num_grays"
of FT_Bitmap to 2 didn't seem to have any effect with FT_Outline_Render().

So is there an easy way to make FT_Outline_Render() or FT_Outline_Get_Bitmap() draw monochrome
pixels as bytes instead of bits or do I have to do two passes, i.e. first draw monochrome
bits into a temporary bitmap and then map them to bytes?

Thanks!

Marco
Marco Wertz | 16 Nov 15:39 2014
Picon
Picon

[ft] Manually constructing an FT_Outline

Hello,

are there any convenience functions or macros to manually construct an FT_Outline in a way that is
similar to the FT_Stroker APIs? e.g. functions like FT_Outline_LineTo(), FT_Outline_CubicTo()....would
come in really handy or do I really have to do all this manually?

Marco
Marco Wertz | 15 Nov 15:15 2014
Picon
Picon

[ft] FT_Stroker_ParseOutline() with optional rewind

Hi,

it would've been nice if there had been an option to tell FT_Stroker_ParseOutline() not to
rewind the stroker object. Currently, it seems to be impossible to simply add new subpaths
to an existing stroker without getting the stroker rewinded first or am I missing something
here?

That's why I have written a function named FT_Stroker_ParseOutline_NoRewind() that is the
same as FT_Stroker_ParseOutline() but doesn't call FT_Stroker_Rewind().

Marco 
Marco Wertz | 12 Nov 20:44 2014
Picon
Picon

[ft] Miter join styles

Please have a look at the attached image. I want FreeType to stroke the shape as indicated by
the black lines at the top. Currently, it just draws what you can see in the white shape with
the line join at the top of the shape not looking very nice. It'd look much nicer if lines
were joined as indicated by the black lines. Is there any way to achieve this look?

I'm currently using the following stroker setting:

    FT_Stroker_Set(stroker, (int) ((double) thickness * 32.0), FT_STROKER_LINECAP_BUTT,
FT_STROKER_LINEJOIN_MITER_FIXED, 128 << 16);	

I have played with the miter limit argument and tried everything from 0 to 1024 but it doesn't make
a difference.

Any ideas how I can achieve the look indicated by the black lines in the attached image?

Thanks!

Marco

_______________________________________________
Freetype mailing list
Freetype <at> nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype
Stanislav Baiduzhyi | 11 Nov 14:27 2014
Picon

[ft] Glyph translucency

Hi All,

I've noticed interesting behaviour in Qt5 which I cannot reproduce using freetype directly. Could anyone tell me how to achieve this? Here are the screenshots:

Top is Qt4, bottom is Qt5, both are using enabled subpixel rendering, default LCD filter, slight hinting.

Also, here is minimal app that uses freetype directly, I'm using it to learn and experiment with freetype API:

And this small app renders fonts identical to Qt4, and I wasn't able to modify it to render similar to Qt5 no matter what I changed.

I'm pretty sure that's freetype rendering and not Qt because I've intercepted and printed slot->bitmap.buffer image right after FT_Render_Glyph invocation. Please see the hex output below.

What I've tried so far:

1. FT_Load_Glyph, arguments are the same between Qt4 and Qt5 and test app.
2. FT_Set_Transform, copied arguments from Qt5 to test app.
3. FT_Library_SetLcdFilter, everyone is using FT_LCD_FILTER_DEFAULT, but I've tried all of them, others are really different and that screenshot is definitely default.
4. FT_Render_Glyph, not much to try there, LCD rendering has to be used.

I'm out of ideas, if anyone can give me some ideas or suggestions what can I do with freetype to repliate the Qt5 rendering - please tell me. I've been trying to ask the same question on Qt devel mailing lists, but no one was able to answer me.


===== Qt4, letter 'T' image buffer in hex:

0  7 2a 79 c7 eb f2 f2 f3 f8 ff ff ff ff f7 f3 f2 f2 e8 bb 63 1e  4  0  0
0  0  0  0  0  0  0  0  b 3c 9e e4 d9 85 2e  7  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  b 3c 9e e4 d9 85 2e  7  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  b 3c 9e e4 d9 85 2e  7  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  b 3c 9e e4 d9 85 2e  7  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  b 3c 9e e4 d9 85 2e  7  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  b 3c 9e e4 d9 85 2e  7  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  b 3c 9e e4 d9 85 2e  7  0  0  0  0  0  0  0  0  0


===== Qt5, letter 'T' image buffer in hex:

0  6 28 74 c4 ea f2 f2 f3 f8 ff ff ff ff f7 f3 f2 f2 e8 bd 67 20  4  0  0
0  0  0  0  0  0  0  0  a 39 99 e1 db 8b 31  8  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  a 39 99 e1 db 8b 31  8  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  a 39 99 e1 db 8b 31  8  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  a 39 99 e1 db 8b 31  8  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  a 39 99 e1 db 8b 31  8  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  a 39 99 e1 db 8b 31  8  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  a 39 99 e1 db 8b 31  8  0  0  0  0  0  0  0  0  0


_______________________________________________
Freetype mailing list
Freetype <at> nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype
Marco Wertz | 8 Nov 18:15 2014
Picon
Picon

[ft] FT_Outline_Get_BBox() negative overflow


I've encountered a strange issue with FT_Outline_Get_BBox(). When getting the dimensions
of the following shape bbox.yMin overflows into the negative:

	setvector(v1, 28800, 9600);
	FT_Stroker_BeginSubPath(stroker, &v1, 0);
	FT_Stroker_LineTo(stroker, &v1);

	setvector(v1, 28800, 6400);
	FT_Stroker_LineTo(stroker, &v1);
		
	setvector(v1, 28800, 10666);
	setvector(v2, 22400, 10666);
	setvector(v3, 22400, 6400);	
	FT_Stroker_CubicTo(stroker, &v1, &v2, &v3);
	
	setvector(v1, 22400, 2133);
	setvector(v2, 28800, 2133);
	setvector(v3, 28800, 6399);
	FT_Stroker_CubicTo(stroker, &v1, &v2, &v3);

Here is the result returned by FT_Outline_Get_BBox():

        BBOX: 22400 -2147474048 28866 9599

Is this a bug or have I done something wrong here? 

Small demo source attached.

Marco

#include <stdio.h>
#include <math.h>

#include <ft2build.h> 
#include FT_FREETYPE_H 
#include FT_GLYPH_H 
#include FT_OUTLINE_H 
#include FT_SYNTHESIS_H 
#include FT_STROKER_H
#include FT_BBOX_H

#define setvector(pv, px, py) (pv).x = (px); (pv).y = (py);

static FT_Library freetype_library = NULL;

int main(int argc, char *argv[])
{
	FT_Stroker stroker;
	FT_UInt points, contours;
	FT_Outline outline;
	FT_BBox bbox;
	FT_Vector v1, v2, v3;
			
	FT_Init_FreeType(&freetype_library);
	
	FT_Stroker_New(freetype_library, &stroker);

	setvector(v1, 28800, 9600);
	FT_Stroker_BeginSubPath(stroker, &v1, 0);
	FT_Stroker_LineTo(stroker, &v1);

	setvector(v1, 28800, 6400);
	FT_Stroker_LineTo(stroker, &v1);
		
	setvector(v1, 28800, 10666);
	setvector(v2, 22400, 10666);
	setvector(v3, 22400, 6400);	
	FT_Stroker_CubicTo(stroker, &v1, &v2, &v3);
	
	setvector(v1, 22400, 2133);
	setvector(v2, 28800, 2133);
	setvector(v3, 28800, 6399);
	FT_Stroker_CubicTo(stroker, &v1, &v2, &v3);
				
	FT_Stroker_EndSubPath(stroker);
	
	FT_Stroker_GetBorderCounts(stroker, FT_STROKER_BORDER_LEFT, &points, &contours);
		
	memset(&outline, 0, sizeof(FT_Outline));
	FT_Outline_New(freetype_library, 1024, 512, &outline);

	outline.n_points = 0;
	outline.n_contours = 0;
	FT_Stroker_Export(stroker, &outline);	
				
	FT_Stroker_Done(stroker);
		
	FT_Outline_Get_BBox(&outline, &bbox);

	printf("BBOX: %d %d %d %d\n", bbox.xMin, bbox.yMin, bbox.xMax, bbox.yMax);
	
	FT_Outline_Done(freetype_library, &outline);	
	FT_Done_FreeType(freetype_library);
			
	return 0;
}
	
_______________________________________________
Freetype mailing list
Freetype <at> nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype
Kristupas Antanavicius | 3 Nov 20:40 2014
Picon

[ft] Compiling FreeType for Android

Hi,

I'm in a need to compile FreeType using Android NDK build tool. I'm using Windows 7 64-bit platform (Probably doesn't really matter, I hope)

So far I have tried this .mk file, but it generated a million warning and errors.

include $(CLEAR_VARS)
LOCAL_MODULE    := freetype
FT_PATH := $(LOCAL_PATH)/libs/freetype
LOCAL_C_INCLUDES := $(FT_PATH)/include \
$(FT_PATH)/src/autofit
LOCAL_SRC_FILES := \
$(FT_PATH)/src/autofit/autofit.c

include $(BUILD_STATIC_LIBRARY)

It would be nice if you could give me some guide lines of how I am supposed to compile FreeType with Android NDK, or point me to some place that might be able to help me.

Thanks!
_______________________________________________
Freetype mailing list
Freetype <at> nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype
Marco Wertz | 28 Oct 14:46 2014
Picon
Picon

[ft] Determining pixel dimensions for bitmap

Hi,

when using FT_Outline_Get_BBox() to get the dimensions of the outline, the values are all in the 26.6 fixed
point format. How do I determine the optimal pixel size for a bitmap to pass to FT_Outline_Get_Bitmap() so
that the outline fits *exactly* into the bitmap dimensions?

The obvious approach would be something like this:

width = bbox.xMax - bbox.xMin;
height = bbox.yMax - bbox.yMin;

pixelwidth = width >> 6;
pixelheight = height >> 6;

if((width & 0x3f) > 31) pixelwidth++;
if((height & 0x3f) > 31) pixelheight++;

This will add another pixel in case the fractional part of the 26.6 fixed point value is >= 0.5. But I'm not
sure if this is the right approach.... is there maybe an "official" way of determining the pixel
allocation size for the bitmap passed to FT_Outline_Get_Bitmap() in order to get an *exact* fit?

Thanks

Marco
Marco Wertz | 28 Oct 10:58 2014
Picon
Picon

[ft] Drawing unfilled shapes with FreeType2

Hi,

I already asked this question in my last e-mail on Saturday but it was probably overlooked, so here it is
again: How can I get FreeType2 to draw only the outline of my FT_Outline object with a fixed pixel stroke
width? When I use FT_Outline_Get_Bitmap() FreeType2 always fills the shape and I don't see any API that
allows me to say "please do not fill the shape!" ... FT_Outline_Render() also doesn't seem to have an
option to make FreeType2 draw unfilled shapes. Could anybody point me to the right APIs? Thanks!

Marco

Gmane