freetype-devel
[Top][All Lists]
Advanced

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

[ft-devel] FreeType with Emscripten: problems with some fonts scale


From: Max Savenkov
Subject: [ft-devel] FreeType with Emscripten: problems with some fonts scale
Date: Thu, 1 May 2014 11:44:00 +0400

I have compiled FreeType 2.5.3 to JavaScript using the latest version
of Emscripten. I'm using it through Allegro game programming library.
Here's my problem: one of the fonts I use does not scale, no matter
what size I specify. However, it DOES scale in Win32 build. I'm trying
to dig into FreeType code to see what's wrong, but I have no prior
experience with FreeType inner workings, so I decided to ask for help
here. I realized that Emscripten/JavaScript isn't one of supported
platforms, so I'm not asking for a solution, just some pointers where
to look in code to see what's wrong. I have already eliminated my own
code and Allegro's code as sources of problem.

To diagnose the problem, I have enabled debug log in FreeType and
compared output in Windows and JavaScript versions. It goes pretty
much the same, until this part when I try to actually render some
glyphs:

------------------------------------------------------------------------------------------
Windows:

FT_Load_Glyph: glyph index 55
tt_face_lookup_table: 02F78328, `glyf' -- found table.
Glyph 55
  # of contours: 1
  xMin:  128  xMax:  896
  yMin:  128  yMax: 1024
  advance width (font units): 1024
  left side bearing (font units): 128
  advance height (font units): 1024
  top side bearing (font units): 0
  Instructions size: 0
  x advance: 1024
  y advance: 0
  linear x advance: 1024
  linear y advance: 1024
latin vertical edge hinting (style `latn_dflt')
  ANCHOR: edge 0 (opos=9.00) and 3 (opos=63.00) snapped to 9.00 and 63.00
  LINK: edge 3 (opos=63.00) linked to 63.00, dist was 54.00, now 54.00
  STEM: edge 1 (opos=27.00) linked to 2 (opos=45.00) snapped to 27.00 and 45.00
  ADJUST: edge 3 (pos=63.00) moved to 63.00

latin horizontal edge hinting (style `latn_dflt')
  BLUE_ANCHOR: edge 0 (opos=9.00) snapped to 9.00, was 9.00 (anchor=edge 0)
  BLUE: edge 2 (opos=72.00) snapped to 72.00, was 72.00
  LINK: edge 1 (opos=63.00) linked to 63.00, dist was -9.00, now -9.00

  x advance: 4608
  y advance: 0
  linear x advance: 4718592
  linear y advance: 4718592
FT_Outline_Decompose: Outline 0
  move to (0.00, 58.50)
  line to (0.00, 63.00)
  line to (27.00, 63.00)
  line to (54.00, 63.00)
  line to (54.00, 58.50)
  line to (54.00, 54.00)
  line to (45.00, 54.00)
  line to (36.00, 54.00)
  line to (36.00, 27.00)
  line to (36.00, 0.00)
  line to (27.00, 0.00)
  line to (18.00, 0.00)
  line to (18.00, 27.00)
  line to (18.00, 54.00)
  line to (9.00, 54.00)
  line to (0.00, 54.00)
  line to (0.00, 58.50)
FT_Outline_Decompose: Done
MD5 checksum for 63x54 bitmap:
  9B3AA693700A7B8812C0CBC0A4BFE102

------------------------------------------------------------------------------------------

JavaScript:

TT_Load_Glyph: glyph index 55
tt_face_lookup_table: 0x5360d0, `glyf' -- found table.
Glyph 55
  # of contours: 1
  xMin:  128  xMax:  896
  yMin:  128  yMax: 1024
  advance width (font units): 1024
  left side bearing (font units): 128
  advance height (font units): 1024
  top side bearing (font units): 0
  Instructions size: 0
  x advance: 1024
  y advance: 0
  linear x advance: 1024
  linear y advance: 1024
  x advance: 4608
  y advance: 0
  linear x advance: 4718592
  linear y advance: 4718592
FT_Outline_Decompose: Outline 0
  move to (0.00, 13.00)
  line to (0.00, 14.00)
  line to (6.00, 14.00)
  line to (12.00, 14.00)
  line to (12.00, 13.00)
  line to (12.00, 12.00)
  line to (10.00, 12.00)
  line to (8.00, 12.00)
  line to (8.00, 6.00)
  line to (8.00, 0.00)
  line to (6.00, 0.00)
  line to (4.00, 0.00)
  line to (4.00, 6.00)
  line to (4.00, 12.00)
  line to (2.00, 12.00)
  line to (0.00, 12.00)
  line to (0.00, 13.00)
FT_Outline_Decompose: Done
MD5 checksum for 14x12 bitmap:
  DE5B6F89C6702E7804018CE6D046ACB9

------------------------------------------------------------------------------------------

As you can see, there are two differences here. First, JavaScript
version omits hinting. Second, outline sizes are all wrong in
JavaScript, even though I render font at exactly the same size.
So it seems to me that for some reason glyph and its outline simple do
not get scaled in JavaScript version. Could anyone point me where to
look in FreeType code to check why does scaling isn't happening?



reply via email to

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