TCAX 字幕特效制作工具官方论坛 | ASS | TCAS | Python | Aegisub | Lua

 找回密码
 新人加入
查看: 5097|回复: 7
打印 上一主题 下一主题

Positioning Issue of Texts [复制链接]

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

跳转到指定楼层
楼主
发表于 2012-2-3 16:52:53 |只看该作者 |倒序浏览
In order to meet the way that both cairo and magick used to position the texts, the TCAX needs to be updated mainly focusing on its position algorithms.

1. meaning of PIX[0] of text PIXs will be changed to 'the offsets to the pen' while the old meaning is 'the distances from the virtual left-top to the bounding-box of the text glyph'.

2. font size definition will also be changed. from FT_SIZE_REQUEST_TYPE_REAL_DIM to FT_SIZE_REQUEST_TYPE_NOMINAL.


for reference, see,
  1.   FT_GlyphSlot  slot = face->glyph;  /* a small shortcut */
  2.   FT_UInt       glyph_index;
  3.   int           pen_x, pen_y, n;


  4.   ... initialize library ...
  5.   ... create face object ...
  6.   ... set character size ...

  7.   pen_x = 300;
  8.   pen_y = 200;

  9.   for ( n = 0; n < num_chars; n++ )
  10.   {
  11.     /* load glyph image into the slot (erase previous one) */
  12.     error = FT_Load_Char( face, text[n], FT_LOAD_RENDER );
  13.     if ( error )
  14.       continue;  /* ignore errors */

  15.     /* now, draw to our target surface */
  16.     my_draw_bitmap( &slot->bitmap,
  17.                     pen_x + slot->bitmap_left,
  18.                     pen_y - slot->bitmap_top );

  19.     /* increment pen position */
  20.     pen_x += slot->advance.x >> 6;
  21.   }
复制代码
from http://www.freetype.org/freetype2/docs/tutorial/step1.html


Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

沙发
发表于 2012-2-3 17:29:08 |只看该作者
While, after trial and error, I find we only need to change FT_SIZE_REQUEST_TYPE_REAL_DIM to FT_SIZE_REQUEST_TYPE_NOMINAL, then every thing goes fine.





Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

板凳
发表于 2012-2-4 14:14:56 |只看该作者
Too bad, I just cannot get the same result of text layout from tcaxLib, cairo, magick, none of them produce the same result, +-1 pixel error occurs by chance. Only a few font may produce the same result. : (

+-1 pixel error of position

And what's worse, it seems that the font size definition of ASS (or say VSFilter) is no good. See,

Font Size Set to 50, ASS - red, TCAS - blue

FT_SIZE_REQUEST_TYPE_NOMINAL
FT_SIZE_REQUEST_TYPE_NOMINAL
FT_SIZE_REQUEST_TYPE_REAL_DIM

Conclusion: if we use FT_SIZE_REQUEST_TYPE_REAL_DIM, the TCAS result can fit better to ASS, but the result of text is too small (smaller than a font size with 50 should be). However the good news is that, with most Japanese fonts, both of the definitions are OK. Sigh~~





Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

地板
发表于 2012-2-29 16:54:39 |只看该作者

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

5#
发表于 2012-3-3 15:21:01 |只看该作者

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

6#
发表于 2012-3-16 08:42:59 |只看该作者
I was informed that NyuFX didn't have the pixelate text positioning issue. So I think it can be a good stuff to refer...

I'll contact Youka in the near future.

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

7#
发表于 2012-3-18 13:34:06 |只看该作者

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

8#
发表于 2012-3-18 14:25:16 |只看该作者
您需要登录后才可以回帖 登录 | 新人加入

GitHub|TCAX 主页

GMT+8, 2024-11-24 21:16

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部
RealH