pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/matplotlib/matplotlib/commit/6ef1b97c928c4641d5c8ea5da5a1e1c45733c2a5

gin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-7a1ad343bd40328c.css" /> Replace std::to_chars with plain snprintf · matplotlib/matplotlib@6ef1b97 · GitHub
Skip to content

Commit 6ef1b97

Browse files
committed
Replace std::to_chars with plain snprintf
The former is not available on the macOS deployment target we use for wheels. We could revert back to `PyOS_snprintf`, but C++11 contains `snprintf`, and it seems to guarantee the same things.
1 parent 1140e14 commit 6ef1b97

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

src/ft2font.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* -*- mode: c++; c-basic-offset: 4 -*- */
22

33
#include <algorithm>
4-
#include <charconv>
4+
#include <cstdio>
55
#include <iterator>
66
#include <set>
77
#include <sstream>
@@ -727,13 +727,20 @@ void FT2Font::get_glyph_name(unsigned int glyph_number, std::string &buffer,
727727
if (!FT_HAS_GLYPH_NAMES(face)) {
728728
/* Note that this generated name must match the name that
729729
is generated by ttconv in ttfont_CharStrings_getname. */
730-
buffer.replace(0, 3, "uni");
731-
std::to_chars(buffer.data() + 3, buffer.data() + buffer.size(),
732-
glyph_number, 16);
730+
auto len = snprintf(buffer.data(), buffer.size(), "uni%08x", glyph_number);
731+
if (len >= 0) {
732+
buffer.resize(len);
733+
} else {
734+
throw std::runtime_error("Failed to convert glyph to standard name");
735+
}
733736
} else {
734737
if (FT_Error error = FT_Get_Glyph_Name(face, glyph_number, buffer.data(), buffer.size())) {
735738
throw_ft_error("Could not get glyph names", error);
736739
}
740+
auto len = buffer.find('\0');
741+
if (len != buffer.npos) {
742+
buffer.resize(len);
743+
}
737744
}
738745
}
739746

src/ft2font_wrapper.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,11 +486,6 @@ PyFT2Font_get_glyph_name(PyFT2Font *self, unsigned int glyph_number)
486486

487487
buffer.resize(128);
488488
self->x->get_glyph_name(glyph_number, buffer, fallback);
489-
// pybind11 uses the entire string's size(), so trim all the NULLs off the end.
490-
auto len = buffer.find('\0');
491-
if (len != buffer.npos) {
492-
buffer.resize(len);
493-
}
494489
return buffer;
495490
}
496491

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy