About FreeType slant(italic,oblique) principle and algorithm

Posted 柳鲲鹏

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了About FreeType slant(italic,oblique) principle and algorithm相关的知识,希望对你有一定的参考价值。

The font is SimSun(宋体), size 17, oblique=0.5, image zoom to 400%.

  • image structure

  • Principle

The special line is baseline. On display, it doesn't move on any value.

  • a bitmap info

We suppose a bitmap format glyph:

width=15
rows=16
bitmap_left=1
bitmap_top=15
  • calculate new bitmap info

above offset=((15-1)*0.5+0.5)=7. Here 1 means baseline(not move).

below offset=((16-15)*0.5+0.5)=1

new width=15+7+1=23

new pitch=(23+7)/8=4

width=23
rows=16
bitmap_left=1-1=0
bitmap_top=15
  • slant 3 blocks:above/baseline/below
ft_slant_bitmap_block()

first line index=0, slant value is max. it's=(15-0)*0.5+0.5=8. This include below offset.

  • ft_slant_bitmap_block

calculate each row slant. For example, now slant above:

each row slant=slant_above-row_id*0.5. So row_id is smaller, the slant is bigger.

Then move every bit to new buffer, new x is (x+slant)

  • save value
    src_byte  = src_y * src_pitch + src_x / 8;
    src_bit   = src_x % 8;

get src bit position(byte/bit)

  • effect

以上是关于About FreeType slant(italic,oblique) principle and algorithm的主要内容,如果未能解决你的问题,请参考以下文章

关于FreeType中文竖排斜体的接口的争论

关于FreeType中文竖排斜体的接口的争论

热烈庆贺FreeType正式支持中文竖排时的斜体功能

question about import google file

安卓平台文字叠加库freetype的编译

安卓平台文字叠加库freetype的编译