Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ The release run heads these entries with the version and opens a fresh

## Unreleased

- `ODR_CLANG_TIDY=ON` runs clang-tidy during C++ compilation and fails
configuration if the executable is unavailable.

- HTTP server shutdown avoids user logging callbacks, so logging failures
cannot interrupt cleanup or terminate the process during destruction.

Expand Down
18 changes: 14 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ option(ODR_JNI "Build JNI bindings" OFF)
option(ODR_APPLE "Build Objective-C bindings as a framework" OFF)
option(ODR_WASM "Build WebAssembly bindings" OFF)

if (ODR_CLANG_TIDY)
find_program(CLANG_TIDY_COMMAND NAMES clang-tidy)
if (NOT CLANG_TIDY_COMMAND)
message(FATAL_ERROR "ODR_CLANG_TIDY is ON but clang-tidy was not found")
endif ()
configure_file(.clang-tidy "${CMAKE_CURRENT_BINARY_DIR}/.clang-tidy" COPYONLY)
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.25")
# Retain the configured compiler's standard-library include paths.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
list(APPEND CMAKE_CXX_CLANG_TIDY -p "${CMAKE_BINARY_DIR}")
endif ()
endif ()

include(GNUInstallDirs)

# TODO defining global compiler flags seems to be bad practice with conan
Expand Down Expand Up @@ -452,10 +466,6 @@ if (ODR_TEST)
add_subdirectory("test")
endif ()

if (ODR_CLANG_TIDY)
add_subdirectory("static_analysis/clang-tidy")
endif ()

if (NOT ODR_WITH_HTTP_SERVER)
# Don't ship the public header for an API that wasn't built.
set(ODR_HEADER_EXCLUDE PATTERN "http_server.hpp" EXCLUDE)
Expand Down
3 changes: 2 additions & 1 deletion src/odr/internal/font/type1_transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ std::string type1::to_cff(const Type1Font &font) {
}
// A charstring that does not translate becomes an empty glyph, so one
// broken glyph does not refuse the font.
std::string charstring(1, static_cast<char>(14));
std::string charstring;
try {
charstring = to_type2(glyph.charstring, font.subrs());
} catch (const std::runtime_error &) {
charstring.assign(1, static_cast<char>(14));
}
glyphs.push_back({glyph.name, std::move(charstring)});
};
Expand Down
19 changes: 11 additions & 8 deletions src/odr/internal/pdf/pdf_document_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,17 @@ void parse_cid_widths(const Array &w, Font &font) {
}
const std::optional<std::uint32_t> first = font_code(w[i], max_cid);
if (i + 1 < w.size() && w[i + 1].is_array()) {
const Array &list = w[i + 1].as_array();
// widths past the CID range are dropped
const std::size_t count =
first ? std::min<std::size_t>(list.size(), max_cid - *first + 1) : 0;
for (std::size_t j = 0; j < count; ++j) {
if (list[j].is_real()) {
font.cid_widths[*first + static_cast<std::uint32_t>(j)] =
list[j].as_real();
if (first.has_value()) {
const std::uint32_t start = *first;
const Array &list = w[i + 1].as_array();
// widths past the CID range are dropped
const std::size_t count =
std::min<std::size_t>(list.size(), max_cid - start + 1);
for (std::size_t j = 0; j < count; ++j) {
if (list[j].is_real()) {
font.cid_widths[start + static_cast<std::uint32_t>(j)] =
list[j].as_real();
}
}
}
i += 2;
Expand Down
10 changes: 0 additions & 10 deletions static_analysis/clang-tidy/CMakeLists.txt

This file was deleted.

Loading
Loading