diff options
author | Matthias Clasen <mclasen@redhat.com> | 2022-06-26 11:13:01 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-07-04 11:17:28 -0400 |
commit | f51d318abbb9e67fd362129a2f2af81e77b9d691 (patch) | |
tree | e41755078c9ed596c23b9b2e44c1954770f86355 | |
parent | b29fdef4cc5bf08bc89066b36907ceddc0657edf (diff) | |
download | pango-f51d318abbb9e67fd362129a2f2af81e77b9d691.tar.gz |
Add defines for native fontmaps
Add PANGO_HAS_FC/CORE_TEXT/DIRECT_WRITE_FONTMAP macros
to let apps check for the presence of native fontmaps.
-rw-r--r-- | docs/migrating.md | 10 | ||||
-rw-r--r-- | pango2/meson.build | 60 | ||||
-rw-r--r-- | pango2/pango-utils.h | 10 | ||||
-rw-r--r-- | pango2/pangocairo-context.c | 6 | ||||
-rw-r--r-- | pango2/pangocairo-dwrite-font.cpp | 3 | ||||
-rw-r--r-- | pango2/pangocoretext-fontmap.c | 5 | ||||
-rw-r--r-- | pango2/pangodwrite-fontmap.cpp | 6 | ||||
-rw-r--r-- | pango2/pangofc-fontmap.c | 6 | ||||
-rw-r--r-- | tests/cxx-test.cpp | 2 |
9 files changed, 67 insertions, 41 deletions
diff --git a/docs/migrating.md b/docs/migrating.md index fbd0bddb..7c1e3b37 100644 --- a/docs/migrating.md +++ b/docs/migrating.md @@ -64,7 +64,15 @@ the `pangocairo.h` header, and use the APIs that are declared in it. There is still a `pango2cairo.pc` file, if you want to be explicit in your build configuration about requiring cairo support. If you want to handle the possible absence of cairo support at runtime, you can check the -[const@Pango2.RENDERING_CAIRO] macro before including `pangocairo.h`. +`PANGO2_HAS_CAIRO` macro before including `pangocairo.h`. + +The native fontmap implementations provide their own headers: +`pangofc-fontmap.h`, `pangocoretext-fontmap.h` and `pangodwrite-fontmap.h`. +If you want to check for the available fontmaps implementations +at runtime (even though they are entirely determined by the platform you +are running on, currently), you can check the `PANGO2_HAS_FC_FONTMAP`, +`PANGO2_HAS_CORE_TEXT_FONTMAP` and `PANGO2_HAS_DIRECT_WRITE_FONTMAP` macros +before including the corresponding header file. ### PangoFontMap changes diff --git a/pango2/meson.build b/pango2/meson.build index dbe56249..0a3e8d32 100644 --- a/pango2/meson.build +++ b/pango2/meson.build @@ -97,6 +97,14 @@ pango_gir_includes = [ 'Gio-2.0' ] +pango_features_conf = configuration_data() +pango_features_conf.set_quoted('PANGO2_VERSION_STRING', meson.project_version()) +pango_features_conf.set('PANGO2_VERSION_MAJOR', pango_major_version) +pango_features_conf.set('PANGO2_VERSION_MINOR', pango_minor_version) +pango_features_conf.set('PANGO2_VERSION_MICRO', pango_micro_version) +pango_features_conf.set('PANGO2_API_VERSION', pango_api_version) +pango_features_conf.set('PANGO2_CURRENT_MINUS_AGE', '0') + if cairo_dep.found() pango_headers += [ 'pangocairo.h', @@ -116,21 +124,8 @@ if cairo_dep.found() pango_gir_includes += [ 'cairo-1.0', ] -endif - -if host_system == 'darwin' - pango_headers += [ - 'pangocoretext-fontmap.h', - ] - pango_sources += [ - 'pangocoretext-fontmap.c', - ] - if cairo_dep.found() - pango_sources += [ - 'pangocairo-coretext-font.c', - ] - endif + pango_features_conf.set('PANGO2_HAS_CAIRO', 1) endif if host_system == 'linux' @@ -146,6 +141,26 @@ if host_system == 'linux' pango_gir_includes += [ 'fontconfig-2.0', ] + + pango_features_conf.set('PANGO2_HAS_FC_FONTMAP', 1) +endif + +if host_system == 'darwin' + pango_headers += [ + 'pangocoretext-fontmap.h', + ] + + pango_sources += [ + 'pangocoretext-fontmap.c', + ] + + if cairo_dep.found() + pango_sources += [ + 'pangocairo-coretext-font.c', + ] + endif + + pango_features_conf.set('PANGO2_HAS_CORE_TEXT_FONTMAP', 1) endif if host_system == 'windows' @@ -156,16 +171,14 @@ if host_system == 'windows' pango_sources += [ 'pangodwrite-fontmap.cpp', ] + if cairo_dep.found() pango_sources += [ 'pangocairo-dwrite-font.cpp', ] endif - pango_deps += [ - cc.find_library('gdi32'), - cc.find_library('dwrite'), - ] + pango_features_conf.set('PANGO2_HAS_DIRECT_WRITE_FONTMAP', 1) endif pango_installed_headers = pango_headers + [ 'pango-version-macros.h' ] @@ -173,18 +186,7 @@ pango_installed_headers = pango_headers + [ 'pango-version-macros.h' ] install_headers(pango_installed_headers, subdir: pango_api_path) # Features header -pango_features_conf = configuration_data() -pango_features_conf.set('PANGO2_VERSION_MAJOR', pango_major_version) -pango_features_conf.set('PANGO2_VERSION_MINOR', pango_minor_version) -pango_features_conf.set('PANGO2_VERSION_MICRO', pango_micro_version) -pango_features_conf.set('PANGO2_API_VERSION', pango_api_version) -pango_features_conf.set('PANGO2_CURRENT_MINUS_AGE', '0') -if cairo_dep.found() - pango_features_conf.set('PANGO2_RENDERING_CAIRO', 1) -endif - pango_features_h = configure_file( - input: 'pango-features.h.meson', output: 'pango-features.h', configuration: pango_features_conf, install: true, diff --git a/pango2/pango-utils.h b/pango2/pango-utils.h index f5187dc9..56ba36ed 100644 --- a/pango2/pango-utils.h +++ b/pango2/pango-utils.h @@ -21,6 +21,7 @@ #include <stdio.h> #include <glib.h> +#include <pango2/pango-features.h> #include <pango2/pango-font.h> G_BEGIN_DECLS @@ -34,12 +35,6 @@ void pango2_find_paragraph_boundary (const char *text, int *paragraph_delimiter_index, int *next_paragraph_start); -/** - * PANGO2_RENDERING_CAIRO: - * - * Defined to 1 at compile time if Pango2 was built with cairo support. - */ - /* Encode a Pango2 version as an integer */ /* Pango2 version checking */ @@ -64,11 +59,13 @@ void pango2_find_paragraph_boundary (const char *text, * * The version of Pango2 available at compile-time, encoded using PANGO2_VERSION_ENCODE(). */ + /** * PANGO2_VERSION_STRING: * * A string literal containing the version of Pango2 available at compile-time. */ + /** * PANGO2_VERSION_MAJOR: * @@ -89,6 +86,7 @@ void pango2_find_paragraph_boundary (const char *text, PANGO2_VERSION_MINOR, \ PANGO2_VERSION_MICRO) + /* Check that compile-time Pango2 is as new as required */ /** * PANGO2_VERSION_CHECK: diff --git a/pango2/pangocairo-context.c b/pango2/pangocairo-context.c index 2346b635..b632457a 100644 --- a/pango2/pangocairo-context.c +++ b/pango2/pangocairo-context.c @@ -29,6 +29,12 @@ #include <string.h> /** + * PANGO2_HAS_CAIRO: + * + * Defined to 1 at compile time if Pango was built with cairo support. + */ + +/** * pango2_cairo_update_context: * @cr: a Cairo context * @context: a `Pango2Context`, from a pangocairo font map diff --git a/pango2/pangocairo-dwrite-font.cpp b/pango2/pangocairo-dwrite-font.cpp index 7068d59f..2d131759 100644 --- a/pango2/pangocairo-dwrite-font.cpp +++ b/pango2/pangocairo-dwrite-font.cpp @@ -30,7 +30,6 @@ #include "pangocairo-private.h" -/* {{{ DirectWrite PangoCairo utilities */ cairo_font_face_t * create_cairo_dwrite_font_face (Pango2Font *font) { @@ -48,6 +47,4 @@ create_cairo_dwrite_font_face (Pango2Font *font) #endif /* HAVE_DIRECT_WRITE */ -/* }}} */ - /* vim:set foldmethod=marker expandtab: */ diff --git a/pango2/pangocoretext-fontmap.c b/pango2/pangocoretext-fontmap.c index 3b7cdd47..0ee64895 100644 --- a/pango2/pangocoretext-fontmap.c +++ b/pango2/pangocoretext-fontmap.c @@ -44,6 +44,11 @@ * CoreText to populate the fontmap with the available fonts. */ +/** + * PANGO2_HAS_CORE_TEXT_FONTMAP: + * + * Defined to 1 at compile time if Pango2 was built with CoreText support. + */ struct _Pango2CoreTextFontMap { diff --git a/pango2/pangodwrite-fontmap.cpp b/pango2/pangodwrite-fontmap.cpp index 37307a3d..9e7d7bfc 100644 --- a/pango2/pangodwrite-fontmap.cpp +++ b/pango2/pangodwrite-fontmap.cpp @@ -45,6 +45,12 @@ * uses DirectWrite to populate the fontmap with the available fonts. */ +/** + * PANGO2_HAS_DIRECT_WRITE_FONTMAP: + * + * Defined to 1 at compile time if Pango was built with DirectWrite support. + */ + struct _PangoDirectWriteFontMap { diff --git a/pango2/pangofc-fontmap.c b/pango2/pangofc-fontmap.c index c3d026e2..d3be561d 100644 --- a/pango2/pangofc-fontmap.c +++ b/pango2/pangofc-fontmap.c @@ -37,7 +37,6 @@ #include <fontconfig/fontconfig.h> #include <hb-ot.h> - /** * Pango2FcFontMap: * @@ -45,6 +44,11 @@ * fontconfig to populate the fontmap with the available fonts. */ +/** + * PANGO2_HAS_FC_FONTMAP: + * + * Defined to 1 at compile time if Pango was built with fontconfig support. + */ struct _Pango2FcFontMap { diff --git a/tests/cxx-test.cpp b/tests/cxx-test.cpp index 3fa1c20d..3a98321c 100644 --- a/tests/cxx-test.cpp +++ b/tests/cxx-test.cpp @@ -4,7 +4,7 @@ #include <pango2/pango.h> -#if PANGO_RENDERING_CAIRO +#if PANGO2_HAS_CAIRO #include <pango2/pangocairo.h> #endif |