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

标题: Positioning Issue of Texts [打印本页]

作者: milkyjing    时间: 2012-2-3 16:52:53     标题: Positioning Issue of Texts

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



作者: milkyjing    时间: 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.






作者: milkyjing    时间: 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~~







图片附件: [+-1 pixel error of position] font2.png (2012-2-4 14:14:44, 5 KB) / 下载次数 1113
http://tcax.org/forum.php?mod=attachment&aid=MjI2fDYyZDhiMDYxfDE3MzIyMjM4MzJ8MHww



图片附件: [FT_SIZE_REQUEST_TYPE_NOMINAL] 2012-02-03_234954.png (2012-2-4 13:57:45, 13.78 KB) / 下载次数 1127
http://tcax.org/forum.php?mod=attachment&aid=MjI1fGJhNjQwNDBlfDE3MzIyMjM4MzJ8MHww



图片附件: [FT_SIZE_REQUEST_TYPE_NOMINAL] 2012-02-03_234834.png (2012-2-4 13:57:45, 12.32 KB) / 下载次数 1126
http://tcax.org/forum.php?mod=attachment&aid=MjI0fDQ2MGVjYzZifDE3MzIyMjM4MzJ8MHww



图片附件: [FT_SIZE_REQUEST_TYPE_REAL_DIM] 2012-02-03_235235.png (2012-2-4 13:57:45, 8.2 KB) / 下载次数 1095
http://tcax.org/forum.php?mod=attachment&aid=MjIzfDc3NjQ4MGNlfDE3MzIyMjM4MzJ8MHww


作者: milkyjing    时间: 2012-2-29 16:54:39

http://source.winehq.org/git/win ... 32/freetype.c#l3377

http://source.winehq.org/git/win ... 32/freetype.c#l3284

http://source.winehq.org/git/win ... 32/freetype.c#l3547

http://www.microsoft.com/typography/otspec140/vdmx.htm

http://code.google.com/p/libass/ ... bass/ass_font.c#215

http://geos.icc.ru:8080/scripts/WWWBinV.dll/ShowR?ttf.rfh

http://www.koders.com/c/fid97865 ... 9D0D06DE4ABB6F.aspx






作者: milkyjing    时间: 2012-3-3 15:21:01

http://www.tcax.org/forum.php?mo ... =1654&fromuid=2
作者: milkyjing    时间: 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.


作者: milkyjing    时间: 2012-3-18 13:34:06

http://blogs.msdn.com/b/oldnewth ... 05/26/10015253.aspx

http://msdn.microsoft.com/en-us/library/dd144891(VS.85).aspx

http://www.microsoft.com/typography/default.mspx

http://www.truetype-typography.com/

http://msdn.microsoft.com/en-us/library/dd183441(VS.85).aspx

http://www.microsoft.com/mspress/books/sampchap/2344c.aspx



作者: milkyjing    时间: 2012-3-18 14:25:16

http://www.codeguru.com/cpp/g-m/gdi/gdi/article.php/c10621

http://msdn.microsoft.com/en-us/library/dd145091(v=vs.85).aspx

http://support.microsoft.com/default.aspx?scid=kb;en-us;243285

http://support.microsoft.com/kb/q87115/






欢迎光临 TCAX 字幕特效制作工具官方论坛 | ASS | TCAS | Python | Aegisub | Lua (http://tcax.org/) Powered by Discuz! X2