# Apple Symbols — named Lion-font reference, 2011 — source transcripts, page 1

[Canonical transcript page](https://www.vintageapple.net/transcripts/media/type-apple-symbols/1)

## Transcribed source material

Machine transcriptions and image descriptions; uncertain copy may be marked [illegible]. Verify against the linked originals. Historical rights remain with the original owners.

### Image 1

[Cite this scan](https://www.vintageapple.net/transcripts/media/type-apple-symbols/1#scan-481243f3efd795ee51364b766e75337c8dfb5017db2dbfb9cd1cc28ab04c62eb)

Transcribed text:

L2/11-415

Unified Emoji Reference
Peter Edberg, Oct. 25, 2011 (updated Oct 28, 2011)

The following table lists the 114 emoji from the core set that were mapped to (unified with) characters or sequences of characters that existed in Unicode 5.2 or earlier.

Within a row, the first three columns give the SJIS code and glyph for each carrier's representation (if any) of an emoji character mapped to the Unicode character or sequence shown column 6 (fallback mappings to a carrier's set are not shown). For mappings to single Unicode characters, column 5 shows the glyph for that Unicode character as shown in the Unicode 6.0 charts.

Finally, column 4 suggests the variety of glyphs that may be used on a single platform (here Mac OS X Lion) to represent the Unicode character or sequence. Glyphs shown before the comma (if any) are from standard non-emoji-specific fonts (typically Apple Symbols, Zapf Dingbats, or a Japanese font from the Hiragino family). Glyphs shown after the comma (if any) are from the emoji-specific Apple Color Emoji font. If there is no glyph after the comma, the Unicode character/sequence is always represented using a glyph from one of the standard fonts. If there is "(n/a)" after the comma, that character is also not capable of being entered from the emoji keyboard in iOS 5.0. Two of the characters have no glyph in any font, and are marked "(n/a)".

DoCoMo | KDDI | Soft-Bankk | Apple glyphs: std(s),emoji | Unicd glyph | Unicode codepoint, name, props
| F7AA | | (n/a) | | 2002;EN SPACE;Zs;
| F7A9 | | (n/a) | | 2003;EM SPACE;Zs;
| F7AB | | (n/a) | | 2005;FOUR-PER-EM SPACE;Zs;
F9D6 © | F774 © | F7EE © | ©©, | © | 00A9;COPYRIGHT SIGN;So;
F9DB ® | F775 ® | F7EF ® | ®®, | ® | 00AE;REGISTERED SIGN;So;
F9D7 TM | F76A TM | FBD7 TM | TM TM, | TM | 2122;TRADE MARK SIGN;So;
| F74F i | | i i, (n/a) | i | 2139;INFORMATION SOURCE;LI;

Image description: A typeset reference page with a boxed document code in the upper right, bold title text, body paragraphs, and a grid table of emoji glyphs with Unicode codepoints and names.

Reading notes: Table glyph columns are small images and transcribed as approximate glyph renderings; Soft-Bankk header spelled as printed. Some fallback glyph entries in the Apple glyphs column are rendered at small size and may be ambiguous. Some empty cells in the DoCoMo, KDDI, and Soft-Bank columns contain no visible text.

Printed dates: Oct. 25, 2011 · Oct 28, 2011

Languages: English

[Original Image 1](https://www.vintageapple.net/files/aad7ba7e280ca40cd986358b814cc9f137caa290bedd2448b1294e81f2366f2d/unified-emoji-2011-p001.jpg)

### PDF page 1

[Cite this scan](https://www.vintageapple.net/transcripts/media/type-apple-symbols/1#scan-a1b7b0b40d220e484a464d7128727f6255f73678ffb3a74278d6052bb7ea8bbe)

Transcribed text:

Unified Emoji Reference
Peter Edberg, Oct. 25, 2011 (updated Oct 28, 2011)
The following table lists the 114 emoji from the core set that were mapped to (unified
with) characters or sequences of characters that existed in Unicode 5.2 or earlier.
Within a row, the first three columns give the SJIS code and glyph for each carrier's
representation (if any) of an emoji character mapped to the Unicode character or
sequence shown column 6 (fallback mappings to a carrier’s set are not shown). For
mappings to single Unicode characters, column 5 shows the glyph for that Unicode
character as shown in the Unicode 6.0 charts.
Finally, column 4 suggests the variety of glyphs that may be used on a single platform
(here Mac OS X Lion) to represent the Unicode character or sequence. Glyphs shown
before the comma (if any) are from standard non-emoji-specific fonts (typically Apple
Symbols, Zapf Dingbats, or a Japanese font from the Hiragino family). Glyphs shown
after the comma (if any) are from the emoji-specific Apple Color Emoji font. If there is
no glyph after the comma, the Unicode character/sequence is always represented
using a glyph from one of the standard fonts. If there is “(n/a)” after the comma, that
character is also not capable of being entered from the emoji keyboard in iOS 5.0. Two
of the characters have no glyph in any font, and are marked “(n/a)”.
DoCo
Mo
KDDI   Soft-
Bankk
Apple glyphs:
std(s),emoji
Unicd
glyph
Unicode codepoint, name, props
F7AA   ,   (n/a)   2002;EN SPACE;Zs;
F7A9   ,   (n/a)   2003;EM SPACE;Zs;
F7AB   ,   (n/a)   2005;FOUR-PER-EM
SPACE;Zs;
F9D6   F774   F7EE   ©   00A9;COPYRIGHT SIGN;So;
F9DB   F775   F7EF   ®   00AE;REGISTERED SIGN;So;
F9D7   F76A   FBD7   ™   2122;TRADE MARK SIGN;So;
F74F   ℹ ℹ ,   (n/a)
2139;INFORMATION
SOURCE;Ll;

Reading notes: Table column headers (DoCo, Mo, KDDI, Softbank, Apple glyphs, Unicode glyph) are fragmented and their alignment is uncertain. Glyph symbols in the table cannot be verified as printed characters and may be lost in extraction. Years 2002, 2003, 2005 and 2139 appear as Unicode codepoint data, not as dates, and were excluded from printedDates. The document is a technical reference rather than an advertisement, so no products or prices are listed.

Printed dates: Oct. 25, 2011 · Oct 28, 2011

Languages: English

[Original PDF page 1](https://www.vintageapple.net/files/41288bbfaf3f05716f8e5c3a6af1b9561cf9f5fb1344f7ec8b68500ee6fbfdb2/unified-emoji-reference-2011.pdf#page=1)

### PDF page 2

[Cite this scan](https://www.vintageapple.net/transcripts/media/type-apple-symbols/1#scan-09d48b5739b69c6d0777685db3c93eef8a2fcf41d8074894137409a447d47a87)

Transcribed text:

F9A9   F3F1   ‼   ,   (n/a)   203C;DOUBLE EXCLAMATION
MARK;Po;
F9A8   F3F0   ⁉   ,   (n/a)   2049;EXCLAMATION
QUESTION MARK;Po;
#   #
F9C4   F797
⌚ ⌚ ,   (n/a)
231A;WATCH;So;
F798
⌛ ⌛ ,   (n/a)
231B;HOURGLASS;So;
F8BD   ,   (n/a)   24C2;CIRCLED LATIN
CAPITAL LETTER M;So;
#   # Misc symbols
F89F   F660   F98B
☀ ,   ☀   2600;BLACK SUN WITH
RAYS;So;
F8A0   F665   F98A
☁ ,   ☁   2601;CLOUD;So;
F8E8   F7B3   F949
☎ ,   ☎   260E;BLACK TELEPHONE;So;
F7D9   ☑ ,   (n/a)   2611;BALLOT BOX WITH
CHECK;So;
F8A1   F664   F98C
☔ ,   ☔   2614;UMBRELLA WITH RAIN
DROPS;So;
F8D1   F7B4   F986
☕ ,   ☕   2615;HOT BEVERAGE;So;
F6CF   F94F
☝ ,   ☝   261D;WHITE UP POINTING
INDEX;So;

Reading notes: No image was provided, so the description relies only on the supplied extracted text. The supplied text is a character-encoding table of symbols, not advertising copy, so no headline, products, prices, or dates were identified. Transcript is intentionally empty because the exact extracted text is preserved separately.

Languages: English

[Original PDF page 2](https://www.vintageapple.net/files/41288bbfaf3f05716f8e5c3a6af1b9561cf9f5fb1344f7ec8b68500ee6fbfdb2/unified-emoji-reference-2011.pdf#page=2)

### PDF page 3

[Cite this scan](https://www.vintageapple.net/transcripts/media/type-apple-symbols/1#scan-4904c862445565e0ff2f6bfeb8d2c3e0a35ce7c35c6e5ded3d0d530592e59102)

Transcribed text:

F6D4   FB54
☺ ,   ☺   263A;WHITE SMILING
FACE;So;
F8A7   F667   F7DF
♈ ,   ♈   2648;ARIES;So;
= ram
F8A8   F668   F7E0
♉ ,   ♉   2649;TAURUS;So;
= bull
F8A9   F669   F7E1
♊ ,   ♊   264A;GEMINI;So;
= twins
F8AA   F66A   F7E2
♋ ,   ♋   264B;CANCER;So;
= crab
F8AB   F66B   F7E3
♌ ,   ♌   264C;LEO;So;
= lion
F8AC   F66C   F7E4
♍ ,   ♍   264D;VIRGO;So;
= virgin maiden
F8AD   F66D   F7E5
♎ ,   ♎   264E;LIBRA;So;
= scales
F8AE   F66E   F7E6
♏ ,   ♏   264F;SCORPIUS;So;
= scorpion
F8AF   F66F   F7E7
♐ ,   ♐   2650;SAGITTARIUS;So;
= archer
F8B0   F670   F7E8
♑ ,   ♑   2651;CAPRICORN;So;
= goat
F8B1   F671   F7E9
♒ ,   ♒   2652;AQUARIUS;So;
= water carrier
F8B2   F672   F7EA
♓ ,   ♓   2653;PISCES;So;
= fish

Reading notes: Source appears to be a character encoding table of Unicode zodiac and smiley symbols rather than advertising copy Entry 'SCORPIUS' may be a misspelling of 'SCORPIO' as printed

Languages: English

[Original PDF page 3](https://www.vintageapple.net/files/41288bbfaf3f05716f8e5c3a6af1b9561cf9f5fb1344f7ec8b68500ee6fbfdb2/unified-emoji-reference-2011.pdf#page=3)

### PDF page 4

[Cite this scan](https://www.vintageapple.net/transcripts/media/type-apple-symbols/1#scan-8060c65df78e66497e6ea49236ae399d67cab887dc84317d0ecccc0b41df10dd)

Transcribed text:

F8EF   F7BE   F7AE
♠   ♠   2660;BLACK SPADE SUIT;So;
F8F1   F7C0   F7AF
♣   ♣   2663;BLACK CLUB SUIT;So;
F8EE   F378   F7AC
♥   ♥   2665;BLACK HEART SUIT;So;
F8F0   F7BF   F7AD
♦   ♦   2666;BLACK DIAMOND SUIT;
F99C   F695   F763
♨   ♨   2668;HOT SPRINGS;So;
F9DA   F47D   ♻   ,   (n/a)   267B;BLACK UNIVERSAL
RECYCLING SYMBOL;So;
F8FC   F657   F7AA
♿ ,   ♿   267F;WHEELCHAIR
SYMBOL;So;
F682   ⚓ ,   (n/a)   2693;ANCHOR;So;
F9DC   F659   F7F2
⚠ ,   ⚠   26A0;WARNING SIGN;So;
F8A3   F65F   F77D
⚡ ,   ⚡   26A1;HIGH VOLTAGE
SIGN;So;
F8B7   F68F   F958
,   ⚽   26BD;SOCCER BALL;So;
F8B4   F693   F956
⚾   26BE;BASEBALL;So;
F8A2   F65D   F989
,   ⛄   26C4;SNOWMAN WITHOUT
SNOW;So;

Reading notes: Source is a character-mapping table of Unicode symbols rather than advertising copy Column alignment of the symbol glyphs is ambiguous in the extracted text

Languages: English

[Original PDF page 4](https://www.vintageapple.net/files/41288bbfaf3f05716f8e5c3a6af1b9561cf9f5fb1344f7ec8b68500ee6fbfdb2/unified-emoji-reference-2011.pdf#page=4)

### PDF page 5

[Cite this scan](https://www.vintageapple.net/transcripts/media/type-apple-symbols/1#scan-4f1b4a44c83bb6adae3cbcbda311fe3418f8d6019935001b53e777d9f1180413)

Transcribed text:

F666   (n/a)   26C5;SUN BEHIND
CLOUD;So;
F65C   (n/a)   26D4;NO ENTRY;So;
F7EB   F977
,   ⛪   26EA;CHURCH;So;
F342   F761
,   ⛲   26F2;FOUNTAIN;So;
F8B5   F7B6   F954
,   26F3;FLAG IN HOLE;So;
F947   F68D   F95C
,   ⛵   26F5;SAILBOAT;So;
F343   F762
,   ⛺   26FA;TENT;So;
F8CC   F78E   F97A
,   ⛽   26FD;FUEL PUMP;So;
= gas station
#   # Dingbats
F8D6   F6EF   F9B3
✂ ,   ✂   2702;BLACK SCISSORS;So
F8C3   F68C   F95D
✈ ,   ✈   2708;AIRPLANE;So;
F977   F6FA   ✉ ,   (n/a)   2709;ENVELOPE;So;
F8F5   F7C3   F951
✌ ,   ✌   270C;VICTORY HAND;So;
F9BE   F679   ✏ ,   (n/a)   270F;PENCIL;So;

Reading notes: Source appears to be a character/symbol mapping table rather than advertising copy; no headline or advertised products identified. Several glyph-column entries contain non-standard or unclear characters that may be damaged in extraction.

Languages: English

[Original PDF page 5](https://www.vintageapple.net/files/41288bbfaf3f05716f8e5c3a6af1b9561cf9f5fb1344f7ec8b68500ee6fbfdb2/unified-emoji-reference-2011.pdf#page=5)

### PDF page 6

[Cite this scan](https://www.vintageapple.net/transcripts/media/type-apple-symbols/1#scan-5fc32d1f7faceaa921c4ccb58f05c8d1107f321e64a286564c94da02df896b8f)

Transcribed text:

F952   F7DA   ✒ ,   (n/a)   2712;BLACK NIB;So;
F773   ✔ ,   (n/a)   2714;HEAVY CHECK
MARK;So;
F76B   ✖ ,   (n/a)   2716;HEAVY
MULTIPLICATION X;So;
F75A   F7A6
✳ ,   ✳   2733;EIGHT SPOKED
ASTERISK;So;0
F651   F7A5
✴ ,   ✴   2734;EIGHT POINTED BLACK
STAR;So;
F662   ❄ ,   (n/a)   2744;SNOWFLAKE;So;
F644
(ani-
mated)
❇ ,   (n/a)   2747;SPARKLE;So;
F9A7   F65A   F961
,   ❗   2757;HEAVY EXCLAMATION
MARK SYMBOL;So;
F991   F7B2   F962
❤ ,   ❤   2764;HEAVY BLACK
HEART;So;
F76E   F7D4
➡   ➡   27A1;BLACK RIGHTWARDS
ARROW;So;
#   #
F76F   F7D5
⬅   ⬅   2B05;LEFTWARDS BLACK
ARROW;So;
F75B   F7D2
⬆   ⬆   2B06;UPWARDS BLACK
ARROW;So;
F75C   F7D3
⬇   ⬇   2B07;DOWNWARDS BLACK
ARROW;So;

Reading notes: Source is a character/symbol code table with names, not advertising copy; no headline or advertised products present. Several entries contain garbled or ambiguous code points and column alignment, so reading order is uncertain.

Languages: English

[Original PDF page 6](https://www.vintageapple.net/files/41288bbfaf3f05716f8e5c3a6af1b9561cf9f5fb1344f7ec8b68500ee6fbfdb2/unified-emoji-reference-2011.pdf#page=6)

### PDF page 7

[Cite this scan](https://www.vintageapple.net/transcripts/media/type-apple-symbols/1#scan-566eee98decbb4621ed321d7ef66bdf0fe2bd09d9ed85c1125928cea2834b217)

Transcribed text:

F8F8   F768   F7D7
↖   ↖   2196;NORTH WEST
ARROW;So;
F8D9   F771   F7D6
↗   ↗   2197;NORTH EAST
ARROW;So;
F8F7   F769   F7D8
↘   ↘   2198;SOUTH EAST
ARROW;So;
F949   F772   F7D9
↙   ↙   2199;SOUTH WEST
ARROW;So;
F9E1   F47E   ↔   ,   (n/a)   2194;LEFT RIGHT ARROW;Sm;
F9E2   F480   ↕ ↕ ,   (n/a)   2195;UP DOWN ARROW;So;
F97E   F779   ↩ ↩ ,   (n/a)
21A9;LEFTWARDS ARROW
WITH HOOK;So;
F778   ↪ ↪ ,   (n/a)
21AA;RIGHTWARDS ARROW
WITH HOOK;So;
F99A   F3EE   ⤴   ,   (n/a)   2934;ARROW POINTING
RIGHTWARDS THEN
CURVING UPWARDS;Sm;
F9A5   F3EF   ⤵   ,   (n/a)   2935;ARROW POINTING
RIGHTWARDS THEN
CURVING DOWNWARDS;Sm;
#   # Geom shapes
F74E   ▪ ▪ ,   (n/a)
25AA;BLACK SMALL
SQUARE;So;
F74D   ▫ ▫ ,   (n/a)
25AB;WHITE SMALL
SQUARE;So;

Reading notes: Source text is a character-mapping table of arrow and geometric symbols rather than advertising copy No headline, products, prices, or dates are present in the supplied text

[Original PDF page 7](https://www.vintageapple.net/files/41288bbfaf3f05716f8e5c3a6af1b9561cf9f5fb1344f7ec8b68500ee6fbfdb2/unified-emoji-reference-2011.pdf#page=7)

### PDF page 8

[Cite this scan](https://www.vintageapple.net/transcripts/media/type-apple-symbols/1#scan-7613d0f3f452a87832e1e6b976109ff329e06119f1d558b14099c2a978866f70)

Transcribed text:

F74A   F7DA
▶ ,   ▶   25B6;BLACK RIGHT-POINTING
TRIANGLE;So;
F749   F7DB
◀ ,   ◀   25C0;BLACK LEFT-POINTING
TRIANGLE;So;
F754   ◻ ◻ ,   (n/a)   25FB;WHITE MEDIUM
SQUARE;Sm;
F755   ◼ ◼ ,   (n/a)   25FC;BLACK MEDIUM
SQUARE;Sm;
F750   ◽ ◽ ,   (n/a)
25FD;WHITE MEDIUM SMALL
SQUARE;Sm;
F751   ◾ ◾ ,   (n/a)
25FE;BLACK MEDIUM SMALL
SQUARE;Sm;
#   #
F756
⚪ ⚪ ,   (n/a)
26AA;MEDIUM WHITE
CIRCLE;So;
F757
⚫ ⚫ ,   (n/a)
26AB;MEDIUM BLACK
CIRCLE;So;
#   #
F765
⬛   2B1B;BLACK LARGE
SQUARE;So;
F764
⬜   2B1C;WHITE LARGE
SQUARE;So;
F663   F9CF
⭐ ,   ⭐   2B50;WHITE MEDIUM
STAR;So
F381   F9D2
,   ⭕   2B55;HEAVY LARGE
CIRCLE;So;
#   #

Reading notes: Source text is a character/glyph mapping table with Unicode code points and names, not advertising copy. No headline, products, prices, or dates are present in the supplied text.

[Original PDF page 8](https://www.vintageapple.net/files/41288bbfaf3f05716f8e5c3a6af1b9561cf9f5fb1344f7ec8b68500ee6fbfdb2/unified-emoji-reference-2011.pdf#page=8)

### PDF page 9

[Cite this scan](https://www.vintageapple.net/transcripts/media/type-apple-symbols/1#scan-01ee93c2f2f47436846ee6a8bc73f2146462e09c8d938cc6ad1b86a725aa3a5f)

Transcribed text:

F9AE   ,   (n/a)   3030;WAVY DASH;Pd;
F76C
,   〽   303D;PART ALTERNATION
MARK;Po;
F36C   F9AD
,   ㊗   3297;CIRCLED IDEOGRAPH
CONGRATULATION;So;
F9D9   F6CA   F9B5
,   ㊙   3299;CIRCLED IDEOGRAPH
SECRET;So;
F344   F76D
,   🀄   1F004;MAHJONG TILE RED
DRAGON;So;
F8CD   F67E   F790
🅿   1F17F;NEGATIVE SQUARED
LATIN CAPITAL LETTER P;So;
F7B6
,   🈚   1F21A;SQUARED CJK
UNIFIED IDEOGRAPH-7121;
So;
F35E   F7CC
,   🈯   1F22F;SQUARED CJK
UNIFIED IDEOGRAPH-6307;
So;
#   # sequences
F985   F489   F7B0
# ⃣   ,   ^   (n/a)   0023;NUMBER SIGN +
20E3;COMBINING
ENCLOSING KEYCAP
F990   F7C9   F7C5
0 ,   _   (n/a)   0030;DIGIT ZERO +
20E3;COMBINING
ENCLOSING KEYCAP
F987   F6FB   F7BC
1 ,   `   (n/a)   0031;DIGIT ONE +
20E3;COMBINING
ENCLOSING KEYCAP
F988   F6FC   F7BD
2 ,   a   (n/a)   0032;DIGIT TWO +
20E3;COMBINING
ENCLOSING KEYCAP

Reading notes: Source text is a Unicode character index listing with private-use codepoints and emoji names, not advertising copy No headline, product names, prices or dates are present in the supplied text

Languages: English

[Original PDF page 9](https://www.vintageapple.net/files/41288bbfaf3f05716f8e5c3a6af1b9561cf9f5fb1344f7ec8b68500ee6fbfdb2/unified-emoji-reference-2011.pdf#page=9)

### PDF page 10

[Cite this scan](https://www.vintageapple.net/transcripts/media/type-apple-symbols/1#scan-b25e8dfbb115fd0ee9982fa1750d4e0a463166c5772d615ee3691105071e3b4a)

Transcribed text:

F989   F740   F7BE
3 ,   b   (n/a)   0033;DIGIT THREE +
20E3;COMBINING
ENCLOSING KEYCAP
F98A   F741   F7BF
4 ,   c   (n/a)   0034;DIGIT FOUR +
20E3;COMBINING
ENCLOSING KEYCAP
F98B   F742   F7C0
5 ,   d   (n/a)   0035;DIGIT FIVE +
20E3;COMBINING
ENCLOSING KEYCAP
F98C   F743   F7C1
6 ,   e   (n/a)   0036;DIGIT SIX +
20E3;COMBINING
ENCLOSING KEYCAP
F98D   F744   F7C2
7 ,   f   (n/a)   0037;DIGIT SEVEN +
20E3;COMBINING
ENCLOSING KEYCAP
F98E   F745   F7C3
8 ,   g   (n/a)   0038;DIGIT EIGHT +
20E3;COMBINING
ENCLOSING KEYCAP
F98F   F746   F7C4
9 ,   h   (n/a)   0039;DIGIT NINE +
20E3;COMBINING
ENCLOSING KEYCAP

Reading notes: Source text is a table of character codes and mappings rather than advertising copy; no headline, products, prices or dates identifiable. Glyph names such as DIGIT THREE and COMBINING ENCLOSING KEYCAP are Unicode character names, not advertised products.

[Original PDF page 10](https://www.vintageapple.net/files/41288bbfaf3f05716f8e5c3a6af1b9561cf9f5fb1344f7ec8b68500ee6fbfdb2/unified-emoji-reference-2011.pdf#page=10)

### Document section 1

[Cite this scan](https://www.vintageapple.net/transcripts/media/type-apple-symbols/1#scan-015b4bd591169d213bbe7c39cfe0e7071fbca6d2bc042e20da3c845db0417bcb)

Transcribed text:

/**
 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
 * (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) 
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB. If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 *
 */

#include "config.h"
#include "RenderTextControl.h"

#include "AXObjectCache.h"
#include "CharacterNames.h"
#include "Editor.h"
#include "Event.h"
#include "EventNames.h"
#include "Frame.h"
#include "HTMLBRElement.h"
#include "HTMLNames.h"
#include "HitTestResult.h"
#include "RenderLayer.h"
#include "RenderText.h"
#include "ScrollbarTheme.h"
#include "SelectionController.h"
#include "Text.h"
#include "TextControlInnerElements.h"
#include "TextIterator.h"

using namespace std;

namespace WebCore {

using namespace HTMLNames;

// Value chosen by observation. This can be tweaked.
static const int minColorContrastValue = 1300;

static Color disabledTextColor(const Color& textColor, const Color& backgroundColor)
{
 // The explicit check for black is an optimization for the 99% case (black on white).
 // This also means that black on black will turn into grey on black when disabled.
 Color disabledColor;
 if (textColor.rgb() == Color::black || differenceSquared(textColor, Color::white) > differenceSquared(backgroundColor, Color::white))
 disabledColor = textColor.light();
 else
 disabledColor = textColor.dark();
 
 // If there's not very much contrast between the disabled color and the background color,
 // just leave the text color alone. We don't want to change a good contrast color scheme so that it has really bad contrast.
 // If the the contrast was already poor, then it doesn't do any good to change it to a different poor contrast color scheme.
 if (differenceSquared(disabledColor, backgroundColor) detach();
}

void RenderTextControl::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
{
 RenderBlock::styleDidChange(diff, oldStyle);

 if (m_innerText) {
 RenderBlock* textBlockRenderer = toRenderBlock(m_innerText->renderer());
 RefPtr textBlockStyle = createInnerTextStyle(style());
 // We may have set the width and the height in the old style in layout().
 // Reset them now to avoid getting a spurious layout hint.
 textBlockRenderer->style()->setHeight(Length());
 textBlockRenderer->style()->setWidth(Length());
 setInnerTextStyle(textBlockStyle);
 }

 setReplaced(isInline());
}

void RenderTextControl::setInnerTextStyle(PassRefPtr style)
{
 if (m_innerText) {
 RefPtr textStyle = style;
 m_innerText->renderer()->setStyle(textStyle);
 for (Node* n = m_innerText->firstChild(); n; n = n->traverseNextNode(m_innerText.get())) {
 if (n->renderer())
 n->renderer()->setStyle(textStyle);
 }
 }
}

static inline bool updateUserModifyProperty(Node* node, RenderStyle* style)
{
 bool isEnabled = true;
 bool isReadOnlyControl = false;

 if (node->isElementNode()) {
 Element* element = static_cast(node);
 isEnabled = element->isEnabledFormControl();
 isReadOnlyControl = element->isReadOnlyFormControl();
 }

 style->setUserModify((isReadOnlyControl || !isEnabled) ? READ_ONLY : READ_WRITE_PLAINTEXT_ONLY);
 return !isEnabled;
}

void RenderTextControl::adjustInnerTextStyle(const RenderStyle* startStyle, RenderStyle* textBlockStyle) const
{
 // The inner block, if present, always has its direction set to LTR,
 // so we need to inherit the direction from the element.
 textBlockStyle->setDirection(style()->direction());

 bool disabled = updateUserModifyProperty(node(), textBlockStyle);
 if (disabled)
 textBlockStyle->setColor(disabledTextColor(textBlockStyle->color(), startStyle->backgroundColor()));
}

void RenderTextControl::createSubtreeIfNeeded(TextControlInnerElement* innerBlock)
{
 if (!m_innerText) {
 // Create the text block element
 // For non-search fields, there is no intermediate innerBlock as the shadow node.
 // m_innerText will be the shadow node in that case. 
 RenderStyle* parentStyle = innerBlock ? innerBlock->renderer()->style() : style();
 m_innerText = new TextControlInnerTextElement(document(), innerBlock ? 0 : node());
 m_innerText->attachInnerElement(innerBlock ? innerBlock : node(), createInnerTextStyle(parentStyle), renderArena());
 }
}

int RenderTextControl::textBlockHeight() const
{
 return height() - paddingTop() - paddingBottom() - borderTop() - borderBottom();
}

int RenderTextControl::textBlockWidth() const
{
 return width() - paddingLeft() - paddingRight() - borderLeft() - borderRight()
 - m_innerText->renderBox()->paddingLeft() - m_innerText->renderBox()->paddingRight();
}

void RenderTextControl::updateFromElement()
{
 updateUserModifyProperty(node(), m_innerText->renderer()->style());
}

void RenderTextControl::setInnerTextValue(const String& innerTextValue)
{
 String value;

 if (innerTextValue.isNull())
 value = "";
 else {
 value = innerTextValue; 
 value = document()->displayStringModifiedByEncoding(value);
 }

 if (value != text() || !m_innerText->hasChildNodes()) {
 if (value != text()) {
 if (Frame* frame = document()->frame()) {
 frame->editor()->clearUndoRedoOperations();
 
 if (AXObjectCache::accessibilityEnabled())
 document()->axObjectCache()->postNotification(this, AXObjectCache::AXValueChanged, false);
 }
 }

 ExceptionCode ec = 0;
 m_innerText->setInnerText(value, ec);
 ASSERT(!ec);

 if (value.endsWith("\n") || value.endsWith("\r")) {
 m_innerText->appendChild(new HTMLBRElement(brTag, document()), ec);
 ASSERT(!ec);
 }

 // We set m_lastChangeWasUserEdit to false since this change was not explicitly made by the user (say, via typing on the keyboard), see .
 m_lastChangeWasUserEdit = false;
 }

 static_cast(node())->setFormControlValueMatchesRenderer(true);
}

void RenderTextControl::setLastChangeWasUserEdit(bool lastChangeWasUserEdit)
{
 m_lastChangeWasUserEdit = lastChangeWasUserEdit;
 document()->setIgnoreAutofocus(lastChangeWasUserEdit);
}

int RenderTextControl::selectionStart()
{
 Frame* frame = document()->frame();
 if (!frame)
 return 0;
 return indexForVisiblePosition(frame->selection()->start());
}

int RenderTextControl::selectionEnd()
{
 Frame* frame = document()->frame();
 if (!frame)
 return 0;
 return indexForVisiblePosition(frame->selection()->end());
}

void RenderTextControl::setSelectionStart(int start)
{
 setSelectionRange(start, max(start, selectionEnd()));
}

void RenderTextControl::setSelectionEnd(int end)
{
 setSelectionRange(min(end, selectionStart()), end);
}

void RenderTextControl::select()
{
 setSelectionRange(0, text().length());
}

void RenderTextControl::setSelectionRange(int start, int end)
{
 end = max(end, 0);
 start = min(max(start, 0), end);

 ASSERT(!document()->childNeedsAndNotInStyleRecalc());

 if (style()->visibility() == HIDDEN || !m_innerText || !m_innerText->renderer() || !m_innerText->renderBox()->height()) {
 cacheSelection(start, end);
 return;
 }
 VisiblePosition startPosition = visiblePositionForIndex(start);
 VisiblePosition endPosition;
 if (start == end)
 endPosition = startPosition;
 else
 endPosition = visiblePositionForIndex(end);

 // startPosition and endPosition can be null position for example when
 // "-webkit-user-select: none" style attribute is specified.
 if (startPosition.isNotNull() && endPosition.isNotNull()) {
 ASSERT(startPosition.deepEquivalent().node()->shadowAncestorNode() == node() && endPosition.deepEquivalent().node()->shadowAncestorNode() == node());
 }
 VisibleSelection newSelection = VisibleSelection(startPosition, endPosition);

 if (Frame* frame = document()->frame())
 frame->selection()->setSelection(newSelection);

 // FIXME: Granularity is stored separately on the frame, but also in the selection controller.
 // The granularity in the selection controller should be used, and then this line of code would not be needed.
 if (Frame* frame = document()->frame())
 frame->setSelectionGranularity(CharacterGranularity);
}

VisibleSelection RenderTextControl::selection(int start, int end) const
{
 return VisibleSelection(VisiblePosition(m_innerText.get(), start, VP_DEFAULT_AFFINITY),
 VisiblePosition(m_innerText.get(), end, VP_DEFAULT_AFFINITY));
}

VisiblePosition RenderTextControl::visiblePositionForIndex(int index)
{
 if (index range = Range::create(document());
 range->selectNodeContents(m_innerText.get(), ec);
 ASSERT(!ec);
 CharacterIterator it(range.get());
 it.advance(index - 1);
 Node* endContainer = it.range()->endContainer(ec);
 ASSERT(!ec);
 int endOffset = it.range()->endOffset(ec);
 ASSERT(!ec);
 return VisiblePosition(endContainer, endOffset, UPSTREAM);
}

int RenderTextControl::indexForVisiblePosition(const VisiblePosition& pos)
{
 Position indexPosition = pos.deepEquivalent();
 if (!indexPosition.node() || indexPosition.node()->rootEditableElement() != m_innerText)
 return 0;
 ExceptionCode ec = 0;
 RefPtr range = Range::create(document());
 range->setStart(m_innerText.get(), 0, ec);
 ASSERT(!ec);
 range->setEnd(indexPosition.node(), indexPosition.deprecatedEditingOffset(), ec);
 ASSERT(!ec);
 return TextIterator::rangeLength(range.get());
}

void RenderTextControl::subtreeHasChanged()
{
 m_wasChangedSinceLastChangeEvent = true;
 m_lastChangeWasUserEdit = true;
}

String RenderTextControl::finishText(Vector& result) const
{
 // Remove one trailing newline; there's always one that's collapsed out by rendering.
 size_t size = result.size();
 if (size && result[size - 1] == '\n')
 result.shrink(--size);

 // Convert backslash to currency symbol.
 document()->displayBufferModifiedByEncoding(result.data(), result.size());
 
 return String::adopt(result);
}

String RenderTextControl::text()
{
 if (!m_innerText)
 return "";
 
 Vector result;

 for (Node* n = m_innerText.get(); n; n = n->traverseNextNode(m_innerText.get())) {
 if (n->hasTagName(brTag))
 result.append(&newlineCharacter, 1);
 else if (n->isTextNode()) {
 String data = static_cast(n)->data();
 result.append(data.characters(), data.length());
 }
 }

 return finishText(result);
}

static void getNextSoftBreak(RootInlineBox*& line, Node*& breakNode, unsigned& breakOffset)
{
 RootInlineBox* next;
 for (; line; line = next) {
 next = line->nextRootBox();
 if (next && !line->endsWithBreak()) {
 ASSERT(line->lineBreakObj());
 breakNode = line->lineBreakObj()->node();
 breakOffset = line->lineBreakPos();
 line = next;
 return;
 }
 }
 breakNode = 0;
 breakOffset = 0;
}

String RenderTextControl::textWithHardLineBreaks()
{
 if (!m_innerText)
 return "";
 Node* firstChild = m_innerText->firstChild();
 if (!firstChild)
 return "";

 document()->updateLayout();

 RenderObject* renderer = firstChild->renderer();
 if (!renderer)
 return "";

 InlineBox* box = renderer->isText() ? toRenderText(renderer)->firstTextBox() : toRenderBox(renderer)->inlineBoxWrapper();
 if (!box)
 return "";

 Node* breakNode;
 unsigned breakOffset;
 RootInlineBox* line = box->root();
 getNextSoftBreak(line, breakNode, breakOffset);

 Vector result;

 for (Node* n = firstChild; n; n = n->traverseNextNode(m_innerText.get())) {
 if (n->hasTagName(brTag))
 result.append(&newlineCharacter, 1);
 else if (n->isTextNode()) {
 Text* text = static_cast(n);
 String data = text->data();
 unsigned length = data.length();
 unsigned position = 0;
 while (breakNode == n && breakOffset position) {
 result.append(data.characters() + position, breakOffset - position);
 position = breakOffset;
 result.append(&newlineCharacter, 1);
 }
 getNextSoftBreak(line, breakNode, breakOffset);
 }
 result.append(data.characters() + position, length - position);
 }
 while (breakNode == n)
 getNextSoftBreak(line, breakNode, breakOffset);
 }

 return finishText(result);
}

int RenderTextControl::scrollbarThickness() const
{
 // FIXME: We should get the size of the scrollbar from the RenderTheme instead.
 return ScrollbarTheme::nativeTheme()->scrollbarThickness();
}

void RenderTextControl::calcHeight()
{
 setHeight(m_innerText->renderBox()->borderTop() + m_innerText->renderBox()->borderBottom() +
 m_innerText->renderBox()->paddingTop() + m_innerText->renderBox()->paddingBottom() +
 m_innerText->renderBox()->marginTop() + m_innerText->renderBox()->marginBottom());

 adjustControlHeightBasedOnLineHeight(m_innerText->renderer()->lineHeight(true, true));
 setHeight(height() + paddingTop() + paddingBottom() + borderTop() + borderBottom());

 // We are able to have a horizontal scrollbar if the overflow style is scroll, or if its auto and there's no word wrap.
 if (style()->overflowX() == OSCROLL || (style()->overflowX() == OAUTO && m_innerText->renderer()->style()->wordWrap() == NormalWordWrap))
 setHeight(height() + scrollbarThickness());

 RenderBlock::calcHeight();
}

void RenderTextControl::hitInnerTextElement(HitTestResult& result, int xPos, int yPos, int tx, int ty)
{
 result.setInnerNode(m_innerText.get());
 result.setInnerNonSharedNode(m_innerText.get());
 result.setLocalPoint(IntPoint(xPos - tx - x() - m_innerText->renderBox()->x(),
 yPos - ty - y() - m_innerText->renderBox()->y()));
}

void RenderTextControl::forwardEvent(Event* event)
{
 if (event->type() == eventNames().blurEvent || event->type() == eventNames().focusEvent)
 return;
 m_innerText->defaultEventHandler(event);
}

IntRect RenderTextControl::controlClipRect(int tx, int ty) const
{
 IntRect clipRect = contentBoxRect();
 clipRect.move(tx, ty);
 return clipRect;
}

static const char* fontFamiliesWithInvalidCharWidth[] = {
 "American Typewriter",
 "Arial Hebrew",
 "Chalkboard",
 "Cochin",
 "Corsiva Hebrew",
 "Courier",
 "Euphemia UCAS",
 "Geneva",
 "Gill Sans",
 "Hei",
 "Helvetica",
 "Hoefler Text",
 "InaiMathi",
 "Kai",
 "Lucida Grande",
 "Marker Felt",
 "Monaco",
 "Mshtakan",
 "New Peninim MT",
 "Osaka",
 "Raanana",
 "STHeiti",
 "Symbol",
 "Times",
 "Apple Braille",
 "Apple LiGothic",
 "Apple LiSung",
 "Apple Symbols",
 "AppleGothic",
 "AppleMyungjo",
 "#GungSeo",
 "#HeadLineA",
 "#PCMyungjo",
 "#PilGi",
};

// For font families where any of the fonts don't have a valid entry in the OS/2 table
// for avgCharWidth, fallback to the legacy webkit behavior of getting the avgCharWidth
// from the width of a '0'. This only seems to apply to a fixed number of Mac fonts,
// but, in order to get similar rendering across platforms, we do this check for
// all platforms.
bool RenderTextControl::hasValidAvgCharWidth(AtomicString family)
{
 static HashSet* fontFamiliesWithInvalidCharWidthMap = 0;
 
 if (!fontFamiliesWithInvalidCharWidthMap) {
 fontFamiliesWithInvalidCharWidthMap = new HashSet;
 
 for (unsigned i = 0; i add(AtomicString(fontFamiliesWithInvalidCharWidth[i]));
 }

 return !fontFamiliesWithInvalidCharWidthMap->contains(family);
}

float RenderTextControl::getAvgCharWidth(AtomicString family)
{
 if (hasValidAvgCharWidth(family))
 return roundf(style()->font().primaryFont()->avgCharWidth());

 const UChar ch = '0'; 
 return style()->font().floatWidth(TextRun(&ch, 1, false, 0, 0, false, false, false));
}

float RenderTextControl::scaleEmToUnits(int x) const
{
 // This matches the unitsPerEm value for MS Shell Dlg and Courier New from the "head" font table.
 float unitsPerEm = 2048.0f;
 return roundf(style()->font().size() * x / unitsPerEm);
}

void RenderTextControl::calcPrefWidths()
{
 ASSERT(prefWidthsDirty());

 m_minPrefWidth = 0;
 m_maxPrefWidth = 0;

 if (style()->width().isFixed() && style()->width().value() > 0)
 m_minPrefWidth = m_maxPrefWidth = calcContentBoxWidth(style()->width().value());
 else {
 // Use average character width. Matches IE.
 AtomicString family = style()->font().family().family();
 m_maxPrefWidth = preferredContentWidth(getAvgCharWidth(family)) + m_innerText->renderBox()->paddingLeft() + m_innerText->renderBox()->paddingRight();
 }

 if (style()->minWidth().isFixed() && style()->minWidth().value() > 0) {
 m_maxPrefWidth = max(m_maxPrefWidth, calcContentBoxWidth(style()->minWidth().value()));
 m_minPrefWidth = max(m_minPrefWidth, calcContentBoxWidth(style()->minWidth().value()));
 } else if (style()->width().isPercent() || (style()->width().isAuto() && style()->height().isPercent()))
 m_minPrefWidth = 0;
 else
 m_minPrefWidth = m_maxPrefWidth;

 if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength) {
 m_maxPrefWidth = min(m_maxPrefWidth, calcContentBoxWidth(style()->maxWidth().value()));
 m_minPrefWidth = min(m_minPrefWidth, calcContentBoxWidth(style()->maxWidth().value()));
 }

 int toAdd = paddingLeft() + paddingRight() + borderLeft() + borderRight();

 m_minPrefWidth += toAdd;
 m_maxPrefWidth += toAdd;

 setPrefWidthsDirty(false);
}

void RenderTextControl::selectionChanged(bool userTriggered)
{
 cacheSelection(selectionStart(), selectionEnd());

 if (Frame* frame = document()->frame()) {
 if (frame->selection()->isRange() && userTriggered)
 node()->dispatchEvent(Event::create(eventNames().selectEvent, true, false));
 }
}

void RenderTextControl::addFocusRingRects(Vector& rects, int tx, int ty)
{
 if (width() && height())
 rects.append(IntRect(tx, ty, width(), height()));
}

HTMLElement* RenderTextControl::innerTextElement() const
{
 return m_innerText.get();
}

void RenderTextControl::updatePlaceholderVisibility(bool placeholderShouldBeVisible, bool placeholderValueChanged)
{
 bool oldPlaceholderVisible = m_placeholderVisible;
 m_placeholderVisible = placeholderShouldBeVisible;
 if (oldPlaceholderVisible != m_placeholderVisible || placeholderValueChanged) {
 // Sets the inner text style to the normal style or :placeholder style.
 setInnerTextStyle(createInnerTextStyle(textBaseStyle()));

 // updateFromElement() of the subclasses updates the text content
 // to the element's value(), placeholder(), or the empty string.
 updateFromElement();
 }
}

} // namespace WebCore

Reading notes: The supplied source text is a WebKit/WebCore C++ source file (RenderTextControl), not an advertisement, poster, or page, so no headline, product names, or prices appear in it. The years 2006, 2007 and 2008 appear only in the copyright notice of the license header comment, not as advertised dates. No visual layout or reading order can be verified because no image was supplied.

Printed dates: 2006 · 2007 · 2008

Languages: English

[Original Document section 1](https://www.vintageapple.net/files/26f61fc5b74f962f36095316eb03d58535f09d0d827ba681bc0f2fc52472987b/rendertextcontrol-2010.cpp)
