Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
ba7f6c37
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
1 年多 前同步成功
通知
0
Star
18
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Harfbuzz
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ba7f6c37
编写于
8月 23, 2012
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[icu-le] Hook up to hb_face_t
上级
e96bb369
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
57 addition
and
169 deletion
+57
-169
src/hb-icu-le.cc
src/hb-icu-le.cc
+13
-4
src/hb-icu-le/FontTableCache.cpp
src/hb-icu-le/FontTableCache.cpp
+17
-17
src/hb-icu-le/FontTableCache.h
src/hb-icu-le/FontTableCache.h
+6
-3
src/hb-icu-le/PortableFontInstance.cpp
src/hb-icu-le/PortableFontInstance.cpp
+12
-132
src/hb-icu-le/PortableFontInstance.h
src/hb-icu-le/PortableFontInstance.h
+8
-13
src/hb-icu-le/README
src/hb-icu-le/README
+1
-0
未找到文件。
src/hb-icu-le.cc
浏览文件 @
ba7f6c37
...
...
@@ -25,6 +25,7 @@
*/
#define HB_SHAPER icu_le
#define hb_icu_le_shaper_font_data_t PortableFontInstance
#include "hb-shaper-impl-private.hh"
#include "hb-icu-le/PortableFontInstance.h"
...
...
@@ -61,18 +62,26 @@ _hb_icu_le_shaper_face_data_destroy (hb_icu_le_shaper_face_data_t *data)
* shaper font data
*/
struct
hb_icu_le_shaper_font_data_t
{};
hb_icu_le_shaper_font_data_t
*
_hb_icu_le_shaper_font_data_create
(
hb_font_t
*
font
)
{
return
(
hb_icu_le_shaper_font_data_t
*
)
HB_SHAPER_DATA_SUCCEEDED
;
LEErrorCode
status
=
LE_NO_ERROR
;
hb_icu_le_shaper_font_data_t
*
data
=
new
PortableFontInstance
(
font
->
face
,
font
->
x_scale
,
font
->
y_scale
,
status
);
if
(
status
!=
LE_NO_ERROR
)
{
delete
(
data
);
return
NULL
;
}
return
data
;
}
void
_hb_icu_le_shaper_font_data_destroy
(
hb_icu_le_shaper_font_data_t
*
data
)
{
fre
e
(
data
);
delet
e
(
data
);
}
...
...
src/hb-icu-le/FontTableCache.cpp
浏览文件 @
ba7f6c37
...
...
@@ -16,7 +16,7 @@
struct
FontTableCacheEntry
{
LETag
tag
;
const
void
*
table
;
hb_blob_t
*
blob
;
};
FontTableCache
::
FontTableCache
()
...
...
@@ -30,18 +30,18 @@ FontTableCache::FontTableCache()
}
for
(
int
i
=
0
;
i
<
fTableCacheSize
;
i
+=
1
)
{
fTableCache
[
i
].
tag
=
0
;
fTableCache
[
i
].
table
=
NULL
;
fTableCache
[
i
].
tag
=
0
;
fTableCache
[
i
].
blob
=
NULL
;
}
}
FontTableCache
::~
FontTableCache
()
{
for
(
int
i
=
fTableCacheCurr
-
1
;
i
>=
0
;
i
-=
1
)
{
DELETE_ARRAY
(
fTableCache
[
i
].
table
);
hb_blob_destroy
(
fTableCache
[
i
].
blob
);
fTableCache
[
i
].
tag
=
0
;
fTableCache
[
i
].
table
=
NULL
;
fTableCache
[
i
].
tag
=
0
;
fTableCache
[
i
].
blob
=
NULL
;
}
fTableCacheCurr
=
0
;
...
...
@@ -49,27 +49,27 @@ FontTableCache::~FontTableCache()
DELETE_ARRAY
(
fTableCache
);
}
void
FontTableCache
::
freeFontTable
(
const
void
*
table
)
const
void
FontTableCache
::
freeFontTable
(
hb_blob_t
*
blob
)
const
{
DELETE_ARRAY
(
table
);
hb_blob_destroy
(
blob
);
}
const
void
*
FontTableCache
::
find
(
LETag
tableTag
)
const
{
for
(
int
i
=
0
;
i
<
fTableCacheCurr
;
i
+=
1
)
{
if
(
fTableCache
[
i
].
tag
==
tableTag
)
{
return
fTableCache
[
i
].
table
;
return
hb_blob_get_data
(
fTableCache
[
i
].
blob
,
NULL
)
;
}
}
const
void
*
table
=
readFontTable
(
tableTag
);
hb_blob_t
*
blob
=
readFontTable
(
tableTag
);
((
FontTableCache
*
)
this
)
->
add
(
tableTag
,
table
);
((
FontTableCache
*
)
this
)
->
add
(
tableTag
,
blob
);
return
table
;
return
hb_blob_get_data
(
blob
,
NULL
)
;
}
void
FontTableCache
::
add
(
LETag
tableTag
,
const
void
*
table
)
void
FontTableCache
::
add
(
LETag
tableTag
,
hb_blob_t
*
blob
)
{
if
(
fTableCacheCurr
>=
fTableCacheSize
)
{
le_int32
newSize
=
fTableCacheSize
+
TABLE_CACHE_GROW
;
...
...
@@ -77,15 +77,15 @@ void FontTableCache::add(LETag tableTag, const void *table)
fTableCache
=
(
FontTableCacheEntry
*
)
GROW_ARRAY
(
fTableCache
,
newSize
);
for
(
le_int32
i
=
fTableCacheSize
;
i
<
newSize
;
i
+=
1
)
{
fTableCache
[
i
].
tag
=
0
;
fTableCache
[
i
].
table
=
NULL
;
fTableCache
[
i
].
tag
=
0
;
fTableCache
[
i
].
blob
=
NULL
;
}
fTableCacheSize
=
newSize
;
}
fTableCache
[
fTableCacheCurr
].
tag
=
tableTag
;
fTableCache
[
fTableCacheCurr
].
table
=
table
;
fTableCache
[
fTableCacheCurr
].
tag
=
tableTag
;
fTableCache
[
fTableCacheCurr
].
blob
=
blob
;
fTableCacheCurr
+=
1
;
}
src/hb-icu-le/FontTableCache.h
浏览文件 @
ba7f6c37
...
...
@@ -9,6 +9,9 @@
#define __FONTTABLECACHE_H
#define HB_H_IN
#include <hb-blob.h>
#include "layout/LETypes.h"
U_NAMESPACE_USE
...
...
@@ -25,12 +28,12 @@ public:
const
void
*
find
(
LETag
tableTag
)
const
;
protected:
virtual
const
void
*
readFontTable
(
LETag
tableTag
)
const
=
0
;
virtual
void
freeFontTable
(
const
void
*
table
)
const
;
virtual
hb_blob_t
*
readFontTable
(
LETag
tableTag
)
const
=
0
;
virtual
void
freeFontTable
(
hb_blob_t
*
blob
)
const
;
private:
void
add
(
LETag
tableTag
,
const
void
*
table
);
void
add
(
LETag
tableTag
,
hb_blob_t
*
blob
);
FontTableCacheEntry
*
fTableCache
;
le_int32
fTableCacheCurr
;
...
...
src/hb-icu-le/PortableFontInstance.cpp
浏览文件 @
ba7f6c37
...
...
@@ -64,83 +64,24 @@ le_int8 PortableFontInstance::highBit(le_int32 value)
return
bit
;
}
PortableFontInstance
::
PortableFontInstance
(
const
char
*
fileName
,
float
pointSiz
e
,
LEErrorCode
&
status
)
:
fF
ile
(
NULL
),
fPointSize
(
pointSize
),
fUnitsPerEM
(
0
),
fFontChecksum
(
0
),
fAscent
(
0
),
fDescent
(
0
),
fLeading
(
0
),
f
Directory
(
NULL
),
f
NAMETable
(
NULL
),
fNameCount
(
0
),
fNameStringOffset
(
0
),
fCMAPMapper
(
NULL
),
fHMTXTable
(
NULL
),
fNumGlyphs
(
0
),
fNumLongHorMetrics
(
0
)
PortableFontInstance
::
PortableFontInstance
(
hb_face_t
*
face
,
float
xScale
,
float
yScal
e
,
LEErrorCode
&
status
)
:
fF
ace
(
face
),
fXScale
(
xScale
),
fYScale
(
yScale
),
fUnitsPerEM
(
0
),
fAscent
(
0
),
fDescent
(
0
),
fLeading
(
0
),
fNAMETable
(
NULL
),
fNameCount
(
0
),
fNameStringOffset
(
0
),
fCMAPMapper
(
NULL
),
fHMTXTable
(
NULL
),
fNumGlyphs
(
0
),
fNumLongHorMetrics
(
0
)
{
if
(
LE_FAILURE
(
status
))
{
return
;
}
// open the font file
fFile
=
fopen
(
fileName
,
"rb"
);
if
(
fFile
==
NULL
)
{
status
=
LE_FONT_FILE_NOT_FOUND_ERROR
;
return
;
}
// read in the directory
SFNTDirectory
tempDir
;
fread
(
&
tempDir
,
sizeof
tempDir
,
1
,
fFile
);
le_int32
dirSize
=
sizeof
tempDir
+
((
SWAPW
(
tempDir
.
numTables
)
-
ANY_NUMBER
)
*
sizeof
(
DirectoryEntry
));
const
LETag
headTag
=
LE_HEAD_TABLE_TAG
;
const
LETag
hheaTag
=
LE_HHEA_TABLE_TAG
;
const
HEADTable
*
headTable
=
NULL
;
const
HHEATable
*
hheaTable
=
NULL
;
// const NAMETable *nameTable = NULL;
le_uint16
numTables
=
0
;
fDirectory
=
(
const
SFNTDirectory
*
)
NEW_ARRAY
(
char
,
dirSize
);
if
(
fDirectory
==
NULL
)
{
status
=
LE_MEMORY_ALLOCATION_ERROR
;
goto
error_exit
;
}
fseek
(
fFile
,
0L
,
SEEK_SET
);
fread
((
void
*
)
fDirectory
,
sizeof
(
char
),
dirSize
,
fFile
);
//
// We calculate these numbers 'cause some fonts
// have bogus values for them in the directory header.
//
numTables
=
SWAPW
(
fDirectory
->
numTables
);
fDirPower
=
1
<<
highBit
(
numTables
);
fDirExtra
=
numTables
-
fDirPower
;
// read unitsPerEm from 'head' table
headTable
=
(
const
HEADTable
*
)
getFontTable
(
headTag
);
if
(
headTable
==
NULL
)
{
status
=
LE_MISSING_FONT_TABLE_ERROR
;
goto
error_exit
;
}
fUnitsPerEM
=
SWAPW
(
headTable
->
unitsPerEm
);
fFontChecksum
=
SWAPL
(
headTable
->
checksumAdjustment
);
//nameTable = (NAMETable *) getFontTable(nameTag);
//if (nameTable == NULL) {
// status = LE_MISSING_FONT_TABLE_ERROR;
// goto error_exit;
//}
//fFontVersionString = findName(nameTable, NAME_VERSION_STRING, PLATFORM_MACINTOSH, MACINTOSH_ROMAN, MACINTOSH_ENGLISH);
//if (fFontVersionString == NULL) {
// status = LE_MISSING_FONT_TABLE_ERROR;
// goto error_exit;
//}
fUnitsPerEM
=
hb_face_get_upem
(
face
);
hheaTable
=
(
HHEATable
*
)
getFontTable
(
hheaTag
);
if
(
hheaTable
==
NULL
)
{
status
=
LE_MISSING_FONT_TABLE_ERROR
;
goto
error_exit
;
return
;
}
fAscent
=
(
le_int32
)
yUnitsToPoints
((
float
)
SWAPW
(
hheaTable
->
ascent
));
...
...
@@ -153,73 +94,14 @@ PortableFontInstance::PortableFontInstance(const char *fileName, float pointSize
if
(
fCMAPMapper
==
NULL
)
{
status
=
LE_MISSING_FONT_TABLE_ERROR
;
goto
error_exit
;
return
;
}
return
;
error_exit:
fclose
(
fFile
);
fFile
=
NULL
;
return
;
}
PortableFontInstance
::~
PortableFontInstance
()
{
if
(
fFile
!=
NULL
)
{
fclose
(
fFile
);
if
(
fCMAPMapper
)
delete
fCMAPMapper
;
DELETE_ARRAY
(
fDirectory
);
}
}
const
DirectoryEntry
*
PortableFontInstance
::
findTable
(
LETag
tag
)
const
{
if
(
fDirectory
!=
NULL
)
{
le_uint16
table
=
0
;
le_uint16
probe
=
fDirPower
;
if
(
SWAPL
(
fDirectory
->
tableDirectory
[
fDirExtra
].
tag
)
<=
tag
)
{
table
=
fDirExtra
;
}
while
(
probe
>
(
1
<<
0
))
{
probe
>>=
1
;
if
(
SWAPL
(
fDirectory
->
tableDirectory
[
table
+
probe
].
tag
)
<=
tag
)
{
table
+=
probe
;
}
}
if
(
SWAPL
(
fDirectory
->
tableDirectory
[
table
].
tag
)
==
tag
)
{
return
&
fDirectory
->
tableDirectory
[
table
];
}
}
return
NULL
;
}
const
void
*
PortableFontInstance
::
readTable
(
LETag
tag
,
le_uint32
*
length
)
const
{
const
DirectoryEntry
*
entry
=
findTable
(
tag
);
if
(
entry
==
NULL
)
{
*
length
=
0
;
return
NULL
;
}
*
length
=
SWAPL
(
entry
->
length
);
void
*
table
=
NEW_ARRAY
(
char
,
*
length
);
if
(
table
!=
NULL
)
{
fseek
(
fFile
,
SWAPL
(
entry
->
offset
),
SEEK_SET
);
fread
(
table
,
sizeof
(
char
),
*
length
,
fFile
);
}
return
table
;
}
const
void
*
PortableFontInstance
::
getFontTable
(
LETag
tableTag
)
const
...
...
@@ -227,11 +109,9 @@ const void *PortableFontInstance::getFontTable(LETag tableTag) const
return
FontTableCache
::
find
(
tableTag
);
}
const
void
*
PortableFontInstance
::
readFontTable
(
LETag
tableTag
)
const
hb_blob_t
*
PortableFontInstance
::
readFontTable
(
LETag
tableTag
)
const
{
le_uint32
len
;
return
readTable
(
tableTag
,
&
len
);
return
hb_face_reference_table
(
fFace
,
tableTag
);
}
CMAPMapper
*
PortableFontInstance
::
findUnicodeMapper
()
...
...
@@ -369,7 +249,7 @@ le_int32 PortableFontInstance::getUnitsPerEM() const
le_uint32
PortableFontInstance
::
getFontChecksum
()
const
{
return
fFontChecksum
;
return
0
;
}
le_int32
PortableFontInstance
::
getAscent
()
const
...
...
@@ -408,12 +288,12 @@ LEGlyphID PortableFontInstance::mapCharToGlyph(LEUnicode32 ch) const
float
PortableFontInstance
::
getXPixelsPerEm
()
const
{
return
f
PointSiz
e
;
return
f
XScal
e
;
}
float
PortableFontInstance
::
getYPixelsPerEm
()
const
{
return
f
PointSiz
e
;
return
f
YScal
e
;
}
float
PortableFontInstance
::
getScaleFactorX
()
const
...
...
src/hb-icu-le/PortableFontInstance.h
浏览文件 @
ba7f6c37
...
...
@@ -15,32 +15,29 @@
#ifndef __PORTABLEFONTINSTANCE_H
#define __PORTABLEFONTINSTANCE_H
#include <stdio.h>
#define HB_H_IN
#include <hb-font.h>
#include <hb-blob.h>
#include "layout/LETypes.h"
#include "layout/LEFontInstance.h"
#include "FontTableCache.h"
#include "sfnt.h"
#include "cmaps.h"
class
PortableFontInstance
:
public
LEFontInstance
,
protected
FontTableCache
{
private:
FILE
*
fFil
e
;
hb_face_t
*
fFac
e
;
float
fPointSize
;
float
fXScale
;
float
fYScale
;
le_int32
fUnitsPerEM
;
le_uint32
fFontChecksum
;
le_int32
fAscent
;
le_int32
fDescent
;
le_int32
fLeading
;
const
SFNTDirectory
*
fDirectory
;
le_uint16
fDirPower
;
le_uint16
fDirExtra
;
float
fDeviceScaleX
;
float
fDeviceScaleY
;
...
...
@@ -56,17 +53,15 @@ private:
static
le_int8
highBit
(
le_int32
value
);
const
DirectoryEntry
*
findTable
(
LETag
tag
)
const
;
const
void
*
readTable
(
LETag
tag
,
le_uint32
*
length
)
const
;
void
getMetrics
();
CMAPMapper
*
findUnicodeMapper
();
protected:
const
void
*
readFontTable
(
LETag
tableTag
)
const
;
hb_blob_t
*
readFontTable
(
LETag
tableTag
)
const
;
public:
PortableFontInstance
(
const
char
*
fileName
,
float
pointSiz
e
,
LEErrorCode
&
status
);
PortableFontInstance
(
hb_face_t
*
face
,
float
xScale
,
float
yScal
e
,
LEErrorCode
&
status
);
virtual
~
PortableFontInstance
();
...
...
src/hb-icu-le/README
浏览文件 @
ba7f6c37
This is PortableFontInstance from icu/test/testle of ICU50.
Modified to use a hb_face_t.
For license information, see the file license.html.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录