line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/* |
2
|
|
|
|
|
|
|
Copyright (C) 2016-2017 Alexander Borisov |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or |
5
|
|
|
|
|
|
|
modify it under the terms of the GNU Lesser General Public |
6
|
|
|
|
|
|
|
License as published by the Free Software Foundation; either |
7
|
|
|
|
|
|
|
version 2.1 of the License, or (at your option) any later version. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful, |
10
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
11
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12
|
|
|
|
|
|
|
Lesser General Public License for more details. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public |
15
|
|
|
|
|
|
|
License along with this library; if not, write to the Free Software |
16
|
|
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Author: lex.borisov@gmail.com (Alexander Borisov) |
19
|
|
|
|
|
|
|
*/ |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#include "myfont/os_2.h" |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
mystatus_t myfont_load_table_os_2(myfont_font_t* mf, uint8_t* font_data, size_t data_size) |
24
|
|
|
|
|
|
|
{ |
25
|
0
|
|
|
|
|
|
memset(&mf->table_os_2, 0, sizeof(myfont_table_os_2_t)); |
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
|
if(mf->cache.tables_offset[MyFONT_TKEY_OS_2] == 0) |
28
|
0
|
|
|
|
|
|
return MyFONT_STATUS_OK; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
myfont_table_os_2_t *tos_2 = &mf->table_os_2; |
31
|
0
|
|
|
|
|
|
const uint32_t table_offset = mf->cache.tables_offset[MyFONT_TKEY_OS_2]; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
/* get current data */ |
34
|
0
|
|
|
|
|
|
uint8_t *data = &font_data[table_offset]; |
35
|
0
|
|
|
|
|
|
uint32_t pos = table_offset + 32 + 10 + 16 + 4 + 16; |
36
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
if(pos > data_size) |
38
|
0
|
|
|
|
|
|
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
tos_2->version = myfont_read_u16(&data); |
41
|
0
|
|
|
|
|
|
tos_2->xAvgCharWidth = myfont_read_16(&data); |
42
|
0
|
|
|
|
|
|
tos_2->usWeightClass = myfont_read_u16(&data); |
43
|
0
|
|
|
|
|
|
tos_2->usWidthClass = myfont_read_u16(&data); |
44
|
0
|
|
|
|
|
|
tos_2->fsType = myfont_read_16(&data); |
45
|
0
|
|
|
|
|
|
tos_2->ySubscriptXSize = myfont_read_16(&data); |
46
|
0
|
|
|
|
|
|
tos_2->ySubscriptYSize = myfont_read_16(&data); |
47
|
0
|
|
|
|
|
|
tos_2->ySubscriptXOffset = myfont_read_16(&data); |
48
|
0
|
|
|
|
|
|
tos_2->ySubscriptYOffset = myfont_read_16(&data); |
49
|
0
|
|
|
|
|
|
tos_2->ySuperscriptXSize = myfont_read_16(&data); |
50
|
0
|
|
|
|
|
|
tos_2->ySuperscriptYSize = myfont_read_16(&data); |
51
|
0
|
|
|
|
|
|
tos_2->ySuperscriptXOffset = myfont_read_16(&data); |
52
|
0
|
|
|
|
|
|
tos_2->ySuperscriptYOffset = myfont_read_16(&data); |
53
|
0
|
|
|
|
|
|
tos_2->yStrikeoutSize = myfont_read_16(&data); |
54
|
0
|
|
|
|
|
|
tos_2->yStrikeoutPosition = myfont_read_16(&data); |
55
|
0
|
|
|
|
|
|
tos_2->sFamilyClass = myfont_read_16(&data); |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
memcpy(tos_2->panose, data, 10); |
58
|
0
|
|
|
|
|
|
data += 10; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
tos_2->ulUnicodeRange1 = myfont_read_u32(&data); |
61
|
0
|
|
|
|
|
|
tos_2->ulUnicodeRange2 = myfont_read_u32(&data); |
62
|
0
|
|
|
|
|
|
tos_2->ulUnicodeRange3 = myfont_read_u32(&data); |
63
|
0
|
|
|
|
|
|
tos_2->ulUnicodeRange4 = myfont_read_u32(&data); |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
memcpy(tos_2->achVendID, data, 4); |
66
|
0
|
|
|
|
|
|
data += 4; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
tos_2->fsSelection = myfont_read_u16(&data); |
69
|
0
|
|
|
|
|
|
tos_2->usFirstCharIndex = myfont_read_u16(&data); |
70
|
0
|
|
|
|
|
|
tos_2->usLastCharIndex = myfont_read_u16(&data); |
71
|
0
|
|
|
|
|
|
tos_2->sTypoAscender = myfont_read_16(&data); |
72
|
0
|
|
|
|
|
|
tos_2->sTypoDescender = myfont_read_16(&data); |
73
|
0
|
|
|
|
|
|
tos_2->sTypoLineGap = myfont_read_16(&data); |
74
|
0
|
|
|
|
|
|
tos_2->usWinAscent = myfont_read_u16(&data); |
75
|
0
|
|
|
|
|
|
tos_2->usWinDescent = myfont_read_u16(&data); |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
switch (tos_2->version) { |
78
|
|
|
|
|
|
|
case 1: |
79
|
0
|
|
|
|
|
|
pos += 8; |
80
|
0
|
0
|
|
|
|
|
if(pos > data_size) |
81
|
0
|
|
|
|
|
|
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING; |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
tos_2->ulCodePageRange1 = myfont_read_u32(&data); |
84
|
0
|
|
|
|
|
|
tos_2->ulCodePageRange2 = myfont_read_u32(&data); |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
break; |
87
|
|
|
|
|
|
|
case 2: |
88
|
|
|
|
|
|
|
case 3: |
89
|
|
|
|
|
|
|
case 4: |
90
|
0
|
|
|
|
|
|
pos += 18; |
91
|
0
|
0
|
|
|
|
|
if(pos > data_size) |
92
|
0
|
|
|
|
|
|
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING; |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
tos_2->ulCodePageRange1 = myfont_read_u32(&data); |
95
|
0
|
|
|
|
|
|
tos_2->ulCodePageRange2 = myfont_read_u32(&data); |
96
|
0
|
|
|
|
|
|
tos_2->sxHeight = myfont_read_16(&data); |
97
|
0
|
|
|
|
|
|
tos_2->sCapHeight = myfont_read_16(&data); |
98
|
0
|
|
|
|
|
|
tos_2->usDefaultChar = myfont_read_u16(&data); |
99
|
0
|
|
|
|
|
|
tos_2->usBreakChar = myfont_read_u16(&data); |
100
|
0
|
|
|
|
|
|
tos_2->usMaxContext = myfont_read_u16(&data); |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
break; |
103
|
|
|
|
|
|
|
case 5: |
104
|
0
|
|
|
|
|
|
pos += 22; |
105
|
0
|
0
|
|
|
|
|
if(pos > data_size) |
106
|
0
|
|
|
|
|
|
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING; |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
tos_2->ulCodePageRange1 = myfont_read_u32(&data); |
109
|
0
|
|
|
|
|
|
tos_2->ulCodePageRange2 = myfont_read_u32(&data); |
110
|
0
|
|
|
|
|
|
tos_2->sxHeight = myfont_read_16(&data); |
111
|
0
|
|
|
|
|
|
tos_2->sCapHeight = myfont_read_16(&data); |
112
|
0
|
|
|
|
|
|
tos_2->usDefaultChar = myfont_read_u16(&data); |
113
|
0
|
|
|
|
|
|
tos_2->usBreakChar = myfont_read_u16(&data); |
114
|
0
|
|
|
|
|
|
tos_2->usMaxContext = myfont_read_u16(&data); |
115
|
0
|
|
|
|
|
|
tos_2->usLowerOpticalPointSize = myfont_read_u16(&data); |
116
|
0
|
|
|
|
|
|
tos_2->usUpperOpticalPointSize = myfont_read_u16(&data); |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
break; |
119
|
|
|
|
|
|
|
default: |
120
|
0
|
|
|
|
|
|
break; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
return MyFONT_STATUS_OK; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
int8_t myfont_os_2_panose(myfont_font_t *mf, myfont_table_os_2_panose_t id) |
127
|
|
|
|
|
|
|
{ |
128
|
0
|
|
|
|
|
|
return mf->table_os_2.panose[id]; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|