Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1eba570

Browse files
committed
Check for italic angle in Face::is_italic.
1 parent 9a5549c commit 1eba570

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## [Unreleased]
8+
### Changed
9+
- `Face::is_italic` checks for italic angle as well.
10+
- `Face::italic_angle` returns just a `f32` and not `Option<f32>` now.
811

912
## [0.24.1] - 2024-08-05
1013
### Added

src/lib.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,21 +1402,14 @@ impl<'a> Face<'a> {
14021402
/// Returns `false` when OS/2 table is not present.
14031403
#[inline]
14041404
pub fn is_regular(&self) -> bool {
1405-
self.tables
1406-
.os2
1407-
.map(|s| s.style() == Style::Normal)
1408-
.unwrap_or(false)
1405+
self.style() == Style::Normal
14091406
}
14101407

14111408
/// Checks that face is marked as *Italic*.
1412-
///
1413-
/// Returns `false` when OS/2 table is not present.
14141409
#[inline]
14151410
pub fn is_italic(&self) -> bool {
1416-
self.tables
1417-
.os2
1418-
.map(|s| s.style() == Style::Italic)
1419-
.unwrap_or(false)
1411+
// A face can have a Normal style and a non-zero italic angle, which also makes it italic.
1412+
self.style() == Style::Italic || self.italic_angle() != 0.0
14201413
}
14211414

14221415
/// Checks that face is marked as *Bold*.
@@ -1432,10 +1425,7 @@ impl<'a> Face<'a> {
14321425
/// Returns `false` when OS/2 table is not present or when its version is < 4.
14331426
#[inline]
14341427
pub fn is_oblique(&self) -> bool {
1435-
self.tables
1436-
.os2
1437-
.map(|s| s.style() == Style::Oblique)
1438-
.unwrap_or(false)
1428+
self.style() == Style::Oblique
14391429
}
14401430

14411431
/// Returns face style.
@@ -1490,10 +1480,13 @@ impl<'a> Face<'a> {
14901480

14911481
/// Returns face's italic angle.
14921482
///
1493-
/// Returns `None` when `post` table is not present.
1483+
/// Returns `0.0` when `post` table is not present.
14941484
#[inline]
1495-
pub fn italic_angle(&self) -> Option<f32> {
1496-
self.tables.post.map(|table| table.italic_angle)
1485+
pub fn italic_angle(&self) -> f32 {
1486+
self.tables
1487+
.post
1488+
.map(|table| table.italic_angle)
1489+
.unwrap_or(0.0)
14971490
}
14981491

14991492
// Read https://github.com/freetype/freetype/blob/49270c17011491227ec7bd3fb73ede4f674aa065/src/sfnt/sfobjs.c#L1279

0 commit comments

Comments
 (0)