@@ -915,10 +915,7 @@ pub(crate) unsafe fn find_native_font(uname: &str, mut scaled_size: Scaled) -> O
915
915
let fontRef = findFontByName ( & nameString, & mut varString, Fix2D ( scaled_size) ) ;
916
916
if !fontRef. is_null ( ) {
917
917
/* update name_of_font to the full name of the font, for error messages during font loading */
918
- let fullName: * const i8 = getFullName ( fontRef) ;
919
- name_of_font = std:: ffi:: CStr :: from_ptr ( fullName)
920
- . to_string_lossy ( )
921
- . to_string ( ) ;
918
+ name_of_font = getFullName ( fontRef) ;
922
919
if scaled_size < Scaled :: ZERO {
923
920
if let Some ( font) = createFont ( fontRef, scaled_size) {
924
921
let dsize_0 = D2Fix ( getDesignSize ( & font) ) ;
@@ -985,7 +982,7 @@ pub(crate) unsafe fn ot_get_font_metrics(
985
982
let mut xheight = D2Fix ( d as f64 ) ;
986
983
/* fallback in case the font does not have OS/2 table */
987
984
if xheight == Scaled :: ZERO {
988
- let glyphID = engine. map_char_to_glyph ( 'x' as i32 as u32 ) as i32 ;
985
+ let glyphID = engine. map_char_to_glyph ( 'x' ) as i32 ;
989
986
if glyphID != 0i32 {
990
987
let ( a, _) = engine. get_glyph_height_depth ( glyphID as u32 ) ;
991
988
xheight = D2Fix ( a as f64 )
@@ -995,7 +992,7 @@ pub(crate) unsafe fn ot_get_font_metrics(
995
992
}
996
993
}
997
994
if capheight == Scaled :: ZERO {
998
- let glyphID_0 = engine. map_char_to_glyph ( 'X' as i32 as u32 ) as i32 ;
995
+ let glyphID_0 = engine. map_char_to_glyph ( 'X' ) as i32 ;
999
996
if glyphID_0 != 0i32 {
1000
997
let ( a, _) = engine. get_glyph_height_depth ( glyphID_0 as u32 ) ;
1001
998
capheight = D2Fix ( a as f64 )
@@ -1292,20 +1289,20 @@ unsafe fn snap_zone(value: &mut Scaled, snap_value: Scaled, fuzz: Scaled) {
1292
1289
* value = snap_value
1293
1290
} ;
1294
1291
}
1295
- pub ( crate ) unsafe fn get_native_char_height_depth ( font : usize , ch : i32 ) -> ( Scaled , Scaled ) {
1292
+ pub ( crate ) unsafe fn get_native_char_height_depth ( font : usize , ch : char ) -> ( Scaled , Scaled ) {
1296
1293
use crate :: xetex_consts:: { QUAD_CODE , X_HEIGHT_CODE } ;
1297
1294
const CAP_HEIGHT : i32 = 8 ;
1298
1295
let ( ht, dp) = match & FONT_LAYOUT_ENGINE [ font] {
1299
1296
#[ cfg( target_os = "macos" ) ]
1300
1297
Font :: Native ( Aat ( attributes) ) => {
1301
1298
let mut ht: f32 = 0.0f64 as f32 ;
1302
1299
let mut dp: f32 = 0.0f64 as f32 ;
1303
- let gid: libc:: c_int = aat:: MapCharToGlyph_AAT ( * attributes, ch as u32 ) ;
1300
+ let gid: libc:: c_int = aat:: MapCharToGlyph_AAT ( * attributes, ch) ;
1304
1301
aat:: GetGlyphHeightDepth_AAT ( * attributes, gid as u16 , & mut ht, & mut dp) ;
1305
1302
( ht, dp)
1306
1303
}
1307
1304
Font :: Native ( Otgr ( engine) ) => {
1308
- let gid = engine. map_char_to_glyph ( ch as u32 ) as i32 ;
1305
+ let gid = engine. map_char_to_glyph ( ch) as i32 ;
1309
1306
engine. get_glyph_height_depth ( gid as u32 )
1310
1307
}
1311
1308
_ => panic ! ( "bad native font flag in `get_native_char_height_depth`" ) ,
@@ -1332,24 +1329,24 @@ pub(crate) unsafe fn get_native_char_height_depth(font: usize, ch: i32) -> (Scal
1332
1329
) ;
1333
1330
( height, depth)
1334
1331
}
1335
- pub ( crate ) unsafe fn getnativecharht ( f : usize , c : i32 ) -> Scaled {
1332
+ pub ( crate ) unsafe fn getnativecharht ( f : usize , c : char ) -> Scaled {
1336
1333
get_native_char_height_depth ( f, c) . 0
1337
1334
}
1338
- pub ( crate ) unsafe fn getnativechardp ( f : usize , c : i32 ) -> Scaled {
1335
+ pub ( crate ) unsafe fn getnativechardp ( f : usize , c : char ) -> Scaled {
1339
1336
get_native_char_height_depth ( f, c) . 1
1340
1337
}
1341
- pub ( crate ) unsafe fn get_native_char_sidebearings ( font : & NativeFont , ch : i32 ) -> ( Scaled , Scaled ) {
1338
+ pub ( crate ) unsafe fn get_native_char_sidebearings ( font : & NativeFont , ch : char ) -> ( Scaled , Scaled ) {
1342
1339
let ( l, r) = match font {
1343
1340
#[ cfg( target_os = "macos" ) ]
1344
1341
Aat ( attributes) => {
1345
1342
let mut l: f32 = 0. ;
1346
1343
let mut r: f32 = 0. ;
1347
- let gid = aat:: MapCharToGlyph_AAT ( * attributes, ch as u32 ) ;
1344
+ let gid = aat:: MapCharToGlyph_AAT ( * attributes, ch) ;
1348
1345
aat:: GetGlyphSidebearings_AAT ( * attributes, gid as u16 , & mut l, & mut r) ;
1349
1346
( l, r)
1350
1347
}
1351
1348
Otgr ( engine) => {
1352
- let gid = engine. map_char_to_glyph ( ch as u32 ) as i32 ;
1349
+ let gid = engine. map_char_to_glyph ( ch) as i32 ;
1353
1350
engine. get_glyph_sidebearings ( gid as u32 )
1354
1351
}
1355
1352
} ;
@@ -1380,7 +1377,7 @@ pub(crate) unsafe fn get_glyph_bounds(font: usize, edge: i32, gid: i32) -> Scale
1380
1377
} ;
1381
1378
D2Fix ( ( if edge <= 2i32 { a } else { b } ) as f64 )
1382
1379
}
1383
- pub ( crate ) unsafe fn getnativecharic ( f : & NativeFont , letter_space : Scaled , c : i32 ) -> Scaled {
1380
+ pub ( crate ) unsafe fn getnativecharic ( f : & NativeFont , letter_space : Scaled , c : char ) -> Scaled {
1384
1381
let ( _, rsb) = get_native_char_sidebearings ( f, c) ;
1385
1382
if rsb < Scaled :: ZERO {
1386
1383
letter_space - rsb
@@ -1389,15 +1386,15 @@ pub(crate) unsafe fn getnativecharic(f: &NativeFont, letter_space: Scaled, c: i3
1389
1386
}
1390
1387
}
1391
1388
/* single-purpose metrics accessors */
1392
- pub ( crate ) unsafe fn getnativecharwd ( f : usize , c : i32 ) -> Scaled {
1389
+ pub ( crate ) unsafe fn getnativecharwd ( f : usize , c : char ) -> Scaled {
1393
1390
match & FONT_LAYOUT_ENGINE [ f] {
1394
1391
#[ cfg( target_os = "macos" ) ]
1395
1392
Font :: Native ( Aat ( attributes) ) => {
1396
- let gid = aat:: MapCharToGlyph_AAT ( * attributes, c as u32 ) ;
1393
+ let gid = aat:: MapCharToGlyph_AAT ( * attributes, c) ;
1397
1394
D2Fix ( aat:: GetGlyphWidth_AAT ( * attributes, gid as u16 ) )
1398
1395
}
1399
1396
Font :: Native ( Otgr ( engine) ) => {
1400
- let gid = engine. map_char_to_glyph ( c as u32 ) as i32 ;
1397
+ let gid = engine. map_char_to_glyph ( c) as i32 ;
1401
1398
D2Fix ( engine. get_glyph_width_from_engine ( gid as u32 ) as f64 )
1402
1399
}
1403
1400
_ => panic ! ( "bad native font flag in `get_native_char_wd`" ) ,
@@ -1431,7 +1428,7 @@ pub(crate) unsafe fn store_justified_native_glyphs(node: &mut NativeWord) {
1431
1428
/* apply justification to spaces (or if there are none, distribute it to all glyphs as a last resort) */
1432
1429
let glyph_count = node. glyph_count ( ) as usize ;
1433
1430
let mut spaceCount: i32 = 0i32 ;
1434
- let spaceGlyph: i32 = map_char_to_glyph ( nf, ' ' as i32 ) ;
1431
+ let spaceGlyph: i32 = map_char_to_glyph ( nf, ' ' ) ;
1435
1432
for i in 0 ..glyph_count {
1436
1433
if node. glyph_ids ( ) [ i] as i32 == spaceGlyph {
1437
1434
spaceCount += 1
@@ -1701,14 +1698,11 @@ pub(crate) unsafe fn measure_native_glyph(node: &mut Glyph, use_glyph_metrics: b
1701
1698
node. set_depth ( Scaled ( DEPTH_BASE [ f] ) ) ;
1702
1699
} ;
1703
1700
}
1704
- pub ( crate ) unsafe fn map_char_to_glyph ( font : & NativeFont , ch : i32 ) -> i32 {
1705
- if ch > 0x10ffff || ch >= 0xd800 && ch <= 0xdfff {
1706
- return 0i32 ;
1707
- }
1701
+ pub ( crate ) unsafe fn map_char_to_glyph ( font : & NativeFont , ch : char ) -> i32 {
1708
1702
match font {
1709
1703
#[ cfg( target_os = "macos" ) ]
1710
- Aat ( engine) => aat:: MapCharToGlyph_AAT ( * engine, ch as u32 ) ,
1711
- Otgr ( engine) => engine. map_char_to_glyph ( ch as u32 ) as i32 ,
1704
+ Aat ( engine) => aat:: MapCharToGlyph_AAT ( * engine, ch) ,
1705
+ Otgr ( engine) => engine. map_char_to_glyph ( ch) as i32 ,
1712
1706
}
1713
1707
}
1714
1708
pub ( crate ) unsafe fn map_glyph_to_index ( font : & NativeFont , name : & str ) -> i32 {
0 commit comments