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

 找回密码
 新人加入
楼主: Alex
打印 上一主题 下一主题

[已解决] PixTexture color! [复制链接]

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

楼主
发表于 2013-11-3 19:51:37 |显示全部楼层
The problem is because in PixTexture() function, the size of PIX_tex will be resampled to meet the PIX_txt, so, if the size of text PIX varies, the looks of PIX_texture will be different.

how to resolve the issue,
immediately, we've got two ways
1. enlarge PIX_txt (by invoking PixEnlarge() function) to meet the size of PIX_txt
2. create a PIX_tex for each PIX_txt, according to the size of PIX_txt (using PixCrop() function to cut a piece from the original PIX_tex and make a new one, then pass it to PixTexture() function)


Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

沙发
发表于 2013-11-3 21:28:05 |显示全部楼层
Alex 发表于 2013-11-3 21:20
OK

I don't know actually which function have to write first..

check it out on this documentation http://www.tcax.org/docs/tcaxLib/namespacemembers_func.html

PIX is a Python structure (object), and can be passed through Pix.... functions, http://www.tcax.org/forum.php?mod=viewthread&tid=220   (unfortunately, this doc is written in Chinese)

We have several ways to create a PIX object, such as TextPix, (create a PIX from text with specified font), BlankPix (a blank square), and pmgToPix (created a PIX from magick image object).

other functions are to manipulate the PIX object, such as PixBlur, PixTexture.


so, when applying the second approach,

PIX_out = PixTexture(PIX_out, PIX_tex2)

can be

PIX_out = PixTexture(PIX_out, PixCrop(PIX_tex2, 0, 0, PIX_out[1][0], PIX_out[1][1]))

the four parameters can be chose by your decision


Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

板凳
发表于 2013-11-4 23:27:46 |显示全部楼层
Alex 发表于 2013-11-4 22:41
I have another 2 question

Why the position it's not exactly correct, there is space between letter ...
Why the position it's not exactly correct, there is space between letters?


Plz post an image to help me understand your question.


to your 2nd question

see the info below

< alignment = 7 >
#  indicate where to put the texts, you can refer to the number keyboard. Default alignment for horizontal layout is an1, default alignment for vertical layout is an9


the alignment set in the TCC file only affects the Offset of the line.
use an() tag function to apply an alignment effect for your FX

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

地板
发表于 2013-11-5 22:18:53 |显示全部楼层
Alex 发表于 2013-11-5 12:25

any description? I can't get your meaning from the pic

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

5#
发表于 2013-11-7 20:48:41 |显示全部楼层
Alex 发表于 2013-11-5 23:11
When i used pixel, I got some space between letters, I think it's happening for pixels
you can see  ...


the text layout, in the horizontal direction, letters are put with 'advance' distance between each other. not just incremented by just 'width', so there may be space between letters.

you can find more information about text layout, by Googling FreeType Text Layout

glyph.png (5.66 KB, 下载次数: 1229)

glyph

glyph

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

6#
发表于 2013-11-12 22:55:23 |显示全部楼层
Alex 发表于 2013-11-12 18:28
milky!

How can I use width & height to get metrics of text?


if you have a PIX object, there is a quick way to get width and height
  1. width = PIX[1][0]
  2. height = PIX[1][1]
复制代码
if you want to get the pre-calculated metrics of texts, use
  1. # tm info (horizontal)
  2. val_Ascender         = 33        # 字体上行高度
  3. val_Descender        = 34        # 字体下行高度 通常为负数
  4. val_TextWidth        = 35        # 第i句卡拉OK歌词的j个字符的宽度
  5. val_TextHeight       = 36        # 第i句卡拉OK歌词的j个字符的高度
  6. val_TextKerning      = 37        # 第i句卡拉OK歌词的j个字符与之前一个字符的kerning 一句歌词第一个字符的kerning为0
  7. val_TextAdvance      = 38        # 第i句卡拉OK歌词的j个字符的水平步距
  8. val_TextAdvanceDiff  = 39        # 从初始位置到第i句卡拉OK歌词的j个字符的水平步距
  9. val_TextLength       = 40        # 第i句卡拉OK歌词的文字总长度
  10. val_TextInitX        = 41        # 第i句卡拉OK歌词的j个字符的左上角X轴坐标
  11. val_TextInitY        = 42        # 第i句卡拉OK歌词的j个字符的左上角Y轴坐标
  12. val_TextBearingY     = 43        # 第i句卡拉OK歌词的j个字符的Y轴bearing
复制代码
e.g.width of the text in the i(th) line j(th) \k tag,
  1. width = GetVal(val_TextWidth)[i][j]
复制代码
the last but least common way is to use

## Initialize a font and retrieves the metrics of the specified text from the font.
# @param font_file a string, filename of the target font file
# @param face_id an integer, font face id, should always be 1 in TTF files
# @param font_size an integer, font size, in em height
# @param spacing an integer, spacing between texts, can be negative
# @param space_scale a float, scale of white spaces
# @param text a string, the text that is going to be measured
# @return (0 width, 1 height, 2 horiBearingX, 3 horiBearingY, 4 horiAdvance, 5 vertBearingX, 6 vertBearingY, 7 vertAdvance, 8 x_ppem, 9 y_ppem, 10 x_scale, 11 y_scale, 12 ascender, 13 descender, 14 px_height, 15 max_advance)
def TextMetrics(font_file, face_id, font_size, spacing, space_scale, text):

## Retrieve the metrics of the specified text from a font.
# @param font a handler, the handler to the font
# @param text a string, the text that is going to generate a PIX
# @return (0 width, 1 height, 2 horiBearingX, 3 horiBearingY, 4 horiAdvance, 5 vertBearingX, 6 vertBearingY, 7 vertAdvance, 8 x_ppem, 9 y_ppem, 10 x_scale, 11 y_scale, 12 ascender, 13 descender, 14 px_height, 15 max_advance)
def TextMetrics(font, text):



APIs from tcaxLib module can be found on http://www.tcax.org/docs/tcaxLib/namespacemembers_func.html

mofe info about PIX, and TCAS FX, http://www.tcax.org/forum.php?mod=viewthread&tid=220, if I not showed you this link before

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

7#
发表于 2013-11-13 22:01:56 |显示全部楼层
Alex 发表于 2013-11-13 18:03
Ok

I'm trying to make a square clip by using text metrics ( Height & width Only)

then you can try "%i" xD

or a more python 3k way, using the string format function
  1. def t1(t1, t2, code):    # deprecated
  2.     return '\\t({0},{1},{2})'.format(int(t1), int(t2), code)

  3. def t(a1, a2 = None, a3 = None, a4 = None):
  4.     if a2 == None:
  5.         return '\\t({code})'.format(code = a1)
  6.     elif a3 == None:
  7.         if a1 == int(a1):
  8.             A = str(int(a1))
  9.         else:
  10.             A = str(format(a1, '.2f'))
  11.         return '\\t({a},{code})'.format(a = A, code = a2)
  12.     elif a4 == None:
  13.         return '\\t({t1},{t2},{code})'.format(t1 = int(a1), t2 = int(a2), code = a3)
  14.     else:
  15.         if a3 == int(a3):
  16.             A = str(int(a3))
  17.         else:
  18.             A = str(format(a3, '.2f'))
  19.         return '\\t({t1},{t2},{a},{code})'.format(t1 = int(a1), t2 = int(a2), a = A, code = a4)
复制代码
you can find these ASS tag functions in tcaxPy.py under the TCAX's root directory.

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

8#
发表于 2013-11-19 13:15:14 |显示全部楼层
Alex 发表于 2013-11-17 20:13
it's ok now,

but shape position why it's different should be same text clip   -_-


Maybe you forgot to use PIX[0][0] and PIX[0][1]


p.s. I just had a four day vocation :xD

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

9#
发表于 2013-11-25 21:44:12 |显示全部楼层
Alex 发表于 2013-11-19 14:45
Hahaha... I see that, I miss you XD
Anyway.  I didn't use pixels its shape only and the position is  ...

Sorry for the late reply, busy recently.
plz, upload the files, :)
您需要登录后才可以回帖 登录 | 新人加入

GitHub|TCAX 主页

GMT+8, 2024-5-3 19:30

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部
RealH