It should, but it does not. It seems the whole font management is based on AWT 
Font and that is missing a lot of CSS features.

Tom

On 4-1-2016 22:46, Phil Race wrote:
Hi,

I'm not certain I understand what it is that is missing.
I don't think Font.loadFont would need to accept the CSS parameters
and do the CSS-style lookup. @font-face should populate a CSS table
of names and styles. I expect that is what browsers do.
The CSS lookup code would then consult this internal table of fonts loaded
for the current CSS context and then ask the font system to use the one
that corresponds. If there is no match then it would be assumed it is a
request for a system provided font.

One thing that might be missing in Font.loadFont() is a way to keep the CSS
loaded fonts partioned. And there's a need for deriving a font with different 
attributes
as simple as a different size.


-phil.


On 01/04/2016 01:36 PM, David Grieve wrote:
The reason CSS ignores everything but src is that there is no public API in 
Font for providing the additional information.

CSS uses Font.loadFont to load a font from a @font-face src url. See 
com/sun/javafx/css/StyleManager.java

On 1/4/16 2:43 PM, Phil Race wrote:
Hi,

I can't speak authoritatively on the CSS implementation because I am not
familiar with it but here are some thoughts and observations that might help.

Suppose you have :
@font-face {
  font-family: RobotoMedium
  src: url("robotomedium.ttf"
}

My reading of the W3C spec. is that the name you specify as font-family
is used by CSS as the family name regardless of the *actual* name of the font
but I don't think FX can be working like that if it ignores font-family.

If CSS is ignoring everything except src that seems like
you then need to know for sure yourself what the family + style of the font is
and per that bug then use it via fx-font using the actual name+style.
This suggests CSS is loading the font into the list of fonts available to be 
used
by creating fonts directly from JavaFX API.
This seems to be confirmed by you seeing that Font.getFontNames()
reports these.

So you'd need to do the following for both font files
ie.

@font-face {
  font-family: BlahBlahDoesNotMatterApparently
  src: url("robotomedium.ttf")
}


@font-face {
  font-family: BlahBlahDoesNotMatterEither
  src: url("robotomediumitalic.ttf")
}

and reference as :

-fx-font: normal normal 12 "Roboto Medium"
-fx-font: italic normal 12 "Roboto Medium"

If this does not work then I don't know what CSS might be doing in its lookup.
The comment about only the last one loaded being available does not add up to me
unless CSS is doing some buggy filtering or remembering of its own.
Perhaps explicitly specifying "normal" will fix that.

-phil.

On 01/04/2016 12:08 AM, Tom Eugelink wrote:
No problem, thanks for the suggestion!

What I expect to be the cause is that the attributes in @font-face, specifying 
if a font is italic or not, are not supported. And they probably aren't 
populated based on the TTF metadata either. But before I dive too deep, maybe 
someone can prevent me from swimming in the wrong direction.

Tom


On 4-1-2016 00:02, cogmission (David Ray) wrote:
I guess I was assuming the "ideal"/expected behavior applied? Sorry...

On Sun, Jan 3, 2016 at 10:14 AM, Tom Eugelink <t...@tbee.org 
<mailto:t...@tbee.org>> wrote:

    Hi David,

    Which would assume that if I specify no keywords, then it should take the 
normal version. It does not. Whatever version is loaded last is used.

    Tom



    On 3-1-2016 17:09, cogmission (David Ray) wrote:

        Hi Tom,

        I Believe in CSS, once you establish the family you can access the 
sub-types via type keywords?
        ...via

        -fx-font-weight: bold,bolder etc.
        -fx-font-style: plain, italic

        Cheers,
        David

        On Sun, Jan 3, 2016 at 8:52 AM, Tom Eugelink <t...@tbee.org <mailto:t...@tbee.org> 
<mailto:t...@tbee.org <mailto:t...@tbee.org>>> wrote:

            Addendum:

            If I list the font families using Font.getFamilies() I get "Roboto Medium" once, given 
that both TTF files are added using @font-face. But if I examine Font.getFontNames() I get separate entries 
for "Roboto Medium" and "Roboto Medium Italic". Closer examination of the font loading 
reveals that indeed each font has its own distinct name and some fonts shared the same family name. That 
makes sense.

            The thing is that in CSS -as far as I can see- fonts can only 
accessed through its family name, not its own name.

            Tom



            On 3-1-2016 11:21, Tom Eugelink wrote:

                I'm currently including Google's Roboto font in JFXtras and making it 
easily available to other users. I noticed that the font-family attribute in font-face is 
ignored, and you have to use the name as it is specified in the TTF file. I found 
https://bugs.openjdk.java.net/browse/JDK-8094516 which says "/Please note that all 
@font‑face descriptors are ignored except for the src descriptor./" That pretty much 
explains what is going on.

                Now, Roboto comes in different styles, condensed, bold, etc, but also 
italic. However, italic is a separate TTF file, so you have a Roboto-Medium.ttf and a 
Roboto-MediumItalic.ttf. The name of the font inside these two TTF files is the same, so 
when I use "font-family: 'Roboto Medium'" whatever ever font is defined last by 
font-face is used, and the other is not accessible.

                My question is: is the way Roboto does Italic, with the same 
font name in the TTF file, a bug of Roboto, or is this common?

                Tom





        --         /With kind regards,/
        David Ray
        Java Solutions Architect
        *Cortical.io <http://cortical.io/>*
        Sponsor of: HTM.java <https://github.com/numenta/htm.java>
        d....@cortical.io <mailto:d....@cortical.io> <mailto:d....@cortical.io 
<mailto:d....@cortical.io>>
        http://cortical.io <http://cortical.io/>





--
/With kind regards,/
David Ray
Java Solutions Architect
*Cortical.io <http://cortical.io/>*
Sponsor of: HTM.java <https://github.com/numenta/htm.java>
d....@cortical.io <mailto:d....@cortical.io>
http://cortical.io <http://cortical.io/>





Reply via email to