# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

CRATES="
	adler2@2.0.1
	aho-corasick@1.1.4
	aligned-vec@0.6.4
	aligned@0.4.3
	alloc-no-stdlib@2.0.4
	alloc-stdlib@0.2.2
	allocator-api2@0.2.21
	alsa-sys@0.4.0
	alsa@0.11.0
	android_system_properties@0.1.5
	anstream@1.0.0
	anstyle-parse@1.0.0
	anstyle-query@1.1.5
	anstyle-wincon@3.0.11
	anstyle@1.0.14
	anyhow@1.0.102
	approx@0.4.0
	approx@0.5.1
	arbitrary@1.4.2
	arg_enum_proc_macro@0.3.4
	arrayref@0.3.9
	arrayvec@0.7.6
	as-slice@0.2.1
	async-channel@2.5.0
	async-executor@1.14.0
	async-fs@2.2.0
	async-io@2.6.0
	async-lock@3.4.2
	async-net@2.0.0
	async-process@2.5.0
	async-signal@0.2.14
	async-task@4.7.1
	atomic-waker@1.1.2
	autocfg@1.5.0
	av-scenechange@0.14.1
	av1-grain@0.2.5
	avif-serialize@0.8.8
	base64@0.22.1
	bit_field@0.10.3
	bitflags@1.3.2
	bitflags@2.11.0
	bitstream-io@4.9.0
	block2@0.6.2
	block@0.1.6
	blocking@1.6.2
	brotli-decompressor@5.0.0
	brotli@8.0.2
	built@0.8.0
	bumpalo@3.20.2
	by_address@1.2.1
	bytemuck@1.25.0
	bytemuck_derive@1.10.2
	byteorder-lite@0.1.0
	byteorder@1.5.0
	bytes@1.11.1
	cairo-rs@0.21.5
	cairo-sys-rs@0.21.5
	cast@0.3.0
	cc@1.2.60
	cesu8@1.1.0
	cfg-expr@0.20.7
	cfg-if@1.0.4
	cgmath@0.18.0
	chacha20@0.10.0
	chrono@0.4.44
	clap@4.6.0
	clap_builder@4.6.0
	clap_derive@4.6.0
	clap_lex@1.1.0
	color@0.3.2
	color_quant@1.1.0
	colorchoice@1.0.5
	combine@4.6.7
	concurrent-queue@2.5.0
	console@0.16.3
	core-foundation-sys@0.8.7
	core2@0.4.0
	core_maths@0.1.1
	coreaudio-rs@0.14.1
	cpal@0.17.3
	cpufeatures@0.3.0
	crc32fast@1.5.0
	crossbeam-deque@0.8.6
	crossbeam-epoch@0.9.18
	crossbeam-utils@0.8.21
	crunchy@0.2.4
	cssparser-color@0.3.0
	cssparser-macros@0.6.1
	cssparser@0.35.0
	darling@0.14.4
	darling_core@0.14.4
	darling_macro@0.14.4
	dashmap@5.5.3
	dasp_sample@0.11.0
	data-url@0.3.2
	derive_builder@0.12.0
	derive_builder_core@0.12.0
	derive_builder_macro@0.12.0
	derive_more-impl@2.1.1
	derive_more@2.1.1
	dialoguer@0.12.0
	dispatch2@0.3.1
	displaydoc@0.2.5
	document-features@0.2.12
	downcast-rs@2.0.2
	dtoa-short@0.3.5
	dtoa@1.0.11
	earcutr@0.4.3
	either@1.15.0
	ena@0.14.4
	encode_unicode@1.0.0
	encoding_rs@0.8.35
	equator-macro@0.4.2
	equator@0.4.2
	equivalent@1.0.2
	errno@0.3.14
	euclid@0.22.14
	event-listener-strategy@0.5.4
	event-listener@5.4.1
	exr@1.74.0
	extended@0.1.0
	fast-srgb8@1.0.0
	fast_image_resize@6.0.0
	fastrand@2.4.1
	fax@0.2.6
	fax_derive@0.2.0
	fdeflate@0.3.7
	fearless_simd@0.4.0
	field-offset@0.3.6
	file-id@0.2.3
	find-msvc-tools@0.1.9
	flate2@1.1.9
	float-cmp@0.10.0
	float-cmp@0.9.0
	float_next_after@1.0.0
	fnv@1.0.7
	foldhash@0.1.5
	foldhash@0.2.0
	font-types@0.11.2
	fontconfig-parser@0.5.8
	fontdb@0.23.0
	form_urlencoded@1.2.2
	fs_extra@1.3.0
	fsevent-sys@4.1.0
	futf@0.1.5
	futures-channel@0.3.32
	futures-core@0.3.32
	futures-executor@0.3.32
	futures-io@0.3.32
	futures-lite@2.6.1
	futures-macro@0.3.32
	futures-sink@0.3.32
	futures-task@0.3.32
	futures-util@0.3.32
	futures@0.3.32
	fxhash@0.2.1
	gdk-pixbuf-sys@0.21.5
	gdk-pixbuf@0.21.5
	gdk4-sys@0.10.3
	gdk4@0.10.3
	geo-types@0.7.18
	geo@0.32.0
	geographiclib-rs@0.2.7
	getrandom@0.2.17
	getrandom@0.3.4
	getrandom@0.4.2
	gettext-rs@0.7.7
	gettext-sys@0.26.0
	gif@0.14.2
	gio-sys@0.21.5
	gio@0.21.5
	glam@0.14.0
	glam@0.15.2
	glam@0.16.0
	glam@0.17.3
	glam@0.18.0
	glam@0.19.0
	glam@0.20.5
	glam@0.21.3
	glam@0.22.0
	glam@0.23.0
	glam@0.24.2
	glam@0.25.0
	glam@0.27.0
	glam@0.28.0
	glam@0.29.3
	glam@0.30.10
	glam@0.31.1
	glam@0.32.1
	glib-build-tools@0.21.0
	glib-macros@0.21.5
	glib-sys@0.21.5
	glib@0.21.5
	gobject-sys@0.21.5
	graphene-rs@0.21.5
	graphene-sys@0.21.5
	gsk4-sys@0.10.3
	gsk4@0.10.3
	gtk4-macros@0.10.3
	gtk4-sys@0.10.3
	gtk4@0.10.3
	guillotiere@0.7.0
	half@2.7.1
	hash32@0.3.1
	hashbrown@0.14.5
	hashbrown@0.15.5
	hashbrown@0.16.1
	hashbrown@0.17.0
	heapless@0.8.0
	heck@0.5.0
	hermit-abi@0.5.2
	i_float@1.15.0
	i_key_sort@0.6.0
	i_overlay@4.0.7
	i_shape@1.14.0
	i_tree@0.16.0
	iana-time-zone-haiku@0.1.2
	iana-time-zone@0.1.65
	icu_collections@2.2.0
	icu_locale_core@2.2.0
	icu_normalizer@2.2.0
	icu_normalizer_data@2.2.0
	icu_properties@2.2.0
	icu_properties_data@2.2.0
	icu_provider@2.2.0
	id-arena@2.3.0
	ident_case@1.0.1
	idna@1.1.0
	idna_adapter@1.2.1
	ijson@0.1.6
	image-webp@0.2.4
	image@0.25.10
	imagesize@0.14.0
	imgref@1.12.0
	indexmap@2.14.0
	indicatif@0.18.4
	ink-stroke-modeler-rs@0.1.0
	inotify-sys@0.1.5
	inotify@0.11.1
	interpolate_name@0.2.4
	is-docker@0.2.0
	is-wsl@0.4.0
	is_terminal_polyfill@1.70.2
	itertools@0.11.0
	itertools@0.14.0
	itoa@1.0.18
	jni-sys-macros@0.4.1
	jni-sys@0.3.1
	jni-sys@0.4.1
	jni@0.21.1
	jobserver@0.1.34
	js-sys@0.3.95
	kqueue-sys@1.0.4
	kqueue@1.1.1
	kurbo@0.11.3
	kurbo@0.13.0
	kurbo@0.9.5
	language-tags@0.3.2
	lazy_static@1.5.0
	leb128fmt@0.1.0
	lebe@0.5.3
	libadwaita-sys@0.8.1
	libadwaita@0.8.1
	libc@0.2.185
	libfuzzer-sys@0.4.12
	libm@0.2.16
	librsvg@2.61.4
	linebender_resource_handle@0.1.1
	linux-raw-sys@0.12.1
	litemap@0.8.2
	litrs@1.0.0
	locale_config@0.3.0
	lock_api@0.4.14
	log@0.4.29
	loop9@0.1.5
	mac@0.1.1
	mach2@0.5.0
	malloc_buf@0.0.6
	markup5ever@0.35.0
	matchers@0.2.0
	matches@0.1.10
	matrixmultiply@0.3.10
	maybe-rayon@0.1.1
	memchr@2.8.0
	memmap2@0.9.10
	memoffset@0.9.1
	miniz_oxide@0.8.9
	mio@1.2.0
	moxcms@0.8.1
	nalgebra-macros@0.2.2
	nalgebra-macros@0.3.0
	nalgebra@0.33.3
	nalgebra@0.34.2
	ndk-context@0.1.1
	ndk-sys@0.6.0+11769913
	ndk@0.9.0
	new_debug_unreachable@1.0.6
	nom@8.0.0
	noop_proc_macro@0.3.0
	notify-debouncer-full@0.7.0
	notify-types@2.1.0
	notify@8.2.0
	nu-ansi-term@0.50.3
	num-bigint@0.4.6
	num-complex@0.4.6
	num-derive@0.4.2
	num-integer@0.1.46
	num-rational@0.4.2
	num-traits@0.2.19
	num_enum@0.7.6
	num_enum_derive@0.7.6
	numeric-sort@0.1.5
	objc-foundation@0.1.1
	objc2-audio-toolbox@0.3.2
	objc2-avf-audio@0.3.2
	objc2-core-audio-types@0.3.2
	objc2-core-audio@0.3.2
	objc2-core-foundation@0.3.2
	objc2-encode@4.1.0
	objc2-foundation@0.3.2
	objc2@0.6.4
	objc@0.2.7
	objc_id@0.1.1
	once_cell@1.21.4
	once_cell_polyfill@1.70.2
	open@5.3.3
	ordered-float@5.3.0
	palette@0.7.6
	palette_derive@0.7.6
	pango-sys@0.21.5
	pango@0.21.5
	pangocairo-sys@0.21.5
	pangocairo@0.21.5
	parking@2.2.1
	parking_lot@0.12.5
	parking_lot_core@0.9.12
	parry2d-f64@0.25.3
	paste@1.0.15
	pastey@0.1.1
	path-absolutize@3.1.1
	path-dedot@3.1.1
	pathdiff@0.2.3
	peniko@0.6.0
	percent-encoding@2.3.2
	phf@0.11.3
	phf@0.13.1
	phf_codegen@0.11.3
	phf_generator@0.11.3
	phf_generator@0.13.1
	phf_macros@0.11.3
	phf_macros@0.13.1
	phf_shared@0.11.3
	phf_shared@0.13.1
	pico-args@0.5.0
	piet-cairo@0.8.0
	piet@0.8.0
	pin-project-lite@0.2.17
	piper@0.2.5
	pkg-config@0.3.33
	png@0.18.1
	points_on_curve@0.7.0
	polling@3.11.0
	portable-atomic@1.13.1
	potential_utf@0.1.5
	ppv-lite86@0.2.21
	precomputed-hash@0.1.1
	prettyplease@0.2.37
	proc-macro-crate@3.5.0
	proc-macro2@1.0.106
	profiling-procmacros@1.0.17
	profiling@1.0.17
	pxfm@0.1.28
	quick-error@2.0.1
	quote@1.0.45
	r-efi@5.3.0
	r-efi@6.0.0
	rand@0.10.1
	rand@0.8.5
	rand@0.9.4
	rand_chacha@0.3.1
	rand_chacha@0.9.0
	rand_core@0.10.1
	rand_core@0.6.4
	rand_core@0.9.5
	rand_distr@0.6.0
	rand_pcg@0.10.2
	rav1e@0.8.1
	ravif@0.13.0
	rawpointer@0.2.1
	rayon-core@1.13.0
	rayon@1.11.0
	rctree@0.6.0
	read-fonts@0.37.0
	redox_syscall@0.5.18
	regex-automata@0.4.14
	regex-syntax@0.8.10
	regex@1.12.3
	rgb@0.8.53
	robust@1.2.0
	rodio@0.22.2
	rough_piet@0.13.0
	roughr@0.12.0
	roxmltree@0.20.0
	roxmltree@0.21.1
	rstar@0.12.2
	rustc-hash@2.1.2
	rustc_version@0.4.1
	rustix@1.1.4
	rustversion@1.0.22
	rustybuzz@0.20.1
	safe_arch@0.7.4
	same-file@1.0.6
	scopeguard@1.2.0
	selectors@0.31.0
	semver@1.0.28
	serde@1.0.228
	serde_arrays@0.2.0
	serde_core@1.0.228
	serde_derive@1.0.228
	serde_json@1.0.149
	serde_spanned@1.1.1
	servo_arc@0.4.3
	sharded-slab@0.1.7
	shell-words@1.1.1
	shlex@1.3.0
	sif-itree@0.4.1
	signal-hook-registry@1.4.8
	simba@0.9.1
	simd-adler32@0.3.9
	simd_helpers@0.1.0
	simplecss@0.2.2
	siphasher@0.3.11
	siphasher@1.0.2
	skrifa@0.40.0
	slab@0.4.12
	slotmap@1.1.1
	smallvec@1.15.1
	smol@2.0.2
	spade@2.15.1
	stable_deref_trait@1.2.1
	strict-num@0.1.1
	string_cache@0.8.9
	string_cache@0.9.0
	string_cache_codegen@0.5.4
	strsim@0.10.0
	strsim@0.11.1
	svg@0.18.0
	svg_path_ops@0.11.0
	svgtypes@0.11.0
	svgtypes@0.16.1
	symphonia-codec-pcm@0.5.5
	symphonia-core@0.5.5
	symphonia-format-riff@0.5.5
	symphonia-metadata@0.5.5
	symphonia@0.5.5
	syn@1.0.109
	syn@2.0.117
	synstructure@0.13.2
	system-deps@7.0.8
	target-lexicon@0.13.3
	temp-dir@0.1.16
	tempfile@3.27.0
	tendril@0.4.3
	thiserror-impl@1.0.69
	thiserror-impl@2.0.18
	thiserror@1.0.69
	thiserror@2.0.18
	thread_local@1.1.9
	tiff@0.11.3
	tiny-skia-path@0.12.0
	tinystr@0.8.3
	tinyvec@1.11.0
	tinyvec_macros@0.1.1
	toml@1.1.2+spec-1.1.0
	toml_datetime@1.1.1+spec-1.1.0
	toml_edit@0.25.11+spec-1.1.0
	toml_parser@1.1.2+spec-1.1.0
	toml_writer@1.1.1+spec-1.1.0
	tracing-attributes@0.1.31
	tracing-core@0.1.36
	tracing-log@0.2.0
	tracing-subscriber@0.3.23
	tracing@0.1.44
	ttf-parser@0.25.1
	typenum@1.19.0
	unic-bidi@0.9.0
	unic-char-property@0.9.0
	unic-char-range@0.9.0
	unic-common@0.9.0
	unic-ucd-bidi@0.9.0
	unic-ucd-version@0.9.0
	unicode-bidi-mirroring@0.4.0
	unicode-bidi@0.3.18
	unicode-ccc@0.4.0
	unicode-ident@1.0.24
	unicode-properties@0.1.4
	unicode-script@0.5.8
	unicode-segmentation@1.13.2
	unicode-vo@0.1.0
	unicode-width@0.2.2
	unicode-xid@0.2.6
	unit-prefix@0.5.2
	url@2.5.8
	usvg@0.47.0
	utf-8@0.7.6
	utf8_iter@1.0.4
	utf8parse@0.2.2
	v_frame@0.3.9
	valuable@0.1.1
	vello_api@0.0.7
	vello_common@0.0.7
	vello_cpu@0.0.7
	version-compare@0.2.1
	version_check@0.9.5
	walkdir@2.5.0
	wasi@0.11.1+wasi-snapshot-preview1
	wasip2@1.0.2+wasi-0.2.9
	wasip3@0.4.0+wasi-0.3.0-rc-2026-01-06
	wasm-bindgen-futures@0.4.68
	wasm-bindgen-macro-support@0.2.118
	wasm-bindgen-macro@0.2.118
	wasm-bindgen-shared@0.2.118
	wasm-bindgen@0.2.118
	wasm-encoder@0.244.0
	wasm-metadata@0.244.0
	wasmparser@0.244.0
	web-sys@0.3.95
	web-time@1.1.0
	web_atoms@0.1.3
	weezl@0.1.12
	wide@0.7.33
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-util@0.1.11
	winapi-x86_64-pc-windows-gnu@0.4.0
	winapi@0.3.9
	windows-collections@0.3.2
	windows-core@0.62.2
	windows-future@0.3.2
	windows-implement@0.60.2
	windows-interface@0.59.3
	windows-link@0.2.1
	windows-numerics@0.3.1
	windows-result@0.4.1
	windows-strings@0.5.1
	windows-sys@0.45.0
	windows-sys@0.60.2
	windows-sys@0.61.2
	windows-targets@0.42.2
	windows-targets@0.53.5
	windows-threading@0.2.1
	windows@0.62.2
	windows_aarch64_gnullvm@0.42.2
	windows_aarch64_gnullvm@0.53.1
	windows_aarch64_msvc@0.42.2
	windows_aarch64_msvc@0.53.1
	windows_i686_gnu@0.42.2
	windows_i686_gnu@0.53.1
	windows_i686_gnullvm@0.53.1
	windows_i686_msvc@0.42.2
	windows_i686_msvc@0.53.1
	windows_x86_64_gnu@0.42.2
	windows_x86_64_gnu@0.53.1
	windows_x86_64_gnullvm@0.42.2
	windows_x86_64_gnullvm@0.53.1
	windows_x86_64_msvc@0.42.2
	windows_x86_64_msvc@0.53.1
	winnow@1.0.1
	winresource@0.1.31
	wit-bindgen-core@0.51.0
	wit-bindgen-rust-macro@0.51.0
	wit-bindgen-rust@0.51.0
	wit-bindgen@0.51.0
	wit-component@0.244.0
	wit-parser@0.244.0
	writeable@0.6.3
	xi-unicode@0.3.0
	xml5ever@0.35.0
	xmlwriter@0.1.0
	y4m@0.8.0
	yoke-derive@0.8.2
	yoke@0.8.2
	zerocopy-derive@0.8.48
	zerocopy@0.8.48
	zerofrom-derive@0.1.7
	zerofrom@0.1.7
	zeroize@1.8.2
	zerotrie@0.2.4
	zerovec-derive@0.11.3
	zerovec@0.11.6
	zlib-rs@0.6.3
	zmij@1.0.21
	zune-core@0.5.1
	zune-inflate@0.2.54
	zune-jpeg@0.5.15
"

declare -A GIT_CRATES=(
	[hayro-ccitt]='https://github.com/LaurenzV/hayro;56c62b2a25232d5407af8efe819c49ad46605979;hayro-%commit%/hayro-ccitt'
	[hayro-cmap]='https://github.com/LaurenzV/hayro;56c62b2a25232d5407af8efe819c49ad46605979;hayro-%commit%/hayro-cmap'
	[hayro-font]='https://github.com/LaurenzV/hayro;56c62b2a25232d5407af8efe819c49ad46605979;hayro-%commit%/hayro-font'
	[hayro-interpret]='https://github.com/LaurenzV/hayro;56c62b2a25232d5407af8efe819c49ad46605979;hayro-%commit%/hayro-interpret'
	[hayro-jbig2]='https://github.com/LaurenzV/hayro;56c62b2a25232d5407af8efe819c49ad46605979;hayro-%commit%/hayro-jbig2'
	[hayro-jpeg2000]='https://github.com/LaurenzV/hayro;56c62b2a25232d5407af8efe819c49ad46605979;hayro-%commit%/hayro-jpeg2000'
	[hayro-postscript]='https://github.com/LaurenzV/hayro;56c62b2a25232d5407af8efe819c49ad46605979;hayro-%commit%/hayro-postscript'
	[hayro-svg]='https://github.com/LaurenzV/hayro;56c62b2a25232d5407af8efe819c49ad46605979;hayro-%commit%/hayro-svg'
	[hayro-syntax]='https://github.com/LaurenzV/hayro;56c62b2a25232d5407af8efe819c49ad46605979;hayro-%commit%/hayro-syntax'
	[hayro]='https://github.com/LaurenzV/hayro;56c62b2a25232d5407af8efe819c49ad46605979;hayro-%commit%/hayro'
)

RUST_MIN_VER="1.92"

inherit cargo gnome2-utils meson xdg

DESCRIPTION="Sketch and take handwritten notes"
HOMEPAGE="
	https://rnote.flxzt.net/
	https://github.com/flxzt/rnote
"
SRC_URI="
	https://github.com/flxzt/rnote/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	${CARGO_CRATE_URIS}
"

LICENSE="GPL-3+"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD-2 BSD CC0-1.0 ISC
	LGPL-2.1+ MIT MPL-2.0 UoI-NCSA Unicode-3.0 ZLIB
"
# Bundled fonts (OFL-1.1) and sound samples (CC0-1.0, CC-BY-3.0)
LICENSE+=" OFL-1.1 CC-BY-3.0"
SLOT="0"
KEYWORDS="~amd64"

# The librsvg crate is compiled into the binaries instead of linking
# gnome-base/librsvg. Its pkg-config checks also want the font stack and
# gdk-pixbuf, which only DEPEND carries: none of them is in DT_NEEDED.
# rodio playback links alsa-lib through cpal. verified 2026-09-22
RDEPEND="
	>=dev-libs/glib-2.76:2
	dev-libs/libxml2:2=
	>=gui-libs/gtk-4.18:4
	>=gui-libs/libadwaita-1.7:1
	media-libs/alsa-lib
	media-libs/graphene
	>=x11-libs/cairo-1.18[glib]
	>=x11-libs/pango-1.50
	virtual/libintl
"
DEPEND="
	${RDEPEND}
	dev-libs/appstream
	media-libs/fontconfig
	media-libs/freetype:2
	media-libs/harfbuzz
	x11-libs/gdk-pixbuf:2
"
# cmake is a required program in meson.build, though no crate uses it.
BDEPEND="
	dev-build/cmake
	dev-libs/glib:2
	dev-util/glib-utils
	sys-devel/gettext
	virtual/pkgconfig
"

src_configure() {
	meson_src_configure
	# meson.build points cargo at its own CARGO_HOME; route it to the
	# eclass config so the vendored crates are used offline.
	ln -s "${CARGO_HOME}" "${BUILD_DIR}/cargo-home" || die
}

src_compile() {
	cargo_env meson_src_compile
}

src_install() {
	cargo_env meson_src_install
}

src_test() {
	cargo_env meson_src_test
}

# Upstream's post-install script refreshes the font cache for the bundled
# fonts, but skips it whenever DESTDIR is set.
rnote_fontcache_update() {
	if [[ -z ${ROOT} ]] && has_version media-libs/fontconfig; then
		fc-cache -fs || ewarn "fc-cache failed"
	fi
}

pkg_postinst() {
	xdg_pkg_postinst
	gnome2_schemas_update
	rnote_fontcache_update
}

pkg_postrm() {
	xdg_pkg_postrm
	gnome2_schemas_update
	rnote_fontcache_update
}