Yaron Cohen-Tal | 26 Jun 10:35 2015
Picon

[ft] Building Freetype 2.6 for Android fails with "arm-linux-androideabi-ranlib: not found".

Hi,

Did any1 succeed with building and installing freetype in Android? I use the following script to build it:

    #!/bin/sh
    export PLATFORM_PREFIX=/opt/android/ndk-standalone_toolchain-r10e-4.9
    export NDKROOT=/opt/android/android-ndk-r10e
    export ARCH_ABI="arm-linux-androideabi-4.9"
    export ANDROID_PLATFORM=android-21
    sudo rm -rf $PLATFORM_PREFIX
    sudo mkdir -p $PLATFORM_PREFIX
    sudo $NDKROOT/build/tools/make-standalone-toolchain.sh --platform=$ANDROID_PLATFORM \
        --system=linux-x86_64 --arch=arm --abis=armeabi-v7a --ndk-dir=$NDKROOT \
        --toolchain=$ARCH_ABI --install-dir=$PLATFORM_PREFIX
    sudo chmod -R 755 $PLATFORM_PREFIX
    export PATH=$PLATFORM_PREFIX/bin:$PATH
    export HOST=arm-linux-androideabi
    BUILD_DIR=freetype-android-standalone-2.6
    rm -rf $BUILD_DIR
    mkdir $BUILD_DIR
    cd $BUILD_DIR
    ../../src/freetype-2.6/configure --host=$HOST --prefix=$PLATFORM_PREFIX \
        --without-zlib --with-png=no
    make -j4
    sudo make install


And the "sudo make install" step it fails with:

libtool: install: arm-linux-androideabi-ranlib /opt/android/ndk-standalone_toolchain-r10e-4.9/lib/libfreetype.a
/home/yaronct/build/freetype-android-standalone-2.6/libtool: 1: eval: arm-linux-androideabi-ranlib: not found
/home/yaronct/src/freetype-2.6/builds/unix/install.mk:32: recipe for target 'install' failed
make: *** [install] Error 127


but the file exists and it's in the "PATH":
which arm-linux-androideabi-ranlib /opt/android/ndk-standalone_toolchain-r10e-4.9/bin/arm-linux-androideabi-ranlibAnd has the required permissions:-rwxr-xr-x 1 root root 732696 Nov 4 05:27 /opt/android/ndk-standalone_toolchain-r10e-4.9/bin/arm-linux-androideabi-ranlibI'm using Debian 8.1 for AMD64.

Thanx,
Yaron.
_______________________________________________
Freetype mailing list
Freetype <at> nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype
Lawrence D'Oliveiro | 26 Jun 00:34 2015
Picon

Re: [ft] Help with making sure all characters fit in Certain pixel dimensions

On Thu, 25 Jun 2015 16:10:06 -0500, Shomari Sharpe wrote:

> I'm creating an font system that uses bitmap fonts generated from
> freetype to be used in my game engine. It appears that even though I
> have specified a pixel size of 64px there are characters that are
> rendered outside the actual pixel size I have specified though the
> actual FT_Face->Glyph->Bitmap is actually smaller the 64px. There
> also seems to be a big gap of approximately 12px above glyphs.

The interpretation of the “size” of the font is very much up to the
font designer. Looking at the bitmap you supplied, the baseline of the
text is situated 64 pixels from the top of the image. But you forgot to
take into account descenders--those characters that extend below the
baseline.

If you want text to fit into an exact cell size, I would suggest
rendering all the needed glyphs into a larger image while measuring
them individually, to find the largest extents. Then use those largest
extents to compute a scale factor to shrink them all down uniformly to
fit into the desired cell dimensions.

The result will probably not look as good as the font designer intended.

_______________________________________________
Freetype mailing list
Freetype <at> nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype
Shomari Sharpe | 25 Jun 23:10 2015
Picon

[ft] Help with making sure all characters fit in Certain pixel dimensions

Hi,
I'm creating an font system that uses bitmap fonts generated from freetype to be used in my game engine. It appears that even though I have specified a pixel size of 64px there are characters that are rendered outside the actual pixel size I have specified though the actual FT_Face->Glyph->Bitmap is actually smaller the 64px. There also seems to be a big gap of approximately 12px above glyphs. Below is the code I am using for placement on a flat bitmap.

------------------------------------- CODE -----------------------------------------
font_size = 64;

        /* convert to an anti-aliased bitmap */
        FT_Render_Glyph( freetype_face->glyph, FT_RENDER_MODE_LCD );

        //This reference will make accessing the bitmap easier
        FT_Bitmap& bitmap=freetype_face->glyph->bitmap;
       
for (int y = 0; y < bitmap.rows; y++)
            for (int x = 0; x < bitmap.width; x++)
            {
                pixel_t pixel = { 0, 0, 0, bitmap.buffer[bi]};
                putpixel((xoffset+x), (yoffset+y+ font_size-abs(freetype_face->glyph->bitmap_top)), maxwidth, fontdata, pixel);
                bi++;
            }
xoffset += bitmap.width;

---------------------------------- END CODE ------------------------------------

I've included a sample png image showing the results. Help please?


Regards,
Shomari Sharpe
_______________________________________________
Freetype mailing list
Freetype <at> nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype
Jun Dai | 18 Jun 01:39 2015

[ft] Possible Bug in FT_Get_FSType_Flags

Deal FreeType Organization,

Thank you for this wonderful library. This is Jun Dai from Prevo Tech.

Currently I experience a strange behave from FT_Get_FSType_Flags call. I load a True Type font from system and use FT_Get_FSType_Flags call to check if this font is editable or not.  
According to FreeType document, the FT_GetFSType should return one of the FT_FSTYPE_XXX flag. But I receive a 1, which is not listed as any of those flags.
The test font is a restricted true type font. I was expecting a return of FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING flag.

 

The following is the testing code.
I am on windows 8.1 pro.
FreeType is 2.6 windows build.  

 

--- Start of Test Code ---

 

int _tmain(int argc, _TCHAR* argv[])

{

       //Free Type Library, it use to load font for library

       FT_Library _library = NULL;

 

       //initial Free Type library;

       FT_Error error = FT_Init_FreeType( &_library );

       if(error)

       {

             return 0;

       }

       //windows font, which is a restricted font

       const char* WINDOWSFONT = "C:\\Windows\\Fonts\\sanss___.ttf";

 

       //load file

       FILE* ffile = NULL;

       int errorcode = fopen_s(&ffile, WINDOWSFONT, "rb");

       if(errorcode == 0 && ffile != NULL)

       {

             //copy font file into memory

             fseek(ffile, 0, SEEK_END);

             int fontFileSize = ftell(ffile);

             fseek(ffile, 0, SEEK_SET);

             BYTE* fontFile = new BYTE[fontFileSize];

             int remain = fontFileSize;

             BYTE* tempbuff = fontFile;

             while(remain > 0)

             {

                    int rbyte = fread(tempbuff, 1, remain, ffile);

                    if(rbyte < 1) break;

                    remain -= rbyte;

                    tempbuff += remain;

             }

             fclose(ffile);

 

             //load font face.

             FT_Face fontface = NULL;

             error=FT_New_Memory_Face(_library, fontFile, fontFileSize, 0, &fontface);

             if (error || fontface ==NULL)

            

             {

                    return 0;

             }

             //check font type flag

             FT_UShort flag = FT_Get_FSType_Flags(fontface);

             switch(flag)

             {

                    case FT_FSTYPE_INSTALLABLE_EMBEDDING:

                    {//Fonts with no fsType bit set may be embedded and permanently installed on the remote system by an application.

                           printf("Font Type INSTALLABLE_EMBEDDING:  %d \n", flag);

                           break;

                    }

                    case FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING:

                    {//Fonts that have only this bit set must not be modified, embedded or exchanged in any manner without first obtaining

                     //permission of the font software copyright owner.

                           printf("Font Type RESTRICTED_LICENSE_EMBEDDING:  %d \n", flag);

                           break;

                    }

                    case FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING:

                    {//If this bit is set, the font may be embedded and temporarily loaded on the remote system. Documents

                     //containing Preview & Print fonts must be opened ‘read-only’; no edits can be applied to the document.

                           printf("Font Type PREVIEW_AND_PRINT_EMBEDDING:  %d \n", flag);

                           break;

                    }

                    case FT_FSTYPE_EDITABLE_EMBEDDING:

                    {//If this bit is set, the font may be embedded but must only be installed temporarily on other systems.

                     //In contrast to Preview & Print fonts, documents containing editable fonts may be opened for reading,

                     //editing is permitted, and changes may be saved.

                           printf("Font Type EDITABLE_EMBEDDING:  %d \n", flag);

                           break;

                    }

                    case FT_FSTYPE_NO_SUBSETTING:

                    {//If this bit is set, the font may not be subsetted prior to embedding.

                           printf("Font Type NO_SUBSETTING:  %d \n", flag);

                           break;

                    }

                    case FT_FSTYPE_BITMAP_EMBEDDING_ONLY:

                    {//If this bit is set, only bitmaps contained in the font may be embedded; no outline data may be embedded.

                    //If there are no bitmaps available in the font, then the font is unembeddable.

                           printf("Font Type BITMAP_EMBEDDING_ONLY:  %d \n", flag);

                           break;

                    }

                    default:

                    {

                           printf("Font Type unknow:  %d \n", flag);

                           break;

                    }

             }

 

             FT_Done_Face(fontface);

             fontface = NULL;

 

       }

 

       if(_library != NULL)

       {

             FT_Done_FreeType(_library);

             _library = NULL;

       }

       return 1;

}

 

--- End of Test Code ---

 

 

Thank you for your help

 

Jun Dai

_______________________________________________
Freetype mailing list
Freetype <at> nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype
TINTU THOMAS | 12 Jun 08:53 2015
Picon

[ft] How can I Minimize Heap Size in Freetype 2.6?

Hello ,

I was using freetype 2.4 version in my embedded application for rendering ttf files only. It uses about 12 KB heap size, when I set  FT_RENDER_POOL_SIZE to 4096 Bytes.
But in freetype 2.6 ,it takes around 20 KB heap size minimum. Here I could observe ,freetype 2.6 doesn't use raster_pool anymore.
So can you answer these...

1. What is the minimum heap size needed for freetype to rasterize ttf files as a binary image? (I don't need smoothing and gray shades)

2.How can I minimize heap size in freetype 2.6 for this purpose?

Regards,
Tintu Thomas
_______________________________________________
Freetype mailing list
Freetype <at> nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype
follower | 12 Jun 02:34 2015

[ft] Change in monochrome rendered font behaviour from 2.5.0.1 to 2.5.1

Hi,

I've encountered a change in behaviour which I've narrowed down to
being between libfreetype6 version 2.5.0.1 and 2.5.1 (I originally
encountered the issue moving code from 2.4.8 & 2.5.2 and can confirm
the new behaviour continues in 2.6).

Specifically, the change is that monochrome rendered fonts (in small
sizes for a low resolution display) appear noticeably "worse" unless
the `FT_LOAD_FORCE_AUTOHINT` option is supplied. It's not clear to me
if this is a bug or an intended change in behaviour.

The following demonstrates the difference in behaviour (when viewed
with a monospace font) with a 14 pt letter 'e' from
`DejaVuSansCondensed-Bold.ttf`:

LD_PRELOAD=../libfreetype6_2.4.8-1ubuntu2.2_amd64/usr/lib/x86_64-linux-gnu/libfreetype.so.6
python fontdemo.py
..###..
.#####.
##...##
#######
#######
##.....
.######
..####.

LD_PRELOAD=../libfreetype6_2.5.1-1ubuntu2_amd64/usr/lib/x86_64-linux-gnu/libfreetype.so.6
python fontdemo.py
..###..
######.
##..###
#######
#######
##.....
###..##
.######

Note particularly the bottom right curved portion of the 'e'. (Another
obvious character is 'f' where the vertical changes from 2 to 3 pixels
wide.)

The `fontdemo.py` file is from
<https://gist.githubusercontent.com/dbader/5488053/raw/b835eb8705ad954a0711248c4b52834243c8b28d/fontdemo.py>
via <https://dbader.org/blog/monochrome-font-rendering-with-freetype-and-python>
using `freetype-py`. But the original code I encountered this with
used the PIL/Pillow library in Python.

In the `fontdemo.py` code, when run with 2.5.1+, if I change this:

    self.face.load_char(char, freetype.FT_LOAD_RENDER |
freetype.FT_LOAD_TARGET_MONO)

to this:

    self.face.load_char(char, freetype.FT_LOAD_RENDER |
freetype.FT_LOAD_TARGET_MONO | freetype.FT_LOAD_FORCE_AUTOHINT)

the original behaviour is retained. Unfortunately PIL/Pillow does not
provide a way to supply this option AFAICT:

   <https://github.com/python-pillow/Pillow/blob/1b2f6ae1b8ab89faba678208cae0d0d7007980ad/_imagingft.c#L371>

I seem to recall reading that there was some intentional change in
hinting/grid-fitting for monochrome fonts. Is what I'm seeing a bug or
is this an intentional change in behaviour?

Thanks!

--Philip;
Erlend Langseth | 7 Jun 11:41 2015

[ft] Can't get offset of glyphs right.

Hi!

I'm trying to render text, using FreeType 2. My problem is in offsetting each glyph with respect to their own origin. In this mail, with "offset", I refer to what is called bearingX and bearingY in this illustration.

I first render all glyphs, storing necessary metrics, then use the results to render text.
Given an unsigned char c, this is how I render glyphs, and need to obtain the correct offsets (C++):

FT_Face face;

if (!FT_Load_Char(face, c, 0)) {
      if (!FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL)) {
             if (!FT_Get_Char_Index( face, c )) continue;
                   // Set offset of glyphs accessing face->glyph here.

I have tried to use face->glyph->bitmap_left (and bitmap_top), and also face->glyph->metrics.horiBearingX / 64.0f (and Y), but the results always look arbitrary:

http://a.pomf.se/iudwvo.png      And with inverted yoffset: http://a.pomf.se/jlkngl.png

This is how I render text at the moment (no kerning yet). (Additional question: is width, height, xadvance, yadvance, xoffset and yoffset all metrics I need to render text?)

On lines 27 and 28, you see how I apply the offset. size is the pixel size of the font (note that I "normalize" the metrics by dividing by pixel size in the first place).

Thanks in xadvance!
_______________________________________________
Freetype mailing list
Freetype <at> nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype
katz - | 7 Jun 09:05 2015
Picon

[ft] How to use subpixel hinting in FreeType

Dear FreeType mailing list,

I am a beginner at using FreeType and new to the concept of subpixel hinting. I've read through most API references that seemed related, but I am still not sure how should I use the library to attain RGB (or RGBA?) bitmaps with glyphs hinted on the subpixel level. If there are any examples on this I did not manage to find, please direct me to it.

So here is what I tried doing so far:
I built the library with both the FT_CONFIG_OPTION_SUBPIXEL_RENDERING and the TT_CONFIG_OPTION_SUBPIXEL_HINTING definitions. Here is my program, that runs without errors:
http://pastebin.com/YNhgwwAN

With this method, I end up with a glyph bitmap which is three times wider than the intended size. If this is the right approach, then my question is how should I use this information to get an RGB bitmap with the right size? The code tries to directly map the values of the result bitmap to the RGB channels, but this doesn't seem right:
http://postimg.org/image/gbfdyh0b9/
The colors are obviously too strong.

I guess I am doing something really wrong here, because if I try different sizes (for example: 31) the result will be distorted:
http://postimg.org/image/7s28scn9j/
I am also getting distortions like that seemingly every time, if I don't turn on LCD filtering.

Any help on the subject is greatly appreciated!

Regards,
- katz
_______________________________________________
Freetype mailing list
Freetype <at> nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype
Werner LEMBERG | 6 Jun 05:38 2015
Picon

[ft] Fw: [ft-devel] fitting a text


[Originally sent to the wrong list.]

Please help this guy.

    Werner
From: folkert <folkert <at> vanheusden.com>
Subject: [ft-devel] fitting a text
Date: 2015-06-05 09:24:12 GMT
Hi,

I'm trying to draw text to a bitmap. It should fit the height of the
bitmap and the width can be extended whenever required.
Getting the width right works fine but the height is a problem: a, b, c
fit nicely but g, q and _ fall below the bottom. How can I get this to
work?
My code is:

	int target_height = 50; // height of bitmap

        FT_Library library;
        FT_Face face;
          (void)FT_Init_FreeType(&library);
          (void)FT_New_Face(library, filename.c_str(), 0, &face);

          (void)FT_Set_Char_Size(face, target_height * 64, 0, 100, 0); /* set character size */
        FT_GlyphSlot slot = face->glyph;

          w = 0;
          h = target_height;

	  // calculate resulting width
          for(int n = 0; n < text.size(); n++)
          {
                 if (FT_Load_Char(face, text.at(n), FT_LOAD_RENDER))
                          continue;

                 w += slot->advance.x / 64;
          }

	  // draw text to bitmap
          image = new uint8_t[w * h];
	  memset(image, 0x00, w * h);

          double x = 0.0;
          for(int n = 0; n < text.size(); n++)
          {
		if (FT_Load_Char(face, text.at(n), FT_LOAD_RENDER))
                          continue;

		draw_bitmap(w, h, &slot->bitmap, slot->bitmap_left + int(x / 64.0), target_height -
slot->bitmap_top - slot->advance.y);

		x += slot->advance.x;
          }

          FT_Done_Face(face);
          FT_Done_FreeType(library);

draw bitmap:
    // x_offset is the 'x' from the code above that gets the slot->advance.x added to it for every character
    // x,y here just iterate from 0 to slot->bitmap.width and .height

    int y_offset = target_height - slot->bitmap_top - slot->advance.y;

    image[(y + y_offset) * image_width + x + x_offset] = slot->bitmap.buffer[y * slot->bitmap.width + x];

Folkert van Heusden

_______________________________________________
Freetype-devel mailing list
Freetype-devel <at> nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel
_______________________________________________
Freetype mailing list
Freetype <at> nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype
Werner LEMBERG | 31 May 05:18 2015
Picon

[ft] New FreeType release soon


Folks,

right now I'm trying to fix GX support[*], then I'm going to do a new
release, which will be 2.6.0.  This should happen within a week, I
hope.  In case you feel that something urgent should be fixed also,
please raise your voice.

    Werner

[*] Behdad, it is indeed necessary to interpolate after each design
    tuple.  My implementation already works quite nicely, but there
    are two glitches that I have to identify and correct before
    committing the code to the repository.
puxi | 29 May 09:51 2015
Picon

[ft] Gamma (?) huge difference between FreeType and others (OS X, or even FreeType based MacType)

I'm fully confused. I don't know how to say properly, because I'm not
talking about font's darken/slightly, I'm saying, they just like got
the different "colors" of the results.
Here are some sreenshots (I use Firefox to compare them),
OS X
https://i.imgur.com/XEO7HY0.png
https://i.imgur.com/fQlKntl.png
https://i.imgur.com/xtVscsr.png

Linux/FreeType2 2.5.5-1
https://i.imgur.com/xoOJ4HN.png
https://i.imgur.com/7WJULvj.png
https://i.imgur.com/IOqdU9i.png

MacType (MacType is FreeType based, more details see bottom external links)
https://i.imgur.com/z5vuZQe.png

!!Especially when setting font's gamma valve to high level as that
makes font get more slightly.
MacType with font gamma changes
https://i.imgur.com/n7yhlXj.png

Linux/FreeType with font gamma changes (I use INFINALITY patch to
tweak the gamma value)
https://i.imgur.com/PsGXzmB.png
https://i.imgur.com/9z77xnb.png

Putting them together,
https://i.imgur.com/dpDEEzO.png
https://i.imgur.com/EJdaCQQ.png

As you can see, even the MacType got the results as same as OS X. Only
Linux is so different.  Still not sure it is a "Gamma correction"
issue. If not, what is making Linux font rendering so "weird"?
How to fix it?
Thanks!

External links:
History of gdi++
http://a.pomf.se/vlgkcm.txt

Gmane