summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkira TAGOH <akira@tagoh.org>2019-07-29 09:38:51 +0000
committerAkira TAGOH <akira@tagoh.org>2019-07-29 10:19:26 +0000
commit80047ed8e8b63153ad2014f731453eb47c79c296 (patch)
tree86821089ecf96c513c8d9e61d9354135fc52f793
parentf555f50a207a96689dd6cf8ef96fd7f01b37a952 (diff)
downloadfontconfig-80047ed8e8b63153ad2014f731453eb47c79c296.tar.gz
Add FC_FONT_HAS_HINT property to see if font has hinting or not.
This may helps to enable autohint only when font doesn't have any hinting
-rw-r--r--conf.d/09-autohint-if-no-hinting.conf20
-rw-r--r--conf.d/Makefile.am1
-rw-r--r--doc/fontconfig-devel.sgml1
-rw-r--r--doc/fontconfig-user.sgml1
-rw-r--r--fontconfig/fontconfig.h1
-rw-r--r--src/fcfreetype.c21
-rw-r--r--src/fcobjs.h1
7 files changed, 46 insertions, 0 deletions
diff --git a/conf.d/09-autohint-if-no-hinting.conf b/conf.d/09-autohint-if-no-hinting.conf
new file mode 100644
index 0000000..afcef3f
--- /dev/null
+++ b/conf.d/09-autohint-if-no-hinting.conf
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
+<fontconfig>
+ <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0">
+ <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/>
+ </its:rules>
+
+ <description>Enable autohinter if font doesn't have any hinting</description>
+ <!-- Use the Autohinter -->
+ <match target="font">
+ <test name="fonthashint"><bool>false</bool></test>
+ <!--
+ This configuration is available on the major desktop environments.
+ We shouldn't overwrite it with "assign" unconditionally.
+ Most clients may picks up the first value only. so using "append"
+ may simply works to avoid it.
+ -->
+ <edit name="autohint" mode="append"><bool>true</bool></edit>
+ </match>
+</fontconfig>
diff --git a/conf.d/Makefile.am b/conf.d/Makefile.am
index 3bb92dd..710318c 100644
--- a/conf.d/Makefile.am
+++ b/conf.d/Makefile.am
@@ -57,6 +57,7 @@ config_DATA = $(DOC_FILES)
templatedir = $(TEMPLATEDIR)
template_DATA = \
05-reset-dirs-sample.conf \
+ 09-autohint-if-no-hinting.conf \
10-autohint.conf \
10-hinting-full.conf \
10-hinting-medium.conf \
diff --git a/doc/fontconfig-devel.sgml b/doc/fontconfig-devel.sgml
index ee4a432..c4d7537 100644
--- a/doc/fontconfig-devel.sgml
+++ b/doc/fontconfig-devel.sgml
@@ -211,6 +211,7 @@ convenience for the application's rendering mechanism.
color FC_COLOR Bool Whether any glyphs have color
fontvariations FC_FONT_VARIATIONS String comma-separated string of axes in variable font
variable FC_VARIABLE Bool Whether font is Variable Font
+ fonthashint FC_FONT_HAS_HINT Bool Whether font has hinting
</programlisting>
</sect2>
</sect1>
diff --git a/doc/fontconfig-user.sgml b/doc/fontconfig-user.sgml
index cfe173f..59431dd 100644
--- a/doc/fontconfig-user.sgml
+++ b/doc/fontconfig-user.sgml
@@ -140,6 +140,7 @@ convenience for the applications' rendering mechanism.
familylang, stylelang, and fullnamelang
prgname String String Name of the running program
postscriptname String Font family name in PostScript
+ fonthashint Bool Whether the font has hinting
</programlisting>
</refsect2>
<refsect2>
diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h
index 14a23be..9586616 100644
--- a/fontconfig/fontconfig.h
+++ b/fontconfig/fontconfig.h
@@ -126,6 +126,7 @@ typedef int FcBool;
#define FC_PRGNAME "prgname" /* String */
#define FC_HASH "hash" /* String (deprecated) */
#define FC_POSTSCRIPT_NAME "postscriptname" /* String */
+#define FC_FONT_HAS_HINT "fonthashint" /* Bool - true if font has hinting */
#define FC_CACHE_SUFFIX ".cache-" FC_CACHE_VERSION
#define FC_DIR_CACHE_FILE "fonts.cache-" FC_CACHE_VERSION
diff --git a/src/fcfreetype.c b/src/fcfreetype.c
index 28fa8ac..77c174e 100644
--- a/src/fcfreetype.c
+++ b/src/fcfreetype.c
@@ -543,6 +543,9 @@ static const FcMacRomanFake fcMacRomanFake[] = {
static FcChar8 *
FcFontCapabilities(FT_Face face);
+static FcBool
+FcFontHasHint (FT_Face face);
+
static int
FcFreeTypeSpacing (FT_Face face);
@@ -1829,6 +1832,9 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
free (complex_);
}
+ if (!FcPatternAddBool (pat, FC_FONT_HAS_HINT, FcFontHasHint (face)))
+ goto bail1;
+
if (!variable_size && os2 && os2->version >= 0x0005 && os2->version != 0xffff)
{
double lower_size, upper_size;
@@ -2552,6 +2558,7 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks FC_UNUSED, int *spac
#define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' )
#define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' )
#define TTAG_SILF FT_MAKE_TAG( 'S', 'i', 'l', 'f')
+#define TTAG_prep FT_MAKE_TAG( 'p', 'r', 'e', 'p' )
#define OTLAYOUT_HEAD "otlayout:"
#define OTLAYOUT_HEAD_LEN 9
@@ -2736,6 +2743,20 @@ bail:
return complex_;
}
+static FcBool
+FcFontHasHint (FT_Face face)
+{
+ FT_ULong *prep = NULL;
+ FT_UShort prep_count = 0;
+
+ prep_count = GetScriptTags (face, TTAG_prep, &prep);
+
+ free (prep);
+
+ return prep_count > 0;
+}
+
+
#define __fcfreetype__
#include "fcaliastail.h"
#include "fcftaliastail.h"
diff --git a/src/fcobjs.h b/src/fcobjs.h
index e3926cc..7bb97d0 100644
--- a/src/fcobjs.h
+++ b/src/fcobjs.h
@@ -72,4 +72,5 @@ FC_OBJECT (COLOR, FcTypeBool, FcCompareBool)
FC_OBJECT (SYMBOL, FcTypeBool, FcCompareBool)
FC_OBJECT (FONT_VARIATIONS, FcTypeString, NULL)
FC_OBJECT (VARIABLE, FcTypeBool, FcCompareBool)
+FC_OBJECT (FONT_HAS_HINT, FcTypeBool, NULL)
/* ^-------------- Add new objects here. */