Merge pull request #303 from aloucks/font_name

Font name length check should use the minimum length
This commit is contained in:
Joonas Javanainen 2020-03-17 00:04:01 +02:00 committed by GitHub
commit 0089636eb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -337,7 +337,7 @@ impl FontConfig {
raw.EllipsisChar = self.ellipsis_char.map(|x| x as u16).unwrap_or(0xffff);
if let Some(name) = self.name.as_ref() {
let bytes = name.as_bytes();
let mut len = bytes.len().max(raw.Name.len() - 1);
let mut len = bytes.len().min(raw.Name.len() - 1);
while !name.is_char_boundary(len) {
len -= 1;
}