尿比重高是什么原因| 灰指甲看什么科| 左肺结节是什么意思| 寄生是什么意思| 对数是什么| 新生儿拉肚子是什么原因引起的| 什么头什么节| 狮子头是什么肉| 细菌感染有什么症状表现| m代表什么| 酸辣土豆丝用什么醋| 什么茶养胃| 重力是什么| dex是什么药| 修身养性下一句是什么| 2021年是什么生肖| 电疗是什么| 土茯苓和什么煲汤最好| 空调管滴水是什么原因| 唐僧是什么转世| pu什么意思| 车水马龙的意思是什么| 双抗是什么药| mansory是什么车| 夏天喝什么茶最好| 行房出血是什么原因| 心脏早博吃什么药好| 早餐吃什么最营养| 什么的流| 金牛女跟什么星座最配| 养什么能清理鱼缸粪便| 为什么会长疱疹| 牙周炎是什么症状| 什么叫免疫组化| 90岁叫什么| 九月是什么星座| 开场白是什么意思| 肩胛骨麻麻的什么原因| 什么争鸣成语| 湿疹为什么要查肝功能| 手机飞行模式是什么意思| 仰卧起坐有什么好处| 韭菜什么时候种| 范思哲是什么品牌| 大便粘稠吃什么药| 怀疑心衰做什么检查| 蚊香对人体有什么危害| 吃维e有什么好处和副作用| pc是什么材质| 珍珠母贝是什么东西| 长期喝酒对身体有什么危害| 痔疮用什么药好| 心花怒放是什么意思| 广藿香是什么味道| 二进宫是什么意思| 成语是什么意思| 关东八大碗都有什么| 为什么会落枕| 经常早上肚子疼是什么原因| 做b超能查出什么| 木克什么| 什么叫淋巴结转移| 夏天吃什么好| 公粮是什么意思| 没事找事是什么意思| 狐假虎威是什么意思| 海虫草是什么| 福建有什么好吃的| 白细胞数目偏高是什么意思| 笑刑是什么| 呼吸困难气短是什么原因| 什么东西不能带上飞机| 子宫有积液是什么原因引起的| 大姨妈期间同房有什么影响| 一个日一个安念什么字| 白带发黄有异味用什么药| 宝藏是什么意思| 周天是什么意思| 被褥是什么| 大便溏稀吃什么药| 为什么会一直打嗝| 属蛇的是什么星座| 属狗和什么属相最配| 太阳穴长痘痘什么原因| 孕妇吃梨有什么好处| 鱼肝油什么时候吃最好| 鱼不能和什么食物一起吃| 三亚在海南的什么位置| 睡美人最怕什么| 阴虚吃什么食补最快| 空调外机不出水是什么原因| 救人一命胜造七级浮屠是什么意思| 玉米属于什么类食物| 孢子粉是什么| 橙子皮泡水喝有什么好处| 肝血不足吃什么食补最快| mtt什么意思| 白羊女和什么星座最配| 喝酒有什么危害| acth是什么| 横空出世什么意思| 氮气是什么| 梦见打架是什么意思| 文房四宝是指什么| 拉锯战是什么意思| 萎缩是什么意思| 白菜属于什么科| 垂死病中惊坐起什么意思| 大腿青筋明显是什么原因| 女人左眼跳是什么预兆| 婴儿外阴粘连挂什么科| 痛风能吃什么菜谱大全| 六月初九是什么日子| 电解工是干什么的| 玫瑰花和什么一起泡水喝好| 2018年属什么| 明了是什么意思| 眉毛中间长痘痘是什么原因| 外阴痒是什么原因| 景色奇异的异是什么意思| 益气养阴是什么意思| 宫外孕有什么症状| 胆固醇偏高有什么危害| 长寿面什么时候吃| mk是什么牌子| 子宫腺肌症是什么原因引起的| 佝偻病什么症状| 白粉病用什么药| 早上起床腰疼是什么原因| 年少有为什么意思| 慢性咽炎用什么药| 道心是什么意思| 玉鸟吃什么饲料好| 深海鱼油的作用是什么| 甲状腺结节3类什么意思| 下眼皮跳是什么原因| 牡丹花代表什么生肖| 三醋酯纤维是什么面料| 去痛片又叫什么名| 台湾什么时候收复| 2023什么年| 大兴什么| 什么叫柏拉图式的爱情| 养肝护肝喝什么茶最好| 祚是什么意思| 宝诰是什么意思| 乌鸡炖什么好吃| 沉默不是代表我的错是什么歌| 细菌性阴道炎有什么症状| 肺部微结节是什么意思| 什么话是世界通用的| 强化灶是什么意思| 锁骨下面的骨头叫什么| 韧带损伤有什么症状| 发烧看什么科室| 尿酸低是什么意思| 胆小如鼠的意思是什么| ofd是什么意思| 梦见自己假牙掉了是什么意思| 结石是什么原因造成的| 吃什么补气| 产妇适合吃什么水果| 亲吻是什么感觉| bg是什么| 卵巢囊肿挂什么科| 男人梦见老鼠什么征兆| 男人左手断掌是什么命| 脂肪最怕什么| 五更泻吃什么药| 翻墙是什么| 哈欠是什么意思| 小狗感冒了吃什么药| 遗言是什么意思| 耳火念什么| 什么的舞蹈| 德巴金是什么药| 血糖高适合吃什么食物| 什么不什么| 姨妈期能吃什么水果| 我做错了什么| 神神叨叨是什么意思| 十二月十二日是什么星座| 汗毛重的女人意味着什么| 欧莱雅属于什么档次| 姜子牙为什么没有封神| 什么的辨认| 天蝎女和什么座最配| 巧囊是什么原因形成的| 为什么膝盖弯曲就疼痛| 相濡以沫是什么意思| 出家当尼姑需要什么条件| 12月18是什么星座| 妊娠期是指什么时候| 孩子睡觉磨牙是什么原因| 喉咙咳出血是什么原因| 牙疼吃什么好得快| tags是什么意思| dxm是什么药| 白喉采取什么隔离| 齐多夫定片是治什么病的| 北京大裤衩建筑叫什么| 脸上为什么会长痣| 鸡炖什么补气血| 996是什么| 客观原因是什么意思| 人巨细胞病毒是什么病| 脚指甲盖凹凸不平是什么原因| 6月1日什么星座| 健康状况填什么| 灰棕色是什么颜色| 宫颈炎用什么药物治疗比较好| 斑点狗是什么品种| mr检查是什么| 束在什么情况下读su| 处女座男和什么座最配对| 肌肉酸痛吃什么药| 饮片是什么意思| 十全十美指什么生肖| 梗阻是什么意思| 水晶粉是什么原料做的| 婴儿什么时候可以睡枕头| 孕妇为什么要躲着白事| 查甲功挂什么科| 29周岁属什么生肖| 骟是什么意思| 梦到吵架是什么意思| 阑尾是什么器官| 胃不舒服吃什么水果好| 迥异是什么意思| 陶渊明是什么朝代的| 为什么会得神经性皮炎| 到底为了什么| 阿贝数是什么意思| 妇科检查清洁度3度什么意思| 泥鳅什么人不能吃| 鱼子酱是什么| 打羽毛球有什么好处| 跑步胸口疼什么原因| 什么叫尊重| 体恤是什么意思| 镉是什么东西| 鸭子什么时候下蛋| 亵渎什么意思| 儒家思想的核心是什么| 一戴套就软是什么原因| 相恋纪念日送什么礼物| 心脏支架和搭桥有什么区别| 孩子脚后跟疼是什么原因| 耿耿什么| mf是什么意思| 什么叫钙化灶| 菌子中毒吃什么解毒| 胸膜炎有什么症状| 糖耐主要是检查什么| 为什么人一瘦就会漂亮| 12月15日什么星座| 印迹杂交技术检查什么| mm是什么意思单位| 既往史是什么意思| 瘦肚子吃什么水果| 男人喝劲酒有什么好处| 1936年中国发生了什么| 翻白草长什么样| 薏米长什么样子的图片| 百度
wiki:FontSelection

易烊千玺《这就是街舞》力挺选手 一展队长风范

百度 因此飞机一定要在条件良好的空调机库内进行维护。

First, let’s introduce the classes involved.

platform/graphics/

At the lowest level, FontPlatformData is a class which simply represents the platform’s concept of a font. On the Cocoa ports, this class holds a CTFontRef. (Actually, it holds two CTFontRefs and one CGFontRef, but conceptually these three all represent the same thing with slight variations.) The implementation of this class is highly platform-dependent.

One step higher, we have a Font class which owns a FontPlatformData. This class represents a platform-independent notion of a font, in addition to caching various aspects about the font such as its metrics, glyph widths, what the space glyph is, etc. These cached values are populated at construction time, by the platform-dependent function Font::platformInit().

I’m going to skip a few levels now and describe FontCascade. This is a notion of a font which represents an entire fallback list of fonts, and each RenderStyle owns one of these objects. A Font can only map a maximum of 216 code points to unique glyphs, so in order to cover the entire 1M+ Unicode code points, you must have a fallback list of fonts. This is conceptually the fallback list you specify in the “font-family” CSS property, except that the CSS property only lists strings of families, while the FontCascade represents a list of actual fonts.

Because each RenderStyle owns one of these objects, any given renderer has exactly one of these. This is the entry point to paint-time font code, and has methods like width(TextRun), offsetForPosition(TextRun) (which is used for finding the coordinates of the caret), drawText(GraphicsContext, TextRun), etc.

That TextRun thing is simply a collection of all parameters necessary for performing measurement or painting. It primarily contains a StringView, but also flags for things like “allows spaces” or “should whitespace be expanded for justification.”

A FontCascade has two pieces to it - a FontDescription object and a FontCascadeFonts object.

FontDescription is a dumping ground for all information related to font lookup. All CSS properties which affect font selection are backed by state in the FontDescription. It doesn’t hold any information about the selected fonts themselves; instead it’s just a bunch of raw data. So, it holds things like weight(), computedSize(), smallCaps(), etc. It also holds the contents of the font-family information which is accessible via familyCount() and familyAt().

FontCascadeFonts is the mediator between the high-level FontCascade and the low-level Font. This is where the actual sequence of Fonts are kept, in a Vector<FontRanges>. This FontRanges thing is just a set of associations of ranges of Unicode code points with Fonts, and is necessary because of the unicode-range CSS property (more on that later). When a FontCascadeFonts object is created, it is empty, however, as it receives requests it will “realize” (e.g. populate) each FontRanges object one by one.

There is also a singleton data structure called FontCache. All font lookups for preinstalled fonts go through this object at the lowest level. The API for FontCache produces Font objects, and internally it does this by using two caches: One for FontPlatformData objects, and one for Font objects. When a FontPlatformData cache miss occurs, this object knows how to (finally) create platform-dependent font objects, and construct a FontPlatformData out of them. If you’re looking for CTFontCreate*(), this is where you’ll find it.

So that’s about half of the picture. The other half is about web fonts.

css/

In CSS, you describe a web font by writing a @font-face rule which includes a font-family and a src. Then, you can style your other elements as if that font-family exists. If the font is used, the browser will download the src url and use it.

There are a few classes at play here. First up, we have CSSFontFace, which represents the @font-face declaration itself. It owns a collection of CSSFontFaceSource objects, which represent each of the src values inside the @font-face.

Each CSSFontFaceSource has a couple of things of interest in it. It first has the string for the URI it targets (of course). In addition, it owns a CachedResource subclass named CachedFont. (CachedResource subclasses are the interface to the network subsystem in WebKit.) When triggered, this is how CSSFontFaceSource initiates downloading the url. When the font finishes downloading, the CachedFont uses the platform-dependent FontCustomPlatformData class to build up the Front from a PlatformFont, and hands it back to CSSFontFaceSource where it is remembered. When the CSSFontFaceSource is asked for a font, if the font has completed downloading, it responds with the newly downloaded font; otherwise, it responds with a fallback font. This fallback font has a particular bit set, isLoading, which means FontCascade::drawText() will not actually draw any text, which is why you see invisible text when fonts are loading.

Going back to CSSFontFace, there is actually a higher-level class on top of it, named CSSSegmentedFontFace. This class is used because you can have multiple @font-face declarations which all have the same attributes / values in them but differ only by the “unicode-range” property. In this situation, elements which target those shared attributes should see both @font-faces together, and use one for code points inside its unicode-range and the other for code points inside its respective unicode-range.

There is an interesting monkey-wrench thrown in here. In particular, if you have an @font-face with a font-family name which is the same name as a preinstalled font, the browser is expected to consider the @font-face and the preinstalled font together (just like multiple @font-faces are considered together if they have the same family names). Therefore, we actually create CSSFontFace objects which represent preinstalled fonts. We do this by emulating “src: local()”. These preinstalled CSSFontFace objects are not specific to font traits (which CSSSegmentedFontFaces are) which means that the same preinstalled CSSFontFace object might actually be added under two different CSSSegmentedFontFaces. Therefore, the relationship between CSSSegmentedFontFaces and CSSFontFaces is both fan-out and fan-in (i.e. from many to many).

The owner of all of these CSS font-related classes is CSSFontSelector. The Document owns exactly one of these classes, and the act of asking the Document for it causes it to be created. This object is in charge of building up all of these CSS objects when an @font-face object is parsed, as well as answering font lookup queries from FontCascadeFonts (when it is trying to realize its FontRanges). The entry point for building up all these objects is CSSFontSelector::addFontFaceRule() and the entry point for answering lookup queries is CSSFontSelector::fontRangesForFamily(). Note that the return type of fontRangesForFamily is a FontRanges object, which comes from the unicode-range property stored in CSSFontFace.

Also note that, because of lifecycle issues explained below, the FontCascadeFonts object holds a reference to the CSSFontSelector. However, FontCascadeFonts is inside platform/, and nothing inside platform/ is supposed to know about anything outside of platform/. The way this is done is by having an abstract FontSelector interface inside platform/ which CSSFontSelector implements (and there are no other implementing classes). The FontSelector reference inside FontFascadeFonts is populated at construction time.

Extra considerations

First of all, the Document’s CSSFontSelector reference can be cleared and recreated at any time. There are certain style changes (such as setting the “media” attribute on a <style> element) which can cause this, but it also occurs in our memory pressure handler. FontCascadeFonts, however, needs access to the FontSelector in order to answer font selection queries, so FontCascadeFonts objects keep their given FontSelector alive with a retain. We don’t have to worry about stale data, though, because FontCascade objects have an update() method which takes the Document’s FontSelector as an argument and will destroy their FontCascadeFonts object if its FontSelector doesn’t match the argument. FontCascade::update() will also recreate the FontCascadeFonts if any part of the FontDescription changes either. If you create a FontCascade and don’t call update() on it, its FontCascadeFonts pointer will be null, and you won’t be able to perform any lookups with the font.

There is another consideration, which is that the Document needs to be re-laid out when a font completes downloading, because any element in the document may have that font somewhere in its fallback list. This means that there has to be some way for the signal to get from CachedFont all the way up to the Document. This is done through a series of weak pointers (actually, raw pointers, not WeakPtrs). CSSFontFaceSource is a CachedFontClient, so it receives a delegate callback. It has a raw pointer to its owning CSSFontFace, who has a raw pointer to each of its owning CSSSegmentedFontFaces, who has a raw pointer to its owning CSSFontSelector. The CSSFontSelector has a client interface, FontSelectorClient, which contains a single function, fontsNeedUpdate(). The Document implements this interface (along with CanvasRenderingContext2D::Font, which is needs to own a collection of FontCascades for canvas’s save() and restore() functionality). The Document implements fontsNeedUpdate() with the giant hammer recalcStyle().

Tour of font selection

So, when you want to measure or draw some text, you first perform a font lookup for a particular character. The flow goes through:

FontCascade::glyphDataForCharacter()

FontCascadeFonts::realizeNextFallback()

CSSFontSelector::fontRangesForFamily()

CSSSegmentedFontFace::fontRanges()

CSSFontFace::font()

CSSFontFaceSource::font()

CachedFont::CreateFont()

FontPlatformData::FontPlatformData()

Literally each one of these steps is cached.

(Orange means platform/ code)

Last modified 10年 ago Last modified on 2025-08-08 上午11:05:54

附件 (3)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.
一鸣惊人指什么生肖 情劫是什么 背部长痘痘是什么原因造成 特别怕热爱出汗是什么原因 1月什么星座
现在是吃什么水果的季节 捣碎东西的器皿叫什么 瓜子脸配什么发型好看 为什么小鸟站在电线上不会触电 坤宁宫是干什么的
腹泻是什么意思 潦草什么意思 闻鸡起舞是什么意思 火气重喝什么茶 尿酸高什么引起的
胸推是什么 套马的汉子你威武雄壮是什么歌 汞中毒有什么症状 兔子的耳朵像什么 六月二七是什么星座
勃起是什么意思hcv9jop6ns8r.cn 爻是什么意思hcv8jop4ns1r.cn 两个叉念什么hcv8jop0ns4r.cn 椰浆和椰汁有什么区别hcv8jop1ns4r.cn 纤维瘤是什么hcv7jop4ns6r.cn
09年的牛是什么命hcv9jop7ns1r.cn 今年什么时候入梅hcv9jop6ns8r.cn 子宫内膜息肉样增生是什么意思hcv7jop4ns6r.cn 生物制剂是什么zhiyanzhang.com 贫血吃什么药最快hcv8jop1ns5r.cn
不能晒太阳是什么病hcv8jop9ns6r.cn 脑白质病变是什么意思hcv8jop7ns8r.cn 浑身瘙痒是什么原因hcv7jop7ns4r.cn 胃难受吃什么食物好hcv8jop7ns7r.cn 创客是什么意思kuyehao.com
钱是什么意思hcv9jop0ns3r.cn 小节是什么意思hcv7jop6ns3r.cn 碱性磷酸酶低是什么原因onlinewuye.com 上火吃什么hcv7jop5ns6r.cn 吐槽是什么意思啊huizhijixie.com
百度