Skip to content

Commit 706a922

Browse files
authored
x.ttf: update to fix compilation of vlang/pdf and failing ci (#15109)
1 parent eed496d commit 706a922

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

vlib/x/ttf/ttf.v

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ pub mut:
8888
metric_data_format i16
8989
num_of_long_hor_metrics u16
9090
kern []Kern0Table
91+
// panose
92+
panose_array []u8 = []u8{len: 12, init: 0}
9193
// cache
9294
glyph_cache map[int]Glyph
9395
// font widths array scale for PDF export
@@ -102,6 +104,7 @@ pub fn (mut tf TTF_File) init() {
102104
tf.read_cmap_table()
103105
tf.read_hhea_table()
104106
tf.read_kern_table()
107+
tf.read_panose_table()
105108
tf.length = tf.glyph_count()
106109
dprintln('Number of symbols: $tf.length')
107110
dprintln('*****************************')
@@ -1088,6 +1091,43 @@ pub fn (mut tf TTF_File) next_kern(glyph_index int) (int, int) {
10881091
return x, y
10891092
}
10901093

1094+
/******************************************************************************
1095+
*
1096+
* Panose table
1097+
*
1098+
******************************************************************************/
1099+
fn (mut tf TTF_File) read_panose_table() {
1100+
dprintln('*** READ PANOSE TABLE ***')
1101+
if 'OS/2' !in tf.tables {
1102+
return
1103+
}
1104+
table_offset := tf.tables['OS/2'].offset
1105+
tf.pos = table_offset
1106+
// dprintln('READING! PANOSE offset:${tf.tables['OS/2']}')
1107+
version := tf.get_u16()
1108+
dprintln('Panose version: ${version:04x}')
1109+
tf.pos += 2 * 14 // move to Panose class + 10 byte array
1110+
mut count := 0
1111+
1112+
// get family
1113+
family_class := tf.get_i16()
1114+
tf.panose_array[count] = u8(family_class >> 8)
1115+
count++
1116+
tf.panose_array[count] = u8(family_class & 0xFF)
1117+
count++
1118+
dprintln('family_class: ${family_class:04x}')
1119+
1120+
// get panose data
1121+
for _ in 0 .. 10 {
1122+
tf.panose_array[count] = tf.get_u8()
1123+
count++
1124+
}
1125+
1126+
// family_class1 := (i16(tf.panose_array[0]) << 8) + i16(tf.panose_array[1])
1127+
// dprintln("family_class: ${family_class1:04x}")
1128+
// dprintln("Panose array: ${tf.panose_array}")
1129+
}
1130+
10911131
/******************************************************************************
10921132
*
10931133
* TTF_File Utility

0 commit comments

Comments
 (0)