zoukankan      html  css  js  c++  java
  • Quartz2D Text

    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来绘制

      

  • 相关阅读:
    BZOJ 3252: 攻略(思路题)
    BZOJ 2821: 作诗(Poetize)(分块)
    BZOJ 2597: [Wc2007]剪刀石头布(费用流)
    BZOJ 1565: [NOI2009]植物大战僵尸(网络流+缩点)
    BZOJ 1927: [Sdoi2010]星际竞速(费用流)
    BZOJ 5120: [2017国家集训队测试]无限之环(费用流)
    洛谷 5205 【模板】多项式开根
    LOJ 2737 「JOISC 2016 Day 3」电报 ——思路+基环树DP
    LOJ 2736 「JOISC 2016 Day 3」回转寿司 ——堆+分块思路
    bzoj 2216 [Poi2011]Lightning Conductor——单调队列+二分处理决策单调性
  • 原文地址:https://www.cnblogs.com/tekkaman/p/3570405.html
Copyright © 2011-2022 走看看