Tekkaman

导航

 

Quartz2D Text

  Quartz 2D provides a limited, low-level interface for drawing text encoded in the MacRoman text encoding and for drawing glyphs.

  Quartz 2D uses fonts, which are sets of shapes that are associated with characters, to draw text. A character abstractly represents the concept of, for example, a lowercase “b”, the number “2”, or the arithmetic operator “+”. You do not ever see a character on a display device. What you see on a display device is a glyph, the path that serves as the visual representation of the character.

  Font是把character与shape绑定起来的东西,character代表字符,glyph代表形状(path组成)。

  One glyph can represent one character, such as a lowercase “b”; more than one character, such as the “fi” ligature, which is a single glyph representing two characters; or a nonprinting character, such as the space character. Quartz renders glyphs using font data provided by the Apple Type Services (ATS) framework.

How Quartz 2D Draws Text

  You specify the location of text in user space coordinates. The text matrix specifies the transform from text space to user space. The text position is stored in the tx and ty variables of the text matrix. When you first create a graphics context, it initializes the text matrix to the identity matrix; thus text space coordinates are initially the same as user space coordinates.

  Quartz conceptually concatenates the text matrix with the current transformation matrix and other parameters from the graphics state to produce the final text rendering matrix, the matrix actually used to draw the text on the page. The text matrix does not include the font size, which is always expressed in text space.

  When Quartz draws the text, it retrieves the relevant glyphs from the ATS font server and paints them using the current parameters in the graphics state, such as fill color (if the text is filled) and stroke color. After a drawing operation, the text position remains at the last point used to image the text.

  通过Text Matrix来控制字体,Graphics Context中存储了一些字体状态。

Controlling How Text Looks

  Some of the settings in the graphics state that apply to painting paths also apply to text drawing. Stroke color and fill color are two such attributes.

  

最后

  The low-level support provided by Quartz has been deprecated and superceded by Core Text, an advanced low-level technology for laying out text and handing fonts. Core Text is designed for high performance and ease of use and allows you to draw Unicode text directly to a graphics context.

  此文中的技术已经被CoreText替代, CoreText是一个高效易用,直接绘制Unicode文本到Graphics Context上的框架. CoreText通过生成CTFrameRef传递给CTFrameDraw来绘制,或通过生成CTLineRef通过CTLineDraw来绘制

 

  

posted on 2014-02-26 22:31  Tekkaman  阅读(310)  评论(0编辑  收藏  举报