зеркало из https://github.com/mozilla/gecko-dev.git
Bug 989557 - Implement a fallback for CJK Compatibility Ideographs Standardized Variants. r=jfkthame
--HG-- rename : layout/reftests/fonts/gw432047-license.txt => layout/reftests/fonts/glyphwiki-license.txt
This commit is contained in:
Родитель
537b992447
Коммит
5e7240163c
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,77 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import os.path
|
||||
import re
|
||||
import sys
|
||||
|
||||
f = open(sys.argv[1] if len(sys.argv) > 1 else 'StandardizedVariants.txt')
|
||||
|
||||
line = f.readline()
|
||||
m = re.compile('^# (StandardizedVariants(-\d+(\.\d+)*)?\.txt)').search(line)
|
||||
fileversion = m.group(1)
|
||||
vsdict = {}
|
||||
r = re.compile('^([0-9A-F]{4,6}) (FE0[0-9A-F]); CJK COMPATIBILITY IDEOGRAPH-([0-9A-F]{4,6});')
|
||||
while True:
|
||||
line = f.readline()
|
||||
if not line:
|
||||
break
|
||||
if not 'CJK COMPATIBILITY IDEOGRAPH-' in line:
|
||||
continue
|
||||
|
||||
m = r.search(line)
|
||||
unified = int(m.group(1), 16)
|
||||
vs = int(m.group(2), 16)
|
||||
compat = int(m.group(3), 16)
|
||||
|
||||
if not vs in vsdict:
|
||||
vsdict[vs] = {}
|
||||
vsdict[vs][unified] = compat
|
||||
|
||||
f.close
|
||||
|
||||
offsets = []
|
||||
length = 10 + 11 * len(vsdict)
|
||||
for (k, mappings) in sorted(vsdict.items()):
|
||||
offsets.append(length)
|
||||
length += 4 + 5 * len(mappings)
|
||||
|
||||
f = open(sys.argv[2] if len(sys.argv) > 2 else 'CJKCompatSVS.cpp', 'wb')
|
||||
f.write("""// Generated by %s. Do not edit.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define U16(v) (((v) >> 8) & 0xFF), ((v) & 0xFF)
|
||||
#define U24(v) (((v) >> 16) & 0xFF), (((v) >> 8) & 0xFF), ((v) & 0xFF)
|
||||
#define U32(v) (((v) >> 24) & 0xFF), (((v) >> 16) & 0xFF), (((v) >> 8) & 0xFF), ((v) & 0xFF)
|
||||
#define GLYPH(v) U16(v >= 0x2F800 ? (v) - (0x2F800 - 0xFB00) : (v))
|
||||
|
||||
// Fallback mappings for CJK Compatibility Ideographs Standardized Variants
|
||||
// taken from %s.
|
||||
// Using OpenType format 14 cmap subtable structure to reuse the lookup code
|
||||
// for fonts. The glyphID field is used to store the corresponding codepoints
|
||||
// CJK Compatibility Ideographs. To fit codepoints into the 16-bit glyphID
|
||||
// field, CJK Compatibility Ideographs Supplement (U+2F800..U+2FA1F) will be
|
||||
// mapped to 0xFB00..0xFD1F.
|
||||
extern const uint8_t sCJKCompatSVSTable[] = {
|
||||
""" % (os.path.basename(sys.argv[0]), fileversion))
|
||||
f.write(' U16(14), // format\n')
|
||||
f.write(' U32(%d), // length\n' % length)
|
||||
f.write(' U32(%d), // numVarSelectorRecords\n' % len(vsdict))
|
||||
for i, k in enumerate(sorted(vsdict.keys())):
|
||||
f.write(' U24(0x%04X), U32(0), U32(%d), // varSelectorRecord[%d]\n' % (k, offsets[i], i))
|
||||
for (k, mappings) in sorted(vsdict.items()):
|
||||
f.write(' // 0x%04X\n' % k)
|
||||
f.write(' U32(%d), // numUVSMappings\n' % len(mappings))
|
||||
for (unified, compat) in sorted(mappings.items()):
|
||||
f.write(' U24(0x%04X), GLYPH(0x%04X),\n' % (unified, compat))
|
||||
f.write("""};
|
||||
|
||||
#undef U16
|
||||
#undef U24
|
||||
#undef U32
|
||||
#undef GLYPH
|
||||
|
||||
static_assert(sizeof sCJKCompatSVSTable == %d, "Table generator has a bug.");
|
||||
""" % length)
|
|
@ -8,6 +8,7 @@
|
|||
#include "harfbuzz/hb.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "gfxFontConstants.h"
|
||||
#include "gfxFontUtils.h"
|
||||
|
||||
using namespace mozilla::gfx;
|
||||
|
||||
|
@ -155,6 +156,10 @@ gfxFT2FontBase::GetGlyph(uint32_t unicode, uint32_t variation_selector)
|
|||
gfxFT2LockedFace(this).GetUVSGlyph(unicode, variation_selector);
|
||||
if (id)
|
||||
return id;
|
||||
id = gfxFontUtils::GetUVSFallback(unicode, variation_selector);
|
||||
if (id) {
|
||||
unicode = id;
|
||||
}
|
||||
}
|
||||
|
||||
return GetGlyph(unicode);
|
||||
|
|
|
@ -692,9 +692,27 @@ gfxFontUtils::MapCharToGlyph(const uint8_t *aCmapBuf, uint32_t aBufLength,
|
|||
uint32_t varGID =
|
||||
gfxFontUtils::MapUVSToGlyphFormat14(aCmapBuf + uvsOffset,
|
||||
aUnicode, aVarSelector);
|
||||
if (!varGID) {
|
||||
aUnicode = gfxFontUtils::GetUVSFallback(aUnicode, aVarSelector);
|
||||
if (aUnicode) {
|
||||
switch (format) {
|
||||
case 4:
|
||||
if (aUnicode < UNICODE_BMP_LIMIT) {
|
||||
varGID = MapCharToGlyphFormat4(aCmapBuf + offset,
|
||||
char16_t(aUnicode));
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
varGID = MapCharToGlyphFormat12(aCmapBuf + offset,
|
||||
aUnicode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (varGID) {
|
||||
gid = varGID;
|
||||
}
|
||||
|
||||
// else the variation sequence was not supported, use default mapping
|
||||
// of the character code alone
|
||||
}
|
||||
|
|
|
@ -639,6 +639,8 @@ enum gfxUserFontType {
|
|||
GFX_USERFONT_WOFF = 3
|
||||
};
|
||||
|
||||
extern const uint8_t sCJKCompatSVSTable[];
|
||||
|
||||
class gfxFontUtils {
|
||||
|
||||
public:
|
||||
|
@ -784,6 +786,15 @@ public:
|
|||
static uint16_t
|
||||
MapUVSToGlyphFormat14(const uint8_t *aBuf, uint32_t aCh, uint32_t aVS);
|
||||
|
||||
// sCJKCompatSVSTable is a 'cmap' format 14 subtable that maps
|
||||
// <char + var-selector> pairs to the corresponding Unicode
|
||||
// compatibility ideograph codepoints.
|
||||
static MOZ_ALWAYS_INLINE uint32_t
|
||||
GetUVSFallback(uint32_t aCh, uint32_t aVS) {
|
||||
aCh = MapUVSToGlyphFormat14(sCJKCompatSVSTable, aCh, aVS);
|
||||
return aCh >= 0xFB00 ? aCh + (0x2F800 - 0xFB00) : aCh;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
MapCharToGlyph(const uint8_t *aCmapBuf, uint32_t aBufLength,
|
||||
uint32_t aUnicode, uint32_t aVarSelector = 0);
|
||||
|
|
|
@ -95,6 +95,24 @@ gfxHarfBuzzShaper::GetGlyph(hb_codepoint_t unicode,
|
|||
unicode,
|
||||
variation_selector);
|
||||
}
|
||||
if (!gid) {
|
||||
uint32_t compat =
|
||||
gfxFontUtils::GetUVSFallback(unicode, variation_selector);
|
||||
if (compat) {
|
||||
switch (mCmapFormat) {
|
||||
case 4:
|
||||
if (compat < UNICODE_BMP_LIMIT) {
|
||||
gid = gfxFontUtils::MapCharToGlyphFormat4(data + mSubtableOffset,
|
||||
compat);
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
gid = gfxFontUtils::MapCharToGlyphFormat12(data + mSubtableOffset,
|
||||
compat);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If the variation sequence was not supported, return zero here;
|
||||
// harfbuzz will call us again for the base character alone
|
||||
return gid;
|
||||
|
|
|
@ -226,6 +226,7 @@ SOURCES += [
|
|||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'CJKCompatSVS.cpp',
|
||||
'gfx3DMatrix.cpp',
|
||||
'gfxAlphaRecovery.cpp',
|
||||
'gfxBaseSharedMemorySurface.cpp',
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html><meta charset=utf-8>
|
||||
<title>Duplicate encoded quartet</title>
|
||||
<style>
|
||||
@font-face { font-family: DupEncQuartet; src: url('../fonts/gw1270797.ttf') format("truetype"); }
|
||||
th { width: 72pt }
|
||||
td { font-size: 72pt; font-family: DupEncQuartet, sans-serif; text-align: center }
|
||||
</style>
|
||||
<body>
|
||||
<table border>
|
||||
<caption>Duplicate encoded quartet</caption>
|
||||
<tr>
|
||||
<th>CJK Compatibility Ideographs</td>
|
||||
<th>Adobe-Japan1 IVS</td>
|
||||
<th>Hanyo-Denshi IVS</td>
|
||||
<th>CJK Compatibility Ideographs Standardized Variant</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html><meta charset=utf-8>
|
||||
<title>Duplicate encoded quartet</title>
|
||||
<style>
|
||||
@font-face { font-family: DupEncQuartet; src: url('../fonts/gw1270797.ttf') format("truetype"); }
|
||||
th { width: 72pt }
|
||||
td { font-size: 72pt; font-family: DupEncQuartet, sans-serif; text-align: center }
|
||||
</style>
|
||||
<body>
|
||||
<table border>
|
||||
<caption>Duplicate encoded quartet</caption>
|
||||
<tr>
|
||||
<th>CJK Compatibility Ideographs</td>
|
||||
<th>Adobe-Japan1 IVS</td>
|
||||
<th>Hanyo-Denshi IVS</td>
|
||||
<th>CJK Compatibility Ideographs Standardized Variant</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>神</td>
|
||||
<td>神󠄀</td>
|
||||
<td>神󠄃</td>
|
||||
<td>神︀</td>
|
||||
</tr>
|
|
@ -142,6 +142,7 @@ HTTP(..) == font-familiy-whitespace-1.html font-familiy-whitespace-1-ref.html
|
|||
HTTP(..) != font-familiy-whitespace-1.html font-familiy-whitespace-1-notref.html
|
||||
|
||||
skip-if(B2G) HTTP(..) == ivs-1.html ivs-1-ref.html # bug 773482
|
||||
skip-if(B2G) HTTP(..) == cjkcisvs-1.html cjkcisvs-1-ref.html
|
||||
|
||||
skip-if(B2G) HTTP(..) == missing-names.html missing-names-ref.html # bug 773482
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
gw432047.ttf, gw1270797.ttf
|
||||
|
||||
<http://en.glyphwiki.org/wiki/GlyphWiki:License>
|
||||
'''This document is a direct translation of the October 8th, 2008 revision of the Japanese original at ([[GlyphWiki:データ・記事のライセンス]]). This translation is provided as a service, and should not be taken to be a definitive statement. Please be aware that in case the Japanese original and the English version differ, the Japanese original takes precedence.'''
|
||||
|
Двоичный файл не отображается.
Загрузка…
Ссылка в новой задаче