Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_34031325
engine
提交
c8769743
E
engine
项目概览
qq_34031325
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c8769743
编写于
7月 18, 2016
作者:
C
Chinmay Garde
提交者:
GitHub
7月 18, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Attempt font fallback resolution using CoreText on iOS. (#2800)
上级
0b1986a5
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
239 addition
and
42 deletion
+239
-42
sky/engine/platform/BUILD.gn
sky/engine/platform/BUILD.gn
+8
-0
sky/engine/platform/fonts/apple/FontCacheIOS.mm
sky/engine/platform/fonts/apple/FontCacheIOS.mm
+183
-0
sky/engine/platform/fonts/apple/FontCacheMac.cpp
sky/engine/platform/fonts/apple/FontCacheMac.cpp
+42
-0
sky/engine/platform/fonts/apple/FontPlatformDataApple.cpp
sky/engine/platform/fonts/apple/FontPlatformDataApple.cpp
+2
-11
sky/engine/platform/fonts/skia/FontCacheSkia.cpp
sky/engine/platform/fonts/skia/FontCacheSkia.cpp
+2
-10
sky/engine/wtf/text/AtomicString.h
sky/engine/wtf/text/AtomicString.h
+0
-4
sky/engine/wtf/text/WTFString.h
sky/engine/wtf/text/WTFString.h
+0
-16
sky/shell/gpu/direct/rasterizer_direct.cc
sky/shell/gpu/direct/rasterizer_direct.cc
+2
-1
未找到文件。
sky/engine/platform/BUILD.gn
浏览文件 @
c8769743
...
...
@@ -332,6 +332,14 @@ source_set("platform") {
sources += [ "fonts/apple/FontPlatformDataApple.cpp" ]
}
if (is_ios) {
sources += [ "fonts/apple/FontCacheIOS.mm" ]
}
if (is_mac && !is_ios) {
sources += [ "fonts/apple/FontCacheMac.cpp" ]
}
configs += [
"//sky/engine:config",
"//sky/engine:non_test_config",
...
...
sky/engine/platform/fonts/apple/FontCacheIOS.mm
0 → 100644
浏览文件 @
c8769743
/*
* Copyright (c) 2016, Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
#import <CoreFoundation/CoreFoundation.h>
#import <CoreText/CoreText.h>
#import <UIKit/UIKit.h>
#include "sky/engine/platform/fonts/FontCache.h"
#include "base/mac/scoped_nsautorelease_pool.h"
#include "base/mac/scoped_nsobject.h"
#include "base/lazy_instance.h"
#include "base/macros.h"
#include "base/logging.h"
namespace
blink
{
template
<
class
T
>
class
CFRef
{
public:
CFRef
()
:
_ref
(
nullptr
)
{}
CFRef
(
T
t
)
:
_ref
(
t
)
{}
CFRef
(
const
CFRef
&
)
=
delete
;
void
operator
=
(
const
CFRef
&
)
=
delete
;
CFRef
(
CFRef
&&
o
)
:
_ref
(
o
.
_ref
)
{
o
.
_ref
=
nullptr
;
}
void
operator
=
(
CFRef
&&
o
)
{
_ref
=
o
.
_ref
;
o
.
_ref
=
nullptr
;
}
operator
bool
()
const
{
return
_ref
!=
nullptr
;
}
T
get
()
const
{
return
_ref
;
}
~
CFRef
()
{
if
(
_ref
!=
nullptr
)
{
CFRelease
(
reinterpret_cast
<
CFTypeRef
>
(
_ref
));
}
}
private:
T
_ref
;
};
class
FontFallbackSelector
{
public:
FontFallbackSelector
()
{
base
::
mac
::
ScopedNSAutoreleasePool
pool
;
UIFontDescriptor
*
ui_desc
=
[
UIFont
systemFontOfSize
:[
UIFont
systemFontSize
]].
fontDescriptor
;
CFRef
<
CTFontDescriptorRef
>
desc
(
CTFontDescriptorCreateWithNameAndSize
(
reinterpret_cast
<
CFStringRef
>
(
ui_desc
.
postscriptName
),
ui_desc
.
pointSize
));
if
(
!
desc
)
{
return
;
}
_prototype
=
CFRef
<
CTFontRef
>
{
CTFontCreateWithFontDescriptor
(
desc
.
get
(),
ui_desc
.
pointSize
,
nullptr
)};
}
CFRef
<
CTFontDescriptorRef
>
fallbackFont
(
unichar
glyph
)
{
if
(
!
_prototype
)
{
return
{};
}
base
::
mac
::
ScopedNSAutoreleasePool
pool
;
CFRef
<
CFStringRef
>
unicode_string
(
CFStringCreateWithFormat
(
kCFAllocatorDefault
,
nullptr
,
CFSTR
(
"%C"
),
glyph
));
if
(
!
unicode_string
)
{
return
{};
}
CFRef
<
CTFontRef
>
font
(
CTFontCreateForString
(
_prototype
.
get
(),
unicode_string
.
get
(),
CFRangeMake
(
0
,
CFStringGetLength
(
unicode_string
.
get
()))));
if
(
!
font
)
{
return
{};
}
return
CTFontCopyFontDescriptor
(
font
.
get
());
}
private:
CFRef
<
CTFontRef
>
_prototype
;
DISALLOW_COPY_AND_ASSIGN
(
FontFallbackSelector
);
};
static
base
::
LazyInstance
<
FontFallbackSelector
>
g_fallback_selector
=
LAZY_INSTANCE_INITIALIZER
;
void
FontCache
::
getFontForCharacter
(
UChar32
c
,
const
char
*
,
FontCache
::
PlatformFallbackFont
*
fallbackFont
)
{
if
(
fallbackFont
==
nullptr
)
{
return
;
}
base
::
mac
::
ScopedNSAutoreleasePool
pool
;
fallbackFont
->
name
=
""
;
fallbackFont
->
filename
=
""
;
fallbackFont
->
ttcIndex
=
0
;
fallbackFont
->
fontconfigInterfaceId
=
0
;
fallbackFont
->
isBold
=
false
;
fallbackFont
->
isItalic
=
false
;
CFRef
<
CTFontDescriptorRef
>
font
=
g_fallback_selector
.
Pointer
()
->
fallbackFont
(
c
);
if
(
!
font
)
{
return
;
}
CFRef
<
CFURLRef
>
cf_url
(
reinterpret_cast
<
CFURLRef
>
(
CTFontDescriptorCopyAttribute
(
font
.
get
(),
kCTFontURLAttribute
)));
if
(
!
cf_url
)
{
return
;
}
CFRef
<
CFURLRef
>
cf_absolute_url
(
CFURLCopyAbsoluteURL
(
cf_url
.
get
()));
if
(
!
cf_absolute_url
)
{
return
;
}
const
NSURL
*
url
=
reinterpret_cast
<
const
NSURL
*>
(
cf_absolute_url
.
get
());
fallbackFont
->
filename
=
[
url
fileSystemRepresentation
];
CFRef
<
CFStringRef
>
cf_name
(
reinterpret_cast
<
CFStringRef
>
(
CTFontDescriptorCopyAttribute
(
font
.
get
(),
kCTFontNameAttribute
)));
if
(
!
cf_name
)
{
return
;
}
const
NSString
*
name
=
reinterpret_cast
<
const
NSString
*>
(
cf_name
.
get
());
fallbackFont
->
name
=
[
name
UTF8String
];
}
}
// namespace blink
sky/engine/platform/fonts/apple/FontCacheMac.cpp
0 → 100644
浏览文件 @
c8769743
/*
* Copyright (c) 2016, Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "sky/engine/platform/fonts/FontCache.h"
#include "base/logging.h"
namespace
blink
{
void
FontCache
::
getFontForCharacter
(
UChar32
,
const
char
*
,
FontCache
::
PlatformFallbackFont
*
)
{
LOG
(
INFO
)
<<
"Font fallbacks unimplemented on Mac."
;
}
}
// namespace blink
sky/engine/platform/fonts/apple/FontPlatformDataApple.cpp
浏览文件 @
c8769743
...
...
@@ -28,9 +28,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "base/logging.h"
#include "sky/engine/platform/fonts/FontPlatformData.h"
#include "sky/engine/platform/fonts/FontCache.h"
#include "third_party/skia/include/core/SkTypeface.h"
namespace
blink
{
...
...
@@ -75,11 +73,4 @@ bool FontPlatformData::defaultUseSubpixelPositioning() {
return
false
;
}
void
FontCache
::
getFontForCharacter
(
UChar32
c
,
const
char
*
preferredLocale
,
FontCache
::
PlatformFallbackFont
*
fallbackFont
)
{
DCHECK
(
false
);
}
}
// namespace blink
sky/engine/platform/fonts/skia/FontCacheSkia.cpp
浏览文件 @
c8769743
...
...
@@ -215,17 +215,9 @@ PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri
sk_sp
<
SkTypeface
>
FontCache
::
createTypeface
(
const
FontDescription
&
fontDescription
,
const
FontFaceCreationParams
&
creationParams
,
CString
&
name
)
{
#if !OS(WIN) && !OS(ANDROID)
&& !OS(IOS) && !OS(MACOSX)
#if !OS(WIN) && !OS(ANDROID)
if
(
creationParams
.
creationType
()
==
CreateFontByFciIdAndTtcIndex
)
{
// TODO(dro): crbug.com/381620 Use creationParams.ttcIndex() after
// https://code.google.com/p/skia/issues/detail?id=1186 gets fixed.
sk_sp
<
SkTypeface
>
typeface
;
if
(
Platform
::
current
()
->
sandboxSupport
())
typeface
=
SkTypeface
::
MakeFromStream
(
streamForFontconfigInterfaceId
(
creationParams
.
fontconfigInterfaceId
()));
else
typeface
=
SkTypeface
::
MakeFromFile
(
creationParams
.
filename
().
data
());
return
typeface
;
return
SkTypeface
::
MakeFromFile
(
creationParams
.
filename
().
data
());
}
#endif
...
...
sky/engine/wtf/text/AtomicString.h
浏览文件 @
c8769743
...
...
@@ -139,10 +139,6 @@ public:
#if USE(CF)
AtomicString
(
CFStringRef
s
)
:
m_string
(
add
(
s
))
{
}
#endif
#ifdef __OBJC__
AtomicString
(
NSString
*
s
)
:
m_string
(
add
((
CFStringRef
)
s
))
{
}
operator
NSString
*
()
const
{
return
m_string
;
}
#endif
// AtomicString::fromUTF8 will return a null string if
// the input data contains invalid UTF-8 sequences.
...
...
sky/engine/wtf/text/WTFString.h
浏览文件 @
c8769743
...
...
@@ -376,14 +376,6 @@ public:
RetainPtr
<
CFStringRef
>
createCFString
()
const
;
#endif
#ifdef __OBJC__
String
(
NSString
*
);
// This conversion maps NULL to "", which loses the meaning of NULL, but we
// need this mapping because AppKit crashes when passed nil NSStrings.
operator
NSString
*
()
const
{
if
(
!
m_impl
)
return
@""
;
return
*
m_impl
;
}
#endif
static
String
make8BitFrom16BitSource
(
const
UChar
*
,
size_t
);
template
<
size_t
inlineCapacity
>
static
String
make8BitFrom16BitSource
(
const
Vector
<
UChar
,
inlineCapacity
>&
buffer
)
...
...
@@ -512,14 +504,6 @@ inline bool String::containsOnlyLatin1() const
return
!
(
ored
&
0xFF00
);
}
#ifdef __OBJC__
// This is for situations in WebKit where the long standing behavior has been
// "nil if empty", so we try to maintain longstanding behavior for the sake of
// entrenched clients
inline
NSString
*
nsStringNilIfEmpty
(
const
String
&
str
)
{
return
str
.
isEmpty
()
?
nil
:
(
NSString
*
)
str
;
}
#endif
inline
bool
String
::
containsOnlyASCII
()
const
{
if
(
isEmpty
())
...
...
sky/shell/gpu/direct/rasterizer_direct.cc
浏览文件 @
c8769743
...
...
@@ -17,7 +17,8 @@
namespace
sky
{
namespace
shell
{
RasterizerDirect
::
RasterizerDirect
()
:
binding_
(
this
),
weak_factory_
(
this
)
{}
RasterizerDirect
::
RasterizerDirect
()
:
binding_
(
this
),
platform_view_
(
nullptr
),
weak_factory_
(
this
)
{}
RasterizerDirect
::~
RasterizerDirect
()
{
weak_factory_
.
InvalidateWeakPtrs
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录