| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1140e14 commit 6ef1b97
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,7 @@ | |||
| 1 | 1 | /* -*- mode: c++; c-basic-offset: 4 -*- */ | |
| 2 | 2 | ||
| 3 | 3 | #include <algorithm> | |
| 4 | - #include <charconv> | ||
| 4 | + #include <cstdio> | ||
| 5 | 5 | #include <iterator> | |
| 6 | 6 | #include <set> | |
| 7 | 7 | #include <sstream> | |
@@ -727,13 +727,20 @@ void FT2Font::get_glyph_name(unsigned int glyph_number, std::string &buffer, | |||
| 727 | 727 | if (!FT_HAS_GLYPH_NAMES(face)) { | |
| 728 | 728 | /* Note that this generated name must match the name that | |
| 729 | 729 | 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 | + } | ||
| 733 | 736 | } else { | |
| 734 | 737 | if (FT_Error error = FT_Get_Glyph_Name(face, glyph_number, buffer.data(), buffer.size())) { | |
| 735 | 738 | throw_ft_error("Could not get glyph names", error); | |
| 736 | 739 | } | |
| 740 | + auto len = buffer.find('\0'); | ||
| 741 | + if (len != buffer.npos) { | ||
| 742 | + buffer.resize(len); | ||
| 743 | + } | ||
| 737 | 744 | } | |
| 738 | 745 | } | |
| 739 | 746 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -486,11 +486,6 @@ PyFT2Font_get_glyph_name(PyFT2Font *self, unsigned int glyph_number) | |||
| 486 | 486 | ||
| 487 | 487 | buffer.resize(128); | |
| 488 | 488 | 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 | - } | ||
| 494 | 489 | return buffer; | |
| 495 | 490 | } | |
| 496 | 491 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments