media-gfx/fontdiff: initial import

Signed-off-by: Alessandro Barbieri <lssndrbarbieri@gmail.com>
This commit is contained in:
Alessandro Barbieri
2021-06-19 02:51:03 +02:00
parent 2db5a8165b
commit dd3025146d
6 changed files with 168 additions and 0 deletions

View File

@@ -0,0 +1 @@
DIST fontdiff-0.2.3.tar.gz 23940699 BLAKE2B 3a14deae16e67ba5c897c9b0779a9a5e4f2f5a5c9bb4ad2dd2e605fbc854b6939196c387160b2ed5b950ce81cf80868aa17414113115058d16e2ffeca752ed97 SHA512 6fb04c1527f8dc73677b8cb5437760f72deabc4ab117e2c16f0bff36e6e5eb58b1e1ff5e45f54de03be0534f0ab55b447a32ce56d9d2750817643dff84e087ea

View File

@@ -0,0 +1,28 @@
--- a/src/fontdiff/fontdiff.gyp
+++ b/src/fontdiff/fontdiff.gyp
@@ -20,9 +20,7 @@
'main.cc',
],
'dependencies': [
- 'fontdiff_lib',
- '../third_party/freetype/freetype.gyp:freetype',
- '../third_party/icu/icu.gyp:icu_uc',
+ 'fontdiff_lib'
],
'conditions': [
['OS == "linux"', {
@@ -67,14 +65,6 @@
'FONTDIFF_VERSION=' + '<!(echo $FONTDIFF_VERSION)',
],
'dependencies': [
- '../third_party/cairo/cairo.gyp:cairo',
- '../third_party/dtl/dtl.gyp:dtl',
- '../third_party/expat/expat.gyp:expat',
- '../third_party/freetype/freetype.gyp:freetype',
- '../third_party/harfbuzz/harfbuzz.gyp:harfbuzz',
- '../third_party/icu/icu.gyp:icu_i18n',
- '../third_party/icu/icu.gyp:icu_uc',
- '../third_party/icu/icu.gyp:icu_data',
],
'conditions': [
['OS == "linux"', {

View File

@@ -0,0 +1,13 @@
--- a/src/fontdiff/diff_job.cc
+++ b/src/fontdiff/diff_job.cc
@@ -77,8 +77,10 @@ void DiffJob::WritePDF(const std::string& filepath) {
creator.append(" ");
creator.append(version);
}
+ #if CAIRO_VERSION > 11499
cairo_pdf_surface_set_metadata(pdf_surface, CAIRO_PDF_METADATA_CREATOR,
creator.c_str());
+ #endif
cairo_t* pdf = cairo_create(pdf_surface);
for (const Page* page : pages_) {

View File

@@ -0,0 +1,53 @@
--- a/src/fontdiff/diff_job.cc
+++ b/src/fontdiff/diff_job.cc
@@ -132,7 +132,7 @@ void DiffJob::HandleEndElement() {
xmlElements_.pop_back();
}
-void DiffJob::HandleCharData(const StringPiece& text) {
+void DiffJob::HandleCharData(const icu::StringPiece& text) {
const XMLElement& e = xmlElements_.back();
e.paragraph->AppendSpan(text, e.style);
}
--- a/src/fontdiff/diff_job.h
+++ b/src/fontdiff/diff_job.h
@@ -62,7 +62,7 @@ class DiffJob {
const std::string& name,
const std::map<std::string, std::string>& attr);
void HandleEndElement();
- void HandleCharData(const StringPiece& text);
+ void HandleCharData(const icu::StringPiece& text);
bool has_diffs_;
const FontCollection* beforeFonts_;
--- a/src/fontdiff/paragraph.cc
+++ b/src/fontdiff/paragraph.cc
@@ -300,7 +300,7 @@ void Paragraph::FindPotentialLineBreaks(int32_t start, int32_t limit,
if (breaker) {
breaker->setText(text_);
int32_t cur = breaker->following(start > 0 ? start - 1 : 0);
- while (cur != BreakIterator::DONE && cur < limit) {
+ while (cur != icu::BreakIterator::DONE && cur < limit) {
breaks->push_back(cur);
cur = breaker->next();
}
--- a/src/fontdiff/shaped_text.cc
+++ b/src/fontdiff/shaped_text.cc
@@ -21,7 +21,7 @@
#include <hb.h>
#include <hb-ft.h>
#include <hb-icu.h>
-#include <unicode/unistr.h>
+#include <unicode/ustring.h>
#include "fontdiff/font.h"
#include "fontdiff/icu_helper.h"
@@ -39,7 +39,7 @@ ShapedText::ShapedText(const UChar* text, int32_t start, int32_t limit,
hb_buffer_(hb_buffer_create()), ascender_(0), descender_(0) {
const int32_t length = limit - start;
hb_buffer_set_unicode_funcs(hb_buffer_, hb_icu_get_unicode_funcs());
- hb_buffer_add_utf16(hb_buffer_, text + start, length, 0, length);
+ hb_buffer_add_utf16(hb_buffer_, (uint16_t*)text + start, length, 0, length);
hb_buffer_set_cluster_level(hb_buffer_,
HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
hb_segment_properties_t props;

View File

@@ -0,0 +1,68 @@
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
inherit toolchain-funcs
SRC_URI="https://github.com/googlefonts/fontdiff/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"
KEYWORDS="~amd64"
DESCRIPTION="A tool for finding visual differences between two font versions"
HOMEPAGE="https://github.com/googlei18n/fontdiff"
LICENSE="Apache-2.0"
SLOT="0"
RDEPEND="
app-i18n/unicode-data
app-i18n/unicode-emoji
dev-libs/expat
dev-libs/fribidi
dev-libs/icu:=
dev-util/ragel
>=media-libs/freetype-2.9:2
>=media-libs/harfbuzz-1.7.4[icu]
x11-libs/cairo
x11-libs/pixman
"
DEPEND="
${RDEPEND}
dev-cpp/dtl
dev-util/gyp
"
BDEPEND="virtual/pkgconfig"
PATCHES=(
"${FILESDIR}/${PN}-cairo114.diff"
"${FILESDIR}/${PN}-hbicu.diff"
"${FILESDIR}/${P}-no-bundled-libs.patch"
)
src_prepare() {
#no bundled libs
rm -r src/third_party || die
default
}
src_configure() {
gyp -f make --depth . "${S}/src/fontdiff/fontdiff.gyp" || die
}
src_compile() {
local _pc="$(tc-getPKG_CONFIG)"
local _d="cairo expat freetype2 harfbuzz-icu icu-uc"
local myargs=(
CXX=$(tc-getCXX)
CC=$(tc-getCC)
AR=$(tc-getAR)
LIBS="$(${_pc} --libs ${_d})"
CPPFLAGS="$(${_pc} --cflags ${_d})"
V=1
)
emake "${myargs[@]}"
}
src_install() {
dobin "${S}/out/Default/${PN}"
einstalldocs
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<!-- maintainer-needed -->
</pkgmetadata>