[Fontconfig] Fwd: [ft-announce] FreeType now supports color emojis

Jungshik SHIN (신정식) jshin1987 at gmail.com
Sun Aug 17 03:08:21 PDT 2014


Hi Behdad,

Attached is my patch to add FC_COLOR (the patch is against ToT as of now).
It's the same patch that I attached to http://crbug.com/386772

I'm not sure about the priority so that I just put it in a rather arbitrary
place.

Jungshik






On Sun, Aug 17, 2014 at 12:04 AM, Jungshik SHIN (신정식) <jshin1987 at gmail.com>
wrote:

>
>
>
> On Sat, Aug 16, 2014 at 12:32 PM, Behdad Esfahbod <behdad at behdad.org>
> wrote:
>
>> [Reviving old thread]
>> On 13-07-16 07:01 PM, Raimund Steger wrote:
>> > Behdad Esfahbod wrote:
>> >> On 13-07-14 09:17 PM, Raimund Steger wrote:
>> >>>
>> >>>>>    3. If user requests FC_COLOR=false and a font with FC_COLOR=true
>> is
>> >>>>> chosen,
>> >>>
>> >>> These should be some real corner cases.
>> >>
>> >> Not really.  If the only fonts supporting a character is color, this
>> happens.
>> >
>> > That's true, but... right now, in many setups most of the Unicode
>> character
>> > range is covered by existing scalable fonts, like Droid Sans Fallback,
>> Arial
>> > Unicode, etc. So right now it would mostly happen for glyphs outside
>> the usual
>> > character ranges; chances are that these *would* be emoji glyphs where
>> user
>> > tolerance toward accidental color rendering might be a bit higher...
>> but of
>> > course that's difficult to say in advance and it's also not a good
>> quality
>> > standard. The picture might change, too. It's just that if we copy the
>> value
>> > from the pattern, I'm not sure how easy it would be for users to
>> disable that
>> > behavior in their local configuration files, if they wanted to. Which
>> again is
>> > a rather far-fetched scenario.
>> > Don't get me wrong, I'm not trying (too hard) to convince you of
>> anything
>> > here. Actually I don't have a very strong opinion on the subject.
>> >
>> > Other possibilities:
>> >
>> > (2) fontconfig could initialize the 'color' property at scan time for
>> cache
>> > entries *only* in the case fonts have no color, and *not* set it in all
>> other
>> > cases. This would a bit like the current 'antialias' behavior and it's
>> > semantically similar, too (meaning it's open to renderer settings and
>> not
>> > predetermined by the cache). If I remember right, that way fontconfig
>> will
>> > copy any value from the pattern automatically if the match result was a
>> color
>> > font, because that font didn't have it in the cache; if no 'color'
>> value was
>> > in the pattern, it will just not set the property which should be fine
>> as
>> > FreeType will just render it in color. Users could disable the behavior
>> with
>> > target="scan" rules.
>>
>> I think I like this!
>>
>> So, for non-color fonts we scan FC_COLOR=false.  Then, in
>> FcDefaultSubstitute(), we set FC_COLOR=false in the pattern.  It won't
>> quite
>> work currently because I broke it in 2008, but I like to fix that soon
>> (https://bugs.freedesktop.org/show_bug.cgi?id=80873#c10).  After that's
>> fixed,
>> this is how it will work:
>>
>>   1) Old clients who don't know about color won't set FC_COLOR, get
>> FC_COLOR=false in FcDefaultSubstitute, and always get FC_COLOR=false in
>> the
>> matched font and will get fallback grayscale rendering from FreeType for
>> color
>> fonts,
>>
>>   2) Color-aware clients will set FC_COLOR=True, which will make them get
>> color fonts preferred over non-color.  The match result will have
>> FC_COLOR if
>> the font was color,
>>
>>   3) Color-aware clients that don't want color to change font matching
>> will
>> continue not setting FC_COLOR, but ignore the FC_COLOR results in the
>> matched
>> font.  The only problem with this is that user config won't be able to
>> turn
>> color on / off.
>>
>> Humm.  One problem with this is that if anyone does 2), then the color
>> font
>> technology will be only usable for emoji.  You can't have a color font
>> (say,
>> that covers ASCII) installed, because with that you will always get that
>> font
>> when you, eg, ask for sans.  So, I think this option is out.
>>
>> Ok, lets fully set FC_COLOR in the font, and match on it (what
>> priority?).  If
>> client doesn't set, we won't prefer color or non-color.  If client asked,
>> with
>> give it just that.  The client's preference will be lost in the matched
>> result, but we don't care, client can look it up itself.
>>
>> Jungshik, do you have a patch for this you said?
>>
>
> My patch is speculative and I only tested with fc-query command. Anyway,
> I'll send it your way in an hour or so (I have to do some chores atm).
>
> Jungshik
>
>
>
>>
>> --
>> behdad
>> http://behdad.org/
>> _______________________________________________
>> Fontconfig mailing list
>> Fontconfig at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/fontconfig
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/fontconfig/attachments/20140817/72eefc6e/attachment-0001.html>
-------------- next part --------------
diff --git a/doc/fontconfig-devel.sgml b/doc/fontconfig-devel.sgml
index 2b1122f..30f5ad4 100644
--- a/doc/fontconfig-devel.sgml
+++ b/doc/fontconfig-devel.sgml
@@ -176,6 +176,7 @@ convenience for the application's rendering mechanism.
     scalable       FC_SCALABLE            Bool    Whether glyphs can be scaled
     scale          FC_SCALE               Double  Scale factor for point->pixel
                                                   conversions
+    color          FC_COLOR               Bool    Whether glyphs are color
     dpi            FC_DPI                 Double  Target dots per inch
     rgba           FC_RGBA                Int     unknown, rgb, bgr, vrgb,
                                                   vbgr, none - subpixel geometry
diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h
index e5b0959..941ff8e 100644
--- a/fontconfig/fontconfig.h
+++ b/fontconfig/fontconfig.h
@@ -94,6 +94,7 @@ typedef int		FcBool;
 #define FC_RASTERIZER	    "rasterizer"	/* String (deprecated) */
 #define FC_OUTLINE	    "outline"		/* Bool */
 #define FC_SCALABLE	    "scalable"		/* Bool */
+#define FC_COLOR	    "color"		/* Bool */
 #define FC_SCALE	    "scale"		/* double */
 #define FC_DPI		    "dpi"		/* double */
 #define FC_RGBA		    "rgba"		/* Int */
diff --git a/src/fcfreetype.c b/src/fcfreetype.c
index aca2f70..ae26bf4 100644
--- a/src/fcfreetype.c
+++ b/src/fcfreetype.c
@@ -1285,6 +1285,10 @@ FcFreeTypeQueryFace (const FT_Face  face,
 			   (face->face_flags & FT_FACE_FLAG_SCALABLE) != 0))
 	goto bail1;
 
+    if (!FcPatternAddBool (pat, FC_COLOR,
+			   (face->face_flags & FT_FACE_FLAG_COLOR) != 0))
+	goto bail1;
+
 
     /*
      * Get the OS/2 table
diff --git a/src/fcmatch.c b/src/fcmatch.c
index b0e695d..43a11e3 100644
--- a/src/fcmatch.c
+++ b/src/fcmatch.c
@@ -284,6 +284,7 @@ typedef enum _FcMatcherPriority {
     PRI1(FILE),
     PRI1(FONTFORMAT),
     PRI1(SCALABLE),
+    PRI1(COLOR),
     PRI1(FOUNDRY),
     PRI1(CHARSET),
     PRI_FAMILY_STRONG,
diff --git a/src/fcobjs.h b/src/fcobjs.h
index bfdf4b5..ab3c9e8 100644
--- a/src/fcobjs.h
+++ b/src/fcobjs.h
@@ -47,6 +47,7 @@ FC_OBJECT (INDEX,		FcTypeInteger,	NULL)
 FC_OBJECT (RASTERIZER,		FcTypeString,	FcCompareString)	/* deprecated */
 FC_OBJECT (OUTLINE,		FcTypeBool,	FcCompareBool)
 FC_OBJECT (SCALABLE,		FcTypeBool,	FcCompareBool)
+FC_OBJECT (COLOR,		FcTypeBool,	FcCompareBool)
 FC_OBJECT (DPI,			FcTypeDouble,	NULL)
 FC_OBJECT (RGBA,		FcTypeInteger,	NULL)
 FC_OBJECT (SCALE,		FcTypeDouble,	NULL)


More information about the Fontconfig mailing list