feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
108
engine/thirdparty/harfbuzz/src/hb-coretext-font.cc
vendored
108
engine/thirdparty/harfbuzz/src/hb-coretext-font.cc
vendored
|
|
@ -34,8 +34,12 @@
|
|||
#include "hb-font.hh"
|
||||
#include "hb-machinery.hh"
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101100
|
||||
#if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1080) \
|
||||
|| (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 60000) \
|
||||
|| (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 90000)
|
||||
# define kCTFontOrientationDefault kCTFontDefaultOrientation
|
||||
# define kCTFontOrientationHorizontal kCTFontHorizontalOrientation
|
||||
# define kCTFontOrientationVertical kCTFontVerticalOrientation
|
||||
#endif
|
||||
|
||||
#define MAX_GLYPHS 64u
|
||||
|
|
@ -56,11 +60,25 @@ hb_coretext_get_nominal_glyph (hb_font_t *font HB_UNUSED,
|
|||
void *user_data HB_UNUSED)
|
||||
{
|
||||
CTFontRef ct_font = (CTFontRef) font_data;
|
||||
UniChar ch = unicode;
|
||||
CGGlyph cg_glyph;
|
||||
if (CTFontGetGlyphsForCharacters (ct_font, &ch, &cg_glyph, 1))
|
||||
UniChar ch[2];
|
||||
CGGlyph cg_glyph[2];
|
||||
unsigned count = 0;
|
||||
|
||||
if (unicode <= 0xFFFF)
|
||||
{
|
||||
*glyph = cg_glyph;
|
||||
ch[count++] = unicode;
|
||||
}
|
||||
else if (unicode <= 0x10FFFF)
|
||||
{
|
||||
ch[count++] = (unicode >> 10) + 0xD7C0;
|
||||
ch[count++] = (unicode & 0x3FF) + 0xDC00;
|
||||
}
|
||||
else
|
||||
ch[count++] = 0xFFFD;
|
||||
|
||||
if (CTFontGetGlyphsForCharacters (ct_font, ch, cg_glyph, count))
|
||||
{
|
||||
*glyph = cg_glyph[0];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -76,6 +94,31 @@ hb_coretext_get_nominal_glyphs (hb_font_t *font HB_UNUSED,
|
|||
unsigned int glyph_stride,
|
||||
void *user_data HB_UNUSED)
|
||||
{
|
||||
// If any non-BMP codepoint is requested, use the slow path.
|
||||
bool slow_path = false;
|
||||
auto *unicode = first_unicode;
|
||||
for (unsigned i = 0; i < count; i++)
|
||||
{
|
||||
if (*unicode > 0xFFFF)
|
||||
{
|
||||
slow_path = true;
|
||||
break;
|
||||
}
|
||||
unicode = &StructAtOffset<const hb_codepoint_t> (unicode, unicode_stride);
|
||||
}
|
||||
|
||||
if (unlikely (slow_path))
|
||||
{
|
||||
for (unsigned i = 0; i < count; i++)
|
||||
{
|
||||
if (!hb_coretext_get_nominal_glyph (font, font_data, *first_unicode, first_glyph, nullptr))
|
||||
return i;
|
||||
first_unicode = &StructAtOffset<const hb_codepoint_t> (first_unicode, unicode_stride);
|
||||
first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
CTFontRef ct_font = (CTFontRef) font_data;
|
||||
|
||||
UniChar ch[MAX_GLYPHS];
|
||||
|
|
@ -88,7 +131,16 @@ hb_coretext_get_nominal_glyphs (hb_font_t *font HB_UNUSED,
|
|||
ch[j] = *first_unicode;
|
||||
first_unicode = &StructAtOffset<const hb_codepoint_t> (first_unicode, unicode_stride);
|
||||
}
|
||||
CTFontGetGlyphsForCharacters (ct_font, ch, cg_glyph, c);
|
||||
if (unlikely (!CTFontGetGlyphsForCharacters (ct_font, ch, cg_glyph, c)))
|
||||
{
|
||||
// Use slow path partially and return at first failure.
|
||||
for (unsigned j = 0; j < c; j++)
|
||||
{
|
||||
if (!hb_coretext_get_nominal_glyph (font, font_data, ch[j], first_glyph, nullptr))
|
||||
return i + j;
|
||||
first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride);
|
||||
}
|
||||
}
|
||||
for (unsigned j = 0; j < c; j++)
|
||||
{
|
||||
*first_glyph = cg_glyph[j];
|
||||
|
|
@ -109,13 +161,38 @@ hb_coretext_get_variation_glyph (hb_font_t *font HB_UNUSED,
|
|||
{
|
||||
CTFontRef ct_font = (CTFontRef) font_data;
|
||||
|
||||
UniChar ch[2] = { unicode, variation_selector };
|
||||
CGGlyph cg_glyph[2];
|
||||
UniChar ch[4];
|
||||
CGGlyph cg_glyph[4];
|
||||
unsigned count = 0;
|
||||
|
||||
CTFontGetGlyphsForCharacters (ct_font, ch, cg_glyph, 2);
|
||||
// Add Unicode, then variation selector. Ugly, but works.
|
||||
//
|
||||
if (unicode <= 0xFFFF)
|
||||
ch[count++] = unicode;
|
||||
else if (unicode <= 0x10FFFF)
|
||||
{
|
||||
ch[count++] = (unicode >> 10) + 0xD7C0;
|
||||
ch[count++] = (unicode & 0x3FF) + 0xDC00;
|
||||
}
|
||||
else
|
||||
ch[count++] = 0xFFFD;
|
||||
|
||||
if (cg_glyph[1])
|
||||
return false;
|
||||
if (variation_selector <= 0xFFFF)
|
||||
ch[count++] = variation_selector;
|
||||
else if (variation_selector <= 0x10FFFF)
|
||||
{
|
||||
ch[count++] = (variation_selector >> 10) + 0xD7C0;
|
||||
ch[count++] = (variation_selector & 0x3FF) + 0xDC00;
|
||||
}
|
||||
else
|
||||
ch[count++] = 0xFFFD;
|
||||
|
||||
CTFontGetGlyphsForCharacters (ct_font, ch, cg_glyph, count);
|
||||
|
||||
// All except for first should be zero if we succeeded
|
||||
for (unsigned i = 1; i < count; i++)
|
||||
if (cg_glyph[i])
|
||||
return false;
|
||||
|
||||
*glyph = cg_glyph[0];
|
||||
return true;
|
||||
|
|
@ -434,10 +511,6 @@ _hb_coretext_get_font_funcs ()
|
|||
* created with hb_face_create(), and therefore was not
|
||||
* initially configured to use CoreText font functions.
|
||||
*
|
||||
* An #hb_font_t object created with hb_coretext_font_create()
|
||||
* is preconfigured for CoreText font functions and does not
|
||||
* require this function to be used.
|
||||
*
|
||||
* <note>Note: Internally, this function creates a CTFont.
|
||||
* </note>
|
||||
*
|
||||
|
|
@ -448,7 +521,12 @@ hb_coretext_font_set_funcs (hb_font_t *font)
|
|||
{
|
||||
CTFontRef ct_font = hb_coretext_font_get_ct_font (font);
|
||||
if (unlikely (!ct_font))
|
||||
{
|
||||
hb_font_set_funcs (font,
|
||||
hb_font_funcs_get_empty (),
|
||||
nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
hb_font_set_funcs (font,
|
||||
_hb_coretext_get_font_funcs (),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue