freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ft-devel] Having trouble rendering emojis with FreeType


From: Moazin Khatri
Subject: [ft-devel] Having trouble rendering emojis with FreeType
Date: Wed, 15 May 2019 22:00:53 +0500

Hi everyone,

I have been trying to use FreeType to render emojis. The goal was to see how FreeType handles CBDT based fonts (by stepping through the code in GDB) in the hope that it'd give me a better idea of how it'll handle OT-SVG fonts. However, I couldn't make it work. Following is a description of the whole issue. The code necessary to reproduce the case is attached.

What am I trying to do here?
I am trying to render emojis from a font called `joypixels-android'. You can get the font file here. It's `JoyPixels 4.5 Free' and I am using the font file that can be found in the `Android' folder of the zip that you'll download from the site.

How am I trying to do it?
You can find the code in `hello.c' and compile it using `Makefile'. After getting through the boiler plate, all I am doing is using `FT_Get_First_Char' and `FT_Get_Next_Char' to get all the `charcodes' and their corresponding `glyph indexes'. For each such pair, I am calling `FT_Load_Glyph' and then `FT_Render_Glyph'. In the code you'll see that I am calling `FT_Set_Char_Size' to set the size. Not sure if it makes any sense with `CBDT' fonts, but I have tried removing it. The problem stays!

What's the problem?
If I call `FT_Set_Char_Size' in the program, it returns error code 0x17 which is `Invalid Pixel Size'. Secondly, `FT_Load_Glyph' returns error code 0x24 which is `Invalid Size Handle'. `FT_Load_Glyph' returns the same even if I don't call `FT_Set_Char_Size' at all. 

Where are the errors coming from?
The error 0x17, `Invalid Pixel Size' coming from `FT_Set_Char_Size' comes from the function `FT_Match_Size' which is in `./src/base/ftobjs.c:2924'. The trace message:
"FT_Match_Size: no matching bitmap strike" also comes up. 
The error 0x24, `Invalid Size Handle' comes from `TT_Load_Glyph' which is in `./src/truetype/ttgload.c:2718'. More specifically from the following lines:
2831     /* if FT_LOAD_NO_SCALE is not set, `ttmetrics' must be valid */
2832     if ( !( load_flags & FT_LOAD_NO_SCALE ) && !size->ttmetrics.valid )
2833     {
2834       error = FT_THROW( Invalid_Size_Handle );
2835       goto Exit;
2836     }
2837

My guess, so far?
Something that really seems suspicious is that the my code doesn't make into this `if' statement, while the comment indicates it should. The snippet is from `TT_Load_Glyph' which is in `./src/truetype/ttgload.c:2718':
2733     /* try to load embedded bitmap (if any) */
2734     if ( size->strike_index != 0xFFFFFFFFUL      &&
2735          ( load_flags & FT_LOAD_NO_BITMAP ) == 0 &&
2736          IS_DEFAULT_INSTANCE                     )
2737     { 
The reason why it doesn't do this is `size->strike_index' has the value `0x0xFFFFFFFFUL'. So I tried to follow the code to see why strike index was being set to this value. Turns out, it's set to this value at the time when the `face->size' object is created. My guess is, some code in between calling `FT_New_Face' and `FT_Load_Glyph' is supposed to set this strike index. Maybe this should have happened in `FT_Set_Char_Size' but it also runs into an error before reaching that point, as I have already mentioned.

Files attached
  1. hello.c: The main code
  2. Makefile: The Makefile for linking it to the FreeType I have installed on my machine
  3. Makefile-debug: The Makefile I am using to link it with a gdb debuggable build of FreeType with tracing enabled.
  4. trace.txt: Contains a very verbose trace of the program. I have removed the last lines because they were simple repetitions (due to the while loop).
Notes: 
  1. I am linking against `FreeType 2.10.0'
  2. I am getting the same issue with any other emoji font I can find.
Please feel free to ask me for more details. :)

Thank you,
Moazin

Attachment: trace.txt
Description: Text document

Attachment: Makefile
Description: Binary data

Attachment: Makefile-debug
Description: Binary data

Attachment: hello.c
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]