| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
#endif // defined(PDF_USE_SKIA)Just leave this out and avoid struggling with the auto-formatter.
const char* skrifa_format = "";Assign in the default case instead?
static std::unique_ptr<CFX_Path> ConvertOutline(Move into anonymous namespace.
reinterpret_cast<const uint8_t*>(bytes.data()), bytes.size());Can this just take `bytes` as 1 argument like fx_skrifa_unittest.cpp?
auto name = std::string(font->postscript_name());Can this be: `std::string name(...);` ?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Change-Id: Ib0f280596579ba702194e3bb73e5b7cd2ac8d32eAdd Bug:
[[maybe_unused]] std::unique_ptr<SkrifaFontHolder> skrifa_font)Is this needed? What build config cares if the parameter is unused?
| Code-Review | +1 |
LGTM, with Lei's feedback addressed. One question on the wrapper type below.
struct SkrifaFontHolder {No objections to using a wrapper type, but would it be enought to use a typedef to `rust::Box<skrifa::SkrifaFont`?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Change-Id: Ib0f280596579ba702194e3bb73e5b7cd2ac8d32eTom SepezAdd Bug:
Done
Just leave this out and avoid struggling with the auto-formatter.
Done
No objections to using a wrapper type, but would it be enought to use a typedef to `rust::Box<skrifa::SkrifaFont`?
This helps when building without Fontations, eg. no rust:: symbols as we just have a dummy struct in that case.
// Private ctor.Tom SepezPreserve comment.
Done
Assign in the default case instead?
Done
static std::unique_ptr<CFX_Path> ConvertOutline(Tom SepezMove into anonymous namespace.
Done
[[maybe_unused]] std::unique_ptr<SkrifaFontHolder> skrifa_font)Is this needed? What build config cares if the parameter is unused?
Think it was a bot suggestion. Namely that although we always have this parameter in the constructor to avoid ugly ifdef's, it matches up with a member that's ifdef'd out in some cases.
reinterpret_cast<const uint8_t*>(bytes.data()), bytes.size());Can this just take `bytes` as 1 argument like fx_skrifa_unittest.cpp?
Done
Can this be: `std::string name(...);` ?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
12 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: core/fxge/skrifa/src/outlines.cpp
Insertions: 4, Deletions: 5.
@@ -23,12 +23,11 @@
// Load the font data
std::string path_str(font_path.data(), font_path.size());
std::ifstream input(path_str, std::ios::binary);
- std::vector<char> bytes((std::istreambuf_iterator<char>(input)),
- (std::istreambuf_iterator<char>()));
+ std::vector<uint8_t> bytes((std::istreambuf_iterator<char>(input)),
+ (std::istreambuf_iterator<char>()));
input.close();
- rust::Slice<const uint8_t> slice(
- reinterpret_cast<const uint8_t*>(bytes.data()), bytes.size());
+ rust::Slice<const uint8_t> slice(bytes);
// Load the font. Note that the bytes vector must live as long as the font
auto font = skrifa::new_font(slice, 0);
@@ -38,7 +37,7 @@
}
// Get the PostScript name
- auto name = std::string(font->postscript_name());
+ std::string name(font->postscript_name());
// And the family name
auto family_name = std::string(font->family_name());
```
```
The name of the file: core/fxge/cfx_face.h
Insertions: 1, Deletions: 1.
@@ -24,7 +24,7 @@
#if defined(PDF_USE_SKIA)
#include "third_party/skia/include/core/SkRefCnt.h" // nogncheck
-#endif // defined(PDF_USE_SKIA)
+#endif
#if defined(PDF_ENABLE_FONTATIONS)
#include "third_party/rust/cxx/v1/cxx.h"
```
```
The name of the file: core/fxge/cfx_face.cpp
Insertions: 59, Deletions: 60.
@@ -172,6 +172,62 @@
return 0;
}
+#if defined(PDF_ENABLE_FONTATIONS)
+std::unique_ptr<CFX_Path> ConvertOutline(const skrifa::Outline& outline) {
+ auto skrifa_path = std::make_unique<CFX_Path>();
+ auto point_idx = 0;
+ CFX_PointF current_point(0, 0);
+ for (auto verb : outline.verbs) {
+ switch (verb) {
+ case skrifa::PathVerb::MoveTo: {
+ auto p = outline.points[point_idx++];
+ current_point = CFX_PointF(p.x, p.y);
+ skrifa_path->AppendPoint(current_point, CFX_Path::Point::Type::kMove);
+ break;
+ }
+ case skrifa::PathVerb::LineTo: {
+ auto p = outline.points[point_idx++];
+ current_point = CFX_PointF(p.x, p.y);
+ skrifa_path->AppendPoint(current_point, CFX_Path::Point::Type::kLine);
+ break;
+ }
+ case skrifa::PathVerb::QuadTo: {
+ auto c0 = outline.points[point_idx++];
+ auto p = outline.points[point_idx++];
+ // Convert quadratic to cubic bezier to match FreeType
+ // decomposition.
+ skrifa_path->AppendPoint(
+ CFX_PointF(current_point.x + (c0.x - current_point.x) * 2 / 3,
+ current_point.y + (c0.y - current_point.y) * 2 / 3),
+ CFX_Path::Point::Type::kBezier);
+ skrifa_path->AppendPoint(
+ CFX_PointF(c0.x + (p.x - c0.x) / 3, c0.y + (p.y - c0.y) / 3),
+ CFX_Path::Point::Type::kBezier);
+ current_point = CFX_PointF(p.x, p.y);
+ skrifa_path->AppendPoint(current_point, CFX_Path::Point::Type::kBezier);
+ break;
+ }
+ case skrifa::PathVerb::CurveTo: {
+ auto c0 = outline.points[point_idx++];
+ auto c1 = outline.points[point_idx++];
+ auto p = outline.points[point_idx++];
+ skrifa_path->AppendPoint(CFX_PointF(c0.x, c0.y),
+ CFX_Path::Point::Type::kBezier);
+ skrifa_path->AppendPoint(CFX_PointF(c1.x, c1.y),
+ CFX_Path::Point::Type::kBezier);
+ current_point = CFX_PointF(p.x, p.y);
+ skrifa_path->AppendPoint(current_point, CFX_Path::Point::Type::kBezier);
+ break;
+ }
+ case skrifa::PathVerb::Close:
+ skrifa_path->ClosePath();
+ break;
+ }
+ }
+ return skrifa_path;
+}
+#endif // defined(PDF_ENABLE_FONTATIONS)
+
FT_Encoding ToFTEncoding(fxge::FontEncoding encoding) {
switch (encoding) {
case fxge::FontEncoding::kAdobeCustom:
@@ -300,8 +356,6 @@
: font(std::move(f)) {}
rust::Box<skrifa::SkrifaFont> font;
};
-
-static std::unique_ptr<CFX_Path> ConvertOutline(const skrifa::Outline& outline);
#endif // defined(PDF_ENABLE_FONTATIONS)
// static
@@ -329,6 +383,7 @@
}
#endif
+ // Private ctor.
RetainPtr<CFX_Face> result = pdfium::WrapRetain(
new CFX_Face(std::move(cache_entry), std::move(font_stream), face_rec,
std::move(skrifa_font)));
@@ -366,7 +421,7 @@
#if defined(PDF_ENABLE_SKIA_TYPEFACE_CHECKS)
#if defined(PDF_ENABLE_FONTATIONS)
if (skrifa_font_ && skrifa_font_->font->is_ok()) {
- const char* skrifa_format = "";
+ const char* skrifa_format;
switch (skrifa_font_->font->font_type()) {
case skrifa::FaceFormat::TrueType:
skrifa_format = "TrueType";
@@ -378,6 +433,7 @@
skrifa_format = "CFF";
break;
default:
+ skrifa_format = "";
break;
}
CHECK_EQ(ft_result, ByteString(skrifa_format));
@@ -896,63 +952,6 @@
return pPath;
}
-#if defined(PDF_ENABLE_FONTATIONS)
-static std::unique_ptr<CFX_Path> ConvertOutline(
- const skrifa::Outline& outline) {
- auto skrifa_path = std::make_unique<CFX_Path>();
- auto point_idx = 0;
- CFX_PointF current_point(0, 0);
- for (auto verb : outline.verbs) {
- switch (verb) {
- case skrifa::PathVerb::MoveTo: {
- auto p = outline.points[point_idx++];
- current_point = CFX_PointF(p.x, p.y);
- skrifa_path->AppendPoint(current_point, CFX_Path::Point::Type::kMove);
- break;
- }
- case skrifa::PathVerb::LineTo: {
- auto p = outline.points[point_idx++];
- current_point = CFX_PointF(p.x, p.y);
- skrifa_path->AppendPoint(current_point, CFX_Path::Point::Type::kLine);
- break;
- }
- case skrifa::PathVerb::QuadTo: {
- auto c0 = outline.points[point_idx++];
- auto p = outline.points[point_idx++];
- // Convert quadratic to cubic bezier to match FreeType
- // decomposition.
- skrifa_path->AppendPoint(
- CFX_PointF(current_point.x + (c0.x - current_point.x) * 2 / 3,
- current_point.y + (c0.y - current_point.y) * 2 / 3),
- CFX_Path::Point::Type::kBezier);
- skrifa_path->AppendPoint(
- CFX_PointF(c0.x + (p.x - c0.x) / 3, c0.y + (p.y - c0.y) / 3),
- CFX_Path::Point::Type::kBezier);
- current_point = CFX_PointF(p.x, p.y);
- skrifa_path->AppendPoint(current_point, CFX_Path::Point::Type::kBezier);
- break;
- }
- case skrifa::PathVerb::CurveTo: {
- auto c0 = outline.points[point_idx++];
- auto c1 = outline.points[point_idx++];
- auto p = outline.points[point_idx++];
- skrifa_path->AppendPoint(CFX_PointF(c0.x, c0.y),
- CFX_Path::Point::Type::kBezier);
- skrifa_path->AppendPoint(CFX_PointF(c1.x, c1.y),
- CFX_Path::Point::Type::kBezier);
- current_point = CFX_PointF(p.x, p.y);
- skrifa_path->AppendPoint(current_point, CFX_Path::Point::Type::kBezier);
- break;
- }
- case skrifa::PathVerb::Close:
- skrifa_path->ClosePath();
- break;
- }
- }
- return skrifa_path;
-}
-#endif // defined(PDF_ENABLE_FONTATIONS)
-
int CFX_Face::GetGlyphTTWidth() const {
const auto* fontglyph = GetRec()->glyph;
const int ft_result =
```
Refactor Skrifa integration to use member methods.
Migrate from free functions that take font data slices to member
methods on SkrifaFont. This allows caching the parsed font state and
prevents repeated passing of raw data slices across the FFI boundary.
Update CFX_Face to manage the SkrifaFont lifecycle and delegate
queries to it.
TAG=agy
CONV=53beacdb-cb1c-42a8-ae3f-b599eabe37b6
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
auto family_name = std::string(font->family_name());Same as line 40. Another time...
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |