File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 1
1
[package ]
2
2
name = " fontkit"
3
- version = " 0.2.0-beta.12 "
3
+ version = " 0.2.0-beta.13 "
4
4
edition = " 2021"
5
5
authors = [
" Zimon Dai <[email protected] >" ]
6
6
description = " A simple library for font loading and indexing"
Original file line number Diff line number Diff line change @@ -183,6 +183,7 @@ struct Name {
183
183
pub struct Font {
184
184
key : FontKey ,
185
185
names : Vec < Name > ,
186
+ style_names : Vec < Name > ,
186
187
face : ArcSwap < Option < StaticFace > > ,
187
188
path : Option < PathBuf > ,
188
189
}
@@ -215,12 +216,19 @@ impl Font {
215
216
face_builder : |buf| Face :: from_slice ( buf, 0 ) ,
216
217
}
217
218
. try_build ( ) ?;
219
+ let mut style_names = vec ! [ ] ;
218
220
let names = face
219
221
. borrow_face ( )
220
222
. names ( )
221
223
. into_iter ( )
222
224
. filter_map ( |name| {
223
225
let id = name. name_id ;
226
+ if id == name_id:: TYPOGRAPHIC_SUBFAMILY {
227
+ style_names. push ( Name {
228
+ name : name. to_string ( ) ?,
229
+ language_id : name. language_id ,
230
+ } ) ;
231
+ }
224
232
if id == name_id:: FAMILY
225
233
|| id == name_id:: FULL_NAME
226
234
|| id == name_id:: POST_SCRIPT_NAME
@@ -271,6 +279,7 @@ impl Font {
271
279
key,
272
280
face : ArcSwap :: new ( Arc :: new ( Some ( face) ) ) ,
273
281
path : None ,
282
+ style_names,
274
283
} ;
275
284
Ok ( font)
276
285
}
@@ -724,7 +733,8 @@ pub unsafe extern "C" fn list_all_font(fontkit: *mut FontKit) -> *const u8 {
724
733
"stretch" : Width :: from( key. stretch as u16 ) . to_string( ) ,
725
734
"italic" : key. italic,
726
735
"weight" : key. weight,
727
- "family" : key. family( )
736
+ "family" : key. family( ) ,
737
+ "styleNames" : font. style_names. clone( )
728
738
} )
729
739
} )
730
740
. collect :: < Vec < _ > > ( ) ;
You can’t perform that action at this time.
0 commit comments