[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cairo
Subject:    Re: [cairo] Variable fonts redux
From:       Behdad Esfahbod <behdad () behdad ! org>
Date:       2017-09-27 22:58:41
Message-ID: CAF63+7W26Q49oOxmKGQ1=m-MJttSqxY_L1KE1T-p9RBPBU0AoQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


This branch is now IMO complete and ready to be merged:

    https://github.com/behdad/fontconfig/commits/varfonts2

I'll merge tomorrow if there's no comments.

Cheers,
b

On Sat, Sep 16, 2017 at 1:49 PM, Behdad Esfahbod <behdad@behdad.org> wrote:

> Hi,
>
> Previously I have had implemented and merged support for named-instances
> in variable fonts, but the generic variation mechanism was not integrated.
> I've finished the core of what was left of implementing variable fonts in
> fontconfig:
>
>   https://github.com/behdad/fontconfig/commits/varfonts2
>
> High-level changes are:
>
>   - Add FC_FONT_VARIATIONS (string): this one is easy.  The library
> doesn't do anything about it.  It's like FC_FONT_FEATURES. Client sets and
> then retrieves. Primarily useful for non-standard variation axes,
>
>   - Add FC_VARIABLE (bool), which is at the core of varfont support.
>
> All font patterns that were discovered previously will get
> FC_VARIABLE=False When querying fonts with (the new)
> FcFreeTypeQueryFaceAll(), or when face index has top 16 bits (instance
> index) set to 0x8000, then a pattern is created for the variable font as a
> whole.  This pattern is only generated if there's actual variation in at
> least one of weight, width, and optical size axes. This pattern then might
> have ranges for FC_WEIGHT, FC_WIDTH, and FC_SIZE, and has FC_VARIABLE=True.
>
>   - FC_WIDTH and FC_WEIGHT are now typed as ranges instead of double.
>
>   - Fix matching and comparison logic with ranges to behave as we expect.
>
>   - In FcDefaultSubstitute(), set FC_VARIABLE to false if it's unset.
> FC_VARIABLE has very high match priority, so this takes care of backward
> compatibility with clients that do not support variable fonts by pushing
> them to the very back of fallback list.
>
>   - In FcFontRenderPrepare, special-case ranges, such that if eg. request
> is for weight=47, and font has weight=[50,100], then rendered pattern will
> get weight=50.  For size, special case again, such that if request size=47
> and font has size=[50,100], then rendered font will have size=47.
>
>   - For clients that support variable font, eg. pango soon, they have to
> opt-in.  I could have special-cased matcher for FC_VARIABLE, such that if
> FC_VARIABLE=True, then both variable and non-variable fonts will be
> returned, but I didn't like a custom match.  Currently if FC_VARIABLE=True
> is set then variable fonts will dominate the results, even if they are not
> the best match.  To solve that:
>
>   - To solve above problem, I added a new value for FcBool: FcDontCare=2.
> Pango should set FC_VARIABLE=FcDontCare.  I was hoping to allow clients to
> tell fontconfig whether, everything else being equal, they prefer variable
> font or static font, but that needs a very low-priority element, or a hack,
> and I didn't like either, so I gave up on that.  It's not particularly
> useful anyway.
>
> Here's what's left, which I'll do in the next few days.  I just wanted to
> get this out for now.
>
>   - Config compare operations on "dontcare" are not implemented yet,
>
>   - The variable-font pattern currently has FC_STYLE set.  I think I
> should completely leave out FC_STYLE,
>
> With those fixed, I think this can be merged.  At some point I also like
> to:
>
>   - Speed up scanning of varfonts that have many named instances.  Voto
> Serif GX has over 500!  Right now we open the face and do everything from
> scratch for each named instance.  Can be considerably sped up by opening
> once and switching coordinates around...
>
>   - Expose slant & italic standard axes as well, but Fontconfig shoves
> FC_SLANT_ITALIC and FC_SLANT_OBLIQUE in the same element, with these values:
>
> #define FC_SLANT_ROMAN              0
> #define FC_SLANT_ITALIC             100
> #define FC_SLANT_OBLIQUE            110
>
> The varfonts axis for italic has a 0..1 range, 1 meaning italic.  And the
> slant axis uses slant angle.  We can:
>
>   - Deprecate FC_SLANT element and add two new ones, eg FC_ITALIC and
> FC_SLANT_ANGLE.  I don't like this particularly,
>
>   - Repurpose FC_SLANT for *italic*, since the 0..1 range maps nicely to
> FC_SLANT_ITALIC=100, and add FC_SLANT_ANGLE for the slant.  I don't
> particularly like to confusing names here either.  So I'm open to
> suggestions.
>
> A point I'll raise before someone asks:
>
>   - Exposing contents of STAT table or non-standard axes is out of scope
> for fontconfig.  The rule of thumb is: if it doesn't participate in font
> selection, it does not belong to fontconfig.  Things that a font dialog
> needs should be fetched directly using FreeType or HarfBuzz.
>
>
> Cheers,
> --
> behdad
> http://behdad.org/
>



-- 
behdad
http://behdad.org/

[Attachment #5 (text/html)]

<div dir="ltr"><div><div><div>This branch is now IMO complete and ready to be \
merged:<br><br>      <a href="https://github.com/behdad/fontconfig/commits/varfonts2" \
target="_blank">https://github.com/behdad/<wbr>fontconfig/commits/varfonts2</a><br><br></div>I&#39;ll \
merge tomorrow if there&#39;s no \
comments.<br><br></div>Cheers,<br></div>b<br></div><div class="gmail_extra"><br><div \
class="gmail_quote">On Sat, Sep 16, 2017 at 1:49 PM, Behdad Esfahbod <span \
dir="ltr">&lt;<a href="mailto:behdad@behdad.org" \
target="_blank">behdad@behdad.org</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div \
dir="ltr"><div><div><div><div><div>Hi,</div><div><br></div><div>Previously I have had \
implemented and merged support for named-instances in variable fonts, but the generic \
variation mechanism was not integrated.   I&#39;ve finished the core of what was left \
of implementing variable fonts in fontconfig:<br></div><br>   <a \
href="https://github.com/behdad/fontconfig/commits/varfonts2" \
target="_blank">https://github.com/behdad/<wbr>fontconfig/commits/varfonts2</a><br></div><br></div>High-level \
changes are:<br><br></div>   - Add FC_FONT_VARIATIONS (string): this one is easy.   \
The library doesn&#39;t do anything about it.   It&#39;s like FC_FONT_FEATURES. \
Client sets and then retrieves. Primarily useful for non-standard variation \
axes,<br><br></div>   - Add FC_VARIABLE (bool), which is at the core of varfont \
support.<br><br>All font patterns that were discovered previously will get \
FC_VARIABLE=False When querying fonts with (the new) FcFreeTypeQueryFaceAll(), or \
when face index has top 16 bits (instance index) set to 0x8000, then a pattern is \
created for the variable font as a whole.   This pattern is only generated if \
there&#39;s actual variation in at least one of weight, width, and optical size axes. \
This pattern then might have ranges for FC_WEIGHT, FC_WIDTH, and FC_SIZE, and has \
FC_VARIABLE=True.<br><div><div><div><div><div><div><div><br></div><div>   - FC_WIDTH \
and FC_WEIGHT are now typed as ranges instead of double.</div><div><br></div><div>   \
- Fix matching and comparison logic with ranges to behave as we \
expect.</div><div><br></div><div>   - In FcDefaultSubstitute(), set FC_VARIABLE to \
false if it&#39;s unset.   FC_VARIABLE has very high match priority, so this takes \
care of backward compatibility with clients that do not support variable fonts by \
pushing them to the very back of fallback list.</div><div><br></div><div>   - In \
FcFontRenderPrepare, special-case ranges, such that if eg. request is for weight=47, \
and font has weight=[50,100], then rendered pattern will get weight=50.   For size, \
special case again, such that if request size=47 and font has size=[50,100], then \
rendered font will have size=47.</div><div><br></div><div>   - For clients that \
support variable font, eg. pango soon, they have to opt-in.   I could have \
special-cased matcher for FC_VARIABLE, such that if FC_VARIABLE=True, then both \
variable and non-variable fonts will be returned, but I didn&#39;t like a custom \
match.   Currently if FC_VARIABLE=True is set then variable fonts will dominate the \
results, even if they are not the best match.   To solve \
that:</div><div><br></div><div>   - To solve above problem, I added a new value for \
FcBool: FcDontCare=2.   Pango should set FC_VARIABLE=FcDontCare.   I was hoping to \
allow clients to tell fontconfig whether, everything else being equal, they prefer \
variable font or static font, but that needs a very low-priority element, or a hack, \
and I didn&#39;t like either, so I gave up on that.   It&#39;s not particularly \
useful anyway.</div><div><br></div><div>Here&#39;s what&#39;s left, which I&#39;ll do \
in the next few days.   I just wanted to get this out for \
now.<br></div><div><br></div><div>   - Config compare operations on \
&quot;dontcare&quot; are not implemented yet,</div><div><br></div><div>   - The \
variable-font pattern currently has FC_STYLE set.   I think I should completely leave \
out FC_STYLE,</div><div><br></div><div>With those fixed, I think this can be merged.  \
At some point I also like to:<br></div><div><br></div><div>   - Speed up scanning of \
varfonts that have many named instances.   Voto Serif GX has over 500!   Right now we \
open the face and do everything from scratch for each named instance.   Can be \
considerably sped up by opening once and switching coordinates \
around...</div><div><br></div><div>   - Expose slant &amp; italic standard axes as \
well, but Fontconfig shoves FC_SLANT_ITALIC and FC_SLANT_OBLIQUE in the same element, \
with these values:</div><div><br></div><div>#define FC_SLANT_ROMAN                    \
0<br>#define FC_SLANT_ITALIC                         100<br>#define FC_SLANT_OBLIQUE  \
110<br></div><div><br></div><div>The varfonts axis for italic has a 0..1 range, 1 \
meaning italic.   And the slant axis uses slant angle.   We \
can:</div><div><br></div><div>   - Deprecate FC_SLANT element and add two new ones, \
eg FC_ITALIC and FC_SLANT_ANGLE.   I don&#39;t like this \
particularly,</div><div><br></div><div>   - Repurpose FC_SLANT for *italic*, since \
the 0..1 range maps nicely to FC_SLANT_ITALIC=100, and add FC_SLANT_ANGLE for the \
slant.   I don&#39;t particularly like to confusing names here either.   So I&#39;m \
open to suggestions.<br></div><div><br></div><div>A point I&#39;ll raise before \
someone asks:</div><div><br></div><div>   - Exposing contents of STAT table or \
non-standard axes is out of scope for fontconfig.   The rule of thumb is: if it \
doesn&#39;t participate in font selection, it does not belong to fontconfig.   Things \
that a font dialog needs should be fetched directly using FreeType or \
HarfBuzz.</div><div><br></div><div><br></div><div>Cheers,<span class="HOEnZb"><font \
color="#888888"><br></font></span></div><span class="HOEnZb"><font \
color="#888888"><div>-- <br></div><div><div \
class="m_-6596104556000006108gmail_signature">behdad<br><a href="http://behdad.org/" \
target="_blank">http://behdad.org/</a></div> \
</div></font></span></div></div></div></div></div></div></div> \
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" \
data-smartmail="gmail_signature">behdad<br><a href="http://behdad.org/" \
target="_blank">http://behdad.org/</a></div> </div>


[Attachment #6 (text/plain)]

-- 
cairo mailing list
cairo@cairographics.org
https://lists.cairographics.org/mailman/listinfo/cairo

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic